#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 strlen(char *);
int main() {
  int t;
  char s[100000];
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%s", s);
    int len_str = strlen(s);
    int count = 0;
    for (int j = 0; j < len_str; j++) {
      if (s[j] == s[j + 1]) {
        count += 1;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x186b4(%rbp)
mov    -0x186b4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1233 <main+0x103>
lea    -0x186b0(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x186b0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x186b8(%rbp)
movl   $0x0,-0x186bc(%rbp)
movl   $0x0,-0x186c0(%rbp)
mov    -0x186c0(%rbp),%eax
cmp    -0x186b8(%rbp),%eax
jge    120d <main+0xdd>
movslq -0x186c0(%rbp),%rax
movsbl -0x186b0(%rbp,%rax,1),%eax
ff
mov    -0x186c0(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x186b0(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    11f4 <main+0xc4>
mov    -0x186bc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x186bc(%rbp)
jmp    11f9 <main+0xc9>
mov    -0x186c0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x186c0(%rbp)
jmp    11a8 <main+0x78>
mov    -0x186bc(%rbp),%esi
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
mov    -0x186b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x186b4(%rbp)
jmp    115e <main+0x2e>
xor    %eax,%eax
add    $0x186c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x186b8,%rsp
lea    0xed8(%rip),%rdi
xor    %r13d,%r13d
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    12df <main+0x1af>
lea    0xeba(%rip),%r14
lea    0x10(%rsp),%r12
lea    0xeb1(%rip),%r15
jmp    1199 <main+0x69>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0x1,%r13d
cmp    0xc(%rsp),%r13d
jge    12df <main+0x1af>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1180 <main+0x50>
mov    %eax,%ecx
mov    0x10(%rsp),%dl
cmp    $0x8,%eax
jae    11d0 <main+0xa0>
xor    %eax,%eax
xor    %ebp,%ebp
jmp    12c0 <main+0x190>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
and    $0xfffffff8,%eax
movzbl %dl,%edx
movd   %edx,%xmm0
pslld  $0x18,%xmm0
pxor   %xmm1,%xmm1
xor    %edx,%edx
pxor   %xmm2,%xmm2
movdqa 0xe0d(%rip),%xmm6
movdqa 0xe15(%rip),%xmm7
nopl   0x0(%rax,%rax,1)
movd   0x11(%rsp,%rdx,1),%xmm3
movdqa %xmm6,%xmm4
pandn  %xmm0,%xmm4
movd   0x15(%rsp,%rdx,1),%xmm0
movdqa %xmm3,%xmm5
pand   %xmm6,%xmm5
por    %xmm4,%xmm5
punpcklbw %xmm5,%xmm5
pshufd $0x44,%xmm5,%xmm4
pshuflw $0xc7,%xmm4,%xmm4
pshufhw $0xe5,%xmm4,%xmm4
movdqa %xmm6,%xmm5
pandn  %xmm3,%xmm5
punpcklbw %xmm3,%xmm3
punpcklwd %xmm3,%xmm3
pcmpeqb %xmm4,%xmm3
pand   %xmm7,%xmm3
paddd  %xmm3,%xmm1
movdqa %xmm0,%xmm3
pand   %xmm6,%xmm3
por    %xmm5,%xmm3
punpcklbw %xmm3,%xmm3
pshufd $0x44,%xmm3,%xmm3
pshuflw $0xc7,%xmm3,%xmm3
pshufhw $0xe5,%xmm3,%xmm3
movdqa %xmm0,%xmm4
punpcklbw %xmm4,%xmm4
punpcklwd %xmm4,%xmm4
pcmpeqb %xmm3,%xmm4
pand   %xmm7,%xmm4
paddd  %xmm4,%xmm2
add    $0x8,%rdx
cmp    %rdx,%rax
jne    1200 <main+0xd0>
paddd  %xmm1,%xmm2
pshufd $0xee,%xmm2,%xmm1
paddd  %xmm2,%xmm1
pshufd $0x55,%xmm1,%xmm2
paddd  %xmm1,%xmm2
movd   %xmm2,%ebp
cmp    %rcx,%rax
je     1180 <main+0x50>
movd   %xmm0,%edx
shr    $0x18,%edx
nopl   (%rax)
movzbl 0x11(%rsp,%rax,1),%ebx
add    $0x1,%rax
xor    %esi,%esi
cmp    %bl,%dl
sete   %sil
add    %esi,%ebp
mov    %ebx,%edx
cmp    %rax,%rcx
jne    12c0 <main+0x190>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x186b8,%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 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100000 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
br label %9
9: ; preds = %45, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %48
13: ; preds = %9
%14 = getelementptr inbounds [100000 x i8], [100000 x i8]* %3, i64 0, i64 0
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [100000 x i8], [100000 x i8]* %3, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %18
18: ; preds = %39, %13
%19 = load i32, i32* %7
%20 = load i32, i32* %5
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %42
22: ; preds = %18
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100000 x i8], [100000 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100000 x i8], [100000 x i8]* %3, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %27, %33
br i1 %34, label %35, label %38
35: ; preds = %22
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %38
38: ; preds = %35, %22
br label %39
39: ; preds = %38
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %18
42: ; preds = %18
%43 = load i32, i32* %6
%44 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %9
48: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100000 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %52, %0
ret i32 0
9: ; preds = %0, %52
%10 = phi i32 [ %55, %52 ], [ 0, %0 ]
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%12 = call i32 @strlen(i8* %4)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %52
14: ; preds = %9
%15 = zext i32 %12 to i64
%16 = load i8, i8* %4
%17 = icmp ult i32 %12, 8
br i1 %17, label %48, label %18
18: ; preds = %14
%19 = and i64 %15, 4294967288
%20 = insertelement <4 x i8> poison, i8 %16, i64 3
br label %21
21: ; preds = %21, %18
%22 = phi i64 [ 0, %18 ], [ %41, %21 ]
%23 = phi <4 x i8> [ %20, %18 ], [ %32, %21 ]
%24 = phi <4 x i32> [ zeroinitializer, %18 ], [ %39, %21 ]
%25 = phi <4 x i32> [ zeroinitializer, %18 ], [ %40, %21 ]
%26 = or i64 %22, 1
%27 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 %26
%28 = bitcast i8* %27 to <4 x i8>*
%29 = load <4 x i8>, <4 x i8>* %28
%30 = getelementptr inbounds i8, i8* %27, i64 4
%31 = bitcast i8* %30 to <4 x i8>*
%32 = load <4 x i8>, <4 x i8>* %31
%33 = shufflevector <4 x i8> %23, <4 x i8> %29, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
%34 = shufflevector <4 x i8> %29, <4 x i8> %32, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
%35 = icmp eq <4 x i8> %33, %29
%36 = icmp eq <4 x i8> %34, %32
%37 = zext <4 x i1> %35 to <4 x i32>
%38 = zext <4 x i1> %36 to <4 x i32>
%39 = add <4 x i32> %24, %37
%40 = add <4 x i32> %25, %38
%41 = add nuw i64 %22, 8
%42 = icmp eq i64 %41, %19
br i1 %42, label %43, label %21
43: ; preds = %21
%44 = add <4 x i32> %40, %39
%45 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %44)
%46 = icmp eq i64 %19, %15
%47 = extractelement <4 x i8> %32, i64 3
br i1 %46, label %52, label %48
48: ; preds = %14, %43
%49 = phi i8 [ %47, %43 ], [ %16, %14 ]
%50 = phi i64 [ %19, %43 ], [ 0, %14 ]
%51 = phi i32 [ %45, %43 ], [ 0, %14 ]
br label %58
52: ; preds = %58, %43, %9
%53 = phi i32 [ 0, %9 ], [ %45, %43 ], [ %67, %58 ]
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %53)
%55 = add nuw nsw i32 %10, 1
%56 = load i32, i32* %1
%57 = icmp slt i32 %55, %56
br i1 %57, label %9, label %8
58: ; preds = %48, %58
%59 = phi i8 [ %64, %58 ], [ %49, %48 ]
%60 = phi i64 [ %62, %58 ], [ %50, %48 ]
%61 = phi i32 [ %67, %58 ], [ %51, %48 ]
%62 = add nuw nsw i64 %60, 1
%63 = getelementptr inbounds [100000 x i8], [100000 x i8]* %2, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = icmp eq i8 %59, %64
%66 = zext i1 %65 to i32
%67 = add nuw nsw i32 %61, %66
%68 = icmp eq i64 %62, %15
br i1 %68, label %52, label %58
}