Problem:
 Score: 600 points    Problem Statement  AtCoder's head office consists of N rooms numbered 1 to N . For any two rooms, there is a direct passage connecting these rooms.  For security reasons, Takahashi the president asked you to set a level for every passage, which is a positive integer and must satisfy the following condition:   For each room i\ (1 \leq i \leq N) , if we leave Room i , pass through some passages whose levels are all equal and get back to Room i , the number of times we pass through a passage is always even.   Your task is to set levels to the passages so that the highest level of a passage is minimized.      Constraints   N is an integer between 2 and 500 (inclusive).         Input  Input is given from Standard Input in the following format:  N       Output  Print one way to set levels to the passages so that the objective is achieved, as follows:  a_{1,2}  a_{1,3}  ...  a_{1,N}  a_{2,3}  ...  a_{2,N}  .  .  .  a_{N-1,N}   Here a_{i,j} is the level of the passage connecting Room i and Room j .  If there are multiple solutions, any of them will be accepted.        Sample Input 1 3      Sample Output 1 1 2
1  The following image describes this output:   For example, if we leave Room 2 , traverse the path 2 \to 3 \to 2 \to 3 \to 2 \to 1 \to 2 while only passing passages of level 1 and get back to Room 2 , we pass through a passage six times.

Solution (Python):
import sys
input = sys.stdin.readline

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

"""
奇閉路がないので二部グラフ
まずは最大の二部グラフを作る．
左右それぞれのグループ内の頂点同士を結ぶ辺がない．
この時点でスケールの小さい同問題に帰着，グループ内で二部グラフを作れば良い．
ただ，これを素直にやると構築が面倒そう．

レベルの最大値の最小値はN<=2^mなる最小のm
つまりNの二進数表記での桁数

レベル1 : 000..111...
レベル2 : 00..11..00..11..
みたいに分けるか．
これ，二進数で各bitが異なる頂点とつなげば良い．すでにあるならば無視
"""
def main():
    mod=10**9+7
    N=I()
    M=2**(N-1).bit_length()
    
    ans=[[-1]*N for _ in range(N)]
    
    for k in range(M):
        for i in range(N):
            for j in range(i+1,N):
                if (i>>k &1)^(j>>k &1):
                    if ans[i][j]==-1:
                        ans[i][j]=k+1
                        
    for i in range(N):
        print(' '.join(map(str, ans[i][i+1:])))
    
    

main()

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    ans = [[0] * (N+1) for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            for k in range(10):
                if (i >> k & 1) != (j >> k & 1):
                    ans[i][j] = k+1
                    break
    for i in range(1, N):
        print(*ans[i][i+1:])


if __name__ == '__main__':
    main()

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

def calc(i,j):
    x = i^j
    for k in range(20):
        if((x>>k)&1):
            return k+1

ans = [[0]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        ans[i][j] = calc(i,j)

for i in range(n-1):
    print(' '.join(map(str,ans[i][i+1:])))

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
ans = [[None]*(n-i-1) for i in range(n-1)]
vs = [list(range(n))]
level = 1
def sub(l):
    if len(l)==1:
        return []
    v = len(l)//2
    for i in l[:v]:
        for j in l[v:]:

            ans[i][j-i-1] = level
    return [l[:v], l[v:]]
while True:
    nvs = []
    for l in vs:
        nvs.extend(sub(l))
    if not nvs:
        break
    vs = nvs
    level += 1
write("\n".join(" ".join(map(str, ans[i])) for i in range(n-1)))

Solution (Python):
n = int(input())
for i in range(n - 1):
    for j in range(i + 1, n):
        print(((i ^ j) &- (i ^ j)).bit_length(), end=" ")
    print()

Solution (Python):







N=int(input())
ans=[[0]*N for j in range(N)]


def dfs(n,vec,level):
    global ans
    
    
    l=vec[:n//2]
    r=vec[n//2:]
    for i in l:
        for j in r:
            ans[i][j]=level
    if len(l)>1:
        dfs(len(l),l,level+1)
    if len(r)>1:
        dfs(len(r),r,level+1)


dfs(N,[i for i in range(N)],1)
for i in range(N-1):
    a=[]
    for j in range(N):
        if i<j:
            a.append(str(ans[i][j]))
    print(" ".join(a))

Solution (Python):
N = int(input())
ans = []

for i in range(N-1):
    ans.clear()
    for j in range(i + 1, N):
        ans.append(list(bin(i ^ j)[::-1]).index('1') + 1)
    print(*ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
half = -int(-N/2)

query = [[0]*N for _ in range(N-1)]
for i in range(N-1):
    for j in range(i+1, N):
        for k in range(10):
            if ((i^j)>>k)&1:
                query[i][j] = k+1
                break

for i in range(N-1):
    print(*[x for x in  query[i] if x!=0])

Solution (Python):
import math
n = int(input())
for i in range(n):
  ans = ""
  for j in range(i + 1, n):
    ixorj = i ^ j
    cnt = 1
    while ixorj >= 2:
      cnt += 1
      ixorj //= 2
    ans += str(cnt)
    if j != n-1:
      ans += " "
  print(ans)

Solution (Python):
n=int(input())
mx=1
for i in range(n-1):
  ans=[]
  for j in range(n-1-i):
    count=1
    tmp=(i)^(i+j+1)
    while tmp%2==0:
      count+=1
      tmp=tmp//2
    ans.append(str(count))
  print(' '.join(ans))

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

l = len(bin(N))-2

ans = [[0]*N for _ in range(N)]
for i in range(l):
    for j in range(N-1):
        for k in range(j+1,N):
            if (j&(1<<i)) == (k&(1<<i)): continue
            if ans[j][k]: continue
            ans[j][k] = ans[k][j] = i+1

for i,row in enumerate(ans[:-1]):
    print(*(row[i+1:]))

Solution (Python):
def dfs(color,l,r):
  if l==r:
    return
  for i in range(l,(l+r)//2+1):
    for j in range((l+r)//2+1,r+1):
      ans[i][j]=color
  dfs(color+1,l,(l+r)//2)
  dfs(color+1,(l+r)//2+1,r)

n=int(input())
ans=[[0]*(n+1) for _ in range(n+1)]
dfs(1,1,n)
for i in range(1,n):
  print(*ans[i][i+1:n+1])

Solution (Python):
n=int(input())
ans=[[0]*n for _ in range(n)]
for i in range(n):
  for j in range(n):
    tmp=i^j
    if tmp==0:
      ans[i][j]=1
    else:
      tmp=format(tmp,'b')[::-1]
      ans[i][j]=tmp.index('1')+1
for i in range(n-1):
  print(*ans[i][i+1:])

Solution (Python):
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    N = I()
    n = (N-1).bit_length()
    V = [[-1]*(1<<n) for i in range(1<<n)]
    
    for i in range(n):
        b1 = 1 << i
        b2 = 1 << (i + 1)
        for j in range(1<<i):
            for k in range(1<<(n-i)):
                for l in range(1<<(n-i)):
                    
                    if j+k*b2>=N or j+b1+l*b2>=N:
                        continue
                    u,v = sorted([j+k*b2,j+b1+l*b2])
                    
                    V[u][v-1] = i+1
    ans = [[]for _ in range(N-1)]
    for i in range(N-1):
        for v in V[i]:
            if v>=0:
                ans[i].append(v)
    for v in ans:
        print(" ".join(map(str,v)))
    return


def examD2():
    N = I()
    ans = [[-1]*(N-1-i) for i in range(N-1)]
    n = N.bit_length()
    for i in range(N):
        for j in range(i+1,N):
            k = 0
            while(True):
                if i&(1<<k) != j&(1<<k):
                    break
                k += 1
            
            ans[i][j-i-1] = k+1
    for v in ans:
        print(" ".join(map(str,v)))
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD2()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    N = I()
    n = (N-1).bit_length()
    V = [[-1]*(1<<n) for i in range(1<<n)]
    
    for i in range(n):
        b1 = 1 << i
        b2 = 1 << (i + 1)
        for j in range(1<<i):
            for k in range(1<<(n-i)):
                for l in range(1<<(n-i)):
                    
                    if j+k*b2>=N or j+b1+l*b2>=N:
                        continue
                    u,v = sorted([j+k*b2,j+b1+l*b2])
                    
                    V[u][v-1] = i+1
    ans = [[]for _ in range(N-1)]
    for i in range(N-1):
        for v in V[i]:
            if v>=0:
                ans[i].append(v)
    for v in ans:
        print(" ".join(map(str,v)))
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
n = int(input())
for i in range(n-1):
  L = []
  for j in range(i+1, n):
    x = i^j
    l = (x&-x).bit_length()
    L.append(l)
  print(*L)

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

lst = []
for i in range(n):
    num = format(i, '09b')
    lst.append(num[::-1])

for i in range(n-1):
    ans = []
    for j in range(i+1, n):
        numi = lst[i]
        numj = lst[j]
        idx = 0
        while True:
            if numi[idx] != numj[idx]:
                ans.append(str(idx+1))
                break
            idx += 1
    print(*ans)

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

A = [[0] * n for i in range(n)]
c = 1

def d(L, c):
    ln = len(L)
    if ln >= 2:
        for i in L[:ln//2]:
            for j in L[ln//2:]:
                A[i][j] = c
                A[j][i] = c
        d(L[:ln//2], c+1)
        d(L[ln//2:], c+1)

d(range(n), c)

for i in range(n):
    print(*A[i][i+1:])

Solution (Python):
import sys
sys.setrecursionlimit(1000)

def rec(l, r, c):
    if l==r:
        return
    
    m = (l+r)//2
    
    for i in range(l, m+1):
        for j in range(m+1, r+1):
            a[i][j] = c
    
    rec(l, m, c+1)
    rec(m+1, r, c+1)

N = int(input())
a = [[-1]*N for _ in range(N)]
rec(0, N-1, 1)

for i in range(N):
    ans = []
    
    for j in range(i+1, N):
        ans.append(a[i][j])
    
    print(*ans)

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

for i in range(N - 1):
    row = []
    for j in range(i + 1, N):
        d = 0
        while (i & (1 << d)) == (j & (1 << d)):
            d += 1
        row.append(d + 1)
    print(*row)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
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 ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
mod = 10 ** 9 + 7

N = INT()
L = N.bit_length()

for i in range(N):
	for j in range(i+1, N):
		for k in range(L):
			if (i >> k) & 1 != (j >> k) & 1:
				print(k+1, end=" ")
				break
	if i != N-1:
		print()

Solution (Python):
n=int(input())
ans=[i&-i for i in range(1,n+1)]
def position_zip(a,flag):
  j=1
  d={}
  for i in sorted(a):
    if i in d:continue
    d[i]=j
    j+=1
  if flag==1:return d
  return [d[i] for i in a]
ans=position_zip(ans,0)
for i in range(n-1,-1,-1):print(*ans[:i])

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
ans = 0
ans = [[0] * (N+1) for _ in range(N+1)]
depth = 1

def dfs(l, r, d):
    global depth
    if l == r:
        return
    depth = max(depth, d)
    m = (l + r) // 2
    for i in range(l, m+1):
        for j in range(m, r+1):
            ans[i][j] = ans[i][j] = d
    dfs(l, m, d+1)
    dfs(m+1, r, d+1)

dfs(1, N, 1)
for i in range(1, N):
    print(*ans[i][i+1:])

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

g = [[0] * n for _ in range(n)]

for i in range(n):
    for j in range(i + 1, n):
        xor = i ^ j
        val = 1
        while xor:
            if xor & 1:
                g[i][j] = val
            xor >>= 1
            val += 1

for i, row in enumerate(g, 1):
    print(*row[i:])

Solution (Python):
N=int(input())
que=[[i for i in range(N)]]

ans={(i,j):-1 for i in range(N) for j in range(N)}

def classified(session):
    global que
    sub=[]
    while que:
        list=que.pop()
        n=len(list)
        if n!=1:
            left=list[:n//2]
            right=list[n//2:]
            for i in left:
                for j in right:
                    ans[(i,j)]=session
            sub.append(left)
            sub.append(right)
    que=sub

session=1
while que:
    classified(session)
    session+=1



Ans=[[] for i in range(N-1)]
for i in range(N-1):
    for j in range(i+1,N):
        Ans[i].append(ans[(i,j)])

for i in range(N-1):
    print(*Ans[i])

Solution (Python):
n = int(input())
for i in range(1,n):
  a = []
  for j in range(i+1,n+1):
    J = j-i
    level = 0
    while not ((J >> level) & 1):
      level += 1
    a.append(level+1)
  print(*a)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

N = int(input())
ans = [[0] * N for i in range(N)]

def calc_level(start, n, now):
  
  
  global ans
  if n == 1:
    return True
  n1 = n // 2
  n2 = n - n1
  for i in range(start, start+n1):
    for j in range(start+n1, start+n):
      ans[i][j] = ans[j][i] = now + 1
  calc_level(start, n1, now+1)
  calc_level(start+n1, n2, now+1)

calc_level(0, N, 0)
for i in range(N):
  print(*ans[i][i+1:])

Solution (Python):
n = int(input())
ans = [[-1] * (n - i - 1) for i in range(n - 1)]
s = [(0, n, 1)]
while s:
    p, q, t = s.pop()
    if p + 1 == q:
        continue
    m = (q - p) // 2 + p
    for i in range(p, m):
        for j in range(m, q):
            ans[i][j - i - 1] = t
    s.append((p, m, t + 1))
    s.append((m, q, t + 1))
for row in ans:
    print(' '.join(map(str, row)))

Solution (Python):
n = int(input())
lsb = dict()
for i in range(10):
    lsb[1<<i] = i

for i in range(n):
    ans = []
    for j in range(i+1, n):
        k = i^j
        ans.append(lsb[k&-k]+1)
    print(*ans)

Solution (Python):
n = int(input())
ans = [[0 for i in range(n)] for j in range(n)]
def p2(a):
  ret = 0
  while a%2 == 0:
    ret += 1
    a //= 2
  return ret
for i in range(n):
  for j in range(n-i-1):
    ans[i][j] = p2(j+1)+1
for i in range(n):
  arr = ans[i][:n-i-1]
  print(*arr)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
res = [[0] * x for x in range(N - 1, 0, -1)]
for x in range(N - 1):
  for y in range(N - 1 - x):
    b = 0
    for k in range(10):
      if (y + 1) & (1 << k):
        b = k + 1
        break
    res[x][y] = b
for r in res: print(*r)

Solution (Python):
N=int(input())
ans=[[-1]*N for _ in range(N)]
for i in range(N-1):
    for j in range(i+1,N):
        for k in range(10):
            if ((i>>k)&1)^((j>>k)&1)==1:
                ans[i][j]=k+1
                break
for i in range(N-1):
    print(*ans[i][i+1:])

Solution (Python):
from itertools import product
N = int(input())

res = [[None]*(N-i-1) for i in range(N-1)]
def register(i,j,c):
    if i > j:
        i,j = j,i
    res[i][j-i-1] = c

d = 1
c = 1
while d < N:
    X = []
    Y = []
    for i in range(0,N,2*d):
        X.extend(range(i,min(N,i+d)))
        Y.extend(range(min(N,i+d), min(N,i+2*d)))

    for x,y in product(X,Y):
        register(x,y,c)
    d *= 2
    c += 1

for r in res:
    print(*r)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    for u in range(n-1):
        ans=[]
        for v in range(u+1,n):
            w=u^v
            for i in range(10):
                if((w>>i)&1):
                    ans.append(i+1)
                    break
        print(*ans)
resolve()

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

vec = [[0] * N for _ in range(N)]
color = [0] * (N + 1)
i = 0
while (1 << i) <= N :
    for j in range((1 << i), N + 1, 1 << (i + 1)) :
        color[j] = i + 1
    i += 1
        
for i in range(N) :
    for j in range(i + 1, N) :
        vec[i][j] = color[j - i]
        
for i in range(N) :
    print(*vec[i][i+1:])

Solution (Python):
def main():
    n=int(input())
    g=[{i for i in range(j+1,n)} for j in range(n)]
    matrix=[[0]*(n-i-1) for i in range(n-1)]
    def dfs(i,now):
        for j in g[i]:
            if visit[j]==False:
                visit[j]=True
                if now%2==0:
                    white.add(j)
                else:
                    black.add(j)
                dfs(j,now+1)
                break
    cnt=0
    cnt2=0
    while cnt<(n*(n-1))//2:
        cnt2+=1
        visit=[False]*n
        black=set()
        white=set()
        for i in range(n):
            if visit[i]==False:
                visit[i]=True
                black.add(i)
                dfs(i,0)
        for i in black:
            for j in white:
                ii,jj=min(i,j),max(i,j)
                if jj in g[ii]:
                    cnt+=1
                    g[ii].remove(jj)
                    matrix[ii][jj-ii-1]=cnt2
    for i in matrix:
        print(*i)
main()

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

n = 0
while True:
    if 2**n >= N:
        break
    n += 1

P = 2**n
graph = [[0]*P for _ in range(P)]
for i in range(1, n+1):
    k = 2**i
    for p in range(P):
        if p%k < k//2:
            offset = p//k*k + k//2
            for q in range(k//2):
                graph[p][q+offset] = i

for i in range(N-1):
    for j in range(i+1, N):
        print(graph[i][j], end=' ')
    print()

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

for i in range(N):
    A = []
    for j in range(i + 1, N):
        A.append((i ^ j).bit_length())
    print(*A)

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

for i in range(N):
    A = []
    for j in range(i + 1, N):
        d = i ^ j
        A.append((d & -d).bit_length())
    print(*A)

Solution (Python):
n = int(input())
lg = 0
while n>>lg >=1:
    lg += 1

a = [[0 for _ in range(n)] for __ in range(n)]
for i in range(n):
    for j in range(i+1,n):
        for k in range(lg):
            if (i>>k)&1!=(j>>k)&1:
                a[i][j] = k+1
                break

for i in range(n):
    for j in range(i+1,n):
        print(a[i][j], end = " ")
    print()

Solution (Python):
N = int(input())
A = [[0] * (1+N) for _ in xrange(1+N)]
def solve(l, r, id):
    if l == r:  return
    mid = (l+r) / 2
    for i in xrange(l, mid+1):
        for j in xrange(mid+1, r+1):
            A[i][j] = str(id)
    solve(l, mid, id+1)
    solve(mid+1, r, id+1)
solve(1, N, 1)
for i in xrange(1, N):
    print(' '.join(A[i][i+1: N+1]))

Solution (Python):
import sys

input = sys.stdin.readline
sys.setrecursionlimit(1000000)


def getN():
    return int(input())


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


import math

n = getN()

def judge(i, j):
    if i == j:
        print("ERROR", i)
        sys.exit()
    res = 1
    while(True):
        if i % 2 != j % 2:
            return res
        else:
            res += 1
            i = i>>1
            j = j>>1


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

    print(*level)

Solution (Python):
import math

N = int(input())

def log_ceil(x):
    return math.ceil(math.log2(x))

edges = [[None for _ in range(N+1)] for _ in range(N+1)]

def solve(lo, hi):
    if lo == hi:
        return
    mid_connect = log_ceil(hi-lo+1)
    mid = (lo+hi)//2
    for l_it in range(lo,mid+1):
        for r_it in range(mid+1, hi+1):
            edges[l_it][r_it] = mid_connect
    solve(lo, mid)
    solve(mid+1,hi)

solve(1,N)

for i,x in enumerate(edges[1:-1]):
    print(" ".join(map(str, x[i+2:])))

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

G = [[-1]*N for i in range(N)]

def f(l, r, d):
    if l+1 >= r:
        return
    m = (l + r) // 2
    f(l, m, d+1)
    f(m, r, d+1)
    for i in range(l, m):
        for j in range(m, r):
            G[j][i] = G[i][j] = d
f(0, N, 1)
for i in range(N):
    print(*G[i][i+1:])

Solution (Python):
N = int(input())
for i in range(N-1):
    print(*[(i^j).bit_length() for j in range(i+1, N)])

Solution (Python):
def num(i,j):
    if i==j:
        return -1
    S=bin(i)[2:][::-1]+"0"*20
    T=bin(j)[2:][::-1]+"0"*20
    for index in range(min(len(S),len(T))):
        if S[index]!=T[index]:
            return index+1
    return -1
N=int(input())
a=[[0 for j in range(N-1-i)] for i in range(N-1)]
for i in range(N-1):
    for j in range(i+1,N):
        a[i][j-i-1]=num(i,j)
for i in range(N-1):
    print(*a[i])

Solution (Python):
n = int(input())
for i in range(n+1):
    for j in range(i+1,n):
      x = i^j
      ct = 0
      while (x>0):
        x //= 2
        ct += 1
      print(ct,end=" ")
    print("")

Solution (Python):
import sys
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
class BinaryIndexedTree:
	def __init__(self, n):
		self.size = n
		self.bit = [0] * (n + 1)
 
	def sum(self, i):
		s = 0
		while i > 0:
			s += self.bit[i]
			i -= (i & -i)
		return s
 
	def add(self, i, x):
		while i <= self.size:
			self.bit[i] += x
			i += (i & -i)

            
def solve():
  n = int(input())
  for i in range(n+1):
    for j in range(i+1,n):
      x = i^j
      ct = 0
      while (x>0):
        x //= 2
        ct += 1
      print(ct,end=" ")
    print("")
      
solve()

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

G = list2d(N, N, 0)
A = list(range(N))

def rec(li, lv):
    n = len(li)
    
    if n <= 1:
        return
    
    li1 = li[:n//2]
    li2 = li[n//2:]
    for u in li1:
        for v in li2:
            G[u][v] = lv
    
    rec(li1, lv+1)
    rec(li2, lv+1)
    return

rec(A, 1)

ans = []
for i in range(N):
    row =[]
    for j in range(i+1, N):
        row.append(G[i][j])
    ans.append(row)

for row in ans:
    print(*row)

Solution (Python):
n = int(input())
for i in range(n):
  now = []
  I = '0' * (11-len(bin(i))) + bin(i)[2:]
  for j in range(i+1,n):
    J = '0' * (11-len(bin(j))) + bin(j)[2:]
    
    for k in range(9):
      if I[k] != J[k]:
        now.append(9-k)
        break
  print(' '.join(list(map(str,now))))

Solution (Python):
n = int(input())
for i in range(n):
    print(*((i ^ j).bit_length() for j in range(i + 1, n)))

Solution (Python):
n = int(input())
for i in range(n):
    print(*((i ^ j & -(i ^ j)).bit_length() for j in range(i + 1, n)))

Solution (Python):
n = int(input())
for i in range(n):
    for j in range(i + 1, n):
        print((i ^ j & -(i ^ j)).bit_length(), end=' ')
    print()

Solution (Python):
N=input()

E=[ [ "" for j in range(N+1) ] for i in range(N+1) ]

for K in range(10):
	if N<=2**K:
		break

for i in range(1,N+1):
	for j in range(i+1,N+1):
			for k in range(K):
				if (i>>k)&1!=(j>>k)&1:
						E[i][j]=str(k+1)
						break
	
for i in range(1,N):
		print " ".join(E[i][i+1:])

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

def b(x):
    return format(x,'04b')

for i in range(1,n+1):
    for j in range(i+1,n+1):
        tmp = i ^ j
        bit = format(tmp, 'b')[::-1]
        
        for k in range(len(bit)):
            
            if int(bit[k]) == 1:
                
                print(k+1, end = ' ')
                break
    print()

Solution (Python):
N=input()

E=[ [ "" for j in range(N+1) ] for i in range(N+1) ]

for K in range(10):
	if N<=2**K:
		break

for i in range(1,N+1):
	for j in range(i+1,N+1):
			for k in range(K):
				if (i>>k)&1!=(j>>k)&1:
						E[i][j]=k+1
						break
	
for i in range(1,N):
	s=""
	for j in range(i+1,N+1):
		s+=str(E[i][j])+" "
	print s

Solution (Python):
from math import ceil, log2

N = int(input())

K = ceil(log2(N))

nodes = [i for i in range(1 << K)]

for i in range(N-1):
    out = []
    for j in range(i+1, N):
        res = nodes[i] ^ nodes[j]
        for k in range(N):
            if (res >> k) & 1:
                out.append(k+1)
                break
    print(*out)

Solution (Python):
def fill(ans, l, r, level):
    if r - l <= 1:
        return
    m = (l + r) // 2
    for i in range(l, m):
        for j in range(m, r):
            ans[i][j] = level
    fill(ans, l, m, level + 1)
    fill(ans, m, r, level + 1)


n = int(input())
ans = [[0] * n for _ in range(n)]
fill(ans, 0, n, 1)
for i, row in enumerate(ans[:-1]):
    print(*row[i + 1:])

Solution (Python):
n=int(input())
def f(x,y):
  ret=1
  while True:
    if x%2!=y%2:
      return ret
      break
    else:
      x//=2
      y//=2
      ret+=1
for i in range(n-1):
  Ans=[]
  for j in range(n-1-i):
    Ans.append(f(i+1,i+j+2))
  print(*Ans)

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

for i in range(1,n+1):
	for j in range(i+1,n+1):
		t = i^j
		cnt = 1
		while t&1^1:
			cnt += 1
			t >>= 1
		print(cnt,end=' ')
	print()

Solution (Python):
N=int(input());exec("N-=1;print(*[9-format(i+1,'09b').rfind('1')for i in range(N)]);"*N)

Solution (Python):
N,j=int(input()),0;exec("print(*[9-format(i+1,'09b').rfind('1')for i in range(N)][:N-j-1]);j+=1;"*N)

Solution (Python):
N = int(input())
for i in range(N-1):
    level = []
    for j in range(i+1, N):
        for k in range(N.bit_length()):
            if (i ^ j) >> k & 1:
                level += [k+1]
                break
    print(*level)

Solution (Python):
n = int(input())
k = 1
while 2**k < n:
    k += 1

m = 2**k
ans = []
for i in range(m):
    x = []
    for j in range(i+1,m):
        for l in range(k):
            if (i^j) &(1<<l):
                x.append(l+1)
                break
    ans.append(x)

for i in range(n-1):
    for j in range(n-i-1):
        print(ans[i][j],end=" ")
    print()

Solution (Python):
n = int(input())
count = 0
def return_level(n):
    level = 0
    while True:
        if (n // (2**level)) % 2 == 1:
            break
        level += 1
    return(level + 1)
while True:
    count += 1
    if n - 1 < 2**count:
        break

to = [[] for _ in range(n-1)]
for i in range(1, n):
    for j in range(i+1,n+1):
        to[i-1].append(return_level(j-i))
for _ in range(n-1):
    print(*to[_])

Solution (Python):
from math import log2

def main():
    n = int(input())
    for u in range(n - 1):
        ans = []
        for v in range(u + 1, n):
            uv = u ^ v
            ans.append(int(log2(uv & -uv) + 1))
        print(*ans)

main()

Solution (Python):
n = int(input())
for i in range(1,n):
	for j in range(i+1,n+1):
		k = i^j
		l = 1
		while k&1==0:
			k >>= 1
			l += 1
		print(l,end=" ")
	print("")