Jewelry

Accepts: 21
Submissions: 48
Time Limit: 8000/4000 MS (Java/Others)
Memory Limit: 262144/262144 K (Java/Others)
Problem Description
After all the difficulties, Psyche and Cupid are finally getting married. No ordinary pearls can hold Cupid's love for Psyche. So he has collected the Jewelry of Gods at the top of Mount Olympus to make her a chain. There are $ n $ beads on the chain. The $ i $-th bead is of the type $ A_i $. Being pretty in appearance and generous in her heart, Psyche decides to give one consecutive part of the chain to her mother. To meet her mother's particular taste, that part must have at least one type of bead that appears $ x $ times exactly. Psyche wants to know the number of ways to choose a part of the chain for her mother. Note that two parts $[L_1, R_1]$ and $[L_2, R_2]$ are different only if $ L_1 \neq L_2 $ or $ R_1 \neq R_2 $.
Input
The first line of the input contains an integer $ T $ $ (1 \le T \le 15) $, which denotes the number of test cases. For each test case, the first line contains two integers $ n,x $ $ (1 \le n \le 10 ^ 5, 1 \le x \le n) $. The second line contains $ n $ integers, the $ i $-th integer denotes $ A_i $ $ (0 \le A_i \le 10 ^ 9) $.
Output
For each test case, print an integer which denotes the number of parts Psyche can choose.
Sample Input
2
3 1
1 2 1
4 2
2 3 2 2
Sample Output
6
3
Hint
In the first example, all solutions all valid. In the second example, solution $ [1,3], [2,4], [3,4] $ have a type of beed, 2, that appears twice exactly.