def bin_no(n):

L=[]

while(n>=1):

L.append(n%2)

n=n//2

L.reverse()

return L

def find(x):

sum,k=0,1

while(sum<x):

res=bin_no(k)

for j in range(len(res)):

if((j+1)%2!=0):

sum=sum+res[j]

k=k+1

return k-1

for _ in range(int(input())):

ans=find(int(input()))

print(ans)

This is my code for the same, but I’m constantly facing Time limit exceeded issue. Can somebody please help me with this problem.