P26392 [AtCoder] Pair Cards
提高-
题目描述

Problem Description

Takahashi is playing with $ N $ cards.

The $ i $ -th card has an integer $ X_i $ written on it.

Takahashi wants to make as many pairs of cards as possible that satisfy one of the following conditions:

  • The two cards have the same integer.
  • The sum of the integers on the two cards is a multiple of $ M $.

Determine the maximum number of pairs Takahashi can make.

Note that a single card cannot be used in multiple pairs.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ X_1 $ $ X_2 $ $ ... $ $ X_N $

Output Format

Output the maximum number of pairs Takahashi can make.

Sample Input and Output

Sample Input #1

7 5
3 1 4 1 5 9 2

Sample Output #1

3

Sample Input #2

15 10
1 5 6 10 11 11 11 20 21 25 25 26 99 99 99

Sample Output #2

6

Notes/Hints

Constraints

  • $2 \leq N \leq 10^5$
  • $1 \leq M \leq 10^5$
  • $1 \leq X_i \leq 10^5$

Sample Explanation 1

It is possible to make $ 3 $ pairs: $(3,2),\ (1,4),\ (1,9)$. Note that it is also possible to make pairs like $(3,2),\ (1,1)$, but this does not maximize the number of pairs.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
7 5 3 1 4 1 5 9 2
样例输出
3