Processing math: 100%
XOR - MarisaOJ: Marisa Online Judge

XOR

Time limit: 1000 ms
Memory limit: 256 MB
Given an array a consisting of n non-negative integers. Count the number of pairs 1≤i,j≤n such that ai≤(ai⊕aj)≤aj. ### Input - The first line contains an integer n. - The second line contains n positive integers ai. ### Output - Print a single integer — the number of valid pairs i,j. ### Constraints - 1≤n≤5×105. - 0≤ai<230. ### Example Input: 501234 Output: 6