Page Contents
Rock and Lever SOLUTION
Danik earnestly needs rock and switch! Clearly, the most effortless approach to get these things is to approach Hermit Lizard for them.
Recluse Lizard consented to give Danik the switch. In any case, to get a stone, Danik needs to unravel the accompanying undertaking.
You are given a positive whole number n, and an exhibit an of positive numbers. The errand is to figure the quantity of such matches (i,j) that i<j and ai and aj≥ai⊕aj, where and signifies the bitwise AND activity, and ⊕ indicates the bitwise XOR activity.
Danik has tackled this assignment. Be that as it may, would you be able to settle it?
Information
Each test contains various experiments.
The principal line contains one certain whole number t (1≤t≤10) indicating the quantity of experiments. Portrayal of the experiments follows.
The main line of each experiment contains one certain number n (1≤n≤105) — length of the exhibit.
The subsequent line contains n positive whole numbers ai (1≤ai≤109) — components of the cluster.
It is ensured that the aggregate of n over all experiments doesn’t surpass 105.
Yield
For each experiment print one non-negative number — the response to the issue.
Model
inputCopy
5
5
1 4 3 7 10
3
1
4
6 2 5 3
2
2 4
1
1
outputCopy
1
3
2
0
0
Note
In the main experiment there is just one sets: (4,7): for it 4 and 7=4, and 4⊕7=3.
In the subsequent experiment all sets are acceptable.
In the third experiment there are two sets: (5,6) and (2,3).
In the fourth experiment there are nothing but bad matches.