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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
cmp    $0x0,%rax
je     11b3 <main+0x83>
lea    0xe91(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
shl    $0x3,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1050 <sqrt@plt>
add    $0xffffffff,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe5c(%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    0xec0(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
subq   $0x1,(%rsp)
jb     11ac <main+0x7c>
lea    0xeaa(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xea3(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
lea    0x1(,%rax,8),%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 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %4)
br label %6
6: ; preds = %10, %0
%7 = load i64, i64* %4
%8 = add nsw i64 %7, -1
store i64 %8, i64* %4
%9 = icmp ne i64 %7, 0
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%12 = load i64, i64* %3
%13 = mul nsw i64 8, %12
%14 = add nsw i64 1, %13
%15 = trunc i64 %14 to i32
%16 = call i32 @sqrt(i32 %15)
%17 = add nsw i32 -1, %16
%18 = sdiv i32 %17, 2
%19 = sext i32 %18 to i64
store i64 %19, i64* %2
%20 = load i64, i64* %2
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %20)
br label %6
22: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [6 x i8] c"%lld\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* %2)
%6 = load i64, i64* %2
%7 = add nsw i64 %6, -1
store i64 %7, i64* %2
%8 = icmp eq i64 %6, 0
br i1 %8, label %23, label %9
9: ; preds = %0, %9
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%11 = load i64, i64* %1
%12 = trunc i64 %11 to i32
%13 = shl i32 %12, 3
%14 = or i32 %13, 1
%15 = call i32 @sqrt(i32 %14)
%16 = add nsw i32 %15, -1
%17 = sdiv i32 %16, 2
%18 = sext i32 %17 to i64
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %18)
%20 = load i64, i64* %2
%21 = add nsw i64 %20, -1
store i64 %21, i64* %2
%22 = icmp eq i64 %20, 0
br i1 %22, label %23, label %9
23: ; preds = %9, %0
ret i32 0
}