Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
def solve(n):
    k= -1
    for i in range(1000):
        if i * (i-1) == 2 * n:
            k =i
            print("Yes")
            break
        elif i*(i-1)  > 2*n:
            print("No")
            return
    ans = [[-1 for i in range(k-1)] for i in range(k)]
    c = 1
    print(k-1)
    for i in range(k):
        for j in range(k-i-1):
            ans[i][i+j] = c
            ans[i+j+1][i] = c
            c += 1

    for i in range(k):
        print(k ,end = "")
        for j in ans[i]:
            print(" " + str(j),end = "")
        print()

solve(int(input()))
    
        




# Example run
# Input:
-5559
# Output:
No
def main():
    #部分集合のサイズnの時n+1個の部分集合
    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()


# Example run
# Input:
1008752943
# Output:
No
def resolve():
    N = int(input())
    #N = 1
    K = -1
    for i in range(1, 1000):
        if (i*(i-1)//2 == N):
            K = i
            break

    if K == -1:
        print("No")
        return
    else:
        S = [[] for _ in range(K+1)]
        cnt = 1
        for i in range(K):
            for j in range(i+1, K):
                S[i].append(cnt)
                S[j].append(cnt)
                cnt += 1

    print("Yes")
    print(K)
    for s in S:
        print(len(s), *s)

if __name__ == "__main__":
    resolve()

# Example run
# Input:
127077282
# Output:
No
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')


# Example run
# Input:
30456987
# Output:
No
N=int(input())
if N%3>0:print('No')
else:
    X=[]
    print('Yes')
    M=N//3
    for i in range(3):
        X.append([(x-1)%N+1 for x in range(1+M*i,2+M+M*i)])
    for i in range(M-1):
        X.append([X[j][i+1] for j in range(3)])

def enstr(x):
    s=''
    for i in x:
        s+=(str(i)+' ')
    return s

for i in X:
    print(len(i),enstr(i))

# Example run
# Input:
-6
# Output:
Yes
0 
0 
0
def issquare(n):
    f = (0,0,1,1,0,1,1,1,1,0,1,1,1,1,1,1)
    if f[n & 0xf]:
         return False
    l, r = 1, n
    while l <= r:
        m  = l + (r - l) // 2
        m2 = m * m
        if m2 < n:
            l = m + 1
        elif m2 > n:
            r = m - 1
        else:
            return True
    return False        

def istriangular(n):
    return issquare(1+8*n)

N = int(input())

if istriangular(N):
    print('Yes')
    n = int((1+8*N)**0.5-1) // 2
    k = n + 1
    print(k)
    base = 1
    for i in range(n):
        s = [n]
        base += i
        add = 0
        for j in range(n):
            s.append(base + add)
            if j < i:
                add += 1
            else:
                add += j + 1
        print(*s)
    s = [n, 1]
    for i in range(2, n+1):
        s.append(s[-1]+i)
    print(*s)
else:
    print('No')

# Example run
# Input:
3
# Output:
Yes
3
2 1 2
2 2 3
2 1 3
N = int(input())

ans = 'No'
k = 2
while True:
    kk = k*(k-1)
    if kk > N*2:
        ans = 'No'
        break
    elif kk == N*2:
        ans = 'Yes'
        break
    k += 1

print(ans)
if ans == 'Yes':
    print(k)
    psum = (k-1)*k//2
    tops = []
    for i in range(k):
        ntop = psum - (k-1-i)*(k-i)//2 + 1
        tops.append(ntop)
    for i in range(k):
        print(k-1, end=" ")
        # 1st
        for j in range(i):
            print(tops[j]+(i-j-1), end=" ")
        # 2nd
        for j in range(k-1-i):
            print(tops[i]+j, end=" ")
        print('')


# 1 2 3 4
# 1 5 6 7
# 2 5 8 9


# Example run
# Input:
-1
# Output:
No
n=int(input())
for i in range(n):
  if i*(i+1)//2>n:
    print('No')
    exit()
  elif i*(i+1)//2==n:break
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)

# Example run
# Input:
115
# Output:
No
N = int(input())

for i in range(N + 1):
    if i * (i + 1) // 2 == N:
        M = i
        print('Yes')
        res = [[] for _ in range(M + 1)]
        for i in range(M + 1):
            res[i].append(M)
        cnt = 1
        for k in range(M):
            for i in range(M - k):
                res[k].append(cnt + i)
            for i in range(M - k):
                res[k + i + 1].append(cnt)
                cnt += 1
        for r in res:
            print(*r)
        break
else:
    print('No')

# Example run
# Input:
10403
# Output:
No
n=int(input())
f=True
r=1
i=2
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])))

# Example run
# Input:
-8132114
# Output:
No
def d_crossing(N):
    """
    S_k は、どの2つの部分集合の共通部分の要素数が1であり、1からNのどの要素も
    ちょうど2回しか使われないため、各集合の要素数はいずれもk-1である。
    また、要素数の和を考えると、 2N=k(k-1) ⇔ N=k(k-1)/2 である。

    逆に、1からk(k-1)/2までの数を三角形に並べたあと、対称行列になるように
    行列を構成すると、各行(列でも可)または対角成分を要素とした集合を部分集合とすれば
    条件を満たせる。
    (例: N=6)
    1         1 2 4
    2 3   <=> 2 3 5
    4 5 6     4 5 6
    として、{1, 2, 4}, {2, 3, 5}, {4, 5, 6}, {1, 3, 6} を部分集合とすればよい。
    """

    # N = k(k-1)/2 となる正整数kが存在するなら、求めるものが作れる
    k = 2
    while True:
        tmp = k * (k - 1)
        if tmp > 2 * N:
            return 'No'
        elif tmp == 2 * N:
            ans = ['Yes']
            break
        k += 1

    ans.append(str(k))
    # 1からk(k-1)/2までの数を三角形に並べ、対称行列を構成する
    matrix = [[0] * (k - 1) for _ in range(k - 1)]
    cnt = 1
    for r in range(k - 1):
        for c in range(r + 1):
            matrix[c][r] = matrix[r][c] = cnt
            cnt += 1
    # 各行を取り出したものを部分集合とする
    for r in matrix:
        ans.append('{0} {1}'.format(k - 1, ' '.join(map(str, r))))
    # 対角成分を取り出したものを部分集合とする
    tmp = [matrix[j][j] for j in range(k - 1)]
    ans.append('{0} {1}'.format(k - 1, ' '.join(map(str, tmp))))
    # 出力形式に沿って出力
    ans = '\n'.join(ans)
    return ans

N = int(input())
print(d_crossing(N))

# Example run
# Input:
-33
# Output:
No
import math

N = int(input())
k = math.ceil((2 * N) ** 0.5)
if N * 2 != k * (k - 1):
    print('No')
else:
    print('Yes')
    print(k)
    S = [[k - 1] for _ in range(k)]
    cnt = 1
    for i in range(k):
        for j in range(i+1, k):
            S[i].append(cnt)
            S[j].append(cnt)
            cnt += 1
    for i in range(k):
        print(" ".join(map(str, S[i])))

# Example run
# Input:
19928
# Output:
No
N = int(input())
L = [[] for _ in range(1000)]
l = 0
r = 1
for i in range(1, N+1):
  L[l].append(i)
  L[r].append(i)
  if(r-l == 1):
    r += 1
    l = 0
  else:
    l += 1
if(l != 0):
  print('No')
else:
  print('Yes')
  print(r)
  for i in range(r):
    print(len(L[i]), *L[i])

# Example run
# Input:
-813
# Output:
Yes
1
0
n = int(input())

r = []
c = 1
i = 1
while i <= n:
    r.append([])
    for j in range(1, c+1):
        r[-1].append(i)
        i += 1
    c += 1

if i == n+1:
    print('Yes')
    print(c)
    for j in range(c-1):
        result = [c-1]
        result.extend(r[j])
        for x in range(j+1, c-1):
            result.append(r[x][j])
        print(*result)
    result = [c-1]
    for x in range(c-1):
        result.append(r[x][x])
    print(*result)
else:
    print("No")


# Example run
# Input:
-75
# Output:
No
N = int(input())

if N == 1:
    print('Yes')
    print(2)
    print(1, 1)
    print(1, 1)
else:
    r = int((N*2)**0.5)
    if N*2 == r*(r+1):
        print('Yes')
        print(r+1)
        ans = []

        if r % 2 == 0:
            for i in range(r//2):
                ans.append([j+1+i*(r+1) for j in range(r+1)])
            for i in range(r//2):
                c = [j+1+i*(r+1) for j in range(r+1)]
                ans.append(c[i+1:]+c[:i+1])

        else:
            for i in range(r//2):
                ans.append([j+1+i*(r+1) for j in range(r+1)])

            m = N % (r+1)

            for i in range(r//2):
                c = [j+1+m+i*(r+1) for j in range(r+1)]
                ans.append(c[i+1:]+c[:i+1])

            l = [i+1 for i in range(N)]
            ans.append(l[-m:]+l[:m])

            # print(ans)

        for i in zip(*ans):
            print(r, *i)

    else:
        print('No')


# Example run
# Input:
2147483647
# Output:
No
n = int(input())
if n == 3:
  print("Yes")
  print("3")
  print("2 1 2")
  print("2 3 1")
  print("2 2 3")
elif n==1:
  print("Yes")
  print("1 1")
  print("1 1")
else:
  print("No")

# Example run
# Input:
-15860207
# Output:
No
def calc(N):
    n = 0
    for i in range(1,N+1):
        n+=i
        if n>=N:break
    if n!=N:
        print("No")
        return
    print("Yes")
    print(i+1)
    S = [list(range(1,i+1))]
    print(i,*S[0])
    m = i
    for j in range(1,i+1):
        S.append([])
        for s in S[:-1]:
            S[-1].append(s.pop())
        S[-1].extend(range(m+1,m+1+i-j))
        m = max(S[-1])
        print(i,*S[-1])
def main():
    N=int(input())
    calc(N)
main()

# Example run
# Input:
3
# Output:
Yes
3
2 1 2
2 2 3
2 1 3
MOD = 10 **9 + 7
INF = 10 ** 10

def main():
    N = int(input())
    K = 0
    for i in range(2,N + 1):
        if i*(i - 1)//2 == N:
            K = i
            break
    if K == 0:
        print('No')
        return
    ans = [[0] * (K - 1) for _ in range(K)]

    before = 1
    for i in range(K - 1):
        for j in range(i,K - 1):
            ans[i][j] = before
            ans[j + 1][i] = before
            before += 1
    print('Yes')
    print(K)
    for i in range(K):
        print(len(ans[i]),*ans[i])
if __name__ == '__main__':
    main()

# Example run
# Input:
0
# Output:
No
N = int(input())
K = (((8 * N + 1) ** (1/2) + 1) / 2)

def recursive(k):
    if k == 2:
        return [[1], [1]]
    else:
        before = recursive(k - 1)
        r = [_ for _ in range(1 + (k - 2) * (k - 1) // 2, 1 + k * (k - 1) // 2)]
        return ([before[_] + [r[_]] for _  in range(len(r))] + [r])

if K.is_integer():
    K = int(K)
    print('Yes')
    print(K)
    [print(K - 1, ' '.join(map(str, ary))) for ary in recursive(K)]
else:
    print('No')

# Example run
# Input:
63
# Output:
No
n = int(input())
kaidan = [1]
for i in range(2,int((2*n)**0.5+1)):
    kaidan.append(kaidan[-1]+i)
if not n in kaidan:
    print("No")
    exit()
print("Yes")
size = kaidan.index(n)+1
print(size+1)
hyo = [[0 for i in range(size)] for j in range(size)]
for i in range(size):
    for j in reversed(range(i+1)):
        hyo[i][j] = kaidan[i] - (i - j)
        hyo[j][i] = hyo[i][j]
kar = []
for i in range(size):
    kar.append(hyo[i][i])
hyo.append(kar)

for i in range(size+1):
    print(size,end=" ")
    print(*hyo[i])

# Example run
# Input:
31447
# Output:
No
N = int(input())

k = N*2
flag = False
tmp = 0
for x in range(2, int(k ** 0.5) + 1):
    if k % x == 0 and k // x == x+1:
        tmp = x
        flag = True
        break
if flag:
    print("Yes")
    print(tmp+1)
    ans = [[] for i in range(tmp+1)]
    count = 0
    for i in range(tmp+1):
        ret = [str(tmp)]
        for k in range(i):
            ret.append(ans[k][i])
        for j in range(tmp):
            if i == 0:
                count += 1
                ret.append(str(count))
            else:
                if j < tmp - i:
                    count += 1
                    ret.append(str(count))

        ans[i] = ret
    for i in range(tmp+1):
        print(" ".join(ans[i]))
else:
    print("No")


# Example run
# Input:
1
# Output:
No
from collections import deque
N = int(input())
used1 = [0] * N
used2 = [0] * N

ans_list = [0] * 400
for i in range(1, 400):
  ans_list[i] = int(i * (i + 1) // 2)

if N in ans_list:
  print("Yes")
  k = ans_list.index(N)
  print(k + 1)
  A = [deque([]) for i in range(k)]
  for i in range(1, N + 1):#最大10 ** 5
    p = int(((1 + 8 * i) ** (1/ 2) - 1.001) // 2)
    A[p].append(i)
  #print(A)
  #print(A[1][0])
  for i in range(k):
    print(k, end = " ")
    for j in range(i + 1):
      #print("j", j)
      print(A[i][j], end = " ")
    for l in range(i + 1, k):
      print(A[l][i], end = " ")
    print("")
  
  print(k, end = " ")
  for i in range(k):
    print(A[i][i], end = " ")
  print("")
else:
  print("No")

# Example run
# Input:
-1
# Output:
No
# tenka1-2018D - Crossing
def main():
    N = int(input())
    K = int((N * 2) ** 0.5)
    if K * (K + 1) / 2 != N:
        print("No")
        return
    row, cur, cnt = [], 1, 1
    while cur + cnt - 1 <= N:
        row.append(list(range(cur, cur + cnt)) + [0] * (K - cnt))
        cur += cnt
        cnt += 1
    col = [list(c) for c in zip(*row)]
    ans, diag = [], []  # diag: diagonal line
    for i, (r, c) in enumerate(zip(row, col)):
        diag.append(r[i])
        ans.append(r[:i] + c[i:])
    ans.append(diag)
    print("Yes", K + 1, sep="\n")
    for a in ans:
        print(K + 1, end=" ")
        print(" ".join(map(str, a)))


if __name__ == "__main__":
    main()

# Example run
# Input:
4331
# Output:
No
def search(n):
    for i in range(1, 3*n):
        if i*(i-1) == 2*n:
            return i
    return 0


n = int(input())

nodes = search(n)
if nodes != 0:
    print("Yes")
    print(nodes)
    out = [[] for i in range(nodes)]
    index = [int(i) for i in range(nodes)]
    counter = 1
    for i in range(len(index)):
        for j in range(index[i]):
            out[j].append(counter)
            out[i].append(counter)
            counter += 1
    for i in range(len(out)):
        str1 = str(out[i])
        table = str1.maketrans({
            ',': '',
            '[': '',
            ']': '',
        })
        str1 = str1.translate(table)
        print(("{} {}".format(len(out[i]), str1)))
else:
    print("No")

# Example run
# Input:
224
# Output:
No
def yaku(n):
    ret = []

    for i in range(n):
        if n % (i+1) == 0:
            ret.append(i+1)

    return list(set(ret))

def choufuku(t, sets):
    for s in sets:
        cnt = 0
        for i in s:
            if i in t:
                cnt += 1
        if cnt > 1:
            return True
    return False

n = int(input())

ele = [int(i / 2)+1 for i in range(n*2)]

yak = yaku(n*2)

dame = 1

for i in range(len(yak)):
    #print('yak', yak[i])
    if yak[i] == 1 or yak[i] == n*2:
        continue
    nsets = yak[i]
    nelem = int(n * 2 / nsets)

    ret = [[] for i in range(nsets)]

    for e in ele:

        for r in ret:
            if len(r) == nelem:
                continue
            elif e in r:
                continue
            else:
                tmp = r[:]
                tmp.append(e)
                if choufuku(tmp, ret):
                    continue
                else:
                    r.append(e)
                    break

    l = 0
    for r in ret:
        l += len(r)
        
    if l != n*2:
        continue

    dame = 0

    for i in range(len(ret) - 1):
        for j in range(i+1, len(ret)):
            if len(set(ret[i] + ret[j])) + 1 != (len(ret[i]) + len(ret[j])):
                dame = 1
                break
    
    if dame == 1:
        continue
    

    print('Yes')
    print(len(ret))
    for r in ret:
        print(str(len(r)) + ' ', end = "")
        for rr in r:
            print(str(rr) + ' ', end = "")
        print('')
    break

if dame == 1:
    print('No')

# Example run
# Input:
-4589549
# Output:
No
import math
n = int(input())
x = (-1+math.sqrt(1+8*n))/2
if not x.is_integer():
  print ('No')
  exit (0)
x = int(x)
ans = []
k = 1
for i in range(x+1):
  a = []
  for j in range(x):
    if j >= i:
      a.append(k)
      k +=1
    else:
      a.append(ans[j][i-1])
  ans.append(a)
for i in range(x+1):
  print (x,*ans[i]) 

# Example run
# Input:
6
# Output:
3 1 2 3
3 1 4 5
3 2 4 6
3 3 5 6
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()

print('Yes')
if N == 1:
	print(1)
	print(1, 1)
	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(k)
for s in S:
	print(k-2, ' '.join(map(str, s)))

# Example run
# Input:
116
# Output:
No
import math
n = int(input())
ok = False
for i in range(2, int(math.sqrt(n*2)+1)):
    if n*2 % i == 0 and n*2 // i == i+1:
        ok = True
        size = i
        break
if ok:
    ans = [[0] * size for _ in range(size+1)]
    val = 1
    for i in range(0, size+1):
        for j in range(i, size):
            ans[i][j] = val
            val += 1
    val = 1
    for i in range(0, size):
        for j in range(i, size):
            ans[1+j][i] = val
            val += 1
    print("Yes")
    print(size+1)
    for line in ans:
        print(str(size) + " " + " ".join([str(item) for item in line]))

else:
    print("No")

# Example run
# Input:
166355
# Output:
No
N = int(input())
for i in range(1,N+1):
  if i*(i-1)//2==N:
    print('Yes')
    ans = [[] for i in range(i)]
    cnt = 0
    p = 0
    q = 1
    while cnt<N:
      cnt += 1
      ans[p].append(cnt)
      ans[q].append(cnt)
      if q==i-1:
        p += 1
        q = p+1
      else:
        q += 1
    print(len(ans))
    for a in ans:
      print(len(a),*a)
    break
else:
  print('No')

# Example run
# Input:
3876
# Output:
No
def main():
    n=int(input())
    m=int((2*n)**0.5)
    if m*(m+1)==n*2:
        print("Yes")
        m+=1
        print(m)
    else:
        print("No")
        exit()
    
    ans=[[m-1] for i in range(m)]
    c=1
    for i in range(m):
        for j in range(i+1,m):
            ans[i].append(c)
            ans[j].append(c)
            c+=1
    for i in ans:
        print(*i)


if __name__ == '__main__':
    main()








# Example run
# Input:
2569
# Output:
No
import math

n = int(input())
num = 2 * n
tmp = int(math.sqrt(num))
if tmp * (tmp + 1) != num:
    print("No")
    exit()
print("Yes")
print(tmp + 1)
lst = [[] for _ in range(tmp + 1)]
last = 1
for i in range(tmp + 1):
    print(tmp, end = " ")
    cnt = 0
    for j in range(i):
        x = lst[j].pop()
        print(x, end = " ")
        cnt += 1
    for k in range(cnt, tmp):
        print(last, end = " ")
        lst[i].append(last)
        last += 1
        
    print()

# Example run
# Input:
337
# Output:
No
n=int(input())
p=int((2*n)**0.5)
if n!=((p+1)*p)//2:
    print("No")
else:
    t=[[]for i in range(p)]
    c=1
    for i in range(1,p):
        for j in range(i):
            t[i].append(c)
            t[j].append(c)
            c+=1
    print("Yes")
    print(p)
    for i in t:
        i=[len(i)]+i
        print(*i)

# Example run
# Input:
57223618
# Output:
No
n=int(input())
if n==1:
    print("Yes")
    print(2)
    print(1)
    print(1)
    exit()
elif n==3:
    print("Yes")
    print(3)
    print(1,2)
    print(2,3)
    print(3,1)
    exit()
else:
    print("No")

# Example run
# Input:
12
# Output:
No
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
#N = k(k-1)//2を満たすkが存在するかをまず判定
k = ceil(sqrt(2*N))
if k*(k-1) != 2*N:
    print("No")
    exit()
print("Yes")
print(k)
#crossing pairを構成する(1からNまで各２個ずつ別々に含まれるように配置)
S = [[]for _ in range(k+1)]
num = 1
for i in range(1,k):
    for j in range(i+1,k+1):
        S[i].append(num)
        S[j].append(num)
        num +=1
for i in range(1,k+1):
    print(k-1," ".join(map(str,S[i])))

# Example run
# Input:
57223618
# Output:
No
from collections import defaultdict

MOD = 998244353


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort(reverse=True)
    total = sum(A)
    half = -(-total//2)
    dp1 = [defaultdict(lambda: 0) for _ in range(2)]
    dp1[0][0] = 1
    dp2 = [defaultdict(lambda: 0) for _ in range(2)]
    dp2[0][0] = 1
    for i in range(N):
        dp1[(i+1) & 1] = defaultdict(lambda: 0)
        dp2[(i+1) & 1] = defaultdict(lambda: 0)
        for j in dp1[i & 1]:
            nj = min(j+A[i], half+1)
            dp1[(i+1) & 1][j] = (dp1[(i+1) & 1][j] + dp1[i & 1][j] * 2) % MOD
            dp1[(i+1) & 1][nj] = (dp1[(i+1) & 1][nj] + dp1[i & 1][j]) % MOD
            dp2[(i+1) & 1][j] = (dp2[(i+1) & 1][j] + dp2[i & 1][j]) % MOD
            dp2[(i+1) & 1][nj] = (dp2[(i+1) & 1][nj] + dp2[i & 1][j]) % MOD
    ans = (3**N) % MOD
    for t in dp1[N & 1]:
        if t >= half:
            ans = (ans - dp1[N & 1][t] * 3) % MOD
            if total % 2 == 0 and t == half:
                ans = (ans + dp2[N & 1][t] * 3) % MOD
    print(ans)


if __name__ == "__main__":
    main()


# Example run
# Input:
-1794
# Output:
0.0
import math
N=int(input())
q=int(math.sqrt(N*2))
if-~q*q+q<N:print("No");exit()
S=[list(range(1,q+1))]
S+=[[j]for j in S[0]]
l=q
for i in range(1,q):
	r=list(range(l+1,l+1+q-i))
	S[i]+=r
	for j in range(q-i):S[i+j+1]+=[r[j]]
	l=r[-1]
print("Yes")
print(len(S))
for s in S:print(len(s)," ".join(map(str,s)))

# Example run
# Input:
8
# Output:
Yes
5
4 1 2 3 4
4 1 5 6 7
4 2 5 8 9
4 3 6 8 10
4 4 7 9 10
K = int(input())

def calc_n(K):
  if K == 1:
    return "Yes\n1"
  for n in range(1, int(K/2)+2):
    if n*(n+1)/2 == K:
      return n
  return "No"

N = calc_n(K)
if not isinstance(N, int):
  print(N)
else:
  print("Yes")
  print(N+1)
  last = [i for i in range(1, N+1)]
  count = 2
  first_set = [str(i) if i == 1 else str(sum(last[:i-1])+1) for i in range(1, N+1)]
  print(N, " ".join(first_set))
  last_set = [str(sum(last[:i])) for i in range(1,N+1)]
  print(N, " ".join(last_set))
  while count != N+1:
    first_number = sum(last[:count-1])+1
    other_set = [i for i in range(first_number, first_number+count)]
    other_set.extend([first_number+count*(i+1)-1+sum(last[:i-1]) for i in range(1, N-count+1)])
    count += 1
    other_set = [str(i) for i in other_set]
    print(N, " ".join(other_set))

# Example run
# Input:
-163
# Output:
No
n=int(input())
a=[[1]]
i=1
for j in range(1,n):
    a.append(list(range(i,i+j)))
    if n==i+j-1:
        break
    elif i+j>n:
        print('No')
        exit()
    i+=j
print('Yes')
m=len(a)
for i in range(m-1):
    for j in range(i+1+(i<1),m):
        a[i].append(a[j][i])
print(m)
for b in a:
    print(len(b),*b)

# Example run
# Input:
-1
# Output:
Yes
1
1 1
n = int(input())

def isTriangular(n):
    i = 1
    while( (i*(i+1))//2 <= n) :
        if (i*(i+1))//2 == n:
            return True
        i+=1
    return False


def solve(n):
    if not isTriangular(n):
        print("No")
        return
    i = 1
    jump = 2
    ans = [[1],[1]]
    while ans[-1][-1] != n:
        next_ind = range(ans[-1][-1]+1, ans[-1][-1]+jump+1)
        for i in range(len(next_ind)):
            ans[i].append(next_ind[i])
        ans.append(next_ind)
        i+=jump
        jump += 1
    print("Yes")
    print(len(ans))
    for x in ans:
        p_str = ""
        p_str += str(len(x))
        for b in x:
            p_str += " " 
            p_str += str(b)
        print(p_str)

        

        

solve(n)

    


# Example run
# Input:
0
# Output:
No
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 = ' ')

# Example run
# Input:
228552
# Output:
No