Problem:


Weight

祖母が天秤を使っています。天秤は、二つの皿の両方に同じ目方のものを載せると釣合い、そうでない場合には、重い方に傾きます。10 個の分銅の重さは、軽い順に 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g です。

祖母は、「1kg くらいまでグラム単位で量れるのよ。」と言います。「じゃあ、試しに、ここにあるジュースの重さを量ってよ」と言ってみると、祖母は左の皿にジュースを、右の皿に 8g と64g と128g の分銅を載せて釣合わせてから、「分銅の目方の合計は 200g だから、ジュースの目方は 200g ね。どう、正しいでしょう？」と答えました。

左の皿に載せる品物の重さを与えるので、天秤で与えられた重みの品物と釣合わせるときに、右の皿に載せる分銅を軽い順に出力するプログラムを作成して下さい。ただし、量るべき品物の重さは、すべての分銅の重さの合計 (=1023g) 以下とします。

Input

複数のデータセットが与えられます。各データセットに、左の皿に載せる品物の重さが１行に与えられます。入力の最後まで処理して下さい。データセットの数は 50 を超えません。

Output

各データセットに対して、右の皿に載せる分銅（昇順）を１つの空白で区切って、１行に出力して下さい。

Sample Input

5
7
127

Output for the Sample Input

1 4
1 2 4
1 2 4 8 16 32 64

Hint

分銅の重さは 2 の n 乗 ( n = 0, 1, .... 9 )g です。



Sample input:
5
7
127


Sample output:
1 4
1 2 4
1 2 4 8 16 32 64

Submission status: Accepted

Solution code:
import math
import fileinput
weight = [2**x for x in range(10)]
for line in fileinput.input():
    if line == "\n":
        break
    else:
        w = int(line)
        log = int(math.log2(w))
        w_type = []
        for i in range(log, -1, -1):
            if sum(w_type) + weight[i] <= w:
                w_type.append(weight[i])
        for i in reversed(range(len(w_type))):
            if i == 0:
                print(w_type[i])
            else:
                print(w_type[i], end=" ")

Submission status: Accepted

Solution code:
# Aizu Problem 0031: Weight
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

while True:
    try:
        w = int(input())
    except EOFError:
        break
    b = bin(w)[2:][::-1]
    while len(b) < 10:
        b += '0'
    out = ""
    for k in range(10):
        if b[k] == '1':
            out += str(2**k) + ' '
    print(out[:-1])

Submission status: Accepted

Solution code:
while True:
    try:
        left = int(input())
        right = []
        i = 9
        while i >= 0:
            w = 2 ** i
            if left >= w:
                left -= w
                right.insert(0, w)
            i -= 1
        print(*right, sep=" ")
    except:
        break

Submission status: Accepted

Solution code:
def main():
    W = [512,256,128,64,32,16,8,4,2,1]
    while True:
        try:
            w = []
            weight = int(input())
            for value in W:
                if weight >= value:
                    weight -= value
                    w.append(value)
            print(*reversed(w))
        except EOFError:
            break
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
w_a = [1,2,4,8,16,32,64,128,256,512]

while True:
    try:
        w_b = int(input())
        b = list(bin(w_b))[::-1]
        w_c = []
        for i in range(len(b)):
            if b[i] == "b":
                break
            elif b[i] == "1":
                w_c.append(w_a[i])
        print(*w_c)
    except:
        break

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
w = [1,2,4,8,16,32,64,128,256,512]
w.reverse()

for l in range(len(N)):
    n = int(N[l])
    ans = []
    for i in range(10):
        if n >= w[i]:
            n = n - w[i]
            ans.append(w[i])
    ans.sort()
    print(ans[0], end="")
    for i in range(1,len(ans)):
        print(" " + str(ans[i]), end="")
    print("")

Submission status: Accepted

Solution code:
import sys
for d in sys.stdin:print(*[int(b)*2**i for i,b in enumerate(bin(int(d))[2:][::-1])if int(b)])

Submission status: Accepted

Solution code:
import sys
for d in sys.stdin:
 c=0
 a=[]
 for b in bin(int(d))[2:][::-1]:
  if int(b):a+=[int(b)*2**c]
  c+=1
 print(*a)

Submission status: Accepted

Solution code:
import sys
for d in sys.stdin:print(*[w for w in[2**i for i in range(10)]if int(d)& w])

Submission status: Accepted

Solution code:
import sys
for d in sys.stdin:
 m=int(d)
 a,c=[],0
 while m:
  if m&1:a.append(2**c)
  c+=1
  m>>=1
 print(*a)

Submission status: Accepted

Solution code:
import itertools
weight=[int(2**i) for i in range(10)]
while True:
	try:
		x=int(input())
		num=x
		a=[]
		while num!=0:
			for i in range(10):
				if num-weight[9-i]>=0:
					num-=weight[9-i]
					a.append(weight[9-i])
		for i in reversed(range(1,len(a))):
			print(a[i] ,end=" ")
		print(a[0])
	except EOFError:
		break

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin:
    g = int(line)
    now = 512
    ans = []
    while True:
        if g == 0:
            break
        elif g >= now:
            g -= now
            ans.append(now)
        now //= 2
    temp = ''
    for i in ans[::-1]:
        temp += str(i) + ' '
    print(temp[:-1])

Submission status: Accepted

Solution code:
while 1:
	li=[]
	w = list(2**i for i in range(10))
	try: a = int(input())
	except: break
	for i in range(9,-1,-1):
		if w[i] <= a:
			a = a - w[i]
			li.append(w[i])
	li.reverse()
	for i in li: 
		if i == li[len(li)-1]:
			print(i)
		else:
			print(i, end=' ')

Submission status: Accepted

Solution code:
import sys
for d in sys.stdin:print(*[w for w in[2**i for i in range(10)]if int(d)&w])

Submission status: Accepted

Solution code:
import sys
bundo = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
bundo.reverse()
for line in sys.stdin:
    n = int(line)
    ans = ''
    for i in bundo:
        if n >= i:
            n -= i
            ans = str(i) + ' ' + ans
    print(ans[:-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python

while True:
	try:
		n = input()
	except:
		break
	ans = []
	for j in range(10):
		if n & (2 ** j):
			ans.append(str(2 ** j))
	print(" ".join(ans))

Submission status: Accepted

Solution code:
import sys
l=[int(i) for i in sys.stdin]
[print(" ".join(map(str,i))) for i in [[2**i for i in range(10) if j&(1<<i)] for j in l]]

Submission status: Accepted

Solution code:
#2進数化
def bin(w, l):
  if w == 0:
    return l

  l.append(w % 2)
  return bin(w // 2, l)

while True:
  try:
    w = int(input())
    w_bin = bin(w, [])
    ans = ""
    for i, v in enumerate(w_bin):
      if v:
        ans += str(2 ** i) + " "
    print(ans.rstrip())

  except EOFError:
    break

Submission status: Accepted

Solution code:
import sys
print("\n".join((" ".join(str(2**i)for i, n in enumerate(bin(int(s))[:1:-1])if n=="1")for s in sys.stdin.readlines())))

Submission status: Accepted

Solution code:
# AOJ 0031 Weight
# Python3 2018.6.14 bal4u

w = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512];

while True:
	try:
		a = int(input())
		ans = []
		i = 0
		while a > 0:
			if a & 1:
				ans.append(w[i])
			a >>= 1
			i += 1
		print(*ans)
	except EOFError:
		break

Submission status: Accepted

Solution code:
# AOJ 0031 Weight
# Python3 2018.6.14 bal4u

w = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512];

while True:
	try:
		a = int(input())
	except EOFError:
		break
		
	ans = []
	i = 0
	while a > 0:
		if a & 1:
			ans.append(w[i])
		a >>= 1
		i += 1
	print(*ans)

Submission status: Accepted

Solution code:
# coding=utf-8


def calc_weights(weight):
    weights_list = []
    counter = 0
    while weight > 0:
        if weight % 2 == 0:
            weight /= 2
        else:
            weights_list.append(2**counter)
            weight = (weight - 1)/2
        counter += 1
    print(' '.join(map(str, weights_list)))


if __name__ == '__main__':
    while True:
        try:
            W = int(input())
            calc_weights(W)
        except EOFError:
            break

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin.readlines():
    num="".join(reversed(format(int(line.strip()),'b').zfill(10)))
    for i in xrange(10):
        if num[i]=="1":print 1<<i,
    print

Submission status: Accepted

Solution code:
while True:
    try:
        a = input()
        array = []
        b = str(format(a,'b'))

        for i in range(len(b)):
            if b[i] == '1':
                array.append(2**(len(b)-i-1))

        array.sort()
        for i in range(len(array)):
            array[i] = str(array[i])

        print ' '.join(array)
    except EOFError:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        g = int(raw_input())
    except:
        break
    for i in [2**j for j in xrange(10)]:
        if(g & i):
            print i,
    print

Submission status: Accepted

Solution code:
while True:
 try:
  l = [];
  n = input();
  for i in range(10):
   if ((n >> i) & 1) == 1:
    l.append(1 << i);
  print " ".join(map(str, l))
 except:
  break

Submission status: Accepted

Solution code:
import sys

def solve(m):
    ans=[]
    for i in range(10)[::-1]:
        w=1<<i
        if m==0: break
        if m >= w:
            m-=w
            ans.append(w)

    ans.reverse()
    return " ".join(map(str,ans))

for m in sys.stdin.readlines():
    print solve(int(m.rstrip()))

Submission status: Accepted

Solution code:
ans=[]
numLst=[512,256,128,64,32,16,8,4,2,1]
while True:
    ansLst=[]
    try:
        n=input()
    except EOFError:
        break
    for i in numLst:
        if n>= i:
            ansLst.append(str(i))
            n-=i
        if n==0:
            break
    ans.append(' '.join(reversed(ansLst)))
for i in ans:
    print i

Submission status: Accepted

Solution code:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    try:
        w = int(line)
    except ValueError:
        break
    print(' '.join(str(1 << i) for i in xrange(10) if w & (1 << i)))

Submission status: Accepted

Solution code:
#!/usr/bin/env

import sys

weights = map(lambda n: 2 ** n, range(0, 10))
weights.reverse()
while True:
    try:
        m = int(raw_input())
    except EOFError:
        break
    s = []
    for w in weights:
        if w <= m:
            s.append(w)
            m -= w
    s.reverse()
    print ' '.join(map(str, s))

Submission status: Accepted

Solution code:
while True:
	try:
		n = input() ; plumbs = [] ; answer = ''
		if n >= 512: plumbs.insert(0,512);n-=512
		if n >= 256: plumbs.insert(0,256);n-=256
		if n >= 128: plumbs.insert(0,128);n-=128
		if n >= 64: plumbs.insert(0,64);n-=64
		if n >= 32: plumbs.insert(0,32);n-=32
		if n >= 16: plumbs.insert(0,16);n-=16
		if n >= 8: plumbs.insert(0,8);n-=8
		if n >= 4: plumbs.insert(0,4);n-=4
		if n >= 2: plumbs.insert(0,2);n-=2
		if n >= 1: plumbs.insert(0,1);n-=1
		for val in plumbs: answer += str(val) + ' '
		print answer.rstrip()
	except: break

Submission status: Accepted

Solution code:

import sys


def subset(a):
    for n in range(2**len(a)):
        yield [a[i] for i in xrange(len(a)) if (n >> i) & 1 == 1]


weights = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]

for line in sys.stdin:
    w = int(line)
    for s in subset(weights):
        if sum(s) == w:
            print ' '.join(map(str, s))

Submission status: Accepted

Solution code:
import math

def cal(x):
    y = []
    for i in xrange(1,11):
        d= pow(2,(10-i))

        if x>=d:
            x -= d
            y.append(d)
    return y

if __name__ == "__main__":
    while True:
        try:

            b = cal(int(raw_input()))
            b.reverse()

            for i in b:
                print i,

            print

        except EOFError:
            break

Submission status: Accepted

Solution code:
while True:
	try:
		ans = []
		n = int(raw_input())
		for b in [512,256,128,64,32,16,8,4,2,1]:
			if n >= b:
				n -= b
				ans.append(b)
		ans.reverse()
		ans = map(str,ans)
		ans = ' '.join(ans)
		print ans
	except:
		break

Submission status: Accepted

Solution code:
import sys
for number in sys.stdin:
    answer = []
    for i, c in enumerate(format(int(number), 'b')[::-1]):
        if int(c):
            answer.append(str(2 ** i))
    print ' '.join(answer)

Submission status: Accepted

Solution code:
import sys
for number in sys.stdin:
   	ans = []
	n = int(number)
	for b in [512,256,128,64,32,16,8,4,2,1]:
		if n >= b:
			n -= b
			ans.append(b)
	ans.reverse()
	ans = map(str,ans)
	ans = ' '.join(ans)
	print ans

Submission status: Accepted

Solution code:
import sys
for number in sys.stdin.readlines():
   	ans = []
	n = int(number)
	for b in [512,256,128,64,32,16,8,4,2,1]:
		if n >= b:
			n -= b
			ans.append(b)
	ans.reverse()
	ans = map(str,ans)
	ans = ' '.join(ans)
	print ans

Submission status: Accepted

Solution code:
import sys
nyu = sys.stdin.read()
nyu = map(int,nyu.split())
for n in nyu:
   	ans = []
	for b in [512,256,128,64,32,16,8,4,2,1]:
		if n >= b:
			n -= b
			ans.append(b)
	ans.reverse()
	ans = map(str,ans)
	ans = ' '.join(ans)
	print ans

Submission status: Accepted

Solution code:
while True:
    try:
        n = int(raw_input())
        print ' '.join([str(1<<i) for i in range(10) if ((n >> i) & 1)])
    except EOFError:
        break

Submission status: Accepted

Solution code:
def dec2bin(n, base=10):
    s=""
    x="01"
    while n>0:
        s+=x[n%2]
        n/=2
    return (s+"0"*base)[:base]

while True:
    try:
        tmp = dec2bin(input())
    except:
        break
    weight = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
    s=[]
    for i in range(len(tmp)):
        if tmp[i]=="1":
            s.append(weight[i])

    for e in s:
        print e,
    print

Submission status: Accepted

Solution code:
while True:
    try:
        tmp = input()
    except:
        break
    i=1
    while tmp>0:
        if tmp%2 ==1: print i,
        tmp/=2
        i*=2
    print

Submission status: Accepted

Solution code:
import sys

for s in sys.stdin:
	inp = int(s)
	l = []
	for i in reversed(range(10)):
		p = 2**i
		if inp >= p:
			l.append(p)
			inp = inp - p
	print ' '.join(map(str,reversed(l)))

Submission status: Accepted

Solution code:
import sys

def main():
    for line in sys.stdin:
        w = int(line)
        dic = calcWeights(w)

        l = []
        for k in sorted(dic.keys()):
            if dic[k] > 0:
                l.append(str(k))

        res = ' '.join(l)
        print res


def calcWeights(w):
    dic = {}
    dic[1] = w >> 0 & 1
    dic[2] = w >> 1 & 1
    dic[4] = w >> 2 & 1
    dic[8] = w >> 3 & 1
    dic[16] = w >> 4 & 1
    dic[32] = w >> 5 & 1
    dic[64] = w >> 6 & 1
    dic[128] = w >> 7 & 1
    dic[256] = w >> 8 & 1
    dic[512] = w >> 9 & 1

    return dic


main()

Submission status: Accepted

Solution code:
import sys
answer = lambda number:[str(2 ** i) for i,c in enumerate(format(int(number), 'b')[::-1]) if c != '0']
for number in sys.stdin:
        print ' '.join(answer(number))

Submission status: Accepted

Solution code:
while True:
    try:
        w = int(raw_input())
        cu = [2**i for i in range(10)]
        all = 1023
        i = 9
        while all != w:
            if all > w:
                all -= cu[i]
                cu[i] = 0
                i -= 1
            if all < w:
                all = all + 2*cu[i] - cu[i]
                cu[i+1] = 2*cu[i]
                cu[i] = 0
                i -= 1
        for j in range(cu.count(0)):
            cu.remove(0)
        print (" ".join(map(str, cu)))
    except:
        break

Submission status: Accepted

Solution code:
W=[1,2,4,8,16,32,64,128,256,512]
import sys
for s in sys.stdin:
    B=format(int(s),'b')[::-1]
    i=0
    for e in B:
        if e=="1": print W[i],
        i+=1
    print

Submission status: Accepted

Solution code:
while True:
	try:
		n = input()
		num = format(n, 'b').zfill(10)
		num = list(str(num))
		num.reverse()
		ans = []
		for i in range(10):
			if num[i] == '1':
				ans.append(2**i)
		print " ".join(map(str, ans))
	except:
		break

Submission status: Accepted

Solution code:
while 1:
    try:
        n = bin(input())[:1:-1]
        print ' '.join(str(1 << i) for i in range(len(n)) if n[i] == '1')
    except:
        break

Submission status: Accepted

Solution code:
try:
    while True:
        s = bin(int(raw_input()))[::-1]
        a = []
        for i in range(len(s)):
            if s[i] == '1':
                a.append(str(1 << i))
        print ' '.join(a)
except:
    pass

Submission status: Accepted

Solution code:
import sys,math
for v in sys.stdin:
	m=int(v)
	for i in range(10):
		if m&(2**i):
			print 2**i,
	print

Submission status: Accepted

Solution code:
import sys

for s in sys.stdin:
  nb = format(int(s), 'b')
  arr = list(reversed(nb))
  ans = []
  i = 0
  for a in arr:
    if a == '1':
      ans.append(str(2**i))
    i += 1
  print ' '.join(ans)

Submission status: Accepted

Solution code:
import sys

for s in sys.stdin:
  nb = format(int(s), 'b')
  arr = list(reversed(nb))
  i = 0
  for a in arr:
    if a == '1':
      print str(2**i),
    i += 1
  print

Submission status: Accepted

Solution code:
import sys

for line in sys.stdin:
    n = int(line)
    print(' '.join(map(str, [2**i for i, b in enumerate(bin(n)[-1:1:-1]) if b == '1'])))

Submission status: Accepted

Solution code:
import sys

w = [512,256,128,64,32,16,8,4,2,1]
ans = []
for x in sys.stdin:
    for i in range(10) :
        if int(x) % w[i] == 0:
            ans.append(w[i])
            ans.reverse()
            print(*ans)
            ans = []
            break
        else:
            if int(x) // w[i] == 1 :
                ans.append(w[i])
                x = int(x) % w[i]

Submission status: Accepted

Solution code:
lst = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]

while True:
    try:
        s = []
        num = int(input())
        for i in lst:
            if num >= i:
                num = num - i
                s.append(i)
        
        s.sort()
        print(*s)

    except EOFError:
        break

Submission status: Accepted

Solution code:
while 1:
    try:
        w = [512,256,128,64,32,16,8,4,2,1]
        x,y = [],[]
        n = int(input())

        for i in w:
            weight = n // i
            n %= i
            x.append(weight)

        for i in range(10):
            if x[i] != 0:
                y.append(w[i])

        y.reverse()        
        print(*y)
    except:
        break

Submission status: Accepted

Solution code:
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    for line in readlines():
        v = int(line)
        res = []
        for i in range(10):
            if v & (1 << i):
                res.append(1 << i)
        write(" ".join(map(str, res)))
        write("\n")
solve()

Submission status: Accepted

Solution code:
while True:
    try:
        n = format(int(input()),"b")
    except:
        break
    l = []
    for i in range(len(n)):
        if n[-(i+1)] == "1":
            l.append(str(2**i))
    print(" ".join(l))

Submission status: Accepted

Solution code:
def solve(num, l):
  if num == 0:
    return l

  l.append(num % 2)
  return solve(num // 2, l)

while True:
  try:
    num = int(input())
    nums = solve(num, [])
    ans = ""
    for i, v in enumerate(nums):
      if v:
        ans += str(2 ** i) + " "
    print(ans.rstrip())

  except EOFError:
    break

Submission status: Accepted

Solution code:
while True:
    try:
        num = int(input())
        L = []
        for i in range(10):
            if num & (1<<i):
                L.append(2**i)
        print(" ".join(map(str,L)))
    except EOFError:
        break

Submission status: Accepted

Solution code:
while True:
  n = []
  try:
    w = bin(int(input()))
  except EOFError:
    break
  for i in range(len(w)-1,1,-1):
    if int(w[i]):
      n.append(int(2**(len(w)-i-1)))
  print(*n)

Submission status: Accepted

Solution code:
while 1:
    try:
        n = int(input())
        s = format(n, '10b')
        ans = [2 ** (9-i) for i in range(10)[::-1] if s[i] == '1']
        print(*ans)

    except:
        break

Submission status: Accepted

Solution code:

if __name__ == '__main__':

	while True:
		try:
			n = int(input())

			ans = []
			for i in range(9,-1,-1):
				if n >=  2**i:
					ans.append(2**i)
					n -= 2**i

			print(*sorted(ans))

		except EOFError:
			break

Submission status: Accepted

Solution code:
import sys
  
def toBin(n):
    l = []
    i = 0
    a,b = n,n
    while True:
        b = a % 2
        a = a // 2
        if b == 1:
            l.append(b*(2**i))
        i += 1
        if a == 0:
            break
    return l


for line in sys.stdin:
    n = int(line)
    print(*toBin(n),sep=' ')

Submission status: Accepted

Solution code:
while 1:
    try:
        n=int(input())
        ans=[]
        for i in range(10):
            if n>=2**(9-i):
                ans.append(2**(9-i))
                n-=2**(9-i)
        print(' '.join(map(str,ans[::-1])))
    except:break

Submission status: Accepted

Solution code:
blist = [int(2**i) for i in range(10)]
while(1):
    try:
        n = int(input())
        b_ = bin(n)
        b = list(b_)[-1:1:-1]
        for i in range(len(b)):
            if b[i] == "1":
                if i == len(b) - 1:
                    print(blist[i])
                else:
                    print(blist[i], end= " ")
    except EOFError:
        break

Submission status: Accepted

Solution code:
while 1:
    try:
        w = int(input())
    except:
        break

    fun = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
    anslist = []
    for f in reversed(fun):
        if w - f >= 0:
            anslist.append(f)
            w -= f
    print(' '.join(str(ans) for ans in reversed(anslist)))

Submission status: Accepted

Solution code:
import math
while True:
  try:
    n = int(input())
    ans = []
    while n != 0:
      if n%2 == 1:
        n -= 1
        ans.append( 1 )
      else:
        buff = []
        tmp = n
        while True:
          tmp //= 2
          buff.append(2)
          if tmp%2 != 0:
            n -= math.pow(2, len(buff))
            ans.append( math.pow(2, len(buff)) )
            break
    print( ' '.join( [f'{int(a)}' for a in ans] ) )
  except:
    break

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import product,permutations,combinations

while(True):
    try:
        n = int(stdin.readline())
        a = str(bin(n))
        print(" ".join(str(2**i) for i,s in enumerate(a[:1:-1]) if s=="1"))
    except:
        break

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin:
    ans=[]
    n=1
    for i in reversed(bin(int(line))):
        if i=="1":
            ans.append(n)
        n*=2
    print(*ans)

Submission status: Accepted

Solution code:
import sys

for line in sys.stdin:
    w_all = reversed([1, 2, 4, 8, 16, 32, 64, 128, 256, 512])
    n = int(line)
    use_w_list = []
    for w in w_all:
        if n >= w:
            n -= w
            use_w_list.append(w)
        if n == 0:
            break
    use_w_list = use_w_list[::-1]
    out = str(use_w_list[0])
    use_w_list.remove(use_w_list[0])
    for u in use_w_list:
        out += ' {0}'.format(str(u))
    print(out)

Submission status: Accepted

Solution code:
import sys

def solve():
    for line in sys.stdin:
        W = int(line)
        pows = []
        idx = 0
        while W > 0:
            r = W % 2
            W = W // 2
            if not r == 0:
                end = ' ' if W > 0 else ''
                print(r*pow(2, idx), end=end)
            idx += 1
        print()
    

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
def bin(w, l):
  if w == 0:
    return l
 
  l.append(w % 2)
  return bin(w // 2, l)
 
while True:
  try:
    w = int(input())
    w_bin = bin(w, [])
    ans = ""
    for i, v in enumerate(w_bin):
      if v:
        ans += str(2 ** i) + " "
    print(ans.rstrip())
 
  except EOFError:
    break

Submission status: Runtime Error

Solution code:
import sys
"""
a=[]
while True:
	n=input()
	if n==-1:
		break
	a.append(n)
"""
for line in sys.stdin:
	a.append(int(line))
for x in a:
	out=1
	while x:
		if x&1:
			print out,
		x/=2
		out*=2
	print

Submission status: Runtime Error

Solution code:
import sys


waight = ["1", "2", "4", "8", "16", "32", "64", "128", "256", "512"]
for n in sys.stdin:
    ans = []
    n = bin(n)[2:].zfill(10)
    for i, x in enumerate(n[::-1]):
        if x == "1":
            ans.append(waight[i])
    print(" ".join(ans))

Submission status: Runtime Error

Solution code:
while True:
    instr = str(bin(int(input())))
    ans = []
    for i in range(len(instr)):
        if instr[-i]=="1": ans.append(1<<i-1)
    print(" ".join(map(lambda x: str(x), ans)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 木 10/26 19:32:38 2017

# Usage
#
"""
import sys

WEIGHTS = [2 ** i for i in range(9)]

def solver_greedy(target_weight: int):
    """
    >>> print(solver_greedy(127))
    [1, 2, 4, 8, 16, 32, 64]
    """
    res = []
    for w in sorted(WEIGHTS, reverse=True):
        if w <= target_weight:
            res.append(w)
            target_weight = target_weight - w
        if target_weight == 0:
            return sorted(res)


if __name__ == '__main__':
    data = []
    for line in sys.stdin:
        data.append(int(line))

    for i in data:
        res = solver_greedy(i)

        for x,n in enumerate(res):
            sys.stdout.write(str(n))
            if x + 1 == len(data):
                sys.stdout.write("\n")
                break
            sys.stdout.write(" ")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 木 10/26 19:32:38 2017

# Usage
#
"""
import sys

WEIGHTS = [2 ** i for i in range(9)]

def solver_greedy(target_weight: int):
    """
    >>> print(solver_greedy(127))
    [1, 2, 4, 8, 16, 32, 64]
    >>> print(solver_greedy(10))
    [2, 8]
    """
    res = []
    for w in sorted(WEIGHTS, reverse=True):
        if w <= target_weight:
            res.append(w)
            target_weight = target_weight - w
        if target_weight == 0:
            return sorted(res)


if __name__ == '__main__':
    data = []
    for line in sys.stdin:
        data.append(line.rstrip("\n"))

    data = [int(d) for d in data[:-1]]

    for i in data:
        res = solver_greedy(i)

        for x,n in enumerate(res):
            sys.stdout.write(str(n))
            if x + 1 == len(data):
                sys.stdout.write("\n")
                break
            sys.stdout.write(" ")

Submission status: Runtime Error

Solution code:
import sys

def isn2(x):
    if(x == 1):
        return True
    elif(x % 2 != 0):
        return False
    return True and isn2(x/2)

def n2(x):
    a = 1
    while(True):
        print a,
        x -= a
        if(isn2(x) == True):
            print x,
            break
        a *= 2
        if(a > x):
            break
    print

l = []
for input in sys.stdin:
    l.append(int(input))
for data in l:
    n2(data)

Submission status: Runtime Error

Solution code:
while 1:print(*[int(b)*2**i for i,b in enumerate(bin(int(input()))[2:][::-1])if int(b)])

Submission status: Runtime Error

Solution code:
import sys
while 1:print(*[int(b)*2**i for i,b in enumerate(bin(int(sys.stdin.readline()))[2:][::-1])if int(b)])

Submission status: Runtime Error

Solution code:
while True:
    g = int(input())
    now = 512
    ans = []
    while True:
        if g == 0:
            break
        elif g >= now:
            g -= now
            ans.append(now)
        now //= 2
    temp = ''
    for i in ans[::-1]:
        temp += str(i) + ' '
    print(temp[:-1])

Submission status: Runtime Error

Solution code:
mport math

def cal(x):
    a=10
    y= []
    for i in range(1,11):
        d= pow(2,(10-i))

        if x>=d:
            x -= d
            y.append(d)
    return y

if __name__ == "__main__":
    while True:
        try:

            a=int(raw_input())
            b = cal(a)
            b.reverse()

            for y in b:
                print y,

            print

        except EOFError:
            break

Submission status: Runtime Error

Solution code:
for n in sys.stdin:
    ans = []
    n = int(n)
    nb = format(n,'b')
    nb.reverse
    nb += " "*(10-len(nb))
    for i in xrange(10):
    	if nb[i] == 1:
    		answer.append(str(2**i))
    print ' '.join(answer)

Submission status: Runtime Error

Solution code:
for n in sys.stdin:
    ans = []
    n = int(n)
    nb = format(n,'b')
    nb.reverse
    nb += " "*(10-len(nb))
    for i in xrange(10):
    	if nb[i] == 1:
    		ans.append(str(2**i))
    print ' '.join(ans)

Submission status: Runtime Error

Solution code:
import sys
for n in sys.stdin:
    ans = []
    n = int(n)
    nb = format(n,'b')
    nb.reverse
    nb += " "*(10-len(nb))
    for i in xrange(10):
    	if nb[i] == 1:
    		ans.append(str(2**i))
    print ' '.join(ans)

Submission status: Runtime Error

Solution code:
import sys
for n in sys.stdin:
    ans = []
    n = int(n)
    nb = format(n,'b')
    nb.reverse
    nb += " "*(10-len(nb))
    for i in xrange(10):
    	if nb[i] == 1:
    		ans.append(str(2**(9-i))
    print ' '.join(ans)

Submission status: Runtime Error

Solution code:
while True:
	try:
	    ans = []
	    n = int(raw_input())
	    nb = format(n,'b')
	    nb.reverse
	    nb += " "*(10-len(nb))
	    for i in xrange(10):
	    	if nb[i] == 1:
	    		ans.append(str(2**(9-i))
	    print ' '.join(ans)
	except:
		break

Submission status: Runtime Error

Solution code:
import sys
from math import sqrt

nyu = sys.stdin.read()
nyu = nyu.split("\n")
cheese = map(float,nyu[0].split())
cheese.sort()
supk = sqrt((cheeze[0]/2)**2 + (cheeze[1]/2)**2)
nyu = nyu[2:]
for k in nyu:
	if k < supk: print "OK"
	else: print "NA"

Submission status: WA: Presentation Error

Solution code:
#encoding=utf-8
import itertools as iter
import sys
for i in sys.stdin:
    omori = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
    x = int(i)
    for i in xrange(1,11):
        for element in iter.combinations(omori,i):
             if sum(element) == x:
                 for k in xrange(len(element)):
                     print element[k],
                 print ""

Submission status: WA: Presentation Error

Solution code:
while True:
    try:
        Num = []
        n = int(input())
        while n > 0:
            if n % 2 == 1:
                Num.append(1)
                n = (n - 1) / 2
            else:
                Num.append(0)
                n = n / 2
        for i in range(len(Num)):
            if Num[i] == 1:
                print(2**i,end = " ")
        print(end = "\n")
    except EOFError:
        break

Submission status: WA: Presentation Error

Solution code:
while True:
	try:
		n = input() ; plumbs = [] ; answer = ''
		if n >= 512: plumbs.insert(0,512);n-=512
		if n >= 256: plumbs.insert(0,256);n-=256
		if n >= 128: plumbs.insert(0,128);n-=128
		if n >= 64: plumbs.insert(0,64);n-=64
		if n >= 32: plumbs.insert(0,32);n-=32
		if n >= 16: plumbs.insert(0,16);n-=16
		if n >= 8: plumbs.insert(0,8);n-=8
		if n >= 4: plumbs.insert(0,4);n-=4
		if n >= 2: plumbs.insert(0,2);n-=2
		if n >= 1: plumbs.insert(0,1);n-=1
		for val in plumbs: answer += str(val) + ' '
		answer.rstrip() ; print answer
	except: break

Submission status: WA: Presentation Error

Solution code:

import sys


def subset(a):
    for n in range(2**len(a)):
        yield [a[i] for i in xrange(len(a)) if (n >> i) & 1 == 1]


weights = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]

for line in sys.stdin:
    w = int(line)
    for s in subset(weights):
        if sum(s) == w:
            for a in s:
                print a,
            print ''