#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 *, ...);
double sqrt(int);
int main() {
  long long int n;
  int t, j;
  scanf("%d", &t);
  for (j = 1; j <= t; j++) {
    scanf("%d", &n);
    long long int i;
    double r = sqrt(2 * n);
    for (i = r - 1;; i++) {
      if (i * (i + 1) / 2 == n) {
        printf("%lld\n", i);
        break;
      } else if (i * (i + 1) / 2 > n) {
        printf("%lld\n", i - 1);
        break;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1248 <main+0x118>
lea    0xe9d(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
imul   %rcx,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    -0x10(%rbp),%rax
jne    11dd <main+0xad>
mov    -0x20(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
jmp    1235 <main+0x105>
mov    -0x20(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
imul   %rcx,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    -0x10(%rbp),%rax
jle    121a <main+0xea>
mov    -0x20(%rbp),%rsi
sub    $0x1,%rsi
lea    0xdfb(%rip),%rdi
call   1030 <printf@plt>
jmp    1235 <main+0x105>
jmp    121f <main+0xef>
jmp    1224 <main+0xf4>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a4 <main+0x74>
jmp    123a <main+0x10a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1158 <main+0x28>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec6(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11eb <main+0xbb>
mov    $0x1,%ebx
lea    0xea3(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe9a(%rip),%r12
jmp    1193 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
call   1030 <printf@plt>
lea    0x1(%rbx),%eax
cmp    0xc(%rsp),%ebx
mov    %eax,%ebx
jge    11eb <main+0xbb>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%edi
add    %edi,%edi
call   1050 <sqrt@plt>
addsd  0xe4d(%rip),%xmm0
cvttsd2si %xmm0,%rax
mov    0x10(%rsp),%rcx
nopl   (%rax)
mov    %rax,%rsi
add    $0x1,%rax
mov    %rax,%rdx
imul   %rsi,%rdx
mov    %rdx,%rdi
shr    $0x3f,%rdi
add    %rdx,%rdi
sar    %rdi
cmp    %rcx,%rdi
je     1180 <main+0x50>
jle    11c0 <main+0x90>
add    $0xfffffffffffffffe,%rax
mov    %rax,%rsi
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca double
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 1, i32* %4
br label %8
8: ; preds = %50, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %53
12: ; preds = %8
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64* %2)
%14 = load i64, i64* %2
%15 = mul nsw i64 2, %14
%16 = trunc i64 %15 to i32
%17 = call double @sqrt(i32 %16)
store double %17, double* %6
%18 = load double, double* %6
%19 = fsub double %18, 1.000000e+00
%20 = fptosi double %19 to i64
store i64 %20, i64* %5
br label %21
21: ; preds = %46, %12
%22 = load i64, i64* %5
%23 = load i64, i64* %5
%24 = add nsw i64 %23, 1
%25 = mul nsw i64 %22, %24
%26 = sdiv i64 %25, 2
%27 = load i64, i64* %2
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i64, i64* %5
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %30)
br label %49
32: ; preds = %21
%33 = load i64, i64* %5
%34 = load i64, i64* %5
%35 = add nsw i64 %34, 1
%36 = mul nsw i64 %33, %35
%37 = sdiv i64 %36, 2
%38 = load i64, i64* %2
%39 = icmp sgt i64 %37, %38
br i1 %39, label %40, label %44
40: ; preds = %32
%41 = load i64, i64* %5
%42 = sub nsw i64 %41, 1
%43 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %42)
br label %49
44: ; preds = %32
br label %45
45: ; preds = %44
br label %46
46: ; preds = %45
%47 = load i64, i64* %5
%48 = add nsw i64 %47, 1
store i64 %48, i64* %5
br label %21
49: ; preds = %40, %29
br label %50
50: ; preds = %49
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %8
53: ; preds = %8
ret i32 0
}

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