I am getting no errors with the code with custom inputs but it shows a runtime error on submitting it. I can’t seem to find the issue with it. Please help.

```
import math
T=int(input())
for i in range(T):
N=int(input())
if math.log(N,2)%1==0:
print(0)
continue
a=0
while math.log(N,2)%1!=0:
x=0
while (2**x)<=N:
x+=1
N=N-2**(x-1)
a=a+1
print(a)
```