Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
X, Y = map(int, input().split())
mod = 10 ** 9 + 7
for t in range(X + Y + 1):
  if t == X + Y:
    print(0)
    exit(0)
  if X + Y - 2 * t == t:
    X -= t
    Y -= t
    break
class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(X + Y, mod)
#print(X, Y)
print(f.combi(X + Y, X))

Fixed submission:
import sys
input = sys.stdin.readline
X, Y = map(int, input().split())
mod = 10 ** 9 + 7
for t in range(X + Y + 1):
  if t == X + Y:
    print(0)
    exit(0)
  if X + Y - 2 * t == t:
    X -= t
    Y -= t
    break
if X < 0 or (Y < 0):
  print(0)
  exit(0)
class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(X + Y, mod)
#print(X, Y)
print(f.combi(X + Y, X))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.buffer.readline
N = int(input())
L = list(map(int, input().split()))
L.sort()
dl = []
for i in range(N - 1):
  for j in range(i + 1, N):
    dl.append((L[i] + L[j], i, j, abs(L[i] - L[j])))
dl.sort()
#print(L)
#print(dl)
res = 0
for d in dl:
  ind = bl(L, d[0])
  ind2 = br(L, d[3])
  res += ind - ind2
  if ind2 <= d[1] <= ind:
    res -= 1
  if ind2 <= d[2] <= ind:
    res -= 1
  #print(res, d, ind, ind2)
print(res // 3)

Fixed submission:
import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.buffer.readline
N = int(input())
L = list(map(int, input().split()))
L.sort()
dl = []
res = 0
for i in range(N - 1):
  for j in range(i + 1, N):
    d0 = L[i] + L[j]
    d1 = i
    d2 = j
    d3 = abs(L[i] - L[j])
    ind = bl(L, d0)
    ind2 = br(L, d3)
    res += ind - ind2
    if ind2 <= d1 <= ind:
      res -= 1
    if ind2 <= d2 <= ind:
      res -= 1
  #print(res, d, ind, ind2)
print(res // 3)
Buggy python submission (verdict: Runtime Error):
from collections import deque as dq
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
ab = []
c = []
inf = 10 ** 10
for i in range(M):
  ab.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
dp = [[inf] * M for _ in range(2 ** 12)]
cc = []
for i in range(M):
  temp = 0
  for k in range(ab[i][1]):
    t = 2 ** (c[i][k] - 1)
    temp = temp | t
  cc.append(temp)
def less(a, b):
  if a > b:
    return b
  else:
    return a
#print(ab, c)
Q = dq([])
Q.append((0, 0))
vis = set()
while len(Q):
  q = Q.popleft()
  i, j = q[0], q[1]
  if j >= M:
    continue
  if q in vis:
    continue
  vis.add(q)
  temp = i ^ 0
  temp2 = cc[j]
  if j > 0:
    #print(temp | temp2, j, ab[j][0])
    dp[temp | temp2][j] = less(dp[temp][j - 1] + ab[j][0], dp[temp | temp2][j])
    dp[temp][j] = less(dp[temp][j], dp[temp][j - 1])
    dp[temp2][j] = less(ab[j][0], dp[temp2][j])
    Q.append((temp | temp2, j + 1))
    Q.append((temp, j + 1))
    Q.append((temp2, j + 1))
  else:
    #print(temp | temp2, j, ab[j][0])
    dp[temp | temp2][j] = less(ab[j][0], dp[temp | temp2][j])
    Q.append((temp | temp2, j + 1))
if dp[2 ** N - 1][-1] == inf:
  print(-1)
else:
  print(dp[2 ** N - 1][-1])



Fixed submission:
N = int(input())
print((N - N // 2) / N)
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
a = set()
b = set()
i = 2
while i <= 10 ** 9:
  if A <= 1:
    break
  while A % i == 0:
    a.add(i)
    A //= i
  i += 1
i = 2
while i <= 10 ** 9:
  if B <= 1:
    break
  while B % i == 0:
    b.add(i)
    B //= i
  i += 1
inter = a.intersection(b)
print(len(inter) + 1)

Fixed submission:
A, B = map(int, input().split())
a = set()
b = set()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
"""
i = 2
temp = A + 0
while i * i <= temp:
  if A <= 1:
    break
  while A % i == 0:
    a.add(i)
    A //= i
  i += 1
i = 2
temp = B + 0
while i * i <= temp:
  if B <= 1:
    break
  while B % i == 0:
    b.add(i)
    B //= i
  i += 1
"""
a = set([i[0] for i in factorization(A)])
b = set([i[0] for i in factorization(B)])
inter = a.intersection(b)
if A == 1 and B == 1:
  print(1)
else:
  print(len(inter) + 1)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
zeta = [0] * (max(A) + 1)
mod = 998244353
for a in A:
  zeta[a] += a
for i in range(1, len(zeta)):
  for j in range(2 * i, len(zeta), i):
    zeta[i] += zeta[j]
for i in range(1, len(zeta)):
  zeta[i] *= zeta[i]
for i in range(len(zeta) - 1, 0, -1):
  for j in range(2 * i, len(zeta), i):
    zeta[i] -= zeta[j]
for a in A:
  zeta[a] -= a ** 2
for i in range(1, len(zeta)):
  zeta[i] //= 2
for i in range(1, len(zeta)):
  zeta[i] //= i
  res = (res + zeta[i]) % mod
print(res)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
zeta = [0] * (max(A) + 1)
mod = 998244353
res = 0
for a in A:
  zeta[a] += a
for i in range(1, len(zeta)):
  for j in range(2 * i, len(zeta), i):
    zeta[i] += zeta[j]
for i in range(1, len(zeta)):
  zeta[i] *= zeta[i]
for i in range(len(zeta) - 1, 0, -1):
  for j in range(2 * i, len(zeta), i):
    zeta[i] -= zeta[j]
for a in A:
  zeta[a] -= a ** 2
for i in range(1, len(zeta)):
  zeta[i] //= 2
for i in range(1, len(zeta)):
  zeta[i] //= i
  res = (res + zeta[i]) % mod
print(res)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = list(input())
temp = S[0]
ind = 0
cs = [1]
for i in range(N - 1):
  if S[i] == S[i + 1]:
    cs[ind] += 1
  else:
    cs.append(1)
    ind += 1
    temp = S[i + 1]
#print(cs)
cscs = [cs[0]] + [0] * (len(cs))
for i in range(len(cs) - 1):
  cscs[i + 1] = cscs[i] + cs[i + 1]
cscs = [0] + cscs
css = [cs[0]] + [0] * (len(cs))
for i in range(len(cs) - 1):
  css[i + 1] = css[i] + cs[i + 1] - 1
css = [0] + css
#print(css)
#print(cscs)
res = 0
for i in range(max(len(cs) - 2 * M + 1, 1)):
  temp = css[-2] - css[i + 2 * M] + css[max(i - 1, 0)]
  #print(temp,css[-2],css[i + 2 * M],css[max(i - 1, 0)])
  res = max(res, cscs[i + 2 * M] - cscs[i] + temp)
  #print(res - 1, i, i + 2 * M)
if len(css) - 2 <= 2 * M + 1:
  print(N - 1)
else:
  print(res - 1)



Fixed submission:
N, M = map(int, input().split())
S = list(input())
temp = S[0]
ind = 0
cs = [1]
for i in range(N - 1):
  if S[i] == S[i + 1]:
    cs[ind] += 1
  else:
    cs.append(1)
    ind += 1
    temp = S[i + 1]
#print(cs)
cscs = [cs[0]] + [0] * (len(cs))
for i in range(len(cs) - 1):
  cscs[i + 1] = cscs[i] + cs[i + 1]
cscs = [0] + cscs
css = [cs[0]] + [0] * (len(cs))
for i in range(len(cs) - 1):
  css[i + 1] = css[i] + cs[i + 1] - 1
css = [0] + css
#print(css)
#print(cscs)
res = 0
for i in range(len(css) - 2 * M):
  temp = css[-2] - css[i + 2 * M] + css[max(i, 0)]
  #print(temp,css[-2],css[i + 2 * M],css[max(i - 1, 0)])
  res = max(res, cscs[i + 2 * M] - cscs[i] + temp)
  #print(res - 1, i, i + 2 * M)
if len(css) - 2 <= 2 * M + 1:
  print(N - 1)
else:
  print(res - 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import sqrt
input = sys.stdin.readline
N = int(input())
e = []
for _ in range(N):
  x, y = map(int, input().split())
  e.append((x, y))
t = pow(10, 5) * 5
res = 0
for a in range(2):
  for b in range(2):
    xbias = (-1) ** a
    ybias = (-1) ** b
    for u in range(t + 1):
      v = sqrt(t ** 2 - u ** 2) * ybias
      px = 0
      py = 0
      for i in range(N):
        x, y = e[i]
        if u * x * xbias + v * y * ybias > 0:
          px += x
          py += y
      res = max(res, sqrt(px ** 2 + py ** 2))
print(res)

Fixed submission:
import sys
from math import sqrt
input = sys.stdin.readline
N = int(input())
e = []
for _ in range(N):
  x, y = map(int, input().split())
  e.append((x, y))
res = 0
for i in range(N):
  for j in range(N):
    u = e[i][0] + e[j][0]
    v = e[i][1] + e[j][1]
    px = 0
    py = 0
    for k in range(N):
      x, y = e[k]
      if u * x + v * y > 0:
        px += x
        py += y
    res = max(res, sqrt(px ** 2 + py ** 2))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import sqrt
input = sys.stdin.readline
N = int(input())
e = []
for _ in range(N):
  x, y = map(int, input().split())
  e.append((x, y))
t = pow(10, 6)
res = 0
for a in range(2):
  for b in range(2):
    xbias = (-1) ** a
    ybias = (-1) ** b
    for u in range(pow(10, 6) + 1):
      v = sqrt(t ** 2 - u ** 2) * ybias
      px = 0
      py = 0
      for i in range(N):
        x, y = e[i]
        if u * x * xbias + v * y * ybias > 0:
          px += x
          py += y
      res = max(res, sqrt(px ** 2 + py ** 2))
print(res)

Fixed submission:
import sys
from math import sqrt
input = sys.stdin.readline
N = int(input())
e = []
for _ in range(N):
  x, y = map(int, input().split())
  e.append((x, y))
res = 0
for i in range(N):
  for j in range(N):
    u = e[i][0] + e[j][0]
    v = e[i][1] + e[j][1]
    px = 0
    py = 0
    for k in range(N):
      x, y = e[k]
      if u * x + v * y > 0:
        px += x
        py += y
    res = max(res, sqrt(px ** 2 + py ** 2))
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
L = [1]
cumsumL = [1]
res = 1
rvisited = 0
mod = 10 ** 9 + 7
class Factorial:
  def __init__(self, n, mod):
    self.f=[1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i=[pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(N, mod)
if S[0] == "W" or S[-1] == "W":
  print(0)
  exit(0)
for i in range(1, 2 * N):
  if S[i - 1] == S[i]:
    L.append((L[i - 1] + 1 )% 2)
  else:
    L.append(L[i - 1])
if sum(L) != N:
  print(0)
  exit(0)
for i in range(1, 2 * N):
  cumsumL.append(cumsumL[i - 1] + L[i])
for i in range(1, 2 * N):
  if L[i] == 0:
    res *= cumsumL[i] - rvisited % mod
    rvisited += 1
print(f.factorial(N) * res % mod)

Fixed submission:
N = int(input())
S = list(input())
L = [1]
cumsumL = [1]
res = 1
rvisited = 0
mod = 10 ** 9 + 7
class Factorial:
  def __init__(self, n, mod):
    self.f=[1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i=[pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(N, mod)
if S[0] == "W" or S[-1] == "W":
  print(0)
  exit(0)
for i in range(1, 2 * N):
  if S[i - 1] == S[i]:
    L.append((L[i - 1] + 1 )% 2)
  else:
    L.append(L[i - 1])
if sum(L) != N:
  print(0)
  exit(0)
for i in range(1, 2 * N):
  cumsumL.append(cumsumL[i - 1] + L[i])
for i in range(1, 2 * N):
  if L[i] == 0:
    res *= cumsumL[i] - rvisited % mod
    res %= mod
    rvisited += 1
print(f.factorial(N) * res % mod)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict as dd
from bisect import bisect_left as bl
s = input()
t = input()
ind = dd(list)
res = 0
for i in range(len(s)):
  ind[s[i]].append(i)
#print(ind)
for i in range(len(t)):
  if len(ind[t[i]]) == 0:
    print(-1)
    exit(0)
  temp = bl(ind[t[i]], res % len(s))
  #print(temp, res, t[i])
  if res % len(s) == ind[t[i]][temp]:
    temp += 1
  if temp == len(ind[t[i]]):
    res += (len(s) - res % len(s)) + ind[t[i]][0]
  else:
    res += ind[t[i]][temp] - res % len(s)
print(res + 1)

Fixed submission:
from collections import defaultdict as dd
from bisect import bisect_left as bl
s = input()
t = input()
ind = dd(list)
res = 0
first = 1
for i in range(len(s)):
  ind[s[i]].append(i)
#print(ind)
for i in range(len(t)):
  if len(ind[t[i]]) == 0:
    print(-1)
    exit(0)
  temp = bl(ind[t[i]], res % len(s))
  #print(temp, res, t[i])
  if first == 0:
    if res % len(s) == ind[t[i]][min(temp, len(ind[t[i]]) - 1)]:
      temp += 1
  first = 0
  if temp == len(ind[t[i]]):
    res += (len(s) - res % len(s)) + ind[t[i]][0]
  else:
    res += ind[t[i]][temp] - res % len(s)
print(res + 1)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bl
N, M = map(int, input().split())
work = [list(map(int, input().split())) for _ in range(N)]
work.sort(key = lambda x: x[1], reverse=True)
#print(work)
inf = 10 ** 5 + 1
money = 0
able = [i for i in range(M + 1)] + [inf]
added = 0
for i in range(N):
  if added == M:
    break
  ind = bl(able, work[i][0])
  if able[ind] != inf:
    able = able[: ind] + able[ind + 1: ]
    money += work[i][1]
    added += 1
print(money)



Fixed submission:
import heapq
N, M = map(int, input().split())
work = [[0] for _ in range(M + 1)]
for _ in range(N):
  d, p = map(int, input().split())
  if d > M: continue
  work[d].append(-p)
#print(work)
money = 0
q = work[1]
heapq.heapify(q)
for i in range(1, M + 1):
  #print(q)
  if len(q) != 0:
    money += heapq.heappop(q)
  if i == M: continue
  for p in work[i + 1]:
    heapq.heappush(q, p)
print(-money)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
slist = S.split("LR")
res = [["0"] * len(s) for s in slist]
for i in range(len(slist)):
  if i < len(slist) - 1:
    slist[i] = slist[i] + "L"
    res[i].append("0")
    slist[i + 1] = "R" + slist[i + 1]
    res[i + 1].append("0")
  Rc = slist[i].count("R")
  Lc = slist[i].count("L")
  #print(slist[i], Rc, Lc)
  res[i][Rc - 1] = str(Lc // 2 + (Rc - Rc // 2))
  res[i][Rc] = str(Rc // 2 + (Lc - Lc // 2))
res2 = ""
#print(res)
for i in range(len(slist)):
  #print(res[i])
  res2 = res2 + " ".join(res[i])
  if i < len(slist) -1:
    res2 = res2 + " "
print(res2)

Fixed submission:
S = input()
slist = S.split("LR")
res = [["0"] * len(s) for s in slist]
for i in range(len(slist)):
  if i < len(slist) - 1:
    slist[i] = slist[i] + "L"
    res[i].append("0")
    slist[i + 1] = "R" + slist[i + 1]
    res[i + 1].append("0")
  Rc = slist[i].count("R")
  Lc = slist[i].count("L")
  #print(slist[i], Rc, Lc)
  res[i][Rc - 1] = str(Lc // 2 + (Rc - Rc // 2))
  res[i][Rc] = str(Rc // 2 + (Lc - Lc // 2))
res2 = ""
#print(res)
for i in range(len(slist)):
  #print(res[i])
  res2 = res2 + " ".join(res[i])
  if i < len(slist) -1:
    res2 = res2 + " "
print(res2)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
slist = S.split("LR")
res = [[0] * len(s) for s in slist]
for i in range(len(slist)):
  if i < len(slist) - 1:
    slist[i] = slist[i] + "L"
    res[i].append(0)
    slist[i + 1] = "R" + slist[i + 1]
    res[i + 1].append(0)
  Rc = slist[i].count("R")
  Lc = slist[i].count("L")
  #print(slist[i], Rc, Lc)
  res[i][Rc - 1] = Lc // 2 + (Rc - Rc // 2)
  res[i][Rc] = Rc // 2 + (Lc - Lc // 2)
res2 = ""
#print(res)
for i in range(len(slist)):
  #print(res[i])
  res2 = res2 + " ".join(map(str, res[i]))
  if i < len(slist) -1:
    res2 = res2 + " "
print(res2)

Fixed submission:
S = input()
slist = S.split("LR")
res = [["0"] * len(s) for s in slist]
for i in range(len(slist)):
  if i < len(slist) - 1:
    slist[i] = slist[i] + "L"
    res[i].append("0")
    slist[i + 1] = "R" + slist[i + 1]
    res[i + 1].append("0")
  Rc = slist[i].count("R")
  Lc = slist[i].count("L")
  #print(slist[i], Rc, Lc)
  res[i][Rc - 1] = str(Lc // 2 + (Rc - Rc // 2))
  res[i][Rc] = str(Rc // 2 + (Lc - Lc // 2))
res2 = ""
#print(res)
for i in range(len(slist)):
  #print(res[i])
  res2 = res2 + " ".join(res[i])
  if i < len(slist) -1:
    res2 = res2 + " "
print(res2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
res = [0] + a[:]
 
for i in range(n, 0, -1):
    ans[i] = sum(ans[i : : i]) % 2 
print(sum(res))
print(*[i + 1 for i in range(n) if res[i]])


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
res = [0] + a[:]
for i in range(N, 0, -1):
  res[i] = sum(res[i : : i]) % 2 
print(sum(res))
print(*[i for i in range(N + 1) if res[i]])

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
res = a[:]
 
for i in range(n, 0, -1):
    ans[i] = sum(ans[i : : i]) % 2 
print(sum(res))
print(*[i + 1 for i in range(n) if res[i]])

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
res = [0] + a[:]
for i in range(N, 0, -1):
  res[i] = sum(res[i : : i]) % 2 
print(sum(res))
print(*[i for i in range(N + 1) if res[i]])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
dp = [0] * (N + 1)
for i in range(N, 0, -1):
  #print(i)
  if i > N // 2:
    dp[i] = a[i - 1]
  else:
    j = 2
    while i * j <= N:
      dp[i] = dp[i] ^ dp[i * j]
      j += 1
    dp[i] = dp[i] ^ a[i - 1]
M = 0
res2 = ""
#print(dp)
for i, v in enumerate(dp):
  if v == 1:
    M += 1
    res2 += str(i) + " "
print(M)
print(res2)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
res = [0] + a[:]
for i in range(N, 0, -1):
  res[i] = sum(res[i : : i]) % 2 
print(sum(res))
print(*[i for i in range(N + 1) if res[i]])
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bl
from copy import deepcopy as dc
N = int(input())
Al = sorted(list(map(int, input().split())))
#print(Al)
q = -1
r = -1
for i in range(1, N - 1):
  A = dc(Al)
  #print(A)
  p = A.pop(0)
  temp = p ^ A[i]
  index = bl(A, temp)
  if index >= N - 1:
    continue
  if temp == A[index]:
    r = A.pop(i)
    q = A.pop(index)
    
    for j in range(1, N - 2):
      temp = q ^ r
      index = bl(A, temp)
      if temp == A[index]:
        t = r + 0
        if i == N - 4:
          r = p
        else:
          r = A.pop(index)
        q = t
      else:
        q = -1
        r = -1
        break
        
    
if q == -1:
  print("No")
  exit(0)
else:
  print("Yes")

Fixed submission:
N = int(input())
Al = list(map(int, input().split()))
p = Al[0]
for i in range(1, N):
  p = p ^ Al[i]
if p == 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bl
from copy import deepcopy as dc
N = int(input())
Al = sorted(list(map(int, input().split())))
#print(Al)
q = -1
r = -1
for i in range(1, N - 1):
  A = dc(Al)
  #print(A)
  p = A.pop(0)
  temp = p ^ A[i]
  index = bl(A, temp)
  if index >= N - 1:
    continue
  if temp == A[index]:
    r = A.pop(i)
    q = A.pop(index)
    
    for j in range(1, N - 2):
      temp = q ^ r
      index = bl(A, temp)
      if temp == A[index]:
        t = r + 0
        if i == N - 4:
          r = p
        else:
          r = A.pop(index)
        q = t
      else:
        q = -1
        r = -1
        break
        
    
if q == -1:
  print("No")
  exit(0)
else:
  print("Yes")

Fixed submission:
N = int(input())
Al = list(map(int, input().split()))
p = Al[0]
for i in range(1, N):
  p = p ^ Al[i]
if p == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict as dd
from collections import deque
from copy import deepcopy as dc
N, M = map(int, input().split())
e = dd(list)
inf = 10 ** 9
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
S, T = map(int, input().split())

stopped = [inf] * (N + 1)
Q = deque()
Q.append(S)
stopped[S] = 0
saw2 = {i: 0 for i in range(1, N + 1)}
saw3 = {i: 0 for i in range(1, N + 1)}
while len(Q) != 0:
  s2 = dc(saw2)
  s3 = dc(saw3)
  p = Q.popleft()
  if stopped[p] >= stopped[T]:
    break
  for q in e[p]:
    for r in e[q]:
      if s2[r] == 1:
        continue
      else:
        s2[r] = 1
      for s in e[r]:
        if s3[s] == 1:
          continue
        else:
          s3[s] = 1
        if stopped[s] > stopped[p] + 1:
          Q.append(s)
          stopped[s] = stopped[p] + 1
if stopped[T] == inf:
  print(-1)
else:
  print(stopped[T])

Fixed submission:
n=int(input());d=sorted(list(map(int,input().split())));print(d[n//2]-d[n//2-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N, K = map(int, input().split())
mod = 10 ** 9 + 7
h = 1
t = set()
while h * h <= N:
  t.add(N // h)
  t.add(h)
  h += 1
t = sorted(t)
#print(t)
tt = []
for x in t:
  tt.append(N // x)

dp = [[0] * len(t) for _ in range(K + 1)]
dp[0][0] = 1
for i in range(K):
  for j in range(len(t)):
    k = bl(t, tt[j])
    dp[i + 1][k] += dp[i][j]
    dp[i + 1][k] %= mod
  #print(dp)
  for k in range(len(t) - 1, 0, -1):
    dp[i + 1][k - 1] += dp[i + 1][k]
    dp[i + 1][k - 1] %= mod
  for k in range(1, len(t)):
    rng = (t[k] - t[k - 1]) % mod
    dp[i + 1][k] *= rng
    dp[i + 1][k] %= mod
  #print(dp)
res = 0
#print(dp)
for j in range(len(t)):
  res += dp[-1][j]
  res %= mod
print(res)

Fixed submission:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
mod = 10 ** 9 + 7
h = 1
t = set()
while h * h <= N:
  t.add(N // h)
  t.add(h)
  h += 1
t = sorted(t)
#print(len(t))
tt = []
for x in t:
  tt.append(N // x)

dp = [[0] * len(t) for _ in range(K + 1)]
dp[0][0] = 1
for i in range(K):
  for j in range(len(t)):
    k = len(t) - j - 1
    dp[i + 1][k] += dp[i][j]
    dp[i + 1][k] %= mod
  #print(dp)
  for k in range(len(t) - 1, 0, -1):
    dp[i + 1][k - 1] += dp[i + 1][k]
    dp[i + 1][k - 1] %= mod
    rng = (t[k] - t[k - 1]) % mod
    dp[i + 1][k] *= rng
    dp[i + 1][k] %= mod

  #print(dp)
res = 0
#print(dp)
for j in range(len(t)):
  res += dp[-1][j]
  res %= mod
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N, K = map(int, input().split())
mod = 10 ** 9 + 7
h = 1
t = set()
while h * h <= N:
  t.add(N // h)
  t.add(h)
  h += 1
t = sorted(t)
#print(t)
tt = []
for x in t:
  tt.append(N // x)

dp = [[0] * len(t) for _ in range(K + 1)]
dp[0][0] = 1
for i in range(K):
  for j in range(len(t)):
    k = bl(t, tt[j])
    dp[i + 1][k] += dp[i][j]
    dp[i + 1][k] %= mod
  #print(dp)
  for k in range(len(t) - 1, 0, -1):
    dp[i + 1][k - 1] += dp[i + 1][k]
    dp[i + 1][k - 1] %= mod
  for k in range(1, len(t)):
    rng = t[k] - t[k - 1]
    dp[i + 1][k] *= rng
    dp[i + 1][k] %= mod
  #print(dp)
res = 0
#print(dp)
for j in range(len(t)):
  res += dp[-1][j]
  res %= mod
print(res)

Fixed submission:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
mod = 10 ** 9 + 7
h = 1
t = set()
while h * h <= N:
  t.add(N // h)
  t.add(h)
  h += 1
t = sorted(t)
#print(len(t))
tt = []
for x in t:
  tt.append(N // x)

dp = [[0] * len(t) for _ in range(K + 1)]
dp[0][0] = 1
for i in range(K):
  for j in range(len(t)):
    k = len(t) - j - 1
    dp[i + 1][k] += dp[i][j]
    dp[i + 1][k] %= mod
  #print(dp)
  for k in range(len(t) - 1, 0, -1):
    dp[i + 1][k - 1] += dp[i + 1][k]
    dp[i + 1][k - 1] %= mod
    rng = (t[k] - t[k - 1]) % mod
    dp[i + 1][k] *= rng
    dp[i + 1][k] %= mod

  #print(dp)
res = 0
#print(dp)
for j in range(len(t)):
  res += dp[-1][j]
  res %= mod
print(res)