Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())

num = np.zeros(10 ** 9, dtype = bool)

for i in range(n):
    a = int(input())

    num[a] = not(num[a])

sum = np.where(num == True) 

print(len(sum[0]))

Fixed submission:
import numpy as np

n = int(input())

a = np.zeros(n, dtype = int)

for i in range(n):
    a[i] = int(input())

a = np.sort(a)

sum = 0
for i in range(n):
    if(i == 0):
        flag = 1
    elif(a[i - 1] == a[i]):
        flag += 1
    else:
        if(flag % 2 == 1):
            sum += 1
        else:
            flag = 1

if(flag % 2 == 1):
    sum += 1

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

buf = set(range(1, n+1))
for i in range(m):
    l, r = map(int, input().split())
    buf = buf & set(range(l, r+1))
print(len(buf))


Fixed submission:
a = 1

n, m = map(int, input().split())
ans_r = 10 ** 5

l_list = []
r_list = []
for i in range(m):
    l, r = map(int, input().split())
    l_list.append(int(l))
    r_list.append(int(r))
for r in r_list:
    if ans_r > r:
        ans_r = r
for l in l_list:
    if a < l:
        a = l

if ans_r >= a:
    print(ans_r - a + 1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = list(input())
s[k] = s[k].lower()
print("".join(s))


Fixed submission:
n, k = map(int, input().split())
s = list(input())
s[k-1] = s[k-1].lower()
print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""

R,G,B,N = tuple(map(int,input().split()))
L = [R,G,B]
L.sort(reverse=True)
c = 0
rmax = N//L[0]

for i in range(rmax+1):
    gmax = (N-L[0]*i)//L[1]
    for j in range(gmax+1):
        bmax = (N-L[0]*i-L[1]*j)//L[2]
        for k in range(bmax+1):
            if L[0]*i+L[1]*j+L[2]*k == N:
                c += 1

print(c)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""

R,G,B,N = tuple(map(int,input().split()))
L = [R,G,B]
L.sort(reverse=True)
c = 0
rmax = N//L[0]

for i in range(rmax+1):
    Nc = N
    Nc -= i*L[0]
    if Nc%L[2] == 0:
            c += 1
    while True:
        Nc -= L[1]
        if Nc < 0:
            break
        if Nc%L[2] == 0:
            c += 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""

R,G,B,N = tuple(map(int,input().split()))
c = 0
rmax = N//R

for i in range(rmax+1):
    gmax = (N-R*i)//G
    for j in range(gmax+1):
        bmax = (N-R*i-G*j)//B
        for k in range(bmax+1):
            if R*i+G*j+B*k == N:
                c += 1

print(c)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""

R,G,B,N = tuple(map(int,input().split()))
L = [R,G,B]
L.sort(reverse=True)
c = 0
rmax = N//L[0]

for i in range(rmax+1):
    Nc = N
    Nc -= i*L[0]
    if Nc%L[2] == 0:
            c += 1
    while True:
        Nc -= L[1]
        if Nc < 0:
            break
        if Nc%L[2] == 0:
            c += 1

print(c)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
K = int(input())
a = S[K]
for i in range(N):
    if S[i] != a:
        S[i] = "*"
print(S)

Fixed submission:
N = int(input())
S = input()
K = int(input())
a = S[K-1]
ans = ""
for i in range(N):
    if S[i] != a:
        ans += "*"
    else:
        ans += S[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
c = 0
for i in range(N - 1, -1, -1):
    if S[i] == ".":
        c1 = i
        break
cc = 0
for i in range(N - 1, c1, -1):
    if S[i] == "#":
        cc += 1
a = S[:i + 1].count(".")
b = S[:i + 1].count("#")
ans = min(a, b, cc)
print(ans)


Fixed submission:
N = int(input())
S = input()
r1 = [0] * N
r2 = [0] * (N+1)
r1[0] = 1 * (S[0] == '#')
for i in range(1, N):
    if S[i] == "#":
        r1[i] = r1[i - 1] + 1
    else:
        r1[i] = r1[i - 1]
#print(r1)
r2[N - 1] = 1 * (S[N - 1] == ".")
r2[N] = r2[N-1]
for i in range(N - 2, -1, -1):
    if S[i] == ".":
        r2[i] = r2[i + 1] + 1
    else:
        r2[i] = r2[i + 1]
#print(r2)
c1 = S.count("#")
c2 = S.count(".")
ans = N
for i in range(N):
    ans = min(ans, r1[i] + r2[i + 1])
print(min(ans, c1, c2))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
c = 0
for i in range(N - 1, -1, -1):
    if S[i] == ".":
        c1 = i
        break
cc = 0
for i in range(N - 1, c1, -1):
    if S[i] == "#":
        cc += 1
a = S[:i + 1].count(".")
b = S[:i + 1].count("#")
ans = min(a, b, c2)
print(ans)

Fixed submission:
N = int(input())
S = input()
r1 = [0] * N
r2 = [0] * (N+1)
r1[0] = 1 * (S[0] == '#')
for i in range(1, N):
    if S[i] == "#":
        r1[i] = r1[i - 1] + 1
    else:
        r1[i] = r1[i - 1]
#print(r1)
r2[N - 1] = 1 * (S[N - 1] == ".")
r2[N] = r2[N-1]
for i in range(N - 2, -1, -1):
    if S[i] == ".":
        r2[i] = r2[i + 1] + 1
    else:
        r2[i] = r2[i + 1]
#print(r2)
c1 = S.count("#")
c2 = S.count(".")
ans = N
for i in range(N):
    ans = min(ans, r1[i] + r2[i + 1])
print(min(ans, c1, c2))
Buggy python submission (verdict: Runtime Error):
a, b, c  = map(int, input().split())
if len(set(a, b, c)) == 1:
  	print('Yes')
else:
  	print('No')

Fixed submission:
a, b, c = map(int, input().split())
l = {a, b, c}
if len(l) == 1:
  	print('Yes')
else:
  	print('No')
Buggy python submission (verdict: Runtime Error):
s = input()
c = 0
ans = []
for a in s:
    if a in ["A", "C","G", "T"]:
        c += 1
    else:
        ans.append(c)
        c = 0
print(max(ans))


Fixed submission:
s = input()
cnt = 0
res = []
res.append(0)
for a in s:
    if a in ["A", "G", "C", "T"]:
        cnt += 1
    else:
        res.append(cnt)
        cnt = 0
    res.append(cnt)
print(max(res))

Buggy python submission (verdict: Runtime Error):
s = input()
c = 0
ans = []
for a in s:
    if a in ["A", "C","G", "T"]:
        c += 1
    else:
        ans.append(cnt)
        c = 0
print(max(ans))

Fixed submission:
s = input()
cnt = 0
res = []
res.append(0)
for a in s:
    if a in ["A", "G", "C", "T"]:
        cnt += 1
    else:
        res.append(cnt)
        cnt = 0
    res.append(cnt)
print(max(res))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
    S.append(input())

count_AB = 0
lefter_B = 0
righter_A = 0
only_lefter_B = 0
only_righter_A = 0
for i in range(N):
    count_AB += S[i].count('AB')
    if S[i][0] == 'B':
        lefter_B += 1
    if S[i][len(S[i])-1] == 'A':
        righter_A += 1
    if (S[i][0] == 'B')and(S[i][len(S[i])-1] != 'A'):
        only_lefter_B += 1
    if (S[i][0] != 'B')and(S[i][len(S[i])-1] == 'A'):
        only_righter_A += 1
        
if (only_lefter_B==0) and (only_righter_A==0):
    Appearing_AB = max(min(lefter_B,righter_A) - 1 , 0)
else:
    Appearing_AB = min(lefter_B,righter_A)


print(count_AB + Appearing_AB)



Fixed submission:
N, K = map(int,input().split())
print(N-K+1)
Buggy python submission (verdict: Runtime Error):
import fraction
from functools import reduce


def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)


N = input()
A = input().split()
for i in range(len(A)):
    A[i] = int(A[i]) 
print("{}".format(gcd_list(A)))

Fixed submission:
A, B = map(int, input().split())
if B%A==0:
    print("{}".format(A+B))
else:
    print("{}".format(B-A))
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce



def gcd_list(numbers):
    return reduce(math.gcd, numbers)


N = input()
A = input().split()
for i in range(len(A)):
    A[i] = int(A[i])
answer = gcd_list(A)
print("{}".format(answer))

Fixed submission:
from functools import reduce

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcd_list(numbers):
    return reduce(gcd, numbers)


N = input()
A = input().split()
for i in range(len(A)):
    A[i] = int(A[i])
answer = gcd_list(A)
print("{}".format(answer))

Buggy python submission (verdict: Runtime Error):
import fraction
from functools import reduce


def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)


N = input()
A = input().split()
for i in range(len(A)):
    A[i] = int(A[i]) 
print("{}".format(gcd_list(A)))

Fixed submission:
from functools import reduce

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcd_list(numbers):
    return reduce(gcd, numbers)


N = input()
A = input().split()
for i in range(len(A)):
    A[i] = int(A[i])
answer = gcd_list(A)
print("{}".format(answer))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


N = input()
A = input().split()
for i in range(len(A)):
    A[i] = int(A[i]) 
print("{}".format(gcd_list(A)))

Fixed submission:
from functools import reduce

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcd_list(numbers):
    return reduce(gcd, numbers)


N = input()
A = input().split()
for i in range(len(A)):
    A[i] = int(A[i])
answer = gcd_list(A)
print("{}".format(answer))
Buggy python submission (verdict: Runtime Error):
n = input().split(" ")

a = int(n[0])
b = int(n[1])
t = int(n[2])

w = (t / a)
pritn(w * b)

Fixed submission:
n = input().split(" ")
 
a = int(n[0])
b = int(n[1])
t = int(n[2])
 
w = int(t / a)
print(w * b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
vs = input().split(" ")
cs = input().split(" ")

xy = 0
for i in range(n):
  v = vs[i]
  c = cs[i]
  if v>c:
    xy += v-c

print(xy)

Fixed submission:
n = int(input())
vs = input().split(" ")
cs = input().split(" ")
 
xy = 0
for i in range(n):
  v = int(vs[i])
  c = int(cs[i])
  if v>c:
    xy += v-c
 
print(xy)
Buggy python submission (verdict: Runtime Error):
a = input().split(' ')
h1 = int(a[0])
h2 = int(a[1])
h3 = int(a[2])
 
if h1 < h3 && h3 < h2:
  print('Yes')
else:
  print('No')

Fixed submission:
a = input().split(' ')
h1 = int(a[0])
h2 = int(a[1])
h3 = int(a[2])
 
if h1 < h3 and h3 < h2:
  print('Yes')
else:
  if h2 < h3 and h3 < h1:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Runtime Error):
a = input().split(" ")
h1 = int(a[0])
h2 = int(a[1])
h3 = int(a[2])

if h1 <= h3 && h3 <= h2:
  print('Yes')
else:
  print('No')

Fixed submission:
a = input().split(' ')
h1 = int(a[0])
h2 = int(a[1])
h3 = int(a[2])
 
if h1 < h3 and h3 < h2:
  print('Yes')
else:
  if h2 < h3 and h3 < h1:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
K = input()
 
moji = S[K-1]
ns = ''
for s in S:
  if moji == s:
    ns += moji
  else:
    ns += '*'
print(ns)

Fixed submission:
N = int(input())
S = input()
K = int(input())
 
moji = S[K-1]
ns = ''
for s in S:
  if moji == s:
    ns += moji
  else:
    ns += '*'
print(ns)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
K = input()
 
moji = S[K-1]
ns = ''
for s in S:
  if moji == s:
    ns += moji
  else:
    ns += '*'
print(ns)

Fixed submission:
N = int(input())
S = input()
K = int(input())
 
moji = S[K-1]
ns = ''
for s in S:
  if moji == s:
    ns += moji
  else:
    ns += '*'
print(ns)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
K = input()

moji = S[K-1]

for s in S:
  if moji == s:
    print(moji, end='')
  else:
    print('*', end='')
print()

Fixed submission:
N = int(input())
S = input()
K = int(input())
 
moji = S[K-1]
ns = ''
for s in S:
  if moji == s:
    ns += moji
  else:
    ns += '*'
print(ns)
Buggy python submission (verdict: Runtime Error):
w = input().split()

a = w[0]
b = w[1]

c = 0
for i in range(2):
  if a>=b:
    c += a
    a -= 1
  else:
    c += b
    b -= 1

print(c)

Fixed submission:
w = input().split()
 
a = int(w[0])
b = int(w[1])
 
c = 0
for i in range(2):
  if a>=b:
    c += a
    a -= 1
  else:
    c += b
    b -= 1
 
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
data = list(map(int, input().split()))
R = data[0]
G = data[1]
B = data[2]
N = data[3]

# R * a + G * b + B * c 

a = N // R + 1
b = N // G + 1
# c = N // B + 1
res = 0

for Ri in range(a):
    Rx = Ri * R
    if Rx > N:
        break
    for Gi in range(b):
        Gx = Gi * G
        if Rx + Gx > N:
            break
        if (N - Rx - Gx) % B == 0:
            res = res + 1

print(res)


Fixed submission:
data = list(map(int, input().split()))
R = data[0]
G = data[1]
B = data[2]
N = data[3]

# R * a + G * b + B * c 

a = N // R + 1
b = N // G + 1
# c = N // B + 1
res = 0

def check(Ri):
    global res
    Rx = Ri * R
    if Rx > N:
        return
    for Gi in range(b):
        Gx = Gi * G
        if Rx + Gx > N:
            break
        if (N - Rx - Gx) % B == 0:
            res = res + 1

[check(Ri) for Ri in range(a)]

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
data = list(map(int, input().split()))
R = data[0]
G = data[1]
B = data[2]
N = data[3]

# R * a + G * b + B * c 

a = N // R + 1
b = N // G + 1
# c = N // B + 1
res = 0

for Ri in range(a):
    if Ri * R > N:
        break
    for Gi in range(b):
        if Ri * R + Gi * G > N:
            break
        if (N - (Ri * R) - (Gi * G)) % B == 0:
            res = res + 1

print(res)


Fixed submission:
data = list(map(int, input().split()))
R = data[0]
G = data[1]
B = data[2]
N = data[3]

# R * a + G * b + B * c 

a = N // R + 1
b = N // G + 1
# c = N // B + 1
res = 0

def check(Ri):
    global res
    Rx = Ri * R
    if Rx > N:
        return
    for Gi in range(b):
        Gx = Gi * G
        if Rx + Gx > N:
            break
        if (N - Rx - Gx) % B == 0:
            res = res + 1

[check(Ri) for Ri in range(a)]

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
data = list(map(int, input().split()))
R = data[0]
G = data[1]
B = data[2]
N = data[3]

# R * a + G * b + B * c 

a = N // R + 1
b = N // G + 1
c = N // B + 1
res = 0

for Ri in range(a):
    if Ri * R > N:
        break
    for Gi in range(b):
        if Ri * R + Gi * G > N:
            break
        for Bi in range(c):
            if Ri * R + Gi * G + Bi * B > N:
                break
            if Ri * R + Gi * G + Bi * B == N:
                res = res + 1

print(res)


Fixed submission:
data = list(map(int, input().split()))
R = data[0]
G = data[1]
B = data[2]
N = data[3]

# R * a + G * b + B * c 

a = N // R + 1
b = N // G + 1
# c = N // B + 1
res = 0

def check(Ri):
    global res
    Rx = Ri * R
    if Rx > N:
        return
    for Gi in range(b):
        Gx = Gi * G
        if Rx + Gx > N:
            break
        if (N - Rx - Gx) % B == 0:
            res = res + 1

[check(Ri) for Ri in range(a)]

print(res)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

ip = input().split()
st = int(ip[1])

li = []

ip2 = input().split()
for i in ip2:
    li.append(abs(int(i) - st))

print(gcd_list(li))

Fixed submission:
import fractions
from functools import reduce
 
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
 
ip = input().split()
st = int(ip[1])
 
li = []
 
ip2 = input().split()
for i in ip2:
    li.append(abs(int(i) - st))
 
print(gcd_list(li))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

lenums = int(input())
nums = [int(i) for i in input().split()]
answer = 0
lenums1 = lenums + 1

ans = [sum([1 for j in range(i + 1, lenums1) if sum(nums[i:j]) == 0]) for i in range(lenums)]
answer = sum(ans)

print(answer)


Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

lenums = int(input())
nums = [int(i) for i in input().split()]
answer = 0

dp = [0]

for i in range(lenums):
    dp.append(dp[i] + nums[i])

count_dict = collections.Counter(dp)
for i in count_dict.values():
    if i <= 1:
        continue
    answer = answer + i * (i - 1) // 2 # xC2

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

lenums = int(input())
nums = [int(i) for i in input().split()]
answer = 0

ans = [sum([1 for j in range(i + 1, lenums + 1) if sum(nums[i:j]) == 0]) for i in range(lenums)]
answer = sum(ans)

print(answer)


Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

lenums = int(input())
nums = [int(i) for i in input().split()]
answer = 0

dp = [0]

for i in range(lenums):
    dp.append(dp[i] + nums[i])

count_dict = collections.Counter(dp)
for i in count_dict.values():
    if i <= 1:
        continue
    answer = answer + i * (i - 1) // 2 # xC2

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import os
import sys

input()
nums = [int(i) for i in input().split()]
answer = 0

for i in range(len(nums)):
    for j in range(i, len(nums) + 1):
        if i == j:
            continue
        if sum(nums[i:j]) == 0:
            answer = answer + 1

print(answer)


Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

lenums = int(input())
nums = [int(i) for i in input().split()]
answer = 0

dp = [0]

for i in range(lenums):
    dp.append(dp[i] + nums[i])

count_dict = collections.Counter(dp)
for i in count_dict.values():
    if i <= 1:
        continue
    answer = answer + i * (i - 1) // 2 # xC2

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import os
import sys

input()
nums = input().split()
answer = 0
temp = 0

for i in range(len(nums)):
    for j in nums[i:]:
        temp = temp + int(j)
        if temp == 0:
            answer = answer + 1
    temp = 0

print(answer)


Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

lenums = int(input())
nums = [int(i) for i in input().split()]
answer = 0

dp = [0]

for i in range(lenums):
    dp.append(dp[i] + nums[i])

count_dict = collections.Counter(dp)
for i in count_dict.values():
    if i <= 1:
        continue
    answer = answer + i * (i - 1) // 2 # xC2

print(answer)
Buggy python submission (verdict: Runtime Error):
import math

data = input().split()

loop_count = int(data[0])
moto = int(data[1])
least_donut = 100000
one = 0

for i in range(loop_count):
    gram = int(input())
    one = one + gram
    if gram < least_donut:
        least_donut = gram

nokori = moto - one
print(loop_count + math.floor(nokori / least_donut))


Fixed submission:
# -*- coding: utf-8 -*-

ramen_basic = 700

data = list(input())

def is_yes(topping):
    if topping == "o":
        return True
    else:
        return False

count = 0

for topping in data:
    if is_yes(topping):
        count = count + 1

print(ramen_basic + count * 100)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

from copy import copy
from fractions import gcd

def all_gcd(numbers):
    result = numbers[0]
    for v in numbers:
        result = gcd(result, v)
    return result

def main():
    n = int(input())
    a = list(map(int, input().split()))
    max_gcd = 0
    del_number = -1
    for i in range(n):
        b = copy(a)
        del b[i]
        bgcd = all_gcd(b)
        if max_gcd < bgcd:
            max_gcd = bgcd
            del_number = a[i]
    print(max_gcd)




if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
 
from fractions import gcd
 
def all_gcd(numbers):
    result = numbers[0]
    for v in numbers:
        result = gcd(result, v)
    return result
 
def main():
    n = int(input())
    a = list(map(int, input().split()))
    # x[i] = gcd 0 to i
    x = []
    for i in range(n):
        prev = 0 if i == 0 else x[i - 1]
        x.append(gcd(a[i], prev))
    # y[i] = gcd i to n
    y = [0] * n
    y[n-1] = a[n-1]
    for i in range(2, n + 1):
        y[n-i] = gcd(y[n-i+1], a[n-i])

    max_gcd = 0
    for i in range(n):
        if i == 0:
            now_gcd = y[1]
        elif i == n-1:
            now_gcd = x[n-2]
        else:
            now_gcd = gcd(x[i-1], y[i+1])
        if now_gcd > max_gcd:
            max_gcd = now_gcd
    print(max_gcd)
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

from copy import copy
from math import gcd

def all_gcd(numbers):
    result = numbers[0]
    for v in numbers:
        result = gcd(result, v)
    return result

def main():
    n = int(input())
    a = list(map(int, input().split()))
    max_gcd = 0
    for i in range(n):
        b = copy(a)
        del b[i]
        bgcd = all_gcd(b)
        if max_gcd < bgcd:
            max_gcd = bgcd
    print(max_gcd)




if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
 
from fractions import gcd
 
def all_gcd(numbers):
    result = numbers[0]
    for v in numbers:
        result = gcd(result, v)
    return result
 
def main():
    n = int(input())
    a = list(map(int, input().split()))
    # x[i] = gcd 0 to i
    x = []
    for i in range(n):
        prev = 0 if i == 0 else x[i - 1]
        x.append(gcd(a[i], prev))
    # y[i] = gcd i to n
    y = [0] * n
    y[n-1] = a[n-1]
    for i in range(2, n + 1):
        y[n-i] = gcd(y[n-i+1], a[n-i])

    max_gcd = 0
    for i in range(n):
        if i == 0:
            now_gcd = y[1]
        elif i == n-1:
            now_gcd = x[n-2]
        else:
            now_gcd = gcd(x[i-1], y[i+1])
        if now_gcd > max_gcd:
            max_gcd = now_gcd
    print(max_gcd)
 
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3


def main():
    n, q = map(int, input().split())
    s = input()
    l = []
    r = []
    for _ in range(q):
        li, ri = map(int, input().split())
        l.append(li-1)
        r.append(ri-1)

    # x[i] = 0文字目からi文字目までのACの出現回数の総和
    y = [i for i, v in enumerate(s) if i < n - 1 and s[i] + s[i+1] == 'AC']
    x = []
    for i in range(n):
        before = 0 if len(x) == 0 else x[-1]
        if i in y:
            x.append(before + 1)
        else:
            x.append(before)
    for i in range(q):
        li = l[i]
        ri = r[i]
        lsum = 0 if li == 0 else x[li-1]
        rsum = x[ri-1]
        print(rsum - lsum)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3


def main():
    n, q = map(int, input().split())
    s = input()
    x = [0] * n
    if s[0:2] == 'AC':
        x[0] = 1
    for i in range(n - 1):
        if s[i+1:i+3] == 'AC':
            x[i+1] = x[i] + 1
        else:
            x[i+1] = x[i]

    for _ in range(q):
        li, ri = map(int, input().split())
        li -= 1
        ri -= 1
        lsum = 0 if li == 0 else x[li-1]
        rsum = x[ri-1]
        print(rsum - lsum)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

from functools import reduce


def main():
    a, b = list(map(int, input().split()))
    l = list(range(a, b + 1))
    result = reduce(lambda x, y : x^y, l)
    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3

from math import log2

def func(n):
    # (2x) ^ (2x+1) = 1 の性質を利用
    # n = 2mのとき
    # 0^1^...^2m = (0^1) ^ (2^3) ^ ... ^ (2m-2- ^ 2m-1) ^ 2m
    # = 1^...^1 ^ 2m (1はm個)

    # n = 2m+1 のとき
    # 0^1^...^2m+1 = (0^1)^...(2m ^ 2m+1)
    # = 1^...^1 (1は m+1個)

    if n % 2 == 0:
        m = n // 2
        if m % 2 == 0:
            return n
        else:
            return n ^ 1
    else:
        m = (n-1) // 2
        return 0 if m % 2 == 1 else 1

def main():
    a, b = list(map(int, input().split()))

    #f(a, b) = f(0, a-1) ^ f(0, b)
    # f(0, n)をfunc(n)とする
    print(func(b) ^ func(a-1))

if __name__ == '__main__':
    main()