import itertools as it
import numpy as np
t = int(input())
while t:
n = bin(int(input()))
n = n[2:]
z = 0; o = 0
ans = 0
for i in n:
if i == “1”:
ans += 3int(o)
ans += int(z)
o += 1
else:
ans += 2int(o)
z += 1
print(ans)
t -= 1
This is my submission for the problem Bit Pair Sum. But it gave me NZEC for some unknown reason.
I’m new to python so please help me find what’s wrong. Thank you in advance!!