d,s,v = int(input()), 0, [] while s < d: v.append(len(v)+1); s = sum([bin(i).count("1",2) for i in v]) v = v[::-1] for i in range(len(v)): if bin(v[i]).count("1",2) == s-d: v.remove(v[i]); break print(len(v)), [print(x, end=" ") for x in v]
1 2 3 4 5 6 | d,s,v = int(input()), 0, [] while s < d: v.append(len(v)+1); s = sum([bin(i).count("1",2) for i in v]) v = v[::-1] for i in range(len(v)): if bin(v[i]).count("1",2) == s-d: v.remove(v[i]); break print(len(v)), [print(x, end=" ") for x in v] |