#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 */
scalar_t__ ceil(int /*<<< orphan*/);
scalar_t__ floor(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ sqrt(int);
int main() {
  int t, a, b;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &a, &b);
    printf("%d\n", (int)(floor(sqrt(b)) - ceil(sqrt(a)) + 1));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11de <main+0x8e>
lea    0xe74(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x10(%rbp),%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1070 <floor@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%esi
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
jmp    1171 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9e(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
subl   $0x1,0x4(%rsp)
jb     11d9 <main+0x89>
lea    0xe82(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xe76(%rip),%r13
nop
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1070 <floor@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
sub    %eax,%ebx
add    $0x1,%ebx
mov    %r13,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
subl   $0x1,0x4(%rsp)
jae    1190 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, -1
store i32 %8, i32* %2
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%12 = load i32, i32* %4
%13 = call i32 @sqrt(i32 %12)
%14 = call i64 @floor(i32 %13)
%15 = load i32, i32* %3
%16 = call i32 @sqrt(i32 %15)
%17 = call i64 @ceil(i32 %16)
%18 = sub nsw i64 %14, %17
%19 = add nsw i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %6
22: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %26, label %11
11: ; preds = %0, %11
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%13 = load i32, i32* %3
%14 = call i32 @sqrt(i32 %13)
%15 = call i64 @floor(i32 %14)
%16 = load i32, i32* %2
%17 = call i32 @sqrt(i32 %16)
%18 = call i64 @ceil(i32 %17)
%19 = sub nsw i64 %15, %18
%20 = trunc i64 %19 to i32
%21 = add i32 %20, 1
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %1
%24 = add nsw i32 %23, -1
store i32 %24, i32* %1
%25 = icmp eq i32 %23, 0
br i1 %25, label %26, label %11
26: ; preds = %11, %0
ret i32 0
}