#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 *, unsigned long long);
int /*<<< orphan*/ scanf(char *, unsigned long long *);
double sqrt(int);
int main() {
  unsigned long long T, N;
  scanf("%llu", &T);
  while (T--) {
    scanf("%llu", &N);
    if (N < 2) {
      printf("%llu\n", N);
      continue;
    }
    printf("%llu\n", (unsigned long long)((sqrt((8 * N) + 1) - 1.0) * 0.5));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11f8 <main+0xc8>
lea    0xea9(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x2,-0x18(%rbp)
jae    1198 <main+0x68>
mov    -0x18(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <main+0x1f>
mov    -0x18(%rbp),%ecx
mov    %ecx,%eax
lea    0x1(,%rax,8),%edi
call   1050 <sqrt@plt>
movsd  0xe4f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe4b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rsi
mov    %rsi,%rcx
sar    $0x3f,%rcx
movsd  0xe38(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rsi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed8(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
subq   $0x1,(%rsp)
jae    115b <main+0x2b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xeb6(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xeaf(%rip),%rbx
jmp    117f <main+0x4f>
mov    %rbx,%rdi
call   1030 <printf@plt>
subq   $0x1,(%rsp)
jb     114f <main+0x1f>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rsi
cmp    $0x1,%rsi
jbe    1170 <main+0x40>
lea    0x1(,%rsi,8),%edi
call   1050 <sqrt@plt>
addsd  0xe57(%rip),%xmm0
mulsd  0xe57(%rip),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xe4b(%rip),%xmm0
cvttsd2si %xmm0,%rsi
and    %rcx,%rsi
or     %rax,%rsi
jmp    1170 <main+0x40>

LLVM IR (-O0):
@.str = [5 x i8] c"%llu\00"
@.str.1 = [6 x i8] c"%llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %5
5: ; preds = %16, %13, %0
%6 = load i64, i64* %2
%7 = add i64 %6, -1
store i64 %7, i64* %2
%8 = icmp ne i64 %6, 0
br i1 %8, label %9, label %26
9: ; preds = %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%11 = load i64, i64* %3
%12 = icmp ult i64 %11, 2
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i64, i64* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %14)
br label %5
16: ; preds = %9
%17 = load i64, i64* %3
%18 = mul i64 8, %17
%19 = add i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call double @sqrt(i32 %20)
%22 = fsub double %21, 1.000000e+00
%23 = fmul double %22, 5.000000e-01
%24 = fptoui double %23 to i64
%25 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %24)
br label %5
26: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%llu\00"
@.str.1 = [6 x i8] c"%llu\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%6 = load i64, i64* %1
%7 = add i64 %6, -1
store i64 %7, i64* %1
%8 = icmp eq i64 %6, 0
br i1 %8, label %27, label %9
9: ; preds = %0, %13
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%11 = load i64, i64* %2
%12 = icmp ult i64 %11, 2
br i1 %12, label %13, label %19
13: ; preds = %9, %19
%14 = phi i64 [ %26, %19 ], [ %11, %9 ]
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %14)
%16 = load i64, i64* %1
%17 = add i64 %16, -1
store i64 %17, i64* %1
%18 = icmp eq i64 %16, 0
br i1 %18, label %27, label %9
19: ; preds = %9
%20 = trunc i64 %11 to i32
%21 = shl i32 %20, 3
%22 = or i32 %21, 1
%23 = call double @sqrt(i32 %22)
%24 = fadd double %23, -1.000000e+00
%25 = fmul double %24, 5.000000e-01
%26 = fptoui double %25 to i64
br label %13
27: ; preds = %13, %0
ret i32 0
}