Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
adj = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
start = 0
queue = [start]
pre = [None]*N
pre[0] = 0
while queue:
    v = queue.pop(0)
    for i in adj[v]:
        if pre[i] is None:
            pre[i] = v
            queue.append(i)
if None in pre:
    print("No")
else:
    print("Yes")
    for p in pre[1:]:
        print(p+1)

Fixed submission:
N, M = map(int, input().split())
adj = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
start = 0
queue = [start]
pre = [None]*N
pre[0] = 0
while queue:
    v = queue.pop(0)
    for i in adj[v]:
        if pre[i] is None:
            pre[i] = v
            queue.append(i)
if None in pre:
    print("No")
else:
    print("Yes")
    for p in pre[1:]:
        print(p+1)
Buggy python submission (verdict: Time Limit Exceeded):
from math import floor
A, B, N = map(int, input().split())
ans = max([floor(A*x/B)-A*floor(x/B) for x in range(1, min(B, N)+1)])
print(ans)

Fixed submission:
from math import floor
A, B, N = map(int, input().split())
print(floor(A*min(B-1, N)/B))

Buggy python submission (verdict: Runtime Error):
import numpy as np
A, B, N, = map(int, input().split())
def f(x):
    global A, B
    return np.floor(A*x/B)-A*np.floor(x/B)
print(int(np.max(f(np.arange(N+1)))))

Fixed submission:
from math import floor
A, B, N = map(int, input().split())
print(floor(A*min(B-1, N)/B))

Buggy python submission (verdict: Runtime Error):
import numpy as np
A, B, N, = map(int, input().split())
def f(x):
    global A, B
    return np.floor(A*x/B)-A*np.floor(x/B)
x = np.arange(N+1)
print(int(np.max(f(np.arange(N+1)))))

Fixed submission:
from math import floor
A, B, N = map(int, input().split())
print(floor(A*min(B-1, N)/B))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if c-(a+b)>sqrt(a*b): print('Yes')
else: print('No')

Fixed submission:
a, b, c = map(int, input().split())
if c>=a+b and (c-(a+b))*(c-(a+b))-4*a*b>0: print('Yes')
else: print('No')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for i in range(Q):
    q = input()
    if q[0]=='1':
        S = S[::-1]
    if q[0]=='2':
        n, f= map(int, q[:-1].split())
        c = q[-1]
        if f==1:
            S = c + S
        if f==2:
            S = S + c
print(S)

Fixed submission:
S = input()
Q = int(input())
reverse = 0
left = ""
right = ""
for _ in range(Q):
    q = input().split()
    if q[0]=="1":
        reverse += 1
        left, right = right, left
    if q[0]=="2" and q[1]=="1":
        if reverse%2==0: left = q[2]+left
        else: left = left+q[2]
    if q[0]=="2" and q[1]=="2":
        if reverse%2==0: right = right+q[2]
        else: right = q[2]+right
if reverse%2==1:
    left = left[::-1]
    right = right[::-1]
    S = S[::-1]
print(left+S+right)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for i in range(Q):
    q = input()
    if q[0]=='1':
        S = S[::-1]
    if q[0]=='2':
        n, f= map(int, q[:-1].split())
        c = q[-1]
        if f==1:
            S = c + S
        if f==2:
            S = S + c
print(S)

Fixed submission:
S = input()
Q = int(input())
reverse = 0
left = ""
right = ""
for _ in range(Q):
    q = input().split()
    if q[0]=="1":
        reverse += 1
        left, right = right, left
    if q[0]=="2" and q[1]=="1":
        if reverse%2==0: left = q[2]+left
        else: left = left+q[2]
    if q[0]=="2" and q[1]=="2":
        if reverse%2==0: right = right+q[2]
        else: right = q[2]+right
if reverse%2==1:
    left = left[::-1]
    right = right[::-1]
    S = S[::-1]
print(left+S+right)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = [0]*N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s-1]==c:
        continue
    if ans[s-1]!=0 or (s==0 and c==0):
        ans = -1
        break
    else:
        ans[s-1] = c
print("".join(map(str, ans)))

Fixed submission:
N, M = map(int, input().split())
ans = ["?" for _ in range(N)]
for _ in range(M):
    s, c = map(int, input().split())
    if N>1 and s==1 and c==0:
        ans = [-1]
        break
    if ans[s-1]!="?" and ans[s-1]!=str(c):
        ans = [-1]
        break
    ans[s-1] = str(c)
if ans==[-1]:
    print(-1)
else:
    if ans[0]=="?" and N>1:
        ans[0] = "1"
    ans = "".join(ans)
    ans = ans.replace("?", "0")
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1)/2.0 for p in P]
ans = 0
for i in range(N-K+1):
    ans = max(ans, sum(E[i:i+K]))
print(ans)

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1)/2.0 for p in P]
tmp = sum(E[0:K])
ans = tmp
for i in range(1, N-K+1):
    tmp = tmp - E[i-1] + E[i+K-1]
    ans = max(ans, tmp)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1)/2.0 for p in P]
ans = 0
for i in range(N-K+1):
    ans = max(ans, sum(E[i:i+K]))
print(ans)

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1)/2.0 for p in P]
tmp = sum(E[0:K])
ans = tmp
for i in range(1, N-K+1):
    tmp = tmp - E[i-1] + E[i+K-1]
    ans = max(ans, tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N,M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
for m in range(M):
    i = bisect.bisect_left(A, A[-1]/2)
    A.insert(i, A[-1]/2)
    A.pop()
print(sum(map(int, A)))

Fixed submission:
from heapq import heappush, heappop, heapify
N,M = map(int, input().split())
A = list(map(int, input().split()))
heap = [-a for a in A]
heapify(heap)
for i in range(M):
    hmax = heappop(heap)
    heappush(heap, hmax/2)
print(sum(map(lambda x: int(-x), heap)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = map(int, input().split())
cnt = 0
ans = []
prev = 0
for i,h in enumerate(H):
    if i==0:
        pass
    else:
        if prev>=h:
            cnt += 1
        else:
            ans.append(cnt)
            cnt = 0
    prev = h
print(max(ans))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = []
c = 0
for i in range(1, N):
    if H[i-1]>=H[i]:
        c += 1
    else:
        ans.append(c)
        c = 0
ans.append(c)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
def walk(n):
    global adj, point
    if len(adj[n])==0:
        return
    else:
        for a in adj[n]:
            point[a] += point[n]
        for a in adj[n]:
            walk(a)
N, Q = map(int, input().split())
adj = [[] for _ in range(N)]
point = [0 for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
for _ in range(Q):
    p, x = map(int, input().split())
    point[p-1] += x
walk(0)
print(" ".join(map(str, point)))

Fixed submission:
a = int(input())
s = input()
if a>=3200:
    print(s)
else:
    print("red")
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
import math
def lcm(x, y):
    return (x*y)//math.gcd(x,y)
ret = 0
ret += B//C - (A-1)//C
ret += B//D - (A-1)//D
L = lcm(C, D)
ret -= B//L - (A-1)//L
print(B-A+1-ret)

Fixed submission:
A, B, C, D = map(int, input().split())
import fractions
def lcm(x, y):
    return (x*y)//fractions.gcd(x,y)
ret = 0
ret += B//C - (A-1)//C
ret += B//D - (A-1)//D
L = lcm(C, D)
ret -= B//L - (A-1)//L
print(B-A+1-ret)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
D = 1000000007
dp = [1]*(N+1)
for i in a:
    dp[i] = 0
for i in range(2, len(dp)):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%D)

Fixed submission:
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
D = 1000000007
dp = [1]*(N+1)
for i in a:
    dp[i] = 0
for i in range(2, len(dp)):
    if dp[i]==0:
        continue
    dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%D)
Buggy python submission (verdict: Runtime Error):
s = input()
s_ = s.replace("BC", "D")
group = re.findall(r"[AD]+", s_)
ans = 0
for grp in group:
    a = 0
    for g in grp:
        if g=="A":
            a += 1
        if g=="D":
            ans += a
print(ans)

Fixed submission:
import re
s = input()
s_ = s.replace("BC", "D")
group = re.findall(r"[AD]+", s_)
ans = 0
for grp in group:
    a = 0
    for g in grp:
        if g=="A":
            a += 1
        if g=="D":
            ans += a
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
st = set(range(1, N+1))
for _ in range(M):
    a, b = map(int, input().split())
    st.intersection_update(set(range(a, b+1)))
print(len(st))

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
Lmax = max(L)
Rmin = min(R)
if Lmax>Rmin:
    print(0)
else:
    print(Rmin-Lmax+1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = 0
st = {*list(range(1, N+1))}
for _ in range(M):
    a, b = map(int, input().split())
    st.intersection_update({*list(range(a, b+1))})
print(len(st))

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
Lmax = max(L)
Rmin = min(R)
if Lmax>Rmin:
    print(0)
else:
    print(Rmin-Lmax+1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = 0.0
if N >= K:
    p1 = (N-K+1)/N
    p2 = 1.0
    p += p1
    temp = 0.0
    for i in range(1, K): # 1 to K-1
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p2 *= temp*(1/N)
    p += p2
else:
    temp = 0
    for i in range(1, N+1): # 1 to N
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p = temp*(1.0/N)
print(p)            

Fixed submission:
from math import log2
N, K = map(int, input().split())
p = 0.0
if N >= K:
    p1 = (N-K+1)/N
    p2 = 1.0
    p += p1
    temp = 0.0
    for i in range(1, K): # 1 to K-1
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p2 *= temp*(1/N)
    p += p2
else:
    temp = 0
    for i in range(1, N+1): # 1 to N
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p = temp*(1.0/N)
print(p)
Buggy python submission (verdict: Runtime Error):
from math import ceil
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
rA.pop(idx)
tA = [ceil(A[i]/10)*10 for i in range(len(A))]
print(sum(tA)+ans)

Fixed submission:
from math import ceil
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
idx = 0
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
tA = [ceil(A[i]/10)*10 for i in range(len(A))]
print(sum(tA)+ans)

Buggy python submission (verdict: Runtime Error):
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
rA.pop(idx)
tA = [A[i]+10-rA[i] for i in range(len(A))]
print(sum(tA)+ans)

Fixed submission:
from math import ceil
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
idx = 0
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
tA = [ceil(A[i]/10)*10 for i in range(len(A))]
print(sum(tA)+ans)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for l,r in lr:
    print(c[r-1]-c[l-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(N):
    c[i] = S[:i+1].count('AC')
for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for i in range(Q):
    l,r = map(int, input().split())
    print(S[l-1:r].count('AC'))

Fixed submission:
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
lr = []
for i in range(Q)
    l,r = map(int, input().split())
    print(S[l-1:r].count('AC'))

Fixed submission:
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
lr = []
for _ in range(Q):
    lr.append(list(map(int, input().split())))
for l,r in lr:
    print(S[l-1:r].count('AC'))

Fixed submission:
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])
Buggy python submission (verdict: Runtime Error):
import dateutil
S = dateutil.parser.parse(input())
base = dateutil.parser.parse('2019/04/30')
if S<=base:
    print("Heisei")
else:
    print("TBD")

Fixed submission:
import datetime
S = input()
dt = datetime.date(*list(map(int, S.split('/'))))
base = datetime.date(2019, 4, 30)
if dt<=base:
    print("Heisei")
else:
    print("TBD")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
dp = [float('inf') for _ in range(N)]
h = list(map(int, input().split()))
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2, N):
    for k in range(1,min(K, i)+1):
        dp[i] = min(dp[i], dp[i-k]+abs(h[i]-h[i-k]))
print(dp[-1])

Fixed submission:
N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')]*len(h)
dp[0] = 0
for i in range(N):
    if i<N-K:
        for k in range(1,K+1):
            dp[i+k] = min(dp[i]+abs(h[i]-h[i+k]), dp[i+k])
    else:
        for k in range(1, N-i):
            dp[i+k] = min(dp[i]+abs(h[i]-h[i+k]), dp[i+k])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')]*len(h)
dp[0] = 0
for i in range(N):
    if i<N-K:
        for k in range(1,K+1):
            dp[i+k] = min(dp[i]+abs(h[i]-h[i+k]), dp[i+k])
    else:
        for k in range(1, N-i):
            dp[i+k] = min(dp[i]+abs(h[i]-h[i+k]), dp[i+k])
print(dp[-1])

Fixed submission:
N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')]*len(h)
dp[0] = 0
for i in range(N):
    if i<N-K:
        for k in range(1,K+1):
            dp[i+k] = min(dp[i]+abs(h[i]-h[i+k]), dp[i+k])
    else:
        for k in range(1, N-i):
            dp[i+k] = min(dp[i]+abs(h[i]-h[i+k]), dp[i+k])
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
M = []
for _ in range(N):
    M.append(list(map(int, input().split())))
h = [0]*N
c = 0
for i,m in enumerate(M):
    if i==0:
        h[i] = max(m)
        c = m.index(h[i])
    else:
        h[i] = h[i-1]+max(map(lambda x: 0 if m.index(x)==c else x, m))
        c = m.index(h[i]-h[i-1])
print(h[-1])

Fixed submission:
N = int(input())
H = []
for _ in range(N):
    H.append(list(map(int, input().split())))
dp = [[0, 0, 0] for _ in range(N)]
dp[0] = H[0]
for i,h in enumerate(H[1:], start=1):
    dp[i][0] = h[0]+max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = h[1]+max(dp[i-1][0], dp[i-1][2])
    dp[i][2] = h[2]+max(dp[i-1][0], dp[i-1][1])
print(max(dp[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
K = [[] for i in range(N)]
for i in range(N):
    K[i] = list(map(int, input().split()))

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1,N+1):
    w, v = K[i-1]
    for sum_w in range(W+1):
        if sum_w-w>=0:
            dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w]+v)
        else:
            dp[i][sum_w] = dp[i-1][sum_w]
print(dp[-1][-1])

Fixed submission:
N, W = map(int, input().split())
K = [[] for i in range(N)]
for i in range(N):
    K[i] = list(map(int, input().split()))

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1,N+1):
    w, v = K[i-1]
    for sum_w in range(W+1):
        if sum_w-w>=0:
            dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w]+v)
        else:
            dp[i][sum_w] = dp[i-1][sum_w]
print(dp[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
K = []
for _ in range(N):
    K.append(list(map(int, input().split())))
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for w in range(W+1):
        wi, vi = K[i]
        if wi<=w:
            dp[i+1][w] = max(dp[i][w-wi]+vi, dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[-1][-1])

Fixed submission:
N, W = map(int, input().split())
K = [[] for i in range(N)]
for i in range(N):
    K[i] = list(map(int, input().split()))

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1,N+1):
    w, v = K[i-1]
    for sum_w in range(W+1):
        if sum_w-w>=0:
            dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w]+v)
        else:
            dp[i][sum_w] = dp[i-1][sum_w]
print(dp[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()

N = len(S)
M = len(T)
dp = [[0 for _ in range(N+1)] for _ in range(M+1)]

for i in range(1, M+1):
    for j in range(1, N+1):
        if S[j-1]==T[i-1]:
            dp[i][j] += dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = M, N
lcs = ""
while i>0 and j>0:
    if T[i-1]==S[j-1]:
        lcs += T[i-1]
        i -= 1
        j -= 1
    else:
        if dp[i-1][j]>dp[i][j-1]:
            i -= 1
        else:
            j -= 1
print(lcs[::-1])

Fixed submission:
S = input()
T = input()

N = len(S)
M = len(T)
dp = [[0 for _ in range(N+1)] for _ in range(M+1)]

for i in range(1, M+1):
    for j in range(1, N+1):
        if S[j-1]==T[i-1]:
            dp[i][j] += dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = M, N
lcs = ""
while i>0 and j>0:
    if T[i-1]==S[j-1]:
        lcs += T[i-1]
        i -= 1
        j -= 1
    else:
        if dp[i-1][j]>dp[i][j-1]:
            i -= 1
        else:
            j -= 1
print(lcs[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
from operator import xor
from functools import reduce
def check(left, right):
    global A
    return reduce(xor, A[left:right])==sum(A[left:right])
N = int(input())
A = list(map(int, input().split()))
right = 0
ans = 0
for left in range(N):
    while right<N and check(left, right+1):
        right += 1
    ans += right-left
    if right==left:
        right += 1
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
right = 0
ans = 0
A_xor = 0
A_sum = 0
for left in range(N):
    while right<N and (A_xor^A[right])==(A_sum+A[right]):
        A_xor ^= A[right]
        A_sum += A[right]
        right += 1
    ans += right-left
    if right==left:
        right += 1
    else:
        A_xor ^= A[left]
        A_sum -= A[left]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect_left(A, b)
    c = bisect_right(C, b)
    ans += a*(N-c)
print(ans)

Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    i = bisect.bisect_left(A, b)
    j = bisect.bisect_right(C, b)
    ans += i*(N-j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right
N = int(input())
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for a in A:
    i = bisect_right(B, a)
    for b in B[i:]:
        j = bisect_right(C, b)
        ans += len(C[j:])
print(ans)

Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    i = bisect.bisect_left(A, b)
    j = bisect.bisect_right(C, b)
    ans += i*(N-j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for a in A:
    i = bisect.bisect_right(B, a)
    for b in B[i:]:
        j = bisect.bisect_right(C, b)
        ans += N-j
print(ans)

Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    i = bisect.bisect_left(A, b)
    j = bisect.bisect_right(C, b)
    ans += i*(N-j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for a in A:
    i = bisect.bisect_right(B, a)
    for b in B[i:]:
        j = bisect.bisect_right(C, b)
        ans += len(C[j:])
print(ans)

Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    i = bisect.bisect_left(A, b)
    j = bisect.bisect_right(C, b)
    ans += i*(N-j)
print(ans)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
def gcd(a, b):
    return gcd(b, a%b) if b!=0 else a

def lcd(a, b):
    return int(a*b/gcd(a,b))

N = int(input())
T = [int(input()) for _ in range(N)]
l = reduce(lcd, T)
print(l)

Fixed submission:
from functools import reduce
def gcd(a, b):
    return gcd(b, a%b) if b!=0 else a

def lcd(a, b):
    return (a*b)//gcd(a,b)

N = int(input())
T = [int(input()) for _ in range(N)]
l = reduce(lcd, T)
print(l)