Submit solution

Points:
7 (partial)

Time limit:
0.1s

Java
0.3s

Python 2
0.3s

Python 3
0.3s

Memory limit:
256M

Problem type

Given a sequence of integers and a nonnegative integer , count the number of pairs that satisfy the following two conditions: , and .

#### Input Specification

- The first line contains integers and , separated by a space.
- The second line contains integers, which denotes .
- In of the test cases, .

#### Output Specification

- The output contains an integer, which denotes the number of pairs that satisfies the two conditions.
- If the output is smaller than , please keep it as is. Otherwise, output the number
*mod*.

#### Sample Input 1

```
5 6
1 2 3 4 5
```

#### Sample Output 1

`6`

#### Sample Input 2

```
5 12
3 6 8 2 8
```

#### Sample Output 2

`7`

**Explanation**: In Sample 1, among the pairs, , , , , , satisfy the conditions. In Sample 2, , , , , , , satisfy the conditions.

## Comments

Why is the time limit only 0.3s?

So solutions like yours can't pass. Find a more efficient way to solve the problem.