#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 *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int sqrt(int);
int main() {
  long long int t, x;
  double n;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lf", &n);
    x = ((-1 + (sqrt(1 + 8 * n))) / 2);
    printf("%lld\n", x);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11ca <main+0x9a>
lea    0xea4(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe77(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe73(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
add    $0xffffffff,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subq   $0x1,(%rsp)
jb     11bd <main+0x8d>
lea    0xebd(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xeb5(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0xe75(%rip),%xmm0
addsd  0xe75(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
shr    $0x1f,%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
sar    %eax
movslq %eax,%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
subq   $0x1,(%rsp)
jae    1170 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca double
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %6
6: ; preds = %10, %0
%7 = load i64, i64* %2
%8 = add nsw i64 %7, -1
store i64 %8, i64* %2
%9 = icmp ne i64 %7, 0
br i1 %9, label %10, label %21
10: ; preds = %6
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%12 = load double, double* %4
%13 = call double @llvm.fmuladd.f64(double 8.000000e+00, double %12, double 1.000000e+00)
%14 = fptosi double %13 to i32
%15 = call i32 @sqrt(i32 %14)
%16 = add nsw i32 -1, %15
%17 = sdiv i32 %16, 2
%18 = sext i32 %17 to i64
store i64 %18, i64* %3
%19 = load i64, i64* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %19)
br label %6
21: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca double
%3 = bitcast i64* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%6 = load i64, i64* %1
%7 = add nsw i64 %6, -1
store i64 %7, i64* %1
%8 = icmp eq i64 %6, 0
br i1 %8, label %22, label %9
9: ; preds = %0, %9
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%11 = load double, double* %2
%12 = call double @llvm.fmuladd.f64(double %11, double 8.000000e+00, double 1.000000e+00)
%13 = fptosi double %12 to i32
%14 = call i32 @sqrt(i32 %13)
%15 = add nsw i32 %14, -1
%16 = sdiv i32 %15, 2
%17 = sext i32 %16 to i64
%18 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %17)
%19 = load i64, i64* %1
%20 = add nsw i64 %19, -1
store i64 %20, i64* %1
%21 = icmp eq i64 %19, 0
br i1 %21, label %22, label %9
22: ; preds = %9, %0
ret i32 0
}