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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186d0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1214 <main+0xe4>
movl   $0x0,-0x18(%rbp)
lea    -0x186c0(%rbp),%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x186c4(%rbp)
lea    -0x186c0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x186c4(%rbp),%eax
cmp    %ecx,%eax
jge    11f7 <main+0xc7>
movslq -0xc(%rbp),%rax
movsbl -0x186c0(%rbp,%rax,1),%eax
ff
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x186c0(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    11e4 <main+0xb4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e9 <main+0xb9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1191 <main+0x61>
mov    -0x18(%rbp),%esi
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1162 <main+0x32>
xor    %eax,%eax
add    $0x186d0,%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    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11e9 <main+0xb9>
mov    $0x1,%r12d
lea    0xe97(%rip),%r14
lea    0x10(%rsp),%r13
lea    0xe8e(%rip),%r15
jmp    1199 <main+0x69>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
lea    0x1(%r12),%eax
cmp    0xc(%rsp),%r12d
mov    %eax,%r12d
jge    11e9 <main+0xb9>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1180 <main+0x50>
xor    %eax,%eax
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl 0x10(%rsp,%rax,1),%ecx
lea    0x1(%rax),%rbx
xor    %edx,%edx
cmp    0x11(%rsp,%rax,1),%cl
sete   %dl
add    %edx,%ebp
mov    %r13,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    %rbx,%rax
cmp    %rcx,%rbx
jl     11c0 <main+0x90>
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 i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [100001 x i8]
store i32 0, i32* %1
store i32 0, i32* %5
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %4
br label %9
9: ; preds = %44, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %47
13: ; preds = %9
store i32 0, i32* %6
%14 = getelementptr inbounds [100001 x i8], [100001 x i8]* %7, 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)
store i32 0, i32* %3
br label %16
16: ; preds = %38, %13
%17 = load i32, i32* %3
%18 = getelementptr inbounds [100001 x i8], [100001 x i8]* %7, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %41
21: ; preds = %16
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100001 x i8], [100001 x i8]* %7, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100001 x i8], [100001 x i8]* %7, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %26, %32
br i1 %33, label %34, label %37
34: ; preds = %21
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %37
37: ; preds = %34, %21
br label %38
38: ; preds = %37
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %16
41: ; preds = %16
%42 = load i32, i32* %6
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %9
47: ; 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 [100001 x i8]
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 1
br i1 %6, label %34, label %7
7: ; preds = %0
%8 = getelementptr inbounds [100001 x i8], [100001 x i8]* %2, i64 0, i64 0
br label %9
9: ; preds = %7, %28
%10 = phi i32 [ 1, %7 ], [ %31, %28 ]
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%12 = call i32 @strlen(i8* %8)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %9, %14
%15 = phi i64 [ %19, %14 ], [ 0, %9 ]
%16 = phi i32 [ %24, %14 ], [ 0, %9 ]
%17 = getelementptr inbounds [100001 x i8], [100001 x i8]* %2, i64 0, i64 %15
%18 = load i8, i8* %17
%19 = add nuw nsw i64 %15, 1
%20 = getelementptr inbounds [100001 x i8], [100001 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %18, %21
%23 = zext i1 %22 to i32
%24 = add nuw nsw i32 %16, %23
%25 = call i32 @strlen(i8* %8)
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %19, %26
br i1 %27, label %14, label %28
28: ; preds = %14, %9
%29 = phi i32 [ 0, %9 ], [ %24, %14 ]
%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 %10, 1
%32 = load i32, i32* %1
%33 = icmp slt i32 %10, %32
br i1 %33, label %9, label %34
34: ; preds = %28, %0
ret i32 0
}