Sector XOR folding
Your task
A tape archive proves a restore by XOR folding the id of every sector it touched. starts and ends describe the runs in order: run i covers every sector id from starts[i] up to ends[i] inclusive, and a run whose start is greater than its end is a placeholder that covers nothing. Overlapping runs are normal, and a sector covered by two runs is folded in twice. Ids are below 2^30 and a single run can span hundreds of millions of sectors, so counting them one at a time is not an option. Return the XOR of every covered id, or 0 when the runs cover nothing at all. The two lists always have the same length.
Examples
archive_run_checksum(starts: list[int], ends: list[int]) -> intExample 1
Input
archive_run_checksum([1], [5])Output
1Example 2
Input
archive_run_checksum([0, 10], [3, 12])Output
13Example 3
Input
archive_run_checksum([7], [3])Output
0