#include //#include //#include #define int long long #define ld long double #define get(T,args...) T args; read(args); #define init(a,T,n,s) vector a((n)+1,s); cin>>a; #define putn(args...) { put(args); cout<<"\n"; } #define pute(args...) { put(args); cout<(b); i--) #define logarr(arr,f,l) { auto start=arr.begin(), end=arr.begin(); advance(start,(f)); advance(end,(l)); for(auto it=start; it!=end; it++) cout<<*it<<" "; cout<<"\n"; } #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sort_by(span,p) sort(span, [&](const auto &l, const auto &r) { return p; }) #define f(u, args...) [&](auto &&u) { return args; } #define g(u, v, args...) [&](auto &&u, auto &&v) { return args; } #define uniq(x) x.erase(unique(all(x)),x.end()); #define sz(x) (int)(x).size() #define mid(l,r) std::midpoint((l),(r)) #define zov(v,z,c) ((c) ? (v) : (z)) #define pii pair #define pb emplace_back #define pf push_front #define fr first #define sc second #define sumv(v,b,e) accumulate((v).begin()+b,(v).begin()+e,0LL) #define minv(v,b,e) min_element((v).begin()+b,(v).begin()+e) #define maxv(v,b,e) max_element((v).begin()+b,(v).begin()+e) #define precise(n) cout< #define set(args...) std::set > #define pqueue(args...) std::priority_queue,Comp > //#define oset(args...) tree, rb_tree_tag, tree_order_statistics_node_update> const int N = 100001, M = 998244353, mod = 1000000007, MX = INT64_MAX, MN = INT64_MIN, oo = 1e18; #ifdef DEBUG #include "./Debug/debug.hpp" #else #define debug(args...) 0; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #endif //using namespace __gnu_pbds; using namespace std; vec(string) tokenizer(string str,char ch) {std::istringstream var((str)); vec(string) v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;} template struct Comp { bool operator()(const T& l, const T& r) const { return l < r; } }; template inline istream& operator >> (istream& in, pair& a) { in>>a.first>>a.second; return in; } template inline ostream& operator << (ostream& out, pair a) { out< istream& operator >> (istream& in, vector& v) { rep(i,1,sz(v)) cin>>v[i]; return in; } template inline bool amax(T &a,T1 b){ if(b>a) { a=b; return true; } return false; } template inline bool amin(T &a,T1 b){ if(b>args), ...); } void put(auto&&... args) { ((cout< odd(n+1,0), even(n+1,0); rep(i,1,n+1) { odd[i] = odd[i-1]; even[i] = even[i-1]; if(b[i]&1) odd[i]++; else even[i]++; } vector last(32,0); int cur = 0; rep(i,1,n+1) { rep(j,0,32) { if((a[i]>>j)&1) { amax(cur,last[j]+1); last[j] = i; } } if(b[i]&1) ans += odd[i-1] - odd[cur-1]; else ans += even[i-1] - even[cur-1]; } putn(ans) } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //file_i_o(); int t=1; rep(i,1,t+1) { //cout<<"Case #"<