import sys from collections import defaultdict def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 A = list(map(int, input[ptr:ptr+N])) ptr += N B = list(map(int, input[ptr:ptr+N])) ptr += N # Compute prefix_xor for B pb = [0] * (N + 1) for i in range(N): pb[i + 1] = pb[i] ^ B[i] # Variables for sum equals xor sliding window bitmask = 0 left_current_sum_xor = 0 # Variables for frequency map of pb[l] where l is in the current window current_freq_left = 0 current_freq_right = -1 freq = defaultdict(int) total = 0 for right in range(N): # Update sum equals xor window a_val = A[right] while left_current_sum_xor <= right and (bitmask & a_val) != 0: bitmask ^= A[left_current_sum_xor] left_current_sum_xor += 1 bitmask |= a_val new_left_current = left_current_sum_xor # Adjust the frequency window [new_left_current, right] # Remove elements from the left if current_freq_left is behind new_left_current while current_freq_left < new_left_current: val = pb[current_freq_left] freq[val] -= 1 if freq[val] == 0: del freq[val] current_freq_left += 1 # Add elements to the right while current_freq_right < right: current_freq_right += 1 val = pb[current_freq_right] freq[val] += 1 # Calculate the target value target = pb[right + 1] count = freq.get(target, 0) total += count print(total) if __name__ == '__main__': main()