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.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting;
using System.Text;
using System.Xml.Schema;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            if (N == 1)
            {
                Console.WriteLine("Yes");
                Console.WriteLine("2");
                Console.WriteLine("1 1");
                Console.WriteLine("1 1");
                return;
            }

            int o;
            if (isSankaku(N, out o))
            {
 
                var sb = new StringBuilder();
                sb.AppendLine("Yes");
                sb.AppendLine((o + 1).ToString());
                bool[,] ans = new bool[o + 1, N];

                for (int i = 0; i <= o; i++)
                {
                    if (i == 0)
                    {
                        for (int j = 0; j < o; j++)
                        {
                            ans[0, j] = true;
                        }
                    }
                    else
                    {
                        int[] cnt = new int[N];
                        for (int j = 0; j < i; j++)
                        {
                            for (int k = 0; k < N; k++)
                            {
                                if (ans[j, k]) cnt[k]++;
                            }
                        }

                        int oneCnt = 0;
                        int zeroCnt = 0;
                        for (int j = 0; j < N; j++)
                        {
                            switch (cnt[j])
                            {
                                case 0:
                                    if (zeroCnt < o - i)
                                    {
                                        zeroCnt++;
                                        ans[i, j] = true;
                                    }

                                    break;
                                case 1:
                                    if (oneCnt < i)
                                    {
                                        oneCnt++;
                                        ans[i, j] = true;
                                    }

                                    break;
                                default:
                                    break;
                            }

                        }
                    }
                    var l = new List<int>();
                    for (int j = 0; j < N; j++)
                    {
           
                        if (ans[i, j])
                        {
                            l.Add(j + 1);

                        }

                    }
                    sb.AppendLine($"{o} {string.Join(" ", l)}");
                }
                Console.Write(sb.ToString());
            }
            else
            {
                Console.WriteLine("No");
            }

        }

        private bool isSankaku(int n, out int nn)
        {
            nn = (int)Math.Round(Math.Sqrt(8 * n + 1) - 1) / 2;
            return nn * nn + nn == 2 * n;
        }

        static void Main() => new Program().Solve();
    }
}