Buggy python submission (verdict: Runtime Error):
import sys

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md, pos):
    res = 0
    fpos = -2
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                if fpos == -2:
                    fpos = pos
                res += pos + 1
                break
    return res, fpos


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        pos = n - 1
    for i in range(31):
        t += pow(2, i) * dp[i]
    print(t)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 31
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        a.sort()
        b.sort()
        p1 = n
        p2 = n
        p3 = n
        for av in a:
            p3 = bisect.bisect_right(b, 3 * mdr // 2 - 1 - av, 0, p3)
            p2 = bisect.bisect_right(b, 2 * mdr // 2 - 1 - av, 0, p2)
            p1 = bisect.bisect_right(b, mdr // 2 - 1 - av, 0, p1)
            dp[i] += n - (p1 + p3 - p2)
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 31
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        a.sort(reverse=True)
        b.sort()
        for av in a:
            p1 = bisect.bisect_right(b, mdr // 2 - 1 - av, 0, n)
            p2 = bisect.bisect_right(b, 2 * mdr // 2 - 1 - av, p1, n)
            p3 = bisect.bisect_right(b, 3 * mdr // 2 - 1 - av, p2, n)
            dp[i] += n - (p1 + p3 - p2)
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 31
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        mdl = pow(2, i)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        a.sort(reverse=True)
        b.sort()
        p_mdr_av = 0
        p_mdl_av = 0
        p_mdr = 0
        p_mdl_mdr_av = 0
        d = collections.defaultdict(int)
        for av in a:
            if mdl - av >= 0:
                p_mdr_av = bisect.bisect_left(b, mdr - av, p_mdr_av)
                p_mdl_av = bisect.bisect_left(b, mdl - av, p_mdl_av, p_mdr_av)
                dp[i] += p_mdr_av - p_mdl_av
            else:
                p_mdr = bisect.bisect_left(b, mdr, p_mdr)
                p_mdr_av = bisect.bisect_left(b, mdr - av, p_mdr_av, p_mdr)
                dp[i] += p_mdr_av
                p_mdl_mdr_av = bisect.bisect_left(b, mdl + mdr - av, p_mdl_mdr_av)
                dp[i] += p_mdr - p_mdl_mdr_av
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 31
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        mdl = pow(2, i)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        a.sort(reverse=True)
        b.sort()
        p_mdr_av = 0
        p_mdl_av = 0
        p_mdr = 0
        p_mdl_mdr_av = 0
        d = collections.defaultdict(int)
        for av in a:
            if mdl - av >= 0:
                if mdr - av not in d:
                    p_mdr_av = bisect.bisect_left(b, mdr - av, p_mdr_av)
                    d[mdr - av] = p_mdr_av
                else:
                    p_mdr_av = d[mdr - av]
                if mdl - av not in d:
                    p_mdl_av = bisect.bisect_left(b, mdl - av, p_mdl_av)
                    d[mdl - av] = p_mdl_av
                else:
                    p_mdl_av = d[mdl - av]
                dp[i] += p_mdr_av - p_mdl_av
            else:
                if mdr - av not in d:
                    p_mdr_av = bisect.bisect_left(b, mdr - av, p_mdr_av)
                    d[mdr - av] = p_mdr_av
                else:
                    p_mdr_av = d[mdr - av]
                dp[i] += p_mdr_av
                if mdr not in d:
                    p_mdr = bisect.bisect_left(b, mdr, p_mdr)
                    d[mdr] = p_mdr
                else:
                    p_mdr = d[mdr]
                if mdl + mdr - av not in d:
                    p_mdl_mdr_av = bisect.bisect_left(b, mdl + mdr - av, p_mdl_mdr_av)
                    d[mdl + mdr - av] = p_mdl_mdr_av
                else:
                    p_mdl_mdr_av = d[mdl + mdr - av]
                dp[i] += p_mdr - p_mdl_mdr_av
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 31
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        mdl = pow(2, i)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        a.sort(reverse=True)
        b.sort()
        p_mdr_av = 0
        p_mdl_av = 0
        p_mdr = 0
        p_mdl_mdr_av = 0
        for av in a:
            if mdl - av >= 0:
                p_mdr_av = bisect.bisect_left(b, mdr - av, p_mdr_av)
                p_mdl_av = bisect.bisect_left(b, mdl - av, p_mdl_av)
                dp[i] += p_mdr_av - p_mdl_av
            else:
                p_mdr_av = bisect.bisect_left(b, mdr - av, p_mdr_av)
                dp[i] += p_mdr_av
                p_mdr = bisect.bisect_left(b, mdr, p_mdr)
                p_mdl_mdr_av = bisect.bisect_left(b, mdl + mdr - av, p_mdl_mdr_av)
                dp[i] += p_mdr - p_mdl_mdr_av
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 30
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        mdl = pow(2, i)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        b.sort()
        d = collections.defaultdict(int)
        for av in a:
            if mdl - av >= 0:
                if mdr - av not in d:
                    big = bisect.bisect_left(b, mdr - av)
                    d[mdr - av] = big
                else:
                    big = d[mdr - av]
                if mdl - av not in d:
                    small = bisect.bisect_left(b, mdl - av)
                    d[mdl - av] = small
                else:
                    small = d[mdl - av]
                dp[i] += big - small
            else:
                if mdr - av not in d:
                    big = bisect.bisect_left(b, mdr - av)
                    d[mdr - av] = big
                else:
                    big = d[mdr - av]
                dp[i] += big
                if mdr not in d:
                    big = bisect.bisect_left(b, mdr)
                    d[mdr] = big
                else:
                    big = d[mdr]
                if mdl + mdr - av not in d:
                    small = bisect.bisect_left(b, mdl + mdr - av)
                    d[mdl + mdr - av] = small
                else:
                    small = d[mdl + mdr - av]
                dp[i] += big - small
    t = 0
    for i in range(30):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 31
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        mdl = pow(2, i)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        b.sort()
        for av in a:
            if mdl - av >= 0:
                dp[i] += bisect.bisect_left(b, mdr - av) - bisect.bisect_left(b, mdl - av)
            else:
                dp[i] += bisect.bisect_left(b, mdr - av)
                dp[i] += bisect.bisect_left(b, mdr) - bisect.bisect_left(b, mdl + mdr - av)
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Runtime Error):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = collections.Counter(list(map(int, input().rstrip('\n').split()))).most_common()
    b = collections.Counter(list(map(int, input().rstrip('\n').split()))).most_common()
    aa = []
    bb = []
    for i in range(n):
        if a[i][1] % 2 != 0:
            aa.append(a[i][0])
        if b[i][1] % 2 != 0:
            bb.append(b[i][0])
    t = 0
    for av in aa:
        for bv in bb:
            t = t ^ (av + bv)
    print(t)


if __name__ == '__main__':
    slove()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Runtime Error):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = collections.Counter(list(map(int, input().rstrip('\n').split()))).most_common()
    b = collections.Counter(list(map(int, input().rstrip('\n').split()))).most_common()
    aa = []
    bb = []
    for i in range(n):
        if a[i][1] % 2 != 0:
            aa.append(a[i][0])
        if b[i][1] % 2 != 0:
            bb.append(b[i][0])
    t = 0
    for av in a:
        for bv in b:
            t = t ^ (av + bv)
    print(t)


if __name__ == '__main__':
    slove()


Fixed submission:
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()