LCPC12F  Johnny The Gambler
Johnny is a gambling addict. He entered a casino and started playing a game with the dealer. The game is as follows: the dealer deals a sequence of N cards, each card containing a number C[i] and asks Johnny how many pairs (j, k) such that j < k and C[j] + C[k] = X. If Johnny answers correctly he wins, otherwise the dealer wins.
Input Format
The first line of input contains an integer T, the number of test cases. T test cases follow, Each test case start with the value of 0 ≤ X ≤ 2*10^{3} followed by the number of cards 0 < N ≤ 10^{5} followed by N numbers representing the numbers on the cards 0 ≤ C[i] ≤ 10^{3}.
Output Format
There should be T lines, containing the following format.
k. S
Where k is the test case number (starting at 1), a single period, a single space and S representing the number of valid pairs (j, k) as described above.
Sample Input
Sample Input
1
10 3 1 5 9
1. 1
hide comments
sudhanshu6324:
20180818 07:23:51
such a creep description!!!!


cosmicray001:
20180613 02:10:46
here, long long int is real! 

mag1x_:
20180531 09:27:07
int  wa :/


nadstratosfer:
20171022 22:48:34
I vaguely remember a video from Google on YT about how their job interviews look like, and this problem was being solved there  couldn't bother to watch until the optimal solution then, and haven't looked for it now because there's an elegant O(n) one with Python's SL they certainly didn't employ solving in C. Anyway 0 doesn't matter, order doesn't matter, just watch out for X/2. 

vengatesh15:
20170218 20:15:37
forget to consider 0 that cost me 2 WA but easy one did in O(n) time and O(n) space 

siddharth_0196:
20160618 19:38:30
Last edit: 20161111 08:49:19 

robin_0:
20150930 08:01:44
I don't get it :/


Jaswanth:
20150902 14:23:29
j<k or j<=k my solution got accepted for j<=k 

iah10:
20150319 17:58:18
how can we see the test cases..my code is giving runtime error and i would like to know the reason 

Abhinandan Agarwal:
20150224 23:28:14
Constraints are correct, if you want include the test case, but declare the variable which is supposed to store the answer, as long long, because answer can be large 
Added by:  Gareev 
Date:  20121006 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  LCPC 2012 