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;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		int k = (1 + (int)Math.Sqrt(1 + 8 * N)) / 2;
		if((k * (k - 1)) / 2 != N)
		{
			Console.WriteLine("No");
			return;
		}
		Console.WriteLine("Yes");

		int[,] table = new int[k - 1, k - 1];
		int cnt = 1;
		for(int i = 0; i < k - 1; i++)
		{
			for(int j = 0; j <= i; j++)
			{
				table[i, j] = cnt;
				cnt++;
			}
		}

		var ans = new StringBuilder();
		for(int i = 0; i < k - 1; i++)
		{
			var S = new List<int>(k - 1);
			int r = i;
			int c = -1;
			while(c + 1 <= i)
			{
				c++;
				S.Add(table[r, c]);
			}
			while(r + 1 < k - 1)
			{
				r++;
				S.Add(table[r, c]);
			}
			ans.Append($"{k - 1} ");
			ans.Append(string.Join(" ", S.Select(x => x.ToString()).ToArray()));
			ans.Append("\n");
		}
		ans.Append($"{k - 1} ");
		ans.Append(string.Join(" ", Enumerable.Range(0, k - 1).Select(x => table[x, x].ToString()).ToArray()));
		ans.Append("\n");

		Console.Write(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}