int n,t,k,a,b[32],c[32]; ll d[32],e[32]; { b[0..30]=-1; rd(n,*b); rep(n){ rep(j,31){ c[j]=b[j]; b[j]=-1; e[j]=d[j]; d[j]=0; } rd(a); rep(j,31){ if(c[j]>=0){ t=c[j]&a; k=BIT_popcount(t); b[k]=t; d[k]>?=e[j]+c[j]-t; t=c[j]|a; k=BIT_popcount(t); b[k]=t; d[k]>?=e[j]-c[j]+t; } } } wt(max(d(31))); }