#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 scanf(char *, int *, ...);
int /*<<< orphan*/ sqrt(int);
int main() {
  int T, a, b;
  scanf("%d", &T);
  while (scanf("%d%d", &a, &b) == 2) {
    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>
lea    0xe88(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    11d3 <main+0x83>
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    0xe3c(%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    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe89(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    11f7 <main+0xa7>
lea    0xe71(%rip),%r14
lea    0xe65(%rip),%r15
lea    0x8(%rsp),%r12
lea    0x4(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x4(%rsp),%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1070 <floor@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
sub    %eax,%ebx
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x2,%eax
je     11b0 <main+0x60>
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 = %9, %0
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = load i32, i32* %4
%11 = call i32 @sqrt(i32 %10)
%12 = call i64 @floor(i32 %11)
%13 = load i32, i32* %3
%14 = call i32 @sqrt(i32 %13)
%15 = call i64 @ceil(i32 %14)
%16 = sub nsw i64 %12, %15
%17 = add nsw i64 %16, 1
%18 = trunc i64 %17 to i32
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %6
20: ; 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 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %23
10: ; preds = %0, %10
%11 = load i32, i32* %3
%12 = call i32 @sqrt(i32 %11)
%13 = call i64 @floor(i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @sqrt(i32 %14)
%16 = call i64 @ceil(i32 %15)
%17 = sub nsw i64 %13, %16
%18 = trunc i64 %17 to i32
%19 = add i32 %18, 1
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%22 = icmp eq i32 %21, 2
br i1 %22, label %10, label %23
23: ; preds = %10, %0
ret i32 0
}