Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())

summary = A
for XORed in range(A+1, B+1):
    summary = summary ^ XORed

print(summary)

# def int2bin(x):
#     quotient = x
#     string_bin = ''
#     while(quotient != 1):
#         rest = quotient % 2
#         quotient = int((quotient - rest) / 2)
#         string_bin = str(rest) + string_bin
#     string_bin = '1' + string_bin
#     return int(string_bin)
#
# def bin2int(x):
#     power = int(len(str(x)) - 1)
#     integer = 0
#     i = 0
#     while(power >= 0):
#         integer += 2**power * int(str(x)[i])
#         i += 1
#         power -= 1
#     return integer


# divided_bin_str1 = str(int2bin(A))
# for divided in range(A+1, B+1):
#     added = ''
#     divided_bin_str2 = str(int2bin(divided))
#     if len(divided_bin_str1) < len(divided_bin_str2):
#         divided_bin_str1 = '0' + divided_bin_str1
#     else:
#         pass
#     # print(divided_bin_str1, divided_bin_str2)
#     for i in range(len(divided_bin_str1)):
#         ans = int(divided_bin_str1[i]) + int(divided_bin_str2[i])
#         if ans == 1:
#             added += '1'
#         else:
#             added += '0'
#     divided_bin_str1 = added
#
# added = int(added)
# ans = bin2int(added)
#
# print(ans)


Fixed submission:
A, B = map(int, input().split())

# summary = A
# for XORed in range(A+1, B+1):
#     summary = summary ^ XORed

def XORfromZERO(x):
    rest = x % 2
    quotient = (x + rest) / 2
    if rest == 0:
        if quotient % 2 == 0:
            return 0 ^ x
        else:
            return 1 ^ x
    else:
        if quotient % 2 == 0:
            return 0
        else:
            return 1

print(XORfromZERO(A-1) ^ XORfromZERO(B))

Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())

# def int2bin(x):
#     quotient = x
#     string_bin = ''
#     while(quotient != 1):
#         rest = quotient % 2
#         quotient = int((quotient - rest) / 2)
#         string_bin = str(rest) + string_bin
#     string_bin = '1' + string_bin
#     return int(string_bin)
#
# def bin2int(x):
#     power = int(len(str(x)) - 1)
#     integer = 0
#     i = 0
#     while(power >= 0):
#         integer += 2**power * int(str(x)[i])
#         i += 1
#         power -= 1
#     return integer


# divided_bin_str1 = str(int2bin(A))
# for divided in range(A+1, B+1):
#     added = '0'
#     divided_bin_str2 = str(int2bin(divided))
#     if len(divided_bin_str1) < len(divided_bin_str2):
#         divided_bin_str1 = '0' + divided_bin_str1
#     else:
#         pass
#     # print(divided_bin_str1, divided_bin_str2)
#     for i in range(len(divided_bin_str1)):
#         ans = int(divided_bin_str1[i]) + int(divided_bin_str2[i])
#         if ans == 1:
#             added += '1'
#         else:
#             if added == '0':
#                 pass
#             else:
#                 added += '0'
#     divided_bin_str1 = added
#
# added = int(added)
# ans = bin2int(added)
#
# print(ans)

summary = A
for XORed in range(A+1, B+1):
    summary = summary ^ XORed

print(summary)


Fixed submission:
A, B = map(int, input().split())

# summary = A
# for XORed in range(A+1, B+1):
#     summary = summary ^ XORed

def XORfromZERO(x):
    rest = x % 2
    quotient = (x + rest) / 2
    if rest == 0:
        if quotient % 2 == 0:
            return 0 ^ x
        else:
            return 1 ^ x
    else:
        if quotient % 2 == 0:
            return 0
        else:
            return 1

print(XORfromZERO(A-1) ^ XORfromZERO(B))