#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() {
  char OX[81];
  int score, inrow, i, T;
  scanf("%d", &T);
  while (T--) {
    inrow = score = 0;
    scanf("%s", OX);
    for (i = 0; OX[i]; i++) {
      if (OX[i] == 'O')
        score += ++inrow;
      else
        inrow = 0;
    }
    printf("%d\n", score);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x70(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x70(%rbp)
cmp    $0x0,%eax
je     11df <main+0xbf>
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
lea    -0x60(%rbp),%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x6c(%rbp)
movslq -0x6c(%rbp),%rax
cmpb   $0x0,-0x60(%rbp,%rax,1)
je     11cb <main+0xab>
movslq -0x6c(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x4f,%eax
jne    11b1 <main+0x91>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
add    -0x64(%rbp),%eax
mov    %eax,-0x64(%rbp)
jmp    11b8 <main+0x98>
movl   $0x0,-0x68(%rbp)
jmp    11bd <main+0x9d>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    117c <main+0x5c>
mov    -0x64(%rbp),%esi
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xece(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1153 <main+0x33>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xea9(%rip),%r14
lea    0x10(%rsp),%r12
lea    0xea0(%rip),%r15
jmp    1181 <main+0x61>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1145 <main+0x25>
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %r12,%rax
xor    %ecx,%ecx
jmp    11ac <main+0x8c>
nopw   0x0(%rax,%rax,1)
add    %ecx,%ebx
add    $0x1,%ebx
add    $0x1,%ecx
add    $0x1,%rax
movzbl (%rax),%edx
cmp    $0x4f,%dl
je     11a0 <main+0x80>
test   %dl,%dl
je     1170 <main+0x50>
xor    %ecx,%ecx
add    $0x1,%rax
jmp    11ac <main+0x8c>

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