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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11e5 <main+0xc5>
lea    -0x186c0(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0x186c0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11d1 <main+0xb1>
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    11be <main+0x9e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c3 <main+0xa3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <main+0x5b>
mov    -0x14(%rbp),%esi
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x186c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x186c0,%rsp
lea    0xeca(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    115b <main+0x3b>
xor    %eax,%eax
add    $0x186c0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x11(%rsp),%r12
lea    0xe9c(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe93(%rip),%rbx
jmp    1191 <main+0x71>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1149 <main+0x29>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%cl
test   %cl,%cl
je     1180 <main+0x60>
xor    %ebp,%ebp
mov    %r12,%rax
nopl   (%rax)
movzbl (%rax),%edx
xor    %esi,%esi
cmp    %dl,%cl
sete   %sil
add    %esi,%ebp
add    $0x1,%rax
mov    %edx,%ecx
test   %dl,%dl
jne    11b0 <main+0x90>
jmp    1180 <main+0x60>

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