Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
def search(n):
    for i in range(1, n+1):
        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:
-1745
# 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(2)
    print(1,1)
    print(1,1)
else:
    print('No')

# Example run
# Input:
542366274
# Output:
No
def ans(n):
    global c
    c+=1
    if n==1:
        return 1
    else:
        return ans(n-1)+n


n=int(input())
f=0
c=0

for i in range(1, n):
    c=0
    ch=ans(i)
    if ch==n:
        print("Yes")
        f=1
        break
    if ch > n:
        print("No")
        break


if f:
    print(c+1)
    k=c
    i=j=0
    li=[[-1 for j in range(c)] for i in range(c+1)]
    #print(li)
    for l in range(1, n+1):
        li[i][j]=l
        j+=1
        if j==k:
            j=0
            i+=1
            k-=1

    nowi=1
    i=1
    j=c-1
    k=c
    count=1
    for l in range(1, n+1):
            #print(nowi)
            li[i][j]=l
            i+=1
            count+=1
            if count==k+1:
                count=1
                nowi+=1
                i=nowi
                j-=1
                k-=1

    for i in li:
        for j in i:
            print(j, end=" ")
        print()


# Example run
# Input:
141
# Output:
No
N = int(input())
if N >= 3:
    print("Yes")
    for i in range(1, N):
        print(2, i, N)
    print(N - 1, " ".join(map(str, range(1, N))))

else:
    print("No")

# Example run
# Input:
-62950208
# Output:
No
n = int(input())
a = []
for i in range(1,500):
    a.append(i*(i-1)//2)
if (n in a):
    print("Yes")
    x = a.index(n)+1 #3
    ans = [[] for _ in range(x)]
    now = 1
    l = 0
    while l<x:
        for i in range(x-l-1):
            ans[l].append(now)
            ans[l+1+i].append(now)
            now += 1
        l += 1
    print(x)
    for i in range(x):
        print(x-1,*ans[i])
        
else:
    print("No")

# Example run
# Input:
-658328
# Output:
No
N=int(input())
print("Yes")
print(N)
for i in range(1,N):
  print(str(N)+" "+str(i)+" "+str(i+1))
print(str(N)+" 1 "+str(N))

# Example run
# Input:
-7
# Output:
Yes
-7
-7 1 -7
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")
    for i in t:
        i=[len(i)]+i
        print(*i)

# Example run
# Input:
923
# Output:
No
n=int(input())
l=[]
s=0
for i in range(n+2):
  l.append(s)
  s+=i+1
if n not in l:
  print('No')
else:
  k=l.index(n)+1
  ans=[[] for i in range(k)]
  c=0
  for i in range(k):
    for j in range(i+1,k):
      ans[i].append(c+1)
      ans[j].append(c+1)
      c+=1
  print('Yes')
  print(k)
  for i in range(k):
    print(k-1,*ans[i])


# Example run
# Input:
-153210247
# Output:
No
from itertools import combinations as comb
n = int(input())
l = int((2*n)**0.5)
if 2*n == l*(l+1):
  print('Yes')
  print(l+1)
  ans = [[] for i in range(l+1)]
  for i,j in zip(range(n),comb(range(l+1),2)):
    ans[j[0]].append(i+1)
    ans[j[1]].append(i+1)
  for i in ans:
    print(l,*i,sep=' ')
else:
  print('No')

# Example run
# Input:
188355
# Output:
No
n = int(input())

k = (1 + (1 + 8 * n)** 0.5) * 0.5
if k.is_integer():
    print('Yes')
    k, num = int(k), 1
    ans = [[] for _ in range(k)]
    for i in range(k):
        for j in range(i + 1, k):
            ans[i].append(num)
            ans[j].append(num)
            num += 1
        print(k - 1, *ans[i])
else:
    print('No')


# Example run
# Input:
3208074
# Output:
No
N = int(input())
num = (N-2)**(0.5)
if N == 3:
  print("Yes");print(3)
  A = [2, 1, 2]; print(*A)
  A = [2, 2, 3]; print(*A)
  A = [2, 3, 1]; print(*A); exit()
if num%1 != 0:
  print("No");exit()
num = int(num)
ans = []
for i in range(num):
  temp = [1] + [2+j+num*i for j in range(num)]
  ans.append(temp)
for i in range(num):
  temp = [2+i+num*j for j in range(num)] + [N]
  ans.append(temp)
print("Yes")
print(num*2)
for x in ans:
  ret = [num+1] + x
  print(*ret)

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

def main():
    n = int(input())
    k = int(math.floor(math.sqrt(2*n)))
    if k * (k + 1) != 2 * n:
        print("No")
    else:
        print("Yes")
        setList = [[0]*k for i in range(k+1)]
        start = 1
        end = start + k
        cnt = 0
        for j in range(k):
            p = 0
            for p, i in enumerate(range(start, end)):
                setList[j][j+p] = i
                setList[j+p+1][j] = i
            cnt += 1
            start = end
            end = end + k - cnt
        for i in range(k+1):
            s = str(k) + " "
            for sl in setList[i]:
                s += str(sl) + " "
            print(s)
        pass

if __name__ == '__main__':
    main()

# Example run
# Input:
5354599
# Output:
No
n = int(input())
t = 2*n
a = int(t**0.5)
if a*(a+1) != t:
    print("No")
    exit()

print("Yes")
print(a+1)
count = [0]*n
ans = [[] for i in range(a+1)]
now = a
p = [0]*(a+1)
for i in range(a):
    ans[i].append(i+1)
    ans[i+1].append(i+1)
    count[i] += 2
for i in range(a+1):
    if i >= 2:
        for j in range(i-1):
            while count[ans[j][p[j]]-1] ==2:
                p[j] += 1
            x = ans[j][p[j]]
            ans[i].append(x)
            count[x-1] +=1
        x = len(ans[i])
        for j in range(a-x):
            ans[i].append(now+1)
            now += 1
    else:
        x = len(ans[i])
        for j in range(a-x):
            ans[i].append(now+1)
            count[now]+=1
            now += 1
for i in range(a+1):
    print(a,*ans[i])


# Example run
# Input:
411
# Output:
No
import math
n = int(input())
s = (-1+math.sqrt(1+8*n))/2
if (int(s)!=s):
    print("No")
else:
    print("Yes")
    s = int(s)
    print(s+1)
    A = []
    w = 1
    for i in range(s+1):
        print(s, end=" ")
        for j in range(len(A)):
            print (A[j][i-j-1], end=" ")
        A.append([])
        for j in range(s-len(A)+1):
            print(w, end=" ")
            A[i].append(w)
            w+=1
        print()

# Example run
# Input:
0
# Output:
Yes
1
0
K = int(input())

def calc_n(K):
  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(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:
-1964
# Output:
No
K = int(input())

def calc_n(K):
  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:
-1
# Output:
No
n=int(input())
for i in range(1,1000):
  if i*(i+1)//2==n:
    D=[[0]*i for l in range(i)]
    stopcnt=i
    cnt=0
    a,b=0,0
    print('Yes')
    print(i+1)
    for j in range(n):
      D[a][j-b]=j+1
      cnt+=1
      if cnt==stopcnt:
        a+=1
        b+=stopcnt-1
        cnt=0
        stopcnt-=1
    for a in range(i):
      for b in range(a,i):
        D[b][a]=D[a][b]
    DD=[]
    for j in range(i):
      DD.append(D[j][j])
    D.append(DD)
    for j in D:
      print(len(j),*j)
    exit()
print('No')


# Example run
# Input:
-37
# Output:
No
N=int(input())
if N==1:
  print('''Yes
2
1
1''')
elif N==3:
  print('''Yes
3
2 1 2
2 3 1
2 2 3''')
else:
  print('No')

# Example run
# Input:
61070189
# Output:
No
n = int(input())

if n == 1:
    print('Yes')
    print(2)
    print('1 1')
    print('1 1')
elif n == 3:
    print('Yes')
    print(3)
    print('2 1 2')
    print('2 3 1')
    print('2 2 3')
elif n == 6:
    print('Yes')
    print(4)
    print('3 1 2 6')
    print('3 2 3 4')
    print('3 4 5 6')
    print('3 1 3 5')
else:
     print('No')


# Example run
# Input:
-194151326
# Output:
No
n=int(input())
d=int((1+8*n)**(1/2))
if d**2!=(1+8*n) or d%2==0:
    print("No");exit()
k=(1+d)//2
print("Yes")
print(k)
haba=1
cnt=1
ret=[[] for i in range(k)]
while cnt<=n:
    for s in range(k-haba):
        ret[s].append(cnt)
        ret[s+haba].append(cnt)
        cnt+=1
    haba+=1
for i in ret:
    print(len(i),*i)

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

k = N*2
flag = False
tmp = 0
if N == 1:
    print("Yes")
    print(2)
    print(1, 1)
    print(1, 1)
    exit(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:
17
# Output:
No
n = int(input())
koho = []
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

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

if is_prime(n):
    print("No")
    exit()

# Example run
# Input:
-163
# Output:
No
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-1, ' '.join(map(str, s)))

# Example run
# Input:
0
# Output:
Yes
1
0 1
0 1
from itertools import combinations
N = int(input())
if N==1:
    print("Yes")
    print(2)
    print(1,1)
    print(1,1)
elif N==2:
    print("No")
elif N==3:
    print("Yes")
    print(3)
    print(2,1,2)
    print(2,1,3)
    print(2,2,3)
else:
    flg = 0
    for i in range(4,int((3*N)**0.5)+2):
        if N==(i*(i-1))//2:
            flg=1
            K = i
            break
    if flg==0:
        print("No")
    else:
        S = {i:[] for i in range(K)}
        for j,x in enumerate(combinations(range(K),2)):
            j += 1
            i0,i1 = x[0],x[1]
            S[i0].append(j)
            S[i1].append(j)
        print("Yes")
        print(K)
        for i in range(K):
            print(len(S[i]),*S[i])

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

for k in range(2, N + 1):
    slen = k - 1
    if k * slen == 2 * N:
        print("Yes")
        print(k)
        x = [0] * N
        for i in range(k):
            s = [None] * slen
            for j in range(slen):
                n = (i + j) % N
                if x[n] < 2:
                    s[j] = str(n)
                    x[n] += 1
            print(slen, " ".join(s))
        break
else:
    print("No")

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

def printCompleteGraph(n):
    edge = [(u, v) for u in range(n)
                   for v in range(u + 1, n)
                   if u != v]
    name = {e: i+1 for i, e in enumerate(edge)}
    for u in range(n):
        e = [name[(min(u, v), max(u, v))] for v in range(n) if u != v]
        print(len(e), ' '.join(map(str, e)))

for n in range(2, N + 1):
    if n * (n - 1) // 2 == N:
        print('Yes')
        print(n)
        printCompleteGraph(n)
        exit()
print('No')


# Example run
# Input:
33
# Output:
No
l = {}
sum_n = 0
n = 1
while sum_n <= 10 ** 5:
    sum_n += n
    l[sum_n] = n
    n += 1
n = int(input())
if n not in l:
    print('No')
else:
    print('Yes')
    m = l[n]
    print(m+1)
    ans = [[] for _ in range(m+1)]
    min_n = 1
    max_n = 1
    for i in range(1, m+1):
        max_n += i
        for j in range(min_n, max_n):
            ans[j-min_n].append(j)
            ans[i].append(j)
        min_n = max_n
    for i in ans:
        print(*i)


# Example run
# Input:
9186
# Output:
No
N = int(input())
Ss = [[1, 2], [2, 3], [3, 1]]
while True:
    k = len(Ss)
    m = k * (k - 1) // 2
    if N < m:
        print("No")
        break
    elif N == m:
        print("Yes")
        print(k)
        for S in Ss:
            print(len(S), " ".join(map(str, S)))
        break
    S_new = []
    for i in range(k):
        x = k + i + 1
        Ss[i].append(x)
        S_new.append(x)
    Ss.append(S_new)

# Example run
# Input:
1049999
# Output:
No
def chk(k):
  if k*(k-1)//2 != n:
    return False
  l=[[] for i in range(k)];x=1
  for i in range(k):
    for j in range(i+1,k):
      l[i].append(x);l[j].append(x);x+=1
  print("Yes\n"+str(k))
  for i in range(k):
    print(len(l[i]),' '.join(map(str,l[i])))
  return True
  
n=int(input());flag=False
for i in range(1,1000):
  if chk(i):
    flag=True
    exit()
if not flag:
  print("No")

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

# Example run
# Input:
3
# Output:
Yes
3
2 1 2
2 1 3
2 2 3
# https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_d
# D - Crossing

N=int(input())
a=set()
b={}

for i in range(1000):
    if i*(i+1)%2==0:
        s= i*(i+1)//2
        if s<=10**5:
            a.add(s)
            b[s]=i
        else:
            break
            
if N not in a:
    print("No")
else:
    print("Yes")
    print(b[N]+1)
    r=[0 for _ in range(N)] #kaisuu
    t=[ [] for _ in range(b[N]+1)]
    for i in range(b[N]):
        r[i] +=1
    t[0]= [i+1 for i in range(b[N])]
    print(b[N],*t[0])

    for i in range(1,b[N]+1):
        for j in range(i):
            for k,num in enumerate(t[j]):
                if r[num-1]==1:
                    t[i].append(num)
                    r[num-1]+=1
                    break
        for k in range(N):
            if r[k]==0:
                r[k] +=1
                t[i].append(k+1)
                if len(t[i])>=b[N]:
                    break
        print(b[N],*t[i])

        
        
        
        
        #print("i=",i)
        #print(r)
#        for j,num in enumerate(r):
#            if num==1:
#                t[i].append(j+1)
#                r[j]+=1
#                break
        #print("t",t)
        #print(r)
#        for k,num in enumerate(r):
#            if num==0:
#                t[i].append(k+1)
#                r[k]+=1
#            if len(t[i])==b[N]:   
#                break
#        else:
#            pass
#        print(b[N],*t[i])

# Example run
# Input:
-249164
# Output:
No
n,k=int(input()),0
for i in range(int((2*n)**0.5)+10):
    if i*(i-1)==2*n:
        k=i
if k==0:
    print('NO')
else:
    print('YES')
    print(k)
    c=1
    a=[[0]*k for _ in range(k)]
    for i in range(1,k):
        for j in range(1,i+1):
            a[i][j]=c
            c+=1
    ans=[[k-1]+[a[i][i] for i in range(1,k)]]
    for i in range(1,k):
        l=[k-1]
        h,w=i,1
        for j in range(1,k):
            l.append(a[h][w])
            h+=0 if j<i else 1
            w+=1 if j<i else 0
        ans.append(l)
    for i in ans:
        print(*i)

# Example run
# Input:
2147483647
# Output:
NO
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')
    for i in range(K):
        print(len(ans[i]),*ans[i])
if __name__ == '__main__':
    main()

# Example run
# Input:
1049999
# Output:
No
n = int(input())
if n%2 ==0:
    print('No')
else:
    print('Yes')
    print(n)
    for i in range(n-1):
        print(n,i+1,i+2)
    print(n,n,1)

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

def f(limit):
    i = 1
    j = 2
    while True:
        if i > limit:
            break
        yield i
        i += j
        j += 1

def h1(l, n):
    s = 0
    for i in range(n):
        yield l[s:s+i+1]
        s += i+1

def h2(p, l):
    if not l:
        return
    for pp, ll in zip(p, l):
        ll.append(pp)
    h2(l[0], l[1:])

l = list(f(10**5))

if N in l:
    print("Yes")

    n = l.index(N)+1
    print(N*2//n)

    t = list(h1(list(range(1, N+1)), n))
    t.reverse()
    t.append([])

    h2(t[0], t[1:])

    for i in t:
        print(len(i), " ".join(str(j) for j in i))
else:
    print("No")


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

# Example run
# Input:
1506843
# Output:
No
n=int(input())
n2=n*2
key=[0,0]
for i in range(1,int(n2**0.5)+3):
  if n2%i==0:
    if i*(i+1)==n2:
      key=[i,i+1]
      break
if key==[0,0]:
  print('No')
  exit()
print('Yes')
a,b=key
print(b)
ans=[[0]*a for _ in range(b)]
cnt=1
for i in range(b):
  for j in range(a):
    if j<i:
      ans[i][j]=ans[j][i-1]
    else:
      ans[i][j]=cnt
      cnt+=1
for x in ans:
  print(len(x),' '.join(map(str,x)))

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

for k in range(N + 1):
    sn = k - 1
    if k * sn == 2 * N:
        print("Yes")
        print(k)
        x = [0] * N
        for i in range(k):
            s = []
            for j in range(N):
                n = (i + j) % N
                if x[n] < 2:
                    s.append(str(n + 1))
                    x[n] += 1
                    if len(s) == sn:
                        break
            print(sn, " ".join(s))
        break
else:
    print("No")

# Example run
# Input:
-2
# Output:
No
#Crossing
n=int(input())
flag=False
index=0
for i in range(1000):
    if i*(i+1)//2==n:
        flag=True
        index=i
        break
if flag:
    print("Yes")
    print(i+1)
    uselist=[[1],[1]]
    if index==1:
        print(1,1)
        print(1,1)
    else:
        def plus(N):
            base=(N)*(N-1)//2
            for k in range(1,N+1):
                uselist[k-1].append(base+k)
            uselist.append([base+i+1 for i in range(N)])

     
        
        for k in range(2,index+1):
            plus(k)
        for some in uselist:
            print(index,*some)
            
else:
    print("No")

# Example run
# Input:
3986
# Output:
No
K = int(input())

def calc_n(K):
  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)
print(N+1)
all_num = {i:2 for i in range(1, K+1)}
remain = K * 2
#print(all_num)
pair = []
for i in range(1, K+1):
  if all_num[i] == 2:
    pair.append(i)
    all_num[i] -= 1
    remain -= 1
    if len(pair) == N:
      break
print(N, " ".join([str(i) for i in pair]))

while remain != N:
  pair = []
  for i in range(1, K+1):
    if all_num[i] == 1 and len(pair) == 0:
      pair.append(i)
      all_num[i] -= 1
      remain -= 1
    if all_num[i] == 2 and len(pair) != 0:
      pair.append(i)
      all_num[i] -= 1
      remain -= 1
      if len(pair) == N:
        break
  print(N, " ".join([str(i) for i in pair]))

pair = []
for i in range(1, K+1):
  if all_num[i] == 1:
    pair.append(i)
    all_num[i] -= 1
    remain -= 1
    if len(pair) == N:
      break
print(N, " ".join([str(i) for i in pair]))

# Example run
# Input:
6
# Output:
4
3 1 2 3
3 1 4 5
3 2 6
3 3
3 4 5 6