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# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    /**
     * 部分集合の組が共通の要素を一つもつので、共通要素から元の部分集合を構成する。
     * S1,S2 => A
     * S1,S3 => B
     * ならば、S1 = {A,B}ということがわかる。
     * また、kC2個のパターンが存在しており、それはNと一致していなければならない。
     * したがって、以下の方針で問題を解くことが可能となる。
     * ①N=kC2からkを確定する。
     * ②kC2の組み合わせを網羅して、共通要素を昇順に割り当てる
     * ③共通要素をあつめて部分集合Siを構成する
     *
     * <see cref="http://tutuz.hateblo.jp/entry/2018/10/28/085507"/>
     */
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        int k = 0;
        for (int i = N; i >= 1; i--)
        {
            if (N == i * (i - 1) / 2)
            {
                k = i;
                break;
            }
        }

        if (N == 1)
        {
            Console.WriteLine("Yes");
            Console.WriteLine("1");
            Console.WriteLine("1 1");
            return;
        }

        if (k == 0)
        {
            Console.WriteLine("No");
            return;
        }

        var S = new List<List<int>>(k);
        var indexList = new int[k];
        for (int i = 0; i < k; i++)
        {
            indexList[i] = i;
            S.Add(new List<int>(N));
        }

        var combList = Combination.Enumerate(indexList, 2, false).ToArray();
        var n = 1;
        foreach (var comb in combList)
        {
            S[comb[0]].Add(n);
            S[comb[1]].Add(n);
            n++;
        }

        Console.WriteLine("Yes");
        Console.WriteLine(k);
        for (int i = 0; i < S.Count; i++)
        {
            var ans = new System.Text.StringBuilder();
            var count = S[i].Count;
            ans.Append(count);
            foreach (var value in S[i])
            {
                ans.Append(" " + value);
            }

            Console.WriteLine(ans);
        }

    }

    /**
     * 組み合わせを求める
     * <see cref="https://qiita.com/gushwell/items/74a96f56ccb64db3660c"/>
     */
    public static class Combination
    {
        public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition)
        {
            if (k == 1)
            {
                foreach (var item in items)
                    yield return new T[] { item };
                yield break;
            }
            foreach (var item in items)
            {
                var leftside = new T[] { item };

                // item よりも前のものを除く （順列と組み合わせの違い)
                // 重複を許さないので、unusedから item そのものも取り除く
                var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

                foreach (var rightside in Enumerate(unused, k - 1, withRepetition))
                {
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }
    }

}