C++ working code :

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
int main() {
ll n;
cin>>n;
vector <ll> b2(n+5,0),b5(n+5,0),answer(n+5,0);
ll i = 1 ;
while(i<=n){
cin>>b2[i];
i++;
}
i = 1 ;
while(i<=n){
cin>>b5[i];
answer[i] = 3 ; //0...1...2...3.......
i++;
}
ll kk = 0 ;
i = 32 ;
while(i>=0){
ll j = 1 ; ll kq = 0 ;
vector <ll> tmp(n+5,0);
while(j<=n){
ll bit1 = 0 ;
ll bit2 = 0 ;
ll k = b2[j] >> i;
if (k & 1) {
bit1 = 1 ;
}
else{
bit1 = 0 ;
}
k = b5[j] >> i;
if (k & 1) {
bit2 = 1 ;
}
else{
bit2 = 0 ;
}
if(bit1==1 && bit2==1){
//answer[j]======answer[j].....
tmp[j] = answer[j] ;
} else if(bit1==1){
if(answer[j]==3 || answer[j]==1){
tmp[j] = 1 ; }
else{
kq = 1 ;
}
} else if(bit2==1){
//tmp[j] = 2 ;
if(answer[j]==3 || answer[j]==2){
tmp[j] = 2 ; }
else{
kq = 1 ;
}
}
else{
kq = 1 ;
}
j++;
}
if(kq==0){
answer = tmp ;
kk = kk + pow(2,i);
}
else{
//fail........
}
i--;
}
cout<<kk;
cout<<" ";
ll oo = 0 ;
i = 1 ;
while(i<=n){
if(answer[i]==2){
oo++;
}
i++;
}
cout<<oo ;
return 0 ;
}