8587: DPL_4_A : Coin Combination Problem
[Creator : ]
Description
You have 4 bags A, B, C and D each of which includes N coins (there are totally 4N coins). Values of the coins in each bag are $a_i, b_i, c_i$ and $d_i$ respectively.
Find the number of combinations that result when you choose one coin from each bag (totally 4 coins) in such a way that the total value of the coins is V. You should distinguish the coins in a bag.
Input
The input is given in the following format.
$N\ V$
$a_1\ a_2\ ...\ a_N$
$b_1\ b_2\ ...\ b_N$
$c_1\ c_2\ ...\ c_N$
$d_1\ d_2\ ...\ d_N$
Output
Print the number of combinations in a line.
Constraints
$1 ≤ N ≤ 1000$
$1 ≤ a_i, b_i, c_i, d_i ≤ 10^{16}$
$1 ≤ V ≤ 10^{16}$
All input values are given in integers
$1 ≤ a_i, b_i, c_i, d_i ≤ 10^{16}$
$1 ≤ V ≤ 10^{16}$
All input values are given in integers
Sample 1 Input
3 14
3 1 2
4 8 2
1 2 3
7 3 2
Sample 1 Output
9
Sample 2 Input
5 4
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
Sample 2 Output
625