import
java.io.*;
import
java.lang.*;
import
java.util.*;
class
GFG{
static
class
pair
{
int
first, second;
public
pair(
int
first,
int
second)
{
this
.first = first;
this
.second = second;
}
}
static
int
NCR(
int
N,
int
R)
{
if
(R > N - R)
R = N - R;
int
ans =
1
;
for
(
int
i =
1
; i <= R; i++)
{
ans *= N - R + i;
ans /= i;
}
return
ans;
}
static
void
solveXorTriplets(
int
arr[],
int
N,
Vector<pair> Q,
int
M)
{
int
preo[] =
new
int
[N +
1
];
int
pree[] =
new
int
[N +
1
];
for
(
int
i =
0
; i < N; i++)
{
preo[i +
1
] += preo[i];
pree[i +
1
] += pree[i];
int
setbits = Integer.bitCount(arr[i]);
if
(setbits %
2
!=
0
)
preo[i +
1
]++;
else
pree[i +
1
]++;
}
for
(
int
i =
0
; i < M; i++)
{
int
L = Q.elementAt(i).first;
int
R = Q.elementAt(i).second;
int
odd = preo[R] - preo[L -
1
];
int
even = pree[R] - pree[L -
1
];
int
ans =
0
;
if
(even >=
3
)
ans += NCR(even,
3
);
if
(odd >=
2
&& even >=
1
)
ans += NCR(odd,
2
) * NCR(even,
1
);
System.out.println(ans);
}
}
public
static
void
main(String[] args)
{
int
arr[] = {
1
,
2
,
3
,
4
,
5
};
int
N = arr.length;
Vector<pair> Q =
new
Vector<>();
Q.add(
new
pair(
1
,
4
));
Q.add(
new
pair(
3
,
4
));
int
M = Q.size();
solveXorTriplets(arr, N, Q, M);
}
}