#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 *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int nofint, n[100] = {0}, mofque, m[20][2] = {{0, 0}}, i, a, b, output;
  scanf("%d", &nofint);
  for (i = 0; i < nofint; i++) {
    scanf("%d", &n[i]);
  }
  scanf("%d", &mofque);
  for (i = 0; i < mofque; i++) {
    scanf("%d%d", &m[i][0], &m[i][1]);
    for (a = 0; n[a] != m[i][0]; a++) {
    }
    for (b = 0; n[b] != m[i][1]; b++) {
    }
    output = (n + b) - (n + a);
    printf("%d\n", output);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
lea    -0x250(%rbp),%rdi
xor    %esi,%esi
mov    $0xa0,%edx
call   1040 <memset@plt>
lea    0xe93(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x254(%rbp)
mov    -0x254(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ca <main+0x9a>
movslq -0x254(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x254(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x254(%rbp)
jmp    1184 <main+0x54>
lea    0xe31(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x254(%rbp)
mov    -0x254(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    131e <main+0x1ee>
movslq -0x254(%rbp),%rax
lea    -0x250(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x254(%rbp),%rax
lea    -0x250(%rbp),%rdx
shl    $0x3,%rax
add    %rax,%rdx
add    $0x4,%rdx
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x258(%rbp)
movslq -0x258(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
movslq -0x254(%rbp),%rcx
cmp    -0x250(%rbp,%rcx,8),%eax
je     127c <main+0x14c>
jmp    1268 <main+0x138>
mov    -0x258(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x258(%rbp)
jmp    1241 <main+0x111>
movl   $0x0,-0x25c(%rbp)
movslq -0x25c(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
movslq -0x254(%rbp),%rcx
cmp    -0x24c(%rbp,%rcx,8),%eax
je     12c1 <main+0x191>
jmp    12ad <main+0x17d>
mov    -0x25c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x25c(%rbp)
jmp    1286 <main+0x156>
lea    -0x1a0(%rbp),%rax
movslq -0x25c(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
lea    -0x1a0(%rbp),%rcx
movslq -0x258(%rbp),%rdx
shl    $0x2,%rdx
add    %rdx,%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,-0x260(%rbp)
mov    -0x260(%rbp),%esi
lea    0xd00(%rip),%rdi
call   1030 <printf@plt>
mov    -0x254(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x254(%rbp)
jmp    11e9 <main+0xb9>
mov    -0x4(%rbp),%eax
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x240,%rsp
lea    0xb0(%rsp),%r14
mov    $0x190,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe66(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11df <main+0xaf>
lea    0xb0(%rsp),%r12
lea    0xe44(%rip),%r15
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     11c0 <main+0x90>
lea    0xe1c(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1284 <main+0x154>
lea    0xdfc(%rip),%r15
lea    0xdfa(%rip),%r12
xor    %ebx,%ebx
nopl   (%rax)
lea    (%rsp,%rbx,8),%rsi
add    $0x10,%rsi
lea    (%rsp,%rbx,8),%r13
add    $0x14,%r13
mov    %r15,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp,%rbx,8),%eax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rcx,%rsi
add    $0x1,%rcx
cmp    %eax,0xb0(%rsp,%rsi,4)
jne    1240 <main+0x110>
mov    0x0(%r13),%eax
not    %esi
mov    %r14,%rcx
nopl   0x0(%rax)
add    $0x1,%esi
lea    0x4(%rcx),%rdx
cmp    %eax,(%rcx)
mov    %rdx,%rcx
jne    1260 <main+0x130>
mov    %r12,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jl     1210 <main+0xe0>
xor    %eax,%eax
add    $0x240,%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 [100 x i32]
%4 = alloca i32
%5 = alloca [20 x [2 x i32]]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [100 x i32]* %3 to i8*
%11 = bitcast [20 x [2 x i32]]* %5 to i8*
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %6
br label %13
13: ; preds = %22, %0
%14 = load i32, i32* %6
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %19
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %13
25: ; preds = %13
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 0, i32* %6
br label %27
27: ; preds = %88, %25
%28 = load i32, i32* %6
%29 = load i32, i32* %4
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %91
31: ; preds = %27
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [20 x [2 x i32]], [20 x [2 x i32]]* %5, i64 0, i64 %33
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %34, i64 0, i64 0
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [20 x [2 x i32]], [20 x [2 x i32]]* %5, i64 0, i64 %37
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %38, i64 0, i64 1
%40 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %35, i32* %39)
store i32 0, i32* %7
br label %41
41: ; preds = %53, %31
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [20 x [2 x i32]], [20 x [2 x i32]]* %5, i64 0, i64 %47
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %48, i64 0, i64 0
%50 = load i32, i32* %49
%51 = icmp ne i32 %45, %50
br i1 %51, label %52, label %56
52: ; preds = %41
br label %53
53: ; preds = %52
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %41
56: ; preds = %41
store i32 0, i32* %8
br label %57
57: ; preds = %69, %56
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [20 x [2 x i32]], [20 x [2 x i32]]* %5, i64 0, i64 %63
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %64, i64 0, i64 1
%66 = load i32, i32* %65
%67 = icmp ne i32 %61, %66
br i1 %67, label %68, label %72
68: ; preds = %57
br label %69
69: ; preds = %68
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 1
store i32 %71, i32* %8
br label %57
72: ; preds = %57
%73 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%74 = load i32, i32* %8
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %73, i64 %75
%77 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%78 = load i32, i32* %7
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i32, i32* %77, i64 %79
%81 = ptrtoint i32* %76 to i64
%82 = ptrtoint i32* %80 to i64
%83 = sub i64 %81, %82
%84 = sdiv exact i64 %83, 4
%85 = trunc i64 %84 to i32
store i32 %85, i32* %9
%86 = load i32, i32* %9
%87 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %72
%89 = load i32, i32* %6
%90 = add nsw i32 %89, 1
store i32 %90, i32* %6
br label %27
91: ; preds = %27
%92 = load i32, i32* %1
ret i32 %92
}

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 [100 x i32]
%3 = alloca i32
%4 = alloca [20 x [2 x i32]]
%5 = bitcast i32* %1 to i8*
%6 = bitcast [100 x i32]* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast [20 x [2 x i32]]* %4 to i8*
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %13
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %0
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %53
24: ; preds = %20, %44
%25 = phi i64 [ %49, %44 ], [ 0, %20 ]
%26 = getelementptr inbounds [20 x [2 x i32]], [20 x [2 x i32]]* %4, i64 0, i64 %25, i64 0
%27 = getelementptr inbounds [20 x [2 x i32]], [20 x [2 x i32]]* %4, i64 0, i64 %25, i64 1
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %26, i32* %27)
%29 = load i32, i32* %26
br label %30
30: ; preds = %30, %24
%31 = phi i64 [ %35, %30 ], [ 0, %24 ]
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, %29
%35 = add nuw i64 %31, 1
br i1 %34, label %36, label %30
36: ; preds = %30
%37 = load i32, i32* %27
br label %38
38: ; preds = %38, %36
%39 = phi i64 [ %43, %38 ], [ 0, %36 ]
%40 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, %37
%43 = add nuw i64 %39, 1
br i1 %42, label %44, label %38
44: ; preds = %38
%45 = trunc i64 %31 to i32
%46 = trunc i64 %39 to i32
%47 = sub nsw i32 %46, %45
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = add nuw nsw i64 %25, 1
%50 = load i32, i32* %3
%51 = sext i32 %50 to i64
%52 = icmp slt i64 %49, %51
br i1 %52, label %24, label %53
53: ; preds = %44, %20
ret i32 0
}