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 (Python):
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    D = [0] * (N+1)
    for i in range(1, N+1):
        D[i] = i*(i+1)//2

    index = bisect_left(D, N)
    if N != D[index]:
        print("No")
    else:
        print("Yes")
        print(index+1)
        D2 = Init(index+1, index,0)
        D2[0] = [i for i in range(1, index+1)]
        num = index
        for i in range(1, index+1):
            for j in range(i):
                D2[i][j] = D2[j][i-1]
            for k in range(j+1, index):
                num += 1
                D2[i][k] = num
        for temp in D2:
            temp = [index]+temp
            temp = [str(i) for i in temp]
            print(" ".join(temp))

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    
    n=int(input())
    if 2*n!=int((2*n)**0.5)*(int((2*n)**0.5)+1):
        print("No")
        exit()
    print("Yes")
    l=int((2*n)**0.5)
    print(l+1)
    work=[[] for _ in range(l+1)]
    now_sub=0
    next_sub=1
    for i in range(1,n+1):
        if len(work[now_sub])==l:
            now_sub+=1
            next_sub=now_sub+1
        work[now_sub].append(i)
        work[next_sub].append(i)
        next_sub+=1
    
    for i in range(l+1):
        print("{} {}".format(l," ".join(map(str,work[i]))))

main()

Solution (Python):
def solve(n):
    k = 1
    while k * (k + 1) < 2 * n:
        k += 1
    if k * (k + 1) != 2 * n:
        return False, [], -1
    ans = [[] for _ in range(1000)]
    add_num = 1
    ans[1].append(add_num)
    ans[0].append(add_num)
    for i in range(2, k + 1):
        for j in range(i):
            add_num += 1
            ans[i].append(add_num)
            ans[i - j - 1].append(add_num)
    return True, ans, k


def main():
    n = int(input())
    res, ans, k = solve(n)
    if res:
        print("Yes")
        print(k + 1)
        for a in ans:
            if a:
                print(len(a), " ".join(map(str, a)))
            else:
                break
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
f=True
r=0
i=1
while r<n:
  i+=1
  r=i*(i-1)//2
  if r==n:
    f=False
if f:
  print("No")
else:
  ans=[[] for j in range(i)]
  j=1
  for a in range(i):
    for b in range(a+1,i):
      ans[a].append(j)
      ans[b].append(j)
      j+=1
  print("Yes")
  print(i)
  for a in range(i):
    print(" ".join(map(str,[len(ans[a])]+ans[a])))

Solution (Python):
from math import ceil
n=int(input())
k=ceil((2*n)**0.5)
if k*(k-1)//2!= n:
  print('No')
  exit()

S=[[] for _ in range(k)]
a=1
for i in range(k):
  for j in range(i+1, k):
    S[i].append(a)
    S[j].append(a)
    a+=1

print('Yes')
print(k)
for i in range(k):
  print(len(S[i]),*S[i])

Solution (Python):
N = int(input())
MAX = 500
A = [[1],[1]] 

size = 0
for i in range(1,MAX):
  if i*(i+1)//2 == N:
    size = i+1
    break
if size == 0:
  print("No")
  exit()
now = 2
while now < size:
  start = now*(now-1)//2+1
  last = [start+i for i in range(now)]
  for j in range(len(A)):
    A[j].append(last[j])
  A.append(last)
  now += 1
print("Yes")
print(len(A))

for x in A:
  x.insert(0,len(A)-1)
  print(*x)

Solution (Python):
n= int(input())
k=((8*n+1)**0.5-1)/2
if k.is_integer():
    print('Yes')
    ik=int(k)
    print(ik+1)
    prel,newl=[],[]
    nexv,last=0,0
    for i in range(ik+1):
        if i==0:
            print(ik,*[t+1 for t in range(ik)])
            nexv=1
        else:
            last+=ik-i+1
            newl=[b+last+1 for b in range(ik-i)]
            for b in range(len(prel)):prel[b]+=1
            print(ik,*(prel+[nexv]+newl))
            prel.append(nexv)
            if newl:nexv=newl[0]
else:print('No')

Solution (Python):
import sys
from itertools import combinations
def I(): return int(sys.stdin.readline().rstrip())


N = I()
A = [(i*(i-1))//2 for i in range(448)]

index = 0
for i in range(2,448):
    if A[i] == N:
        print('Yes')
        print(i)
        index = i
        break
else:
    print('No')
    exit()

ANS = [[index-1] for _ in range(index)]
for i,a in enumerate(list(combinations([i for i in range(index)],2))):
    b,c = a
    ANS[b].append(i+1)
    ANS[c].append(i+1)

for ans in ANS:
    print(*ans)

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  k=2
  while True:
    kk=k*(k-1)
    if kk>n*2:
      print('No')
      exit()
    if kk==n*2:
      break
    k+=1

  print('Yes')
  print(k)
  ans=[[] for _ in range(k)]
  ln=2*n//k

  st=0
  for i in range(k):
    tmp=[]
    i_ln=ln-len(ans[i])
    for j in range(i_ln):
      st+=1
      tmp.append(st)
    ans[i]+=tmp
    
    for j in range(i+1,k):
      ans[j].append(tmp.pop())

  
  for x in ans:
    print(ln,' '.join(str(y) for y in x))

main()

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]







n = I()

a = floor(sqrt(n*2))
b = a + 1

if a*b==n*2:
    print("Yes")
    print(b)
    d = [ [0]*a for _ in range(b) ]
    for i in range(1,a+1):
        d[i-1][i-1] = i
        d[i][i-1] = i
    
    c = b
    for i in range(b):
        for j in range(a):
            if d[i][j]==0:
                d[i][j] = c
                d[j+1][i] = c
                c += 1
    
    for i in range(b):
        print(a,end=" ")
        myoutput(d[i],space=True)
else:
    print("No")

Solution (Python):
n = int(input())

ok = False
x = 0

for i in range(1000):
    if n == i * (i + 1) // 2:
        ok = True
        x = i
        break

if ok:
    print('Yes')
    d = n * 2 // x
    print(d)

    a = [[] for _ in range(d)]
    a[0].append(1)
    a[1].append(1)

    now = 1
    for i in range(2, d):
        for j in range(i):
            a[j].append(now + j + 1)
        for j in range(i):
            a[i].append(now + j + 1)
        now += i

    for i in range(d):
        print(x, *a[i])
else:
    print('No')

Solution (Python):
from itertools import combinations
N = int(input())
K = 0
for i in range(2,N+2):
    if N==(i*(i-1))//2:
        K = i
        break
if K==0:
    print("No")
else:
    S = {i:[] for i in range(1,K+1)}
    cnt = 1
    for x in combinations(range(1,K+1),2):
        i,j = x
        S[i].append(cnt)
        S[j].append(cnt)
        cnt += 1
    print("Yes")
    print(K)
    for i in range(1,K+1):
        print(len(S[i]),*S[i])

Solution (Python):
import math

N = int(input())
s = int(math.sqrt(2*N))
if s*(s+1) != 2*N:
    print('No')
else: 
    print('Yes')
    print(s+1)
    a = []
    for i in range(1, s+1):
        n0 = 1 + s*(i-1) - (i-2)*(i-2+1)//2
        a.append(n0)
    w = a[-1] + 1 ; a.extend((w, w))  

    for i in range(s+1):
        nL = []
        for k in range(i):
            nL.append(a[k]+(i-k-1))
            
        nL = nL + list(range(a[i], a[i+1]))
            
        print(s, *nL)

Solution (Python):
N = int(input())
k = 1
n = 0
while n < N:
    n += k
    k += 1
if n!=N:
    print('No')
    exit()
print('Yes')
print(k)
ans = [[] for _ in range(k)]
v = 1
for i in range(k-1):
    for j in range(i+1,k):
        ans[i].append(v)
        ans[j].append(v)
        v += 1
for row in ans:
    print(len(row),*row)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



N = INT()
k = int((2*N)**0.5)
if k*(k+1) == 2*N:
	print("Yes")
	print(k+1)
	ans = [[] for _ in range(k+1)]
	for i, (x, y) in enumerate(combinations(range(k+1), 2), 1):
		ans[x].append(i)
		ans[y].append(i)
	for l in ans:
		print(k, *l)

else:
	print("No")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



N = INT()
k = int(0.5+(2*N)**0.5)
if k*(k+1) == 2*N:
	print("Yes")
	print(k+1)
	ans = [[] for _ in range(k+1)]
	for i, (x, y) in enumerate(combinations(range(k+1), 2), 1):
		ans[x].append(i)
		ans[y].append(i)
	for l in ans:
		print(k, *l)

else:
	print("No")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6
mod = 10 ** 9 + 7 





N = INT()

lim = int(-(-sqrt(2*N)//1))+1
for i in range(lim):
	if i*(i+1) == 2*N:
		break
else:
	print("No")
	exit()

n = i+1
print("Yes")
print(n)
ans = [[] for _ in range(n)]
cnt = 1
for j in range(n):
	k = j+1
	while k < n:
		ans[j].append(cnt)
		ans[k].append(cnt)
		cnt += 1
		k += 1

for l in range(n):
	print(i, *ans[l])

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(N):
    if N == 1:
        print(Yes)
        print(2)
        print(1, 1)
        print(1, 1)
        return
    K = -1
    for k in range(1, N + 1):
        if (k * (k - 1)) // 2 == N:
            K = k

    if K == -1:
        print(No)
        return

    ans = [[] for _ in range(K)]
    num = 1
    for i in range(0, K):
        for j in range(i + 1, K):
            ans[i].append(num)
            ans[j].append(num)
            num += 1

    print(Yes)
    print(K)
    for v in ans:
        print(len(v), *v, sep=" ")


def main():
    N = int(input())
    solve(N)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
flg = False
for i in range(N+1):
    if (i*(i+1))//2 == N:
        flg = True
        a = i
if flg == False:
    print('No')
    exit()
lis = [[0] * a for _ in range(a+1)]
p = 0
for i in range(a+1):
    for j in range(a):
        lis[i][j] = (i)*a+(j+1)-p
    p += (i+1)

for i in range(1,a+1):
    for j in range(i):
        lis[i][j] = lis[j][i-1]

print('Yes')
print(a+1)
for i in range(a+1):
    print(a,' '.join(map(str,lis[i])))

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7

    n=I()
    dic=defaultdict(lambda:0)
    k=1
    while k*(k-1)//2<10**6:
        dic[k*(k-1)//2]=k
        k+=1
    
    if dic[n]==0:
        print("No")
        sys.exit()
    print("Yes")
    x=dic[n]
    
    item=x-1
    ans=[[0]*(item+1) for i in range(x)]
    res=0
    for i in range(item):
        for j in range(item-i):
            ans[i][j+i+1]=j+res+1
            
        res+=item-i
    
    print(x)
    res=0
    for i in range(item):
        for j in range(item-i):
            ans[j+i+1][i+1]=j+res+1
        res+=item-i
    for i in range(item+1):
        ans[i][0]=item
    for i in range(item+1):
        print(*ans[i])
    
        
    
    
    


    
if __name__=="__main__":
    main()

Solution (Python):
n=int(input())
if n==1:
  print('Yes')
  print('2\n1 1\n1 1')
  exit()
for i in range(n):
  if i*(i+1)//2==n:break
else:
  print('No')
  exit()
m=i
a=[[0]*m for _ in range(m)]
i=0
while n>0:
  for j in range(i+1):
    a[i][j]=n
    n-=1
  i+=1
a=a[::-1]
s=[[] for _ in range(m+1)]
for i in range(m):
  s[i]=a[i][:m-i]
  for j in range(i):
    s[i]+=[a[i-1-j][m-i-1]]
for i in range(m):
  s[-1]+=[a[i][m-i-1]]
print('Yes')
print(len(s))
for i in s:
  print(len(i),*i)

Solution (Python):

N = int(input())
k = 1

def list_print(S):
    print(len(S), end='')
    for i in range(len(S)):
        print(' {}'.format(S[i]), end='')
    print('')

while k<1000:
    if k*(k-1)//2==N:
        break
    k += 1
if k==1000:
    print('No')
else:
    S = [[] for _ in range(k)]
    i = 1
    for l in range(k):
        for r in range(l+1,k):
            S[l].append(i)
            S[r].append(i)
            i += 1
    print('Yes')
    print(k)
    for i in range(k):
        list_print(S[i])

Solution (Python):
N = int(input())

size = 1
while True:
    n = size * (size-1) // 2
    if n == N:
        break
    elif n > N:
        print('No')
        exit()
    size += 1

sets = [[] for _ in range(size)]

n = 1
for i in range(size):
    for j in range(i+1, size):
        sets[i].append(n)
        sets[j].append(n)
        n += 1

print('Yes')
print(size)
for i in range(size):
    print(' '.join(map(str, [len(sets[i])] + sets[i])))

Solution (Python):
n=int(input())

num=0
for i in range(1,10**3):
    if i*(i-1)//2==n:
        num=i
        break

if num==0:print("No");exit()
length=num-1
A,cnt=[],1
for i in range(1,num):
    B=[]
    cnt +=i-1
    for j in range(i):B.append(cnt+j)
    for j in range(i,length):B.append(B[-1]+j)
    A.append(B)
A.append([i*(i+1)//2 for i in range(1,length+1)])

print("Yes")
print(length+1)
for i in A:
    print(length,*i)

Solution (Python):
N=int(input())
N_max=10**5

Trig=[0]
k=1
T=0
while T<=N_max:
    T+=k
    k+=1
    Trig.append(T)

try:
    K=Trig.index(N)+1
except:
    print("No")
    exit()
S=[set() for _ in range(K)]
m=0
for i in range(K):
    for j in range(i+1,K):
        m+=1
        S[i].add(m)
        S[j].add(m)

print("Yes")
print(K)
X=[""]*K
for i in range(K):
    X[i]="{} ".format(len(S[i]))+" ".join(map(str,S[i]))

print("\n".join(X))

Solution (Python):


from itertools import combinations

n = int(input())
k = -1
for i in range(10**3):
    if i*i - i - 2 * n == 0:
        k = i

if k == -1:
    print('No')
    exit()




num = 0
V = [[] for _ in range(k)]
for cmb in combinations(range(k), r=2):
    num += 1
    a, b = cmb
    V[a].append(num)
    V[b].append(num)
print('Yes')
print(k)
for v in V:
    print(len(v), end=" ")
    print(*v)

Solution (Python):
from math import ceil
import sys
n = int(input())

k = ceil((2 * n) ** 0.5)
if k * (k - 1) // 2 != n:
    print('No')
    sys.exit(0)

S = [[] for _ in range(k)]
a = 1
for i in range(k):
    for j in range(i + 1, k):
        S[i].append(a)
        S[j].append(a)
        a += 1

print('Yes')
print(k)
for i in range(k):
    print(len(S[i]), *S[i], sep = ' ')

Solution (Python):






n = int(input())
if n == 1:  
    print("Yes")
    print(2)
    print("1 1")
    print("1 1")
    exit()
anss = [[1, 2], [2, 3], [1, 3]]
target, length = 3, 3
while target <= n:
    if target == n:
        print("Yes")
        print(length)
        for ans in anss:
            b = " ".join(list(map(str, ans)))
            print(f"{len(ans)} {b}")
        exit()
    nex = list(range(target + 1, target + length + 1))
    for i, ans in enumerate(anss):
        ans.append(nex[i])
    anss.append(nex)
    target += length
    length += 1
print("No")

Solution (Python):
n = int(input())
tri = [1]
for i in  range(2, 450):
    tri.append(i * (i + 1) // 2)
if not n in tri:
    exit(print("No"))
print("Yes")
ind = tri.index(n) + 2
ans = [[] for i in range(ind)]
cur = 1
print(ind)
for i in range(ind):
    for j in range(i + 1, ind):
        ans[i].append(cur)
        ans[j].append(cur)
        cur += 1
for i in ans:
    print(len(i), *i)

Solution (Python):
from itertools import combinations

def main():
    N = int(input())
    k = 0
    for i in range(N+5):
        if i * (i - 1) == 2 * N:
            k = i
            break
    if k == 0:
        print('No')
        exit()
    num = 0
    groups = [[] for _ in range(k)]
    for pattern in combinations(range(k), r=2):
        num += 1
        a, b = pattern
        groups[a].append(num)
        groups[b].append(num)
    print('Yes')
    print(k)
    for g in groups:
        print(len(g), end=" ")
        print(*g, sep=' ')


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
k = 1
yes_n = (k * (k+1)) // 2
flag = False
while N >= yes_n:
    if N == yes_n:
        flag = True
        break
    k += 1
    yes_n = (k * (k+1)) // 2
if flag:
    ans = []
    max_n = 1
    for i in range(k+1):
        tmp = []
        for j in range(i):
            tmp += [ans[j][i-1]]
        for j in range(k-i):
            tmp += [str(max_n)]
            max_n += 1
        ans += [tmp]
    print('Yes')
    print(k+1)
    for a in ans:
        print(k, ' '.join(a))
else:
    print('No')

Solution (Python):
import math

N = int(input())
k,S,t = int(math.sqrt(N*2))+1,[[1],[1]],[]

if k*(k-1) != N*2:
	print('No')
	exit()

for i in range(k-2):
	S[0].append(S[0][i]+i+1)
	S[1].append(S[1][i]+i+2)
	t.append([S[0][i+1]])

for i in range(k-2):
	b,n = False,t[i][-1]+1
	while n <= N:
		t[i].append(n)
		tk = int(math.sqrt(n*2))+1
		if tk*(tk-1) == n*2:
			b = True
		n = t[i][-1]+len(t[i]) if b else t[i][-1]+1
S += t

print('Yes')
print(k)
for s in S:
	print(k-1, ' '.join(map(str, s)))

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())

    x = 0
    cur = 0
    while cur < n:
        x += 1
        cur += x

    if cur == n:
        print("Yes")
        k = x + 1
        res = [[0] * x for _ in range(x + 1)]

        for i in range(1, x + 1):
            l = i * (i - 1) // 2 + 1
            for j in range(i):
                res[j][i - 1] = j + l
            for j in range(i):
                res[i][j] = j + l
        print(k)
        for row in res:
            print(k - 1, *row)
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
def tenka18_d():
    n = int(input())
    if n == 1:
        ans = ['Yes', '2', '1 1', '1 1']
        return print(*ans, sep='\n')
    if n == 2:
        return print('No')

    k = -1
    for i in range(2, int((2*n)**0.5)+2):
        if 2*n % i > 0: continue
        if 2*n // i == i - 1:
            k = i
            break
    if k == -1:
        return print('No')

    l = k-1
    res = [[l] for _ in range(k)]
    for i in range(l):
        s = l*(l+1)//2 - (l-i)*(l-i+1)//2 + 1
        arr = [x for x in range(s, s+l-i)]
        res[i] += arr
        for j in range(l-i):
            res[i+1+j].append(arr[j])

    print('Yes')
    print(k)
    for ln in res:
        print(*ln, sep=' ')

if __name__ == '__main__':
    tenka18_d()

Solution (Python):
def main():
    N = int(input())
    
    
    
    
    
    
    n = 1
    while n * (n + 1) < 2 * N:
        n += 1
    if n * (n + 1) != 2 * N:
        print('No')
        return
    ans = [list() for _ in range(n + 1)]
    num = 0
    for left in range(n):
        for right in range(left + 1, n + 1):
            num += 1
            ans[left].append(num)
            ans[right].append(num)
    print('Yes')
    print(len(ans))
    for li in ans:
        print('{} {}'.format(len(li), ' '.join(map(str, li))))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import collections
import bisect
import copy



sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7


ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))





def main():
    n = ni()
    yes = dict()
    for i in range(3, 1000):
        if (i * (i - 1)) % 2 == 0:
            yes[(i * (i - 1)) // 2] = [i, i - 1]
    tmp = max(yes)

    if n == 1:
        print("Yes")
        print(2)
        print(1, 1)
        print(1, 1)
        exit(0)


    if n not in yes.keys():
        print("No")
        exit(0)

    xl, xs = yes[n]

    ans = [[] for _ in range(xl)]
    cnt = 1
    idx = 0
    while xs >= 1:
        tmp = cnt
        for i in range(idx, min(xl, idx + 3)):
            for j in range(xs):
                if cnt == tmp + 3 * (xs - 1):
                    ans[i].append(tmp)
                    break
                else:
                    ans[i].append(cnt)
                if j != 0 and j != xs - 1:
                    ans[idx + 2 + j].append(cnt)
                if j != xs - 1:
                    cnt += 1
        idx += 3
        xs -= 3

    print("Yes")
    print(len(ans))
    for ansi in ans:
        print(len(ansi), *ansi, sep=" ")


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import collections
import bisect
import copy



sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7


ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))





def main():
    n = ni()
    yes = dict()
    for i in range(3, 1000):
        if (i * (i - 1)) % 2 == 0:
            yes[(i * (i - 1)) // 2] = [i, i - 1]
    tmp = max(yes)

    if n == 1:
        print("Yes")
        print(2)
        print(1, 1)
        print(1, 1)
        exit(0)


    if n not in yes.keys():
        print("No")
        exit(0)

    xl, xs = yes[n]

    ans = [[] for _ in range(xl)]
    cnt = 1
    idx = 0
    while xs >= 0:
        tmp = cnt
        for i in range(idx, min(xl, idx + 3)):
            for j in range(xs):
                if cnt == tmp + 3 * (xs - 1):
                    ans[i].append(tmp)
                    break
                else:
                    ans[i].append(cnt)

                if j != 0 and j != xs - 1:
                    ans[idx + 2 + j].append(cnt)
                if j != xs - 1:
                    cnt += 1
        idx += 3
        xs -= 3

    print("Yes")
    print(len(ans))
    for ansi in ans:
        print(len(ansi), *ansi, sep=" ")


if __name__ == '__main__':
    main()

Solution (Python):
import itertools
N = int(input())
r = int((N*2)**0.5)
if r * (r+1) == N*2:
    print('Yes')
    print(r+1)
    ans = [[r] for _ in range(r+2)]
    for i, c in enumerate(itertools.combinations(range(1, r+2), 2), start=1):
        ans[c[0]].append(i)
        ans[c[1]].append(i)
    for a in ans[1:]:
        print(*a)
else:
    print('No')

Solution (Python):



n = int(input())
for k in range(10000):
    if k*(k-1) == 2*n:
        break
    elif k*(k-1) > 2*n:
        print('No')
        exit()
print('Yes')
print(k)
ret = [[] for _ in range(k)]
ii = 0
for i in range(k-1):
    for j in range(1,k-i):
        ret[i].append(ii+j)
        ret[i+j].append(ii+j)
    ii += k-i-1
for i in range(k):
    print(' '.join(map(str,[k-1] + ret[i])))

Solution (Python):
import sys


n=int(input())

if n==1:
    print('Yes')
    print(2)
    print(1,1)
    print(1,1)
    sys.exit()

k=3
while True:
    if (k-1)*k//2<n:
        k+=1
    elif (k-1)*k//2==n:
        break
    else:
        print('No')
        sys.exit()

print('Yes')
print(k)

def divide(x,y):
    if x==3:
        return [[1,2],[2,3],[3,1]]
    else:
        res=divide(x-(y-1),y-1)
        for i in range(y-1):
            res[i].append((x-y+2)+i)
        res.append([i for i in range(x-y+2,x+1)])
        return res


Ans=divide(n,k)
for ans in Ans:
    print(k-1,*ans)

Solution (Python):
n = int(input())
if n == 1:
    print('Yes')
    print(2)
    print(1,1)
    print(1,1)
    exit()


for i in range(2,10**3):
    if i*(i+1) == n*2:
        k,l = i+1, i
        break
else:
    print('No')
    exit()

print('Yes')

ans = [ [] for _ in range(k)]
top = 0
bottom = 1
for i in range(1,n+1):
    ans[top].append(i)
    ans[bottom].append(i)
    if bottom < k-1:
        bottom += 1
    else:
        top += 1
        bottom = top+1

print(len(ans))
for row in ans:
    print(len(row), *row )

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
tmp=int(math.sqrt(n*2))
if tmp*(tmp+1)!=n*2:
    print("No")
    exit()

lst=[]
cnt=1

for i in range(tmp+1):
    lsttmp=[len(lst)+1]
    for j in range(len(lst)):
        lsttmp.append(lst[j][lst[j][0]])
        lst[j][0]+=1
    
    
    while len(lsttmp)<tmp+1:
        lsttmp.append(cnt)
        cnt+=1
    lst.append(lsttmp)

print("Yes")
print(tmp+1)
for i in range(tmp+1):
    print(*([tmp]+lst[i][1:]))