#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 a[100000];
  long int n;
  long int k;
  long int sum;
  int count = 0;
  scanf("%ld %ld", &n, &k);
  for (long int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  for (int i = 1; i <= n - 1; i++) {
    for (int j = i + 1; j <= n; j++) {
      sum = a[i] + a[j];
      if (sum % k == 0)
        count++;
    }
  }
  printf("%d", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ac0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x61aac(%rbp)
lea    0xebd(%rip),%rdi
lea    -0x61a98(%rbp),%rsi
lea    -0x61aa0(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x1,-0x61ab8(%rbp)
mov    -0x61ab8(%rbp),%rax
cmp    -0x61a98(%rbp),%rax
jg     11b1 <main+0x91>
mov    -0x61ab8(%rbp),%rax
lea    -0x61a90(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x61ab8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x61ab8(%rbp)
jmp    1163 <main+0x43>
movl   $0x1,-0x61abc(%rbp)
movslq -0x61abc(%rbp),%rax
mov    -0x61a98(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jg     1279 <main+0x159>
mov    -0x61abc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61ac0(%rbp)
movslq -0x61ac0(%rbp),%rax
cmp    -0x61a98(%rbp),%rax
jg     1260 <main+0x140>
movslq -0x61abc(%rbp),%rax
mov    -0x61a90(%rbp,%rax,4),%eax
movslq -0x61ac0(%rbp),%rcx
add    -0x61a90(%rbp,%rcx,4),%eax
cltq
mov    %rax,-0x61aa8(%rbp)
mov    -0x61aa8(%rbp),%rax
cqto
idivq  -0x61aa0(%rbp)
cmp    $0x0,%rdx
jne    1247 <main+0x127>
mov    -0x61aac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61aac(%rbp)
jmp    124c <main+0x12c>
mov    -0x61ac0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61ac0(%rbp)
jmp    11e5 <main+0xc5>
jmp    1265 <main+0x145>
mov    -0x61abc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61abc(%rbp)
jmp    11bb <main+0x9b>
mov    -0x61aac(%rbp),%esi
lea    0xd82(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x61ac0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x61a90,%rsp
lea    0xecd(%rip),%rdi
xor    %ebx,%ebx
mov    %rsp,%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
cmpq   $0x0,(%rsp)
jle    11ef <main+0xcf>
lea    0x14(%rsp),%r15
lea    0xead(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    (%rsp),%r10
add    $0x1,%rbx
add    $0x4,%r15
cmp    %r10,%rbx
jl     1160 <main+0x40>
xor    %ebx,%ebx
cmp    $0x2,%r10
jl     11ef <main+0xcf>
xor    %ebx,%ebx
mov    $0x2,%r9d
mov    $0x1,%r8d
mov    0x8(%rsp),%rdi
jmp    11a9 <main+0x89>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r9
cmp    %r10,%r8
je     11ef <main+0xcf>
movslq 0x10(%rsp,%r8,4),%rsi
add    $0x1,%r8
mov    %r9,%rcx
jmp    11d5 <main+0xb5>
nopw   0x0(%rax,%rax,1)
cqto
idiv   %rdi
cmp    $0x1,%rdx
adc    $0x0,%ebx
add    $0x1,%rcx
cmp    %rcx,%r10
jl     11a0 <main+0x80>
movslq 0x10(%rsp,%rcx,4),%rax
add    %rsi,%rax
mov    %rax,%rdx
or     %rdi,%rdx
shr    $0x20,%rdx
jne    11c0 <main+0xa0>
xor    %edx,%edx
div    %edi
jmp    11c5 <main+0xa5>
lea    0xe12(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x61a90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"%ld %ld\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [100000 x i32]
%2 = alloca i64
%3 = alloca i64
%4 = bitcast [100000 x i32]* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %2, i64* %3)
%8 = load i64, i64* %2
%9 = icmp slt i64 %8, 1
br i1 %9, label %24, label %14
10: ; preds = %14
%11 = icmp sgt i64 %19, 1
br i1 %11, label %12, label %24
12: ; preds = %10
%13 = load i64, i64* %3
br label %27
14: ; preds = %0, %14
%15 = phi i64 [ %18, %14 ], [ 1, %0 ]
%16 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %15
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = add nuw nsw i64 %15, 1
%19 = load i64, i64* %2
%20 = icmp slt i64 %15, %19
br i1 %20, label %14, label %10
21: ; preds = %34
%22 = add nuw i64 %29, 1
%23 = icmp eq i64 %31, %19
br i1 %23, label %24, label %27
24: ; preds = %21, %0, %10
%25 = phi i32 [ 0, %10 ], [ 0, %0 ], [ %44, %21 ]
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret i32 0
27: ; preds = %21, %12
%28 = phi i64 [ 1, %12 ], [ %31, %21 ]
%29 = phi i64 [ 2, %12 ], [ %22, %21 ]
%30 = phi i32 [ 0, %12 ], [ %44, %21 ]
%31 = add nuw nsw i64 %28, 1
%32 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %28
%33 = load i32, i32* %32
br label %34
34: ; preds = %27, %34
%35 = phi i64 [ %29, %27 ], [ %45, %34 ]
%36 = phi i32 [ %30, %27 ], [ %44, %34 ]
%37 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %35
%38 = load i32, i32* %37
%39 = add nsw i32 %38, %33
%40 = sext i32 %39 to i64
%41 = srem i64 %40, %13
%42 = icmp eq i64 %41, 0
%43 = zext i1 %42 to i32
%44 = add nsw i32 %36, %43
%45 = add nuw i64 %35, 1
%46 = icmp slt i64 %19, %45
br i1 %46, label %21, label %34
}