cswork / OAOpen practice workspace

AmazonOA #368

Get Discount Pairs

Estimated MediumJudge-ready

Topics (AI-labelled)HashingBits & Math

Count the index pairs i<j such that prices[i]+prices[j] is divisible by x. Items have their own identities, so repeated prices can form several pairs, and an item cannot be paired with itself.

Input

The first line contains n x and the second line contains n prices. The original bounds are 1≤n≤100000, 1≤x≤2×10^9, prices[i]≥1. Only the superscript 9 of the original upper bound on prices survives and its base is missing, so this site explicitly adds price≤10^9 and does not claim this restores the original upper bound.

Output

Output a single integer, the answer.

Example 1

Input:

5 60
31 25 85 29 35

Output:

3

Example 2

Input:

3 2
1 1 1

Output:

3

Example 3

Input:

1 1
1

Output:

0

Example notes

The outputs of the three public examples are 3; 3; and 0, checked by independent enumeration or direct simulation.

Editorial

Loading solution…