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.



Sample input:
3


Sample output:
1 2
1

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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:]))

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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:])

Submission status: Accepted

Solution code:
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)]
    #print(V)
    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)):
                    #print(i,j,k,l,j+k*b2,j+b1+l*b2)
                    if j+k*b2>=N or j+b1+l*b2>=N:
                        continue
                    u,v = sorted([j+k*b2,j+b1+l*b2])
                    #print(u,v)
                    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
            #print(i,j,j-i)
            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
"""

Submission status: Accepted

Solution code:
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)]
    #print(V)
    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)):
                    #print(i,j,k,l,j+k*b2,j+b1+l*b2)
                    if j+k*b2>=N or j+b1+l*b2>=N:
                        continue
                    u,v = sorted([j+k*b2,j+b1+l*b2])
                    #print(u,v)
                    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
"""

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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:])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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:])

Submission status: Accepted

Solution code:
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:])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

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

def calc_level(start, n, now):
  # start, start+1, ..., start+n-1 までを埋める
  # 今は level=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:])

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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:])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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:])

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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:])))

Submission status: Accepted

Solution code:
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:])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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)
    # 頂点が1つ以下になったら終了
    if n <= 1:
        return
    # 頂点集合を半分に分けて、2部グラブにする
    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)

Submission status: Accepted

Solution code:
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:]
    #print(I,J)
    for k in range(9):
      if I[k] != J[k]:
        now.append(9-k)
        break
  print(' '.join(list(map(str,now))))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:])

Submission status: Accepted

Solution code:
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]
        # print(bit)
        for k in range(len(bit)):
            # print(bit[k])
            if int(bit[k]) == 1:
                # print(bit, bit[k],k+1)
                print(k+1, end = ' ')
                break
    print()

        # print(b(i),b(j),b(tmp))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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:])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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
# countは最大レベル
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[_])

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    m, d = LI()
    ans = 0
    for i in range(1, m + 1):
        for j in range(10, d + 1):
            if int(str(j)[0]) < 2 or int(str(j)[1]) < 2:
                continue
            if i == int(str(j)[0]) * int(str(j)[1]):
                ans += 1
    print(ans)
    return

#B
def B():
    n, l = LI()
    a = LI()
    d0 = defaultdict(int)
    d1 = defaultdict(int)
    for i in a:
        d0[i] += 1
    for i in range(n):
        b = 0
        for k in range(i+1, n):
            if a[i] > a[k]:
                b += 1
        d1[i] = b
    ans = 0
    d2 = list(d0.items())
    d2.sort()
    d3 = defaultdict(int)
    d = 0
    for key, value in d2:
        d3[key] = d
        d += value
    for i in range(n):
        ans += d3[a[i]] * l * (l-1) // 2 + d1[i] * l
        ans %= mod
    print(ans % mod)
    return

#C
def C():
    n = II()
    s = S()
    if s[0] == "W":
        print(0)
        return
    lis = [0] * (2 * n)
    l = [0] * (2 * n)
    l[0] = 1
    for i in range(1, 2 * n):
        lis[i] = (lis[i-1] ^ (s[i] == s[i-1]))
        l[i] += l[i - 1] + (lis[i] == 0)
    ans = 1
    if l[-1] != n or s[0] == "W":
        print(0)
        return
    k = 1
    for i in range(2 * n):
        if lis[i]:
            ans *= l[i] - (k - 1)
            ans %= mod
            k += 1
    print(ans * math.factorial(n) % mod)
    return

#D
def D():
    n = II()
    l = len(bin(n)) - 2
    for i in range(n - 1):
        for j in range(i + 2, n + 1):
            for k in range(l):
                if (j >> k) & 1 != ((i + 1) >> k) & 1:
                    print(k + 1, end=" ")
                    break
        print()
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()