#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 *);
int main() {
  int testcase = 0;
  scanf("%d", &testcase);
  while (testcase--) {
    int n, i;
    int hashtable[10] = {0};
    int collison = 0;
    scanf("%d", &n);
    int a[n];
    for (i = 0; i < 10; i++)
      hashtable[i] = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      hashtable[a[i] % 10]++;
    }
    for (i = 0; i < 10; i++) {
      if (hashtable[i] > 1)
        collison = collison + (hashtable[i] - 1);
    }
    printf("%d\n", collison);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1294 <main+0x174>
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xe85(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    11d6 <main+0xb6>
movslq -0x10(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b2 <main+0x92>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1233 <main+0x113>
mov    -0x60(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe01(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x60(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11dd <main+0xbd>
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    1279 <main+0x159>
movslq -0x10(%rbp),%rax
cmpl   $0x1,-0x40(%rbp,%rax,4)
jle    1266 <main+0x146>
mov    -0x44(%rbp),%eax
movslq -0x10(%rbp),%rcx
mov    -0x40(%rbp,%rcx,4),%ecx
sub    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x44(%rbp)
jmp    126b <main+0x14b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    123a <main+0x11a>
mov    -0x44(%rbp),%esi
lea    0xd80(%rip),%rdi
call   1030 <printf@plt>
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
jmp    1146 <main+0x26>
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movl   $0x0,-0x30(%rbp)
lea    0xed1(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <scanf@plt>
subl   $0x1,-0x30(%rbp)
jae    115f <main+0x3f>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeaa(%rip),%r12
xor    %r13d,%r13d
jmp    1185 <main+0x65>
nopl   0x0(%rax,%rax,1)
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rsp
subl   $0x1,-0x30(%rbp)
jb     114e <main+0x2e>
mov    %r12,%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rsp,%r14
mov    -0x2c(%rbp),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
pxor   %xmm0,%xmm0
movdqa %xmm0,-0x50(%rbp)
movdqa %xmm0,-0x60(%rbp)
movq   $0x0,-0x40(%rbp)
cmpl   $0x0,-0x2c(%rbp)
mov    $0x0,%esi
jle    1170 <main+0x50>
xor    %r15d,%r15d
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq (%rbx),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cltq
addl   $0x1,-0x60(%rbp,%rax,4)
add    $0x1,%r15
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r15
jl     11d0 <main+0xb0>
mov    -0x60(%rbp),%ecx
mov    -0x5c(%rbp),%edx
movdqu -0x48(%rbp),%xmm0
movdqu -0x58(%rbp),%xmm1
lea    -0x1(%rcx),%eax
cmp    $0x2,%ecx
cmovl  %r13d,%eax
lea    -0x1(%rdx),%ecx
cmp    $0x2,%edx
cmovl  %r13d,%ecx
movdqa %xmm1,%xmm2
movdqa 0xdbf(%rip),%xmm4
pcmpgtd %xmm4,%xmm2
movdqa %xmm0,%xmm3
pcmpgtd %xmm4,%xmm3
pcmpeqd %xmm4,%xmm4
paddd  %xmm4,%xmm1
pand   %xmm2,%xmm1
paddd  %xmm4,%xmm0
pand   %xmm3,%xmm0
paddd  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%esi
add    %ecx,%esi
add    %eax,%esi
jmp    1170 <main+0x50>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i32]
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %75, %0
%11 = load i32, i32* %2
%12 = add nsw i32 %11, -1
store i32 %12, i32* %2
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %79
14: ; preds = %10
%15 = bitcast [10 x i32]* %5 to i8*
store i32 0, i32* %6
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %7
%20 = alloca i32, i64 %18
store i64 %18, i64* %8
store i32 0, i32* %4
br label %21
21: ; preds = %28, %14
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 10
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %26
store i32 0, i32* %27
br label %28
28: ; preds = %24
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %21
31: ; preds = %21
store i32 0, i32* %4
br label %32
32: ; preds = %50, %31
%33 = load i32, i32* %4
%34 = load i32, i32* %3
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %53
36: ; preds = %32
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %20, i64 %38
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %39)
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %20, i64 %42
%44 = load i32, i32* %43
%45 = srem i32 %44, 10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = add nsw i32 %48, 1
store i32 %49, i32* %47
br label %50
50: ; preds = %36
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %32
53: ; preds = %32
store i32 0, i32* %4
br label %54
54: ; preds = %72, %53
%55 = load i32, i32* %4
%56 = icmp slt i32 %55, 10
br i1 %56, label %57, label %75
57: ; preds = %54
%58 = load i32, i32* %4
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = icmp sgt i32 %61, 1
br i1 %62, label %63, label %71
63: ; preds = %57
%64 = load i32, i32* %6
%65 = load i32, i32* %4
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = sub nsw i32 %68, 1
%70 = add nsw i32 %64, %69
store i32 %70, i32* %6
br label %71
71: ; preds = %63, %57
br label %72
72: ; preds = %71
%73 = load i32, i32* %4
%74 = add nsw i32 %73, 1
store i32 %74, i32* %4
br label %54
75: ; preds = %54
%76 = load i32, i32* %6
%77 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %76)
%78 = load i8*, i8** %7
br label %10
79: ; preds = %10
%80 = load i32, i32* %1
ret i32 %80
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
%5 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = add nsw i32 %7, -1
store i32 %8, i32* %1
%9 = icmp eq i32 %7, 0
br i1 %9, label %60, label %10
10: ; preds = %0
%11 = bitcast i32* %2 to i8*
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
%15 = bitcast i32* %14 to <8 x i32>*
br label %16
16: ; preds = %10, %40
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%18 = load i32, i32* %2
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
%21 = alloca i32, i64 %19
%22 = load i32, i32* %2
%23 = icmp sgt i32 %22, 0
br i1 %23, label %46, label %40
24: ; preds = %46
%25 = load i32, i32* %12
%26 = load i32, i32* %13
%27 = load <8 x i32>, <8 x i32>* %15
%28 = icmp sgt i32 %25, 1
%29 = add nsw i32 %25, -1
%30 = select i1 %28, i32 %29, i32 0
%31 = icmp sgt i32 %26, 1
%32 = add nsw i32 %26, -1
%33 = select i1 %31, i32 %32, i32 0
%34 = icmp sgt <8 x i32> %27, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
%35 = add nsw <8 x i32> %27, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
%36 = select <8 x i1> %34, <8 x i32> %35, <8 x i32> zeroinitializer
%37 = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %36)
%38 = add nuw nsw i32 %37, %33
%39 = add nuw nsw i32 %38, %30
br label %40
40: ; preds = %24, %16
%41 = phi i32 [ %39, %24 ], [ 0, %16 ]
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %1
%44 = add nsw i32 %43, -1
store i32 %44, i32* %1
%45 = icmp eq i32 %43, 0
br i1 %45, label %60, label %16
46: ; preds = %16, %46
%47 = phi i64 [ %56, %46 ], [ 0, %16 ]
%48 = getelementptr inbounds i32, i32* %21, i64 %47
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %48)
%50 = load i32, i32* %48
%51 = srem i32 %50, 10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = add nsw i32 %54, 1
store i32 %55, i32* %53
%56 = add nuw nsw i64 %47, 1
%57 = load i32, i32* %2
%58 = sext i32 %57 to i64
%59 = icmp slt i64 %56, %58
br i1 %59, label %46, label %24
60: ; preds = %40, %0
ret i32 0
}