#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, p, ans;
  scanf("%d", &n);
  while (n--) {
    ans = 0;
    scanf("%d", &p);
    if (p > 2048)
      ans = p / 2048, p = p % 2048;
    while (p) {
      if ((p & 1) == 1)
        ans++;
      p = p >> 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11dc <main+0xbc>
movl   $0x0,-0x10(%rbp)
lea    0xe9f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x800,-0xc(%rbp)
jle    1193 <main+0x73>
mov    -0xc(%rbp),%eax
mov    $0x800,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x800,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
jmp    1198 <main+0x78>
cmpl   $0x0,-0xc(%rbp)
je     11c8 <main+0xa8>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    11ba <main+0x9a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1198 <main+0x78>
mov    -0x10(%rbp),%esi
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    114d <main+0x2d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xeac(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xea3(%rip),%rbx
jmp    117f <main+0x5f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1141 <main+0x21>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
xor    %esi,%esi
cmp    $0x801,%eax
jl     11a5 <main+0x85>
mov    %eax,%esi
shr    $0xb,%esi
and    $0x7ff,%eax
mov    %eax,0x8(%rsp)
test   %eax,%eax
je     1170 <main+0x50>
nopl   0x0(%rax)
mov    %eax,%ecx
mov    %eax,%edx
and    $0x1,%edx
add    %edx,%esi
sar    %eax
cmp    $0x1,%ecx
ja     11b0 <main+0x90>
mov    %eax,0x8(%rsp)
jmp    1170 <main+0x50>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %33, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, -1
store i32 %8, i32* %2
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %36
10: ; preds = %6
store i32 0, i32* %4
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 2048
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %3
%16 = sdiv i32 %15, 2048
store i32 %16, i32* %4
%17 = load i32, i32* %3
%18 = srem i32 %17, 2048
store i32 %18, i32* %3
br label %19
19: ; preds = %14, %10
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %3
%25 = and i32 %24, 1
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %30
30: ; preds = %27, %23
%31 = load i32, i32* %3
%32 = ashr i32 %31, 1
store i32 %32, i32* %3
br label %20
33: ; preds = %20
%34 = load i32, i32* %4
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %6
36: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp eq i32 %6, 0
br i1 %8, label %34, label %9
9: ; preds = %0, %28
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 2048
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = lshr i32 %11, 11
%15 = and i32 %11, 2047
store i32 %15, i32* %2
br label %16
16: ; preds = %13, %9
%17 = phi i32 [ %15, %13 ], [ %11, %9 ]
%18 = phi i32 [ %14, %13 ], [ 0, %9 ]
%19 = icmp eq i32 %17, 0
br i1 %19, label %28, label %20
20: ; preds = %16, %20
%21 = phi i32 [ %24, %20 ], [ %18, %16 ]
%22 = phi i32 [ %25, %20 ], [ %17, %16 ]
%23 = and i32 %22, 1
%24 = add nuw nsw i32 %21, %23
%25 = ashr i32 %22, 1
%26 = icmp ult i32 %22, 2
br i1 %26, label %27, label %20
27: ; preds = %20
store i32 %25, i32* %2
br label %28
28: ; preds = %27, %16
%29 = phi i32 [ %24, %27 ], [ %18, %16 ]
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %1
%32 = add nsw i32 %31, -1
store i32 %32, i32* %1
%33 = icmp eq i32 %31, 0
br i1 %33, label %34, label %9
34: ; preds = %28, %0
ret i32 0
}