Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import math


def f(n, k):
    base = 2 ** k
    syou = n // base
    amari = n % base
    q = max(0, amari - (base // 2) + 1)
    res1 = syou * (base // 2) + q
    return res1 % 2


def g(n):  # nを累計xorで表現
    if n == 0:
        return "0"
    keta = int(math.log2(n) + 1)
    s = ""
    for i in range(keta):
        s = str(f(n, i + 1)) + s
    return s


def xor(a, b):
    max_len = max(len(a), len(b))
    a = (("0" * max_len) + a)[-max_len:]
    b = (("0" * max_len) + b)[-max_len:]

    s = ""
    for i in range(max_len):
        if a[i] != b[i]:
            s += "1"
        else:
            s += "0"
    return s


def to10(s):
    res = 0
    for c in s:
        res *= 2
        if c == "1":
            res += 1
    return res


def main():
    n, m = [int(q) for q in input().split()]
    A = g(n - 1)
    B = g(m)
    res = xor(A, B)
    print(to10(res))


if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict
import math


def f(n, k):
    base = 2 ** k
    syou = n // base
    amari = n % base
    q = max(0, amari - (base // 2) + 1)
    res1 = syou * (base // 2) + q
    return res1 % 2


def g(n):  # nを累計xorで表現
    if n <= 0:
        return "0"
    keta = int(math.log2(n) + 1)
    s = ""
    for i in range(keta):
        s = str(f(n, i + 1)) + s
    return s


def xor(a, b):
    max_len = max(len(a), len(b))
    a = (("0" * max_len) + a)[-max_len:]
    b = (("0" * max_len) + b)[-max_len:]

    s = ""
    for i in range(max_len):
        if a[i] != b[i]:
            s += "1"
        else:
            s += "0"
    return s


def to10(s):
    res = 0
    for c in s:
        res *= 2
        if c == "1":
            res += 1
    return res


def main():
    n, m = [int(q) for q in input().split()]
    A = g(n - 1)
    B = g(m)
    res = xor(A, B)
    print(to10(res))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import math


def f(n, k):
    base = 2 ** k
    syou = n // base
    amari = n % base
    q = max(0, amari - (base // 2) + 1)
    res1 = syou * (base // 2) + q
    return res1 % 2


def g(n):  # nを累計xorで表現
    keta = int(math.log2(n) + 1)
    s = ""
    for i in range(keta):
        s = str(f(n, i + 1)) + s
    return s


def xor(a, b):
    max_len = max(len(a), len(b))
    a = (("0" * max_len) + a)[-max_len:]
    b = (("0" * max_len) + b)[-max_len:]

    s = ""
    for i in range(max_len):
        if a[i] != b[i]:
            s += "1"
        else:
            s += "0"
    return s


def to10(s):
    res = 0
    for c in s:
        res *= 2
        if c == "1":
            res += 1
    return res


def main():
    n, m = [int(q) for q in input().split()]
    A = g(n - 1)
    B = g(m)
    res = xor(A, B)
    print(to10(res))


if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict
import math


def f(n, k):
    base = 2 ** k
    syou = n // base
    amari = n % base
    q = max(0, amari - (base // 2) + 1)
    res1 = syou * (base // 2) + q
    return res1 % 2


def g(n):  # nを累計xorで表現
    if n <= 0:
        return "0"
    keta = int(math.log2(n) + 1)
    s = ""
    for i in range(keta):
        s = str(f(n, i + 1)) + s
    return s


def xor(a, b):
    max_len = max(len(a), len(b))
    a = (("0" * max_len) + a)[-max_len:]
    b = (("0" * max_len) + b)[-max_len:]

    s = ""
    for i in range(max_len):
        if a[i] != b[i]:
            s += "1"
        else:
            s += "0"
    return s


def to10(s):
    res = 0
    for c in s:
        res *= 2
        if c == "1":
            res += 1
    return res


def main():
    n, m = [int(q) for q in input().split()]
    A = g(n - 1)
    B = g(m)
    res = xor(A, B)
    print(to10(res))


if __name__ == '__main__':
    main()