#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 count, len, inc, dec, cases;
  scanf("%d", &cases);
  while (cases--) {
    char arr[10000];
    scanf("%s", arr);
    count = 0;
    len = strlen(arr);
    inc = 0;
    dec = len - 1;
    while (inc <= dec) {
      if (arr[inc] > arr[dec])
        count += arr[inc] - arr[dec];
      else
        count += arr[dec] - arr[inc];
      inc++;
      dec--;
    }
    printf("%d\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     123f <main+0x10f>
lea    -0x2730(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x8(%rbp)
lea    -0x2730(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     122b <main+0xfb>
movslq -0x10(%rbp),%rax
movsbl -0x2730(%rbp,%rax,1),%eax
ff
movslq -0x14(%rbp),%rcx
movsbl -0x2730(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jle    11f4 <main+0xc4>
movslq -0x10(%rbp),%rax
movsbl -0x2730(%rbp,%rax,1),%eax
ff
movslq -0x14(%rbp),%rcx
movsbl -0x2730(%rbp,%rcx,1),%ecx
ff
sub    %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1214 <main+0xe4>
movslq -0x14(%rbp),%rax
movsbl -0x2730(%rbp,%rax,1),%eax
ff
movslq -0x10(%rbp),%rcx
movsbl -0x2730(%rbp,%rcx,1),%ecx
ff
sub    %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11a3 <main+0x73>
mov    -0x8(%rbp),%esi
lea    0xdd1(%rip),%rdi
call   1040 <printf@plt>
jmp    1154 <main+0x24>
xor    %eax,%eax
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2720,%rsp
lea    0xeba(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    116b <main+0x3b>
xor    %eax,%eax
add    $0x2720,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe91(%rip),%r14
lea    0x10(%rsp),%r12
lea    0xe88(%rip),%r15
jmp    1191 <main+0x61>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1159 <main+0x29>
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,%eax
add    $0xffffffffffffffff,%rax
xor    %ecx,%ecx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movsbl 0x10(%rsp,%rcx,1),%edx
movsbl 0x10(%rsp,%rax,1),%ebx
mov    %edx,%edi
sub    %ebx,%edi
mov    %ebx,%esi
sub    %edx,%esi
cmp    %bl,%dl
cmovg  %edi,%esi
add    %esi,%ebp
add    $0x1,%rcx
lea    -0x1(%rax),%rdx
cmp    %rax,%rcx
mov    %rdx,%rax
jl     11c0 <main+0x90>
jmp    1180 <main+0x50>

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 [10000 x i8]
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* %6)
br label %9
9: ; preds = %69, %0
%10 = load i32, i32* %6
%11 = add nsw i32 %10, -1
store i32 %11, i32* %6
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %72
13: ; preds = %9
%14 = getelementptr inbounds [10000 x i8], [10000 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* %2
%16 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %3
store i32 0, i32* %4
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %5
br label %20
20: ; preds = %64, %13
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %69
24: ; preds = %20
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp sgt i32 %29, %34
br i1 %35, label %36, label %50
36: ; preds = %24
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = sub nsw i32 %41, %46
%48 = load i32, i32* %2
%49 = add nsw i32 %48, %47
store i32 %49, i32* %2
br label %64
50: ; preds = %24
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = load i32, i32* %4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = sub nsw i32 %55, %60
%62 = load i32, i32* %2
%63 = add nsw i32 %62, %61
store i32 %63, i32* %2
br label %64
64: ; preds = %50, %36
%65 = load i32, i32* %4
%66 = add nsw i32 %65, 1
store i32 %66, i32* %4
%67 = load i32, i32* %5
%68 = add nsw i32 %67, -1
store i32 %68, i32* %5
br label %20
69: ; preds = %20
%70 = load i32, i32* %2
%71 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %70)
br label %9
72: ; 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 [10000 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 = add nsw i32 %5, -1
store i32 %6, i32* %1
%7 = icmp eq i32 %5, 0
br i1 %7, label %40, label %8
8: ; preds = %0
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
br label %10
10: ; preds = %8, %34
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%12 = call i32 @strlen(i8* %9)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %10
%15 = zext i32 %12 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %32, %16 ]
%18 = phi i64 [ %15, %14 ], [ %20, %16 ]
%19 = phi i32 [ 0, %14 ], [ %31, %16 ]
%20 = add nsw i64 %18, -1
%21 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 %17
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 %20
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp sgt i8 %22, %25
%28 = sub nsw i32 %23, %26
%29 = sub nsw i32 %26, %23
%30 = select i1 %27, i32 %28, i32 %29
%31 = add nsw i32 %30, %19
%32 = add nuw nsw i64 %17, 1
%33 = icmp slt i64 %32, %20
br i1 %33, label %16, label %34
34: ; preds = %16, %10
%35 = phi i32 [ 0, %10 ], [ %31, %16 ]
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %1
%38 = add nsw i32 %37, -1
store i32 %38, i32* %1
%39 = icmp eq i32 %37, 0
br i1 %39, label %40, label %10
40: ; preds = %34, %0
ret i32 0
}