UNique number III

two test case passed and one gives wrong answer , what may be the reason, this is my code

#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,x; cin>>n;
int binary[64]={0};
for(int i=0;i<n;i++)
{
cin>>x;
int k=0;
while(x)
{
if(x&1)
binary[k++]++;

        x = x>>1;
        
   }

}

int ans =0;

for(int i=0;i<64;i++)
{
binary[i] = binary[i]%3;
ans = ans + pow(2,i)*binary[i];
}

   cout<<ans<<endl;
   
   return 0;

}

got the error
, I make mistake in incrementing the index

Yeah, just needa do binary[k++] += x&1