Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    a=1
    m=int((2*n)**0.5)
    if m*(m+1)==n*2:
        a=m+1
        print("Yes")
    else:
        print("No")
        exit()
    print(a)
    s=set(range(1,1+n))
    l=[0]*(n+1)
    ans=[set()]

    for i in range(a):
        ll=set()
        for j in ans[:i+1]:
            for p in s&j-ll:
                ll.add(p)
                if l[p]==1:
                    s.remove(p)
                else:
                    l[p]+=1
                break

        for p in s:
            if len(ll)>=n*2//a:
                break
            else:
                if l[p]==0:
                    ll.add(p)
                    l[p]+=1

        ans.append(ll)
    for i in ans[1:]:
        print(n*2//a,*i)


if __name__ == '__main__':
    main()








Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    a=1
    m=int((2*n)**0.5)
    if m*(m+1)==n*2:
        a=m+1
        print("Yes")
    else:
        print("No")
        exit()
    print(a)
    s=set(range(1,1+n))
    l=[0]*(n+1)
    ans=[set()]

    for i in range(a):
        ll=set()
        for j in ans[:i+1]:
            for p in s&j:
                if p not in ll:
                    ll.add(p)
                    if l[p]==1:
                        s.remove(p)
                    else:
                        l[p]+=1
                    break

        for p in s:
            if len(ll)>=n*2//a:
                break
            else:
                if l[p]==0:
                    ll.add(p)
                    l[p]+=1

        ans.append(ll)
    for i in ans[1:]:
        print(n*2//a,*i)


if __name__ == '__main__':
    main()








Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    if n==1:
        print("Yes")
        print(2)
        print(1,1)
        print(1,1)
        exit()
    a=1
    while True:
        t=a*(a-1)//2
        if t>n:
            print("No")
            exit()
        if t==n:
            print("Yes")
            break
        a+=1
    print(a)
    s=set(range(1,1+n))
    l=[0]*(n+1)
    ans=[set()]

    for i in range(a):
        ll=set()
        for j in ans[:i+1]:
            for p in s&j:
                if p not in ll:
                    ll.add(p)
                    if l[p]==1:
                        s.remove(p)
                    else:
                        l[p]+=1
                    break

        for p in s:
            if len(ll)>=n*2//a:
                break
            else:
                if l[p]==0:
                    ll.add(p)
                    l[p]+=1

        ans.append(ll)
    for i in ans[1:]:
        print(n*2//a,*i)


if __name__ == '__main__':
    main()








Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    if n==1:
        print("Yes")
        print(2)
        print(1,1)
        print(1,1)
        exit()
    a=1
    while True:
        t=a*(a-1)//2
        if t>n:
            print("No")
            exit()
        if t==n:
            print("Yes")
            break
        a+=1
    print(a)
    s=set(range(1,1+n))
    l=[0]*(n+1)
    ans=[set()]

    for i in range(a):
        ll=set()
        for j in ans[:i+1]:
            for p in s&j:
                if p not in ll:
                    ll.add(p)
                    if l[p]==1:
                        s.remove(p)
                    else:
                        l[p]+=1
                    break

        for p in s:
            if len(ll)>=n*2//a:
                break
            else:
                if l[p]==0:
                    ll.add(p)
                    l[p]+=1

        ans.append(ll)
        print(n*2//a,*ll)


if __name__ == '__main__':
    main()








Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    if n==1:
        print("Yes")
        print(2)
        print(1,1)
        print(1,1)
        exit()
    a=1
    while True:
        t=a*(a-1)//2
        if t>n:
            print("No")
            exit()
        if t==n:
            print("Yes")
            break
        a+=1
    print(a)
    s=set(range(1,1+n))
    l=[0]*(n+1)
    ans=[set()]

    for i in range(a):
        ll=set()
        for j in ans[:i+1]:
            for p in s&j:
                if p not in ll:
                    ll.add(p)
                    if l[p]==1:
                        s.remove(p)
                    else:
                        l[p]+=1
                    break

        for p in s:
            if len(ll)>=n*2//a:
                break
            else:
                if l[p]==0:
                    ll.add(p)
                    l[p]+=1

        ans.append(ll)
        q=[n*2//a]+list(ll)
        print(*q)


if __name__ == '__main__':
    main()








Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

a=1
while True:
    t=a*(a-1)//2
    if t>n:
        print("No")
        exit()
    if t==n:
        print("Yes")
        break
    a+=1
print(a)
s=set()
for i in range(1,1+n):
    s.add(i)
l=[0]*(n+1)
ans=[set()]

for i in range(a):
    ll=set()
    for j in ans[:i+1]:
        for p in s&j-ll:
            if p not in ll:
                ll.add(p)
                if l[p]==1:
                    s.remove(p)
                else:
                    l[p]+=1
                break

    for p in s:
        if len(ll)>=n*2//a:
            break
        else:
            if l[p]==0:
                ll.add(p)
                l[p]+=1

    ans.append(ll)
    print(n*2//a,*ll)

Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

a=1
while True:
    t=a*(a-1)//2
    if t>n:
        print("No")
        exit()
    if t==n:
        print("Yes")
        break
    a+=1
print(a)
s=set(range(1,1+n))
l=[0]*(n+1)
ans=[set()]

for i in range(a):
    ll=set()
    for j in ans[:i+1]:
        for p in s&j-ll:
            ll.add(p)
            if l[p]==1:
                s.remove(p)
            else:
                l[p]+=1
            break

    for p in s:
        if len(ll)>=n*2//a:
            break
        else:
            if l[p]==0:
                ll.add(p)
                l[p]+=1

    ans.append(ll)
    print(n*2//a,*ll)

Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

if n==1:
    print("Yes")
    print(2)
    print(1,1)
    print(1,1)
    exit()
a=1
while True:
    t=a*(a-1)//2
    if t>n:
        print("No")
        exit()
    if t==n:
        print("Yes")
        break
    a+=1
print(a)
s=set(range(1,1+n))
l=[0]*(n+1)
ans=[set()]

for i in range(a):
    ll=set()
    for j in ans[:i+1]:
        for p in s&j:
            if p not in ll:
                ll.add(p)
                if l[p]==1:
                    s.remove(p)
                else:
                    l[p]+=1
                break

    for p in s:
        if len(ll)>=n*2//a:
            break
        else:
            if l[p]==0:
                ll.add(p)
                l[p]+=1

    ans.append(ll)
    print(n*2//a,*ll)

Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
def f():
    n=int(input())

    if n==1:
        print("Yes")
        print(2)
        print(1,1)
        print(1,1)
        exit()
    a=1
    while True:
        t=a*(a-1)//2
        if t>n:
            print("No")
            exit()
        if t==n:
            print("Yes")
            break
        a+=1
    print(a)
    s=set(range(1,1+n))
    l=[0]*(n+1)
    ans=[set()]

    for i in range(a):
        ll=set()
        for j in ans[:i+1]:
            for p in s&j:
                if p not in ll:
                    ll.add(p)
                    if l[p]==1:
                        s.remove(p)
                    else:
                        l[p]+=1
                    break

        for p in s:
            if len(ll)>=n*2//a:
                break
            else:
                if l[p]==0:
                    ll.add(p)
                    l[p]+=1

        ans.append(ll)
        q=[n*2//a]+list(ll)
        print(*q)

f()


Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

if n==1:
    print("Yes")
    print(2)
    print(1,1)
    print(1,1)
    exit()
a=1
while True:
    t=a*(a-1)//2
    if t>n:
        print("No")
        exit()
    if t==n:
        print("Yes")
        break
    a+=1
print(a)
s=set(range(1,1+n))
l=[0]*(n+1)
ans=[set()]

for i in range(a):
    ll=set()
    for j in ans[:i+1]:
        for p in s&j:
            if p not in ll:
                ll.add(p)
                if l[p]==1:
                    s.remove(p)
                else:
                    l[p]+=1
                break

    for p in s:
        if len(ll)>=n*2//a:
            break
        else:
            if l[p]==0:
                ll.add(p)
                l[p]+=1

    ans.append(ll)
    q=[n*2//a]+list(ll)
    print(*q)










Fixed submission:
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()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

if n==1:
    print("Yes")
    print(2)
    print(1,1)
    print(1,1)
    exit()
a=1
while True:
    t=a*(a-1)//2
    if t>n:
        print("No")
        exit()
    if t==n:
        print("Yes")
        break
    a+=1
print(a)
s=set(range(1,1+n))
l=[0]*(n+1)
ans=[set()]

for i in range(a):
    ll=set()
    for j in ans[:i+1]:
        for p in s&j:
            if p not in ll:
                ll.add(p)
                if l[p]==1:
                    s.remove(p)
                else:
                    l[p]+=1
                break

    for p in s:
        if len(ll)>=n*2//a:
            break
        else:
            if l[p]==0:
                ll.add(p)
                l[p]+=1

    ans.append(ll)
    q=[n*2//a]+list(ll)
    print(*q)










Fixed submission:
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()