t=int(input())
c=[]
a=[]
for i in range(1,13):
c.append(2**(i-1))
for i in range(t):
count=0
int(count)
p=int(input())
while(p!=0):
i=0
while(c[i]<=p):
x=c[i]
i=i+1
p=p-x
count=count+1
a.append(count)
for i in range(t):
print("%d"%a[i])
the same happens for some of my Dlang ( D2 ) code, which makes me resort to C++
below is one of them
import std.stdio;
void main(string[] args) {
uint testCases;
readf( "%d\n", &testCases );
while( testCases-- > 0 )
{
uint input, reversed = 0, temp;
readf( "%d\n", &input );
temp = input;
while( temp > 0 )
{
reversed = reversed + ( temp % 10 );
temp = temp / 10;
reversed = reversed * 10;
}
reversed /= 10;
if ( input == reversed ) writeln( "wins" );
else writeln( "losses" );
}
}