#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 */
double modf(double, double *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
double sqrt(long long);
int main(int argc, char const *argv[]) {
  int t;
  scanf("%d", &t);
  for (int i_t = 0; i_t < t; i_t++) {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    double result_a = sqrt(a);
    double result_b = sqrt(b);
    double integral_a;
    double decimal_a = modf(result_a, &integral_a);
    int count = (int)result_b - (int)result_a;
    if (decimal_a == 0) {
      count++;
    }
    printf("%d\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    120d <main+0xcd>
lea    0xe81(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    -0x40(%rbp),%rdi
call   1040 <modf@plt>
movsd  %xmm0,-0x48(%rbp)
cvttsd2si -0x38(%rbp),%eax
cvttsd2si -0x30(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11f0 <main+0xb0>
jp     11f0 <main+0xb0>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%esi
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116f <main+0x2f>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xeb3(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11fd <main+0xbd>
lea    0xe98(%rip),%r14
lea    0x28(%rsp),%r15
lea    0x20(%rsp),%r12
lea    0x30(%rsp),%r13
lea    0xe8c(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x28(%rsp),%rdi
call   1060 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x20(%rsp),%rdi
call   1060 <sqrt@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %r13,%rdi
call   1040 <modf@plt>
cvttsd2si 0x18(%rsp),%esi
cvttsd2si 0x10(%rsp),%eax
sub    %eax,%esi
cmpeqsd 0xe1b(%rip),%xmm0
movq   %xmm0,%rax
sub    %eax,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1190 <main+0x50>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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