#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, h[26] = {1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                  0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0},
         i, n;
  char s[100];
  scanf("%d", &t);
  while (t--) {
    scanf("%s", &s);
    for (i = n = 0; s[i] != '\0'; ++i)
      n += h[(int)s[i] - 65];
    printf("%d\n", n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x68,%edx
call   1040 <memcpy@plt>
lea    0xf0a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11f2 <main+0xc2>
lea    0xee7(%rip),%rdi
lea    -0xe0(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11de <main+0xae>
movslq -0x74(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
sub    $0x41,%eax
cltq
mov    -0x70(%rbp,%rax,4),%eax
add    -0x78(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11a0 <main+0x70>
mov    -0x78(%rbp),%esi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
jmp    1169 <main+0x39>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xf33(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1159 <main+0x39>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x11(%rsp),%r12
lea    0xf06(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xefd(%rip),%r13
lea    0xe88(%rip),%rbx
jmp    1191 <main+0x71>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1148 <main+0x28>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%al
test   %al,%al
je     1180 <main+0x60>
xor    %ebp,%ebp
mov    %r12,%rcx
nopl   (%rax)
movsbq %al,%rax
add    -0x104(%rbx,%rax,4),%ebp
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    11b0 <main+0x90>
jmp    1180 <main+0x60>

LLVM IR (-O0):
@__const.main.h = <{ [18 x i32], [8 x i32] }> <{ [18 x i32] [i32 1, i32 2, i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 1], [8 x i32] zeroinitializer }>
@.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 [26 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i8]
store i32 0, i32* %1
%7 = bitcast [26 x i32]* %3 to i8*
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %37, %0
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -1
store i32 %11, i32* %2
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %40
13: ; preds = %9
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [100 x i8]* %6)
store i32 0, i32* %5
store i32 0, i32* %4
br label %15
15: ; preds = %34, %13
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 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 %37
22: ; preds = %15
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 65
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = load i32, i32* %5
%33 = add nsw i32 %32, %31
store i32 %33, i32* %5
br label %34
34: ; preds = %22
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %15
37: ; preds = %15
%38 = load i32, i32* %5
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %9
40: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@__const.main.h = <{ [18 x i32], [8 x i32] }> <{ [18 x i32] [i32 1, i32 2, i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 1], [8 x i32] zeroinitializer }>
@.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 [100 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [100 x i8], [100 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 %32, label %9
9: ; preds = %0, %26
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [100 x i8]* %2)
%11 = load i8, i8* %4
%12 = icmp eq i8 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %9, %13
%14 = phi i64 [ %22, %13 ], [ 0, %9 ]
%15 = phi i8 [ %24, %13 ], [ %11, %9 ]
%16 = phi i32 [ %21, %13 ], [ 0, %9 ]
%17 = sext i8 %15 to i64
%18 = add nsw i64 %17, -65
%19 = getelementptr inbounds [26 x i32], [26 x i32]* bitcast (<{ [18 x i32], [8 x i32] }>* @__const.main.h to [26 x i32]*), i64 0, i64 %18
%20 = load i32, i32* %19
%21 = add nsw i32 %20, %16
%22 = add nuw nsw i64 %14, 1
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %13
26: ; preds = %13, %9
%27 = phi i32 [ 0, %9 ], [ %21, %13 ]
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %1
%30 = add nsw i32 %29, -1
store i32 %30, i32* %1
%31 = icmp eq i32 %29, 0
br i1 %31, label %32, label %9
32: ; preds = %26, %0
ret i32 0
}