local mfl, mce = math.floor, math.ceil local bls, brs = bit.lshift, bit.rshift local bxor = bit.bxor local function grayCode(x) return bxor(x, brs(x, 1)) end local k, x = io.read("*n", "*n") if x == 0 then if k == 0 then print("Yes") print(1) print(1) else print("Yes") print(1) print(0) end os.exit() end if k == 0 then x = x + 1 end local cnt = 0 local mul = 1 while cnt < 40 do if mul == x then break end cnt = cnt + 1 mul = mul * 2 end if 40 <= cnt then print("No") os.exit() end print("Yes") local tk = k local mul = 1 local t = {} local baselim = 7 for i = 1, 40 do if #t < baselim then table.insert(t, mul) else if tk % 2 == 1 then t[baselim] = t[baselim] + mul end end mul = mul * 2 tk = mfl(tk / 2) end if cnt == 0 then print(baselim) print(table.concat(t, " ")) os.exit() end local function grayWalk(size, add_func, rm_func, work_func) local prv = 0 local total = bls(1, size) - 1 local bpos = {} for i = 1, size do bpos[bls(1, i - 1)] = i end -- work_func() for i = 1, total do local v = grayCode(i) if prv < v then prv, v = v, v - prv add_func(bpos[v]) else prv, v = v, prv - v rm_func(bpos[v]) end work_func() end end local v = 0 local c = 0 local function add_func(idx) v = v + t[idx] c = c + 1 end local function rm_func(idx) v = v - t[idx] c = c - 1 end local function work_func() if 2 <= c and #t < baselim + cnt then table.insert(t, v) end end grayWalk(baselim, add_func, rm_func, work_func) print(#t) print(table.concat(t, " "))