https://graphics.stanford.edu/~seander/bithacks.html#ParityMultiply
Is that the cheapest even/odd checker?
a byte-wise lookup table of it and then run across the bytes is more expensive I think, you have 4 bytes here, so 4 pointer offset grabs, 4 bit ops on the results of that, and a conditional around the mess. however, his lookup attempt is really slick:
https://graphics.stanford.edu/~seander/bithacks.html#ParityLookupTable
a lookup table (vector bool) should serve for dupes if I was right about the 131071. But some of these sites have a memory limit too.
I think you are right about having to do the xors.
so basically get x, see if it is even or odd, and xor it with each thing in S. without an if statement, use bools as 0/1 values, add to your total for e/o based off whether you already saw it using the lookup table, then set the lookup table to seen status (which I am thinking will be zero, not one, here, to make it easier?).
that looks like, without if statements,
for(all in s)
{
y = s.nextvalue(); //however you want to handle this. this is a critical step.
something = x^y;
e+= (int)(table[something]==true); //adds 0 or 1
o+= (int)(table[something]==false); //adds 0 or 1
table[something] = false; //or true, not 100% sure on the reverse logic being easier
}
don't forget insert x and update e and o