#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 abs(char);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int strlen(char *);
int main() {
  char a[10003];
  int t, c, n, i, n0;
  scanf("%d", &t);
  while (t--) {
    c = 0;
    scanf(" %s", a);
    n = strlen(a);
    for (i = 0; i < n / 2; i++) {
      n0 = abs(a[i] - a[n - 1 - i]);
      c = c + n0;
    }
    printf("%d\n", c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2740,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x2724(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x2724(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x2724(%rbp)
cmp    $0x0,%eax
je     125c <main+0x11c>
movl   $0x0,-0x2728(%rbp)
lea    -0x2720(%rbp),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x2720(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x272c(%rbp)
movl   $0x0,-0x2730(%rbp)
mov    -0x2730(%rbp),%eax
mov    %eax,-0x2738(%rbp)
mov    -0x272c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2738(%rbp),%eax
cmp    %ecx,%eax
jge    1245 <main+0x105>
movslq -0x2730(%rbp),%rax
movsbl -0x2720(%rbp,%rax,1),%eax
ff
mov    -0x272c(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x2730(%rbp),%ecx
movslq %ecx,%rcx
movsbl -0x2720(%rbp,%rcx,1),%ecx
ff
sub    %ecx,%eax
movsbl %al,%edi
call   1030 <abs@plt>
mov    %eax,-0x2734(%rbp)
mov    -0x2728(%rbp),%eax
add    -0x2734(%rbp),%eax
mov    %eax,-0x2728(%rbp)
mov    -0x2730(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2730(%rbp)
jmp    11bc <main+0x7c>
mov    -0x2728(%rbp),%esi
lea    0xdb5(%rip),%rdi
call   1050 <printf@plt>
jmp    1167 <main+0x27>
xor    %eax,%eax
add    $0x2740,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2728,%rsp
lea    0xea8(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    117f <main+0x3f>
xor    %eax,%eax
add    $0x2728,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe7d(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe75(%rip),%r12
jmp    11b1 <main+0x71>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     116b <main+0x2b>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11a0 <main+0x60>
mov    %eax,%r13d
shr    %eax
cmp    $0x1,%eax
mov    %rax,0x8(%rsp)
jne    11f0 <main+0xb0>
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    1245 <main+0x105>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,%r14
and    $0xfffffffe,%r14d
lea    -0x2(%r13),%r12d
xor    %r15d,%r15d
xor    %ebp,%ebp
movzbl 0x10(%rsp,%r15,1),%eax
lea    0x1(%r12),%ecx
movslq %ecx,%rcx
sub    0x10(%rsp,%rcx,1),%al
movsbl %al,%edi
call   1030 <abs@plt>
mov    %eax,%ebx
add    %ebp,%ebx
movzbl 0x11(%rsp,%r15,1),%eax
movslq %r12d,%r12
sub    0x10(%rsp,%r12,1),%al
movsbl %al,%edi
call   1030 <abs@plt>
mov    %eax,%ebp
add    %ebx,%ebp
add    $0x2,%r15
add    $0xfffffffe,%r12d
cmp    %r15,%r14
jne    1200 <main+0xc0>
testb  $0x1,0x8(%rsp)
lea    0xdb2(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xdaa(%rip),%r12
je     11a0 <main+0x60>
mov    0x10(%rsp,%r15,1),%al
not    %r15d
add    %r15d,%r13d
movslq %r13d,%rcx
sub    0x10(%rsp,%rcx,1),%al
movsbl %al,%edi
call   1030 <abs@plt>
add    %eax,%ebp
jmp    11a0 <main+0x60>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10003 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
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* %3)
br label %9
9: ; preds = %46, %0
%10 = load i32, i32* %3
%11 = add nsw i32 %10, -1
store i32 %11, i32* %3
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %49
13: ; preds = %9
store i32 0, i32* %4
%14 = getelementptr inbounds [10003 x i8], [10003 x i8]* %2, i64 0, i64 0
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [10003 x i8], [10003 x i8]* %2, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %5
store i32 0, i32* %6
br label %18
18: ; preds = %43, %13
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = sdiv i32 %20, 2
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %46
23: ; preds = %18
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10003 x i8], [10003 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i32, i32* %5
%30 = sub nsw i32 %29, 1
%31 = load i32, i32* %6
%32 = sub nsw i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [10003 x i8], [10003 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = sub nsw i32 %28, %36
%38 = trunc i32 %37 to i8
%39 = call i32 @abs(i8 signext %38)
store i32 %39, i32* %7
%40 = load i32, i32* %4
%41 = load i32, i32* %7
%42 = add nsw i32 %40, %41
store i32 %42, i32* %4
br label %43
43: ; preds = %23
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %18
46: ; preds = %18
%47 = load i32, i32* %4
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %9
49: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [10003 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [10003 x i8], [10003 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 %73, label %9
9: ; preds = %0, %67
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%11 = call i32 @strlen(i8* %3)
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %67
13: ; preds = %9
%14 = lshr i32 %11, 1
%15 = zext i32 %14 to i64
%16 = and i64 %15, 1
%17 = icmp eq i32 %14, 1
br i1 %17, label %50, label %18
18: ; preds = %13
%19 = and i64 %15, 2147483646
br label %20
20: ; preds = %20, %18
%21 = phi i64 [ 0, %18 ], [ %47, %20 ]
%22 = phi i32 [ 0, %18 ], [ %46, %20 ]
%23 = phi i64 [ 0, %18 ], [ %48, %20 ]
%24 = getelementptr inbounds [10003 x i8], [10003 x i8]* %1, i64 0, i64 %21
%25 = load i8, i8* %24
%26 = trunc i64 %21 to i32
%27 = xor i32 %26, -1
%28 = add i32 %11, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10003 x i8], [10003 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sub i8 %25, %31
%33 = call i32 @abs(i8 signext %32)
%34 = add nsw i32 %33, %22
%35 = or i64 %21, 1
%36 = getelementptr inbounds [10003 x i8], [10003 x i8]* %1, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = trunc i64 %35 to i32
%39 = xor i32 %38, -1
%40 = add i32 %11, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [10003 x i8], [10003 x i8]* %1, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sub i8 %37, %43
%45 = call i32 @abs(i8 signext %44)
%46 = add nsw i32 %45, %34
%47 = add nuw nsw i64 %21, 2
%48 = add i64 %23, 2
%49 = icmp eq i64 %48, %19
br i1 %49, label %50, label %20
50: ; preds = %20, %13
%51 = phi i32 [ undef, %13 ], [ %46, %20 ]
%52 = phi i64 [ 0, %13 ], [ %47, %20 ]
%53 = phi i32 [ 0, %13 ], [ %46, %20 ]
%54 = icmp eq i64 %16, 0
br i1 %54, label %67, label %55
55: ; preds = %50
%56 = getelementptr inbounds [10003 x i8], [10003 x i8]* %1, i64 0, i64 %52
%57 = load i8, i8* %56
%58 = trunc i64 %52 to i32
%59 = xor i32 %58, -1
%60 = add i32 %11, %59
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [10003 x i8], [10003 x i8]* %1, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = sub i8 %57, %63
%65 = call i32 @abs(i8 signext %64)
%66 = add nsw i32 %65, %53
br label %67
67: ; preds = %55, %50, %9
%68 = phi i32 [ 0, %9 ], [ %51, %50 ], [ %66, %55 ]
%69 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %68)
%70 = load i32, i32* %2
%71 = add nsw i32 %70, -1
store i32 %71, i32* %2
%72 = icmp eq i32 %70, 0
br i1 %72, label %73, label %9
73: ; preds = %67, %0
ret i32 0
}