a,b =0,0 for x in range(1,1001): bx = bin(x)[2:] cnt1 = bx.count('1') cnt0 = bx.count('0') if cnt1>cnt0: a+=1 else: b +=1 print(a,b)