Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque

V = list(input())
S = deque()
S.extend(V)
Q = int(input())

r = 0
for i in range(Q):
    c = sys.stdin.readline().split()
    
    #print('s:', S)
    #print('c:', c)

    if c[0] == '1':
        if r == 0: r+= 1
        else: r -= 1
        continue

    else:            
        if r == 1:
            S.reverse()
            r -= 1

        if c[1] == '1':
            S.appendleft(c[2])
        else:
            S.append(c[2])

if r == 1:
    S.reverse()

print(''.join(S))

Fixed submission:
import sys
from collections import deque

V = list(input())
S = deque()
S.extend(V)
Q = int(input())

memo = []
r = 0
for i in range(Q):
    c = sys.stdin.readline().split()
    #print(c)
    if c[0] == '1':
        r += 1
        continue
    else:
        if c[1] == '1':
            memo.append((r, c[2]))
        else:
            memo.append((r+1, c[2]))
        
#print(memo)        
if r % 2 == 1:
    S.reverse()

for m in memo:
    s, l = m
    s = r - s
    if s % 2 == 0:
        S.appendleft(l)
    else:
        S.append(l)    

print(''.join(S))

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

V = list(input())
S = deque()
S.extend(V)
Q = int(input())

for i in range(Q):
    c = sys.stdin.readline().split()
    #print('s:', S)
    #print('c:', c)

    if c[0] == '1':
        S.reverse()
    else:
        if c[1] == '1':
            S.appendleft(c[2])
        else:
            S.append(c[2])

print(''.join(S))

Fixed submission:
import sys
from collections import deque

V = list(input())
S = deque()
S.extend(V)
Q = int(input())

memo = []
r = 0
for i in range(Q):
    c = sys.stdin.readline().split()
    #print(c)
    if c[0] == '1':
        r += 1
        continue
    else:
        if c[1] == '1':
            memo.append((r, c[2]))
        else:
            memo.append((r+1, c[2]))
        
#print(memo)        
if r % 2 == 1:
    S.reverse()

for m in memo:
    s, l = m
    s = r - s
    if s % 2 == 0:
        S.appendleft(l)
    else:
        S.append(l)    

print(''.join(S))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
SC = [[] for _ in range(N)]

error = False
for _ in range(M):
    s, c = map(int, input().split())
    s -= 1
    if SC[s] and SC[s] != c:
        error = True
        break
    else:
        SC[s] = c

if error:
    print(-1)
elif SC[0] == 0 and len(SC) > 1:
    print(-1)
else:
    if not SC[0]:
        SC[0] = 1
    if not SC[1]:
        SC[1] = 0
    if not SC[2]:
        SC[2] = 0
    print(''.join(map(str,SC)))

Fixed submission:
N, M = map(int, input().split())
A = [float('inf') for _ in range(N)]

for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    
    if A[s] != float('inf') and A[s] != c:
        print(-1)
        exit()

    A[s] = min(A[s], c)
    #A[s] = c

for i in range(1, N):
    if A[i] == float('inf'):
        A[i] = '0'
    A[i] = str(A[i]) 

#print(A)

if A[0] == float('inf'):
    if len(A) == 1: A[0] = '0'
    else: A[0] = '1'
else:
    A[0] = str(A[0])

ans = int(''.join(A))

if len(str(ans)) == N: print(ans)
else: print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())

attack = []
magic = []
for i in range(n):
    a, b = map(int, input().split())
    attack.append(a)
    magic.append(b)

dp = [[float('inf') for _ in range(h+1)] for _ in range(n+1)]
dp[0][0] = 0
#print(attack, magic)
for i in range(n):
    for j in range(h+1):
        #print(max(dp[i][j], dp[i][j-attack[i]] + magic[i]))
        if dp[i+1][j] > dp[i][j]: dp[i+1][j] = dp[i][j]
        if dp[i+1][min(j+attack[i], h)] > dp[i+1][j]+magic[i]: dp[i+1][min(j+attack[i], h)] = dp[i+1][j]+magic[i]

print(dp[-1][-1])

Fixed submission:
h, n = map(int, input().split())
magic = [tuple(map(int, input().split())) for _ in range(n)]
#magic = [list(map(int, input().split())) for _ in range(n)]

dp = [float('inf')] * (h+1)
dp[0] = 0

for i in range(h):
    for d, c in magic:
        next_index = min(i+d, h)
        dp[next_index] = min(dp[next_index], dp[i]+c)
        #print(d, c, dp)

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
magic = [tuple(map(int, input().split())) for _ in range(n)]
#magic = [list(map(int, input().split())) for _ in range(n)]

dp = [float('inf')] * (h+1)
dp[0] = 0

for i in range(h):
    for d, c in magic:
        next_index = min(i+d, h)
        dp[next_index] = min(dp[next_index], dp[i]+c)
        #print(d, c, dp)

print(dp[-1])

Fixed submission:
h, n = map(int, input().split())
magic = [tuple(map(int, input().split())) for _ in range(n)]
#magic = [list(map(int, input().split())) for _ in range(n)]

dp = [float('inf')] * (h+1)
dp[0] = 0

for i in range(h):
    for d, c in magic:
        next_index = min(i+d, h)
        dp[next_index] = min(dp[next_index], dp[i]+c)
        #print(d, c, dp)

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(n)]

dp = [float('inf')] * (h+1)
dp[0] = 0

for i in range(h):
    for d, c in magic:
        next_index = min(i+d, h)
        dp[next_index] = min(dp[next_index], dp[i]+c)
        #print(d, c, dp)

print(dp[-1])

Fixed submission:
h, n = map(int, input().split())
magic = [tuple(map(int, input().split())) for _ in range(n)]
#magic = [list(map(int, input().split())) for _ in range(n)]

dp = [float('inf')] * (h+1)
dp[0] = 0

for i in range(h):
    for d, c in magic:
        next_index = min(i+d, h)
        dp[next_index] = min(dp[next_index], dp[i]+c)
        #print(d, c, dp)

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import fractions

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

g = lcm(a[0], a[1])

for val in a[2:]:
    g = lcm(g, val)

ans = 0
for val in a:
    ans += g//val % mod

print(ans % mod)

Fixed submission:
import fractions

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

aset = set(a)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

if n == 1:
    print(1)

elif 1 < n:
    g = lcm(a[0], a[1])

    if n != 2:
        for val in aset:
            g = lcm(g, val)

    ans = 0
    for val in a:
        ans += g//val

    print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

dp = [0 for _ in range(n+1)]

def ans(dp, n, m) -> list:
    if m == 0:
        return [0, 0]

    answerd = []
    ac = 0
    wa = 0
    i = 0
    while i < m:
        q, r = input().split()
        q = int(q)

        if q in answerd:
            pass
        elif r == 'WA':
            dp[q] += 1
        elif r == 'AC':
            ac += 1
            wa += dp[q]
            answerd.append(q)

        i += 1

    return [ac, wa]

a = ans(dp, n, m)

print(*a)

Fixed submission:
n, m = map(int, input().split())

dp = [0 for _ in range(n+1)]

def ans(dp, n, m) -> list:
    if m == 0:
        return [0, 0]

    ac = 0
    wa = 0
    i = 0
    while i < m:
        q, r = input().split()
        q = int(q)

        if dp[q] == None:
            pass
        elif r == 'WA':
            dp[q] += 1
        elif r == 'AC':
            ac += 1
            wa += dp[q]
            dp[q] = None

        i += 1

    return [ac, wa]

a = ans(dp, n, m)

print(*a)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

if 0 == (b-a) % 2:
    print((b-a) // 2)

else:
    upper = max(a-1, b-1)
    lower = max(n-a, n-b)

	print(min(upper, lower))

Fixed submission:
def upper_cnt(a, b):
    upper_cnt = n-b + 1
    a += upper_cnt
    upper_cnt += ((n-a) // 2)    
    return upper_cnt

def lower_cnt(a, b):
    lower_cnt = a-1 + 1
    b -= lower_cnt
    lower_cnt += ((b-1) // 2)
    return lower_cnt

n, a, b = map(int, input().split())

if 0 == (b-a) % 2:
    print((b-a) // 2)

else:
    up = upper_cnt(a, b)
    low = lower_cnt(a, b)
    print(min(up, low))

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

if 0 == (b-a) % 2:
    print((b-a) // 2)

else:
    upper = max(a-1, b-1)
    lower = max(n-a, n-b)

print(min(upper, lower))

Fixed submission:
def upper_cnt(a, b):
    upper_cnt = n-b + 1
    a += upper_cnt
    upper_cnt += ((n-a) // 2)    
    return upper_cnt

def lower_cnt(a, b):
    lower_cnt = a-1 + 1
    b -= lower_cnt
    lower_cnt += ((b-1) // 2)
    return lower_cnt

n, a, b = map(int, input().split())

if 0 == (b-a) % 2:
    print((b-a) // 2)

else:
    up = upper_cnt(a, b)
    low = lower_cnt(a, b)
    print(min(up, low))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(i) for i in input().split()]
divide = 10 ** 9 + 7

inf=float("inf")
dp=[[inf for i in range(n+1)] for j in range(n+1)]

sum = 0
for i in range(n):
    for j in range(i+1, n):
        if dp[i][j] != inf or dp[j][i] != inf:
            sum += dp[i][j]
            print('yes')
        else:
            val =  a_list[i] ^ a_list[j]
            dp[i][j] = val
            dp[j][i] = val
            sum += val

print(sum % divide)

Fixed submission:
n = int(input())
divide = 10 ** 9 + 7

a = [format(i, '060b') for i in map(int, input().split())]
ans = []

for i in range(60):
    bit_list = [b[59-i] for b in a]
    val = bit_list.count('0') * bit_list.count('1')
    ans.append((val * 2 ** i))

print(sum(ans)%divide)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(i) for i in input().split()]
divide = 10 ** 9 + 7

sum = 0
for i in range(n):
    for j in range(i+1, n):
        # print(a_list[i], a_list[j] , a_list[i] ^ a_list[j])
        sum += (a_list[i] ^ a_list[j]) % divide

print(sum  % divide)

Fixed submission:
n = int(input())
divide = 10 ** 9 + 7

a = [format(i, '060b') for i in map(int, input().split())]
ans = []

for i in range(60):
    bit_list = [b[59-i] for b in a]
    val = bit_list.count('0') * bit_list.count('1')
    ans.append((val * 2 ** i))

print(sum(ans)%divide)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(i) for i in input().split()]
divide = 10 ** 9 + 7

sum = 0
for i in range(n):
    for j in range(i+1, n):
        # print(a_list[i], a_list[j] , a_list[i] ^ a_list[j])
        sum += (a_list[i] ^ a_list[j])

print(sum % divide)

Fixed submission:
n = int(input())
divide = 10 ** 9 + 7

a = [format(i, '060b') for i in map(int, input().split())]
ans = []

for i in range(60):
    bit_list = [b[59-i] for b in a]
    val = bit_list.count('0') * bit_list.count('1')
    ans.append((val * 2 ** i))

print(sum(ans)%divide)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
S = input()

ans = set(itertools.combinations(S, 3))
print(len(ans))


Fixed submission:
N = int(input())
S = input()

cnt = 0
for i in range(1000):
    key = str(i).zfill(3)
    ki = 0
    for j in range(N):
        if key[ki] == S[j]: ki += 1
        if ki == 3:
            cnt += 1
            break

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

cnt = 0
for i in range(1000):
    key = str(i).zfill(3)
    ki = 0
    for j in range(N):
        if key[ki] == S[j]: ki += 1
        if ki == 3:
            cnt += 1
            break

print(cnt)


Fixed submission:
N = int(input())
S = input()

cnt = 0
for i in range(1000):
    key = str(i).zfill(3)
    ki = 0
    for j in range(N):
        if key[ki] == S[j]: ki += 1
        if ki == 3:
            cnt += 1
            break

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
S = input()

ans = set(itertools.combinations(S, 3))
print(len(ans))

Fixed submission:
N = int(input())
S = input()

cnt = 0
for i in range(1000):
    key = str(i).zfill(3)
    ki = 0
    for j in range(N):
        if key[ki] == S[j]: ki += 1
        if ki == 3:
            cnt += 1
            break

print(cnt)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = list(input())

cnt = 0

i = 1
while i < len(s):
    print(i, s, cnt)
    if cnt == k:
        break

    if s[i] != s[i-1]:
        cnt += 1
        start = i
        target = s[i]

        while  i < len(s) and target == s[i]:
            if s[i] == 'R': s[i] = 'L'
            else: s[i] = 'R'

            i += 1   

        continue    

    i += 1

ans = 0
for i in range(1, len(s)):
    if s[i] == s[i-1]:
        ans += 1

print(ans)



Fixed submission:
n, k = map(int, input().split())
s = list(input())

cnt = 0

i = 1
while i < len(s):
    if cnt == k:
        break

    if s[i] != s[i-1]:
        cnt += 1
        start = i
        target = s[i]

        while  i < len(s) and target == s[i]:
            if s[i] == 'R': s[i] = 'L'
            else: s[i] = 'R'

            i += 1   

        continue    

    i += 1

ans = 0
for i in range(1, len(s)):
    if s[i] == s[i-1]:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

cost = [0 for _ in range(n)]
for _ in range(q):
    pos, point = map(int, input().split())
    cost[pos-1] += point

ans = [0 for i in range(n)]
memo = [0]

def dfs(i, cnt, ans, memo):
    cnt += cost[i]
    ans[i] = cnt
    if not tree[i]:
        return

    for x in tree[i]:
        if x in memo:
            continue
        memo.append(x)
        dfs(x, cnt, ans, memo)

dfs(0, 0, ans, memo)

print(*ans)

Fixed submission:
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

cost = [0 for _ in range(n)]
for _ in range(q):
    pos, point = map(int, input().split())
    cost[pos-1] += point

memo = set([0])
stack = [0]

while len(stack) > 0:
    cur_node = stack.pop()
    cur_cost = cost[cur_node]

    for node in tree[cur_node]:
        if node not in memo:
            memo.add(node)
            cost[node] += cur_cost
            stack.append(node)

print(*cost)

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)

cost = [0 for _ in range(n)]
for _ in range(q):
    pos, point = map(int, input().split())
    cost[pos-1] += point

ans = [0 for i in range(n)]

def dfs(i, cnt, ans):
    cnt += cost[i]
    ans[i] = cnt
    if not tree[i]:
        return

    for x in tree[i]:
        dfs(x, cnt, ans)

dfs(0, 0, ans)

print(*ans)

Fixed submission:
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

cost = [0 for _ in range(n)]
for _ in range(q):
    pos, point = map(int, input().split())
    cost[pos-1] += point

memo = set([0])
stack = [0]

while len(stack) > 0:
    cur_node = stack.pop()
    cur_cost = cost[cur_node]

    for node in tree[cur_node]:
        if node not in memo:
            memo.add(node)
            cost[node] += cur_cost
            stack.append(node)

print(*cost)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
stairs = list([int(input()) for i in range(m)])
dp = [0] * (n+1)
dp[0] = 1

for i in range(1, n+1):
    if i in stairs: 
        dp[i] = 0
        continue

    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)

print(dp[n])

Fixed submission:
n, m = map(int,input().split())
stairs = set([int(input()) for i in range(m)])
dp = [0] * (n+1)
dp[0] = 1

for i in range(1, n+1):
    if i in stairs: 
        dp[i] = 0
        continue

    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)

print(dp[n])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
cards = sorted(list(map(int, input().split())))
sum_cards = [cards[0]]
for i in range(1, n):
    sum_cards.append(cards[i-1] + cards[i])

changer = []
for i in range(m):
    p, c = map(int, input().split())
    gap = p*c - sum_cards[p-1]
    changer.append((p, c, gap))

changer.sort(key=lambda x: x[2])

cur = 0
while len(changer):
    p, c, _ = changer.pop()
    i = cur
    while i < cur + p:
        if cards[i] < c: cards[i] = c
        else: break
        i += 1
    cur = i
print(sum(cards))

Fixed submission:
n, m = map(int, input().split())
cards = sorted(list(map(int, input().split())))

changer = []
for i in range(m):
    p, c = map(int, input().split())
    changer.append((p, c))

changer.sort(key=lambda x: x[1])

cur = 0
while len(changer) and cur < n:
    p, c = changer.pop()
    i = cur
    while i < n and i < cur + p:
        if cards[i] < c: cards[i] = c
        else: break
        i += 1
    cur = i
print(sum(cards))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = input()
ss = []

cnt = 0

if s[0] == '0': ss.append(0)
i = 0
while i < n:
    j = i
    while j < n and s[i] == s[j]: j += 1
    ss.append(j-i)
    i = j
if s[-1] == '0': ss.append(0)

#print(ss)
ans = []
i = 0
while i < n:
    #print(ans, i, sum(ss[i:i+2*k+1]))
    #if i+2*k+1 > n:
    #    break
    ans.append(sum(ss[i:i+2*k+1]))
    i += 2

print(max(ans))


Fixed submission:
n, k = map(int, input().split())
s = input()
ss = []

cnt = 0

if s[0] == '0': ss.append(0)
i = 0
while i < n:
    j = i
    while j < n and s[i] == s[j]: j += 1
    ss.append(j-i)
    i = j
if s[-1] == '0': ss.append(0)

right = 2*k+1
left = 0
val = sum(ss[:right])
ans = val

#print(ss)
while right < len(ss):
    for i in [1, 2]:
        #print('for', ss[left], ss[right])
        val += ss[right]
        val -= ss[left]
        left += 1
        right += 1
    #print(left, right, val)
    ans = max(ans, val)
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = input()
ss = []

cnt = 0

if s[0] == '0': ss.append(0)
i = 0
while i < n:
    j = i
    while j < n and s[i] == s[j]: j += 1
    ss.append(j-i)
    i = j
if s[-1] == '0': ss.append(0)

#print(ss)
ans = 0
i = 0
while i < n:
    #print(ans, i, sum(ss[i:i+2*k+1]))
    #if i+2*k+1 > n:
    #    break
    ans = max(ans, sum(ss[i:i+2*k+1]))

    i += 2

print(ans)


Fixed submission:
n, k = map(int, input().split())
s = input()
ss = []

cnt = 0

if s[0] == '0': ss.append(0)
i = 0
while i < n:
    j = i
    while j < n and s[i] == s[j]: j += 1
    ss.append(j-i)
    i = j
if s[-1] == '0': ss.append(0)

right = 2*k+1
left = 0
val = sum(ss[:right])
ans = val

#print(ss)
while right < len(ss):
    for i in [1, 2]:
        #print('for', ss[left], ss[right])
        val += ss[right]
        val -= ss[left]
        left += 1
        right += 1
    #print(left, right, val)
    ans = max(ans, val)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
*args, = [int(input()) for _ in range(n)]

worst = min(args)

print(6 + n // worst)

Fixed submission:
import math

n = int(input())
traffic_list = [int(input()) for _ in range(5)]

print(4 + math.ceil(n/min(traffic_list)))
Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
result = []

for c in range(z):
    for b in range(y):
        for a in range(x):
            result.append(A[a] + B[b] + C[c])

result.sort()
[print(val) for val in result[-k:][::-1]]

Fixed submission:
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
result = []

def func1():
    E = [a+b for a in A for b in B]
    E.sort()
    if len(E) > k: E = E[-k:]
    F = [c+e for c in C for e in E]
    F.sort()
    return F[-k:][::-1]

[print(val) for val in func1()]
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())

word = input()

for _ in range(q):
    start, end = map(int, input().split())
    cnt = word[start-1:end].count('AC')
    print(cnt)


Fixed submission:
n, q = map(int, input().split())

word = input()

counter = [0] * n

for i in range(1, len(word)):
    counter[i] = counter[i-1]
    if word[i-1] + word[i] == 'AC':
        counter[i] += 1

for i in range(q):
    start, end = map(int, input().split())
    print(counter[end-1] - counter[start-1])
Buggy python submission (verdict: Runtime Error):
num = int(input())
words = input()

words_count = {}
for key in words:
    if words_count[key] in words_count:
        words_count[key] += 1
    else:
        words_count[key] = 1

ans = 1
for key, val in words_count:
    ans *= (val + 1)

print(ans - 1)

Fixed submission:
num = int(input())
words = input()
mod = 10**9+7

words_count = {}
for key in words:
    if key in words_count:
        words_count[key] += 1
    else:
        words_count[key] = 1

ans = 1
for key, val in words_count.items():
    ans *= (val + 1)

print((ans - 1) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())

bit = ['0' for _ in range(41)]
while a <= b:
    val = bin(a)[2:]
    for i in range(1, len(val)+1):
        if val[-i] == '1' and bit[-i] == '0': bit[-i] = '1'
        elif val[-i] == '1' and bit[-i] == '1': bit[-i] = '0'
    a += 1
print(int(''.join(bit), 2))

Fixed submission:
a, b = map(int, input().split())
if a%2 == b%2: # 3, 4, 5  => 3^1 / 4, 5, 6 => 1^6
    k = (b-a)//2
    print(b^(k%2) if a%2==0 else a^(k%2))
elif a%2 == 0 and b%2 == 1: # 4, 5, 6, 7 => 1^1
    print(((b-a+1)//2)%2)
elif a%2 == 1 and b%2 ==0: # 3, 4, 5, 6 => 3^1^6
    print(a^b^((b-a-1)//2)%2)

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

bit = [[0, 0] for _ in range(41)]
while a <= b:
    val = bin(a)[2:]
    for i in range(1, len(val)+1):
        if val[-i] == '0': bit[-i][0] += 1
        else: bit[-i][1] += 1

    a += 1

ans = [0 for _ in range(41)]

for i in range(41):
    if bit[i][1] % 2 == 1: ans[i] = '1'
    else: ans[i] = '0'
        
print(int(''.join(ans), 2))

Fixed submission:
a, b = map(int, input().split())
if a%2 == b%2: # 3, 4, 5  => 3^1 / 4, 5, 6 => 1^6
    k = (b-a)//2
    print(b^(k%2) if a%2==0 else a^(k%2))
elif a%2 == 0 and b%2 == 1: # 4, 5, 6, 7 => 1^1
    print(((b-a+1)//2)%2)
elif a%2 == 1 and b%2 ==0: # 3, 4, 5, 6 => 3^1^6
    print(a^b^((b-a-1)//2)%2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
input_list = list(map(int, input().split()))
ans_list = input_list[::-2] + input_list[n%2::2]
print(*ans_list)

Fixed submission:
s = input()
zero = s.count('0')
one = s.count('1')

print(min(zero, one) * 2)