Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import*
n, k = map(int, input().split())
a, b = divmod(n, k)
t = 0 if k%2 else a + (b >= k//2)
j = lambda i: len(list(product(range(i), repeat=3)))
print(j(a)+j(t))

Fixed submission:
n,k=map(int,input().split())
print((n//k) ** 3 + (k%2 == 0) * ((n + k//2) // k) ** 3)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import*
n, k = map(int, input().split())
a, b = divmod(n, k)
t = 0 if k%2 else a + (b >= k//2)
j = lambda i: len(list(product(range(i), repeat=3)))
print(j(a)+j(t))

Fixed submission:
n,k=map(int,input().split())
print((n//k) ** 3 + (k%2 == 0) * ((n + k//2) // k) ** 3)
Buggy python submission (verdict: Runtime Error):
s = input()
print(1 if s.startswith("1"*int(input())) else s.replace("1","")[0])

Fixed submission:
a = input()[:int(input())]
j = set(sorted(set(a), key=a.index)[:2])
j.discard("1")
print(list(j)[0] if j else 1)
Buggy python submission (verdict: Runtime Error):
print(1 if evac(input().replace(" ", "%")) else 0)

Fixed submission:
print(1 if eval(input().replace(" ", "%")) else 0)
Buggy python submission (verdict: Runtime Error):
from itertools import*
print(sum(len(j)//2 for _, j in groupby(open(0).read().split()[1:])))

Fixed submission:
from itertools import*
print(sum(len(list(j))//2 for _, j in groupby(open(0).read().split()[1:])))
Buggy python submission (verdict: Runtime Error):
from itertools import*
_, s = open(0)
b, c = [([0]+list(accumulate(map(int, s[::a].translate(str.maketrans("EW","01"[::a])))))[:-1])[::a] for a in [-1,1]]
print(min(x+y for x, y in zip(b, c)))

Fixed submission:
from itertools import*
input();s = input()
b, c = [([0]+list(accumulate(map(int, s[::a].translate(str.maketrans("EW","01"[::a])))))[:-1])[::a] for a in [-1,1]]
print(min(x+y for x, y in zip(b, c)))

Buggy python submission (verdict: Runtime Error):
from itertools import*
_, s = open(0)
print(min(b+c for b, c in zip(*[([0]+list(accumulate(map(int, s[::a].translate(str.maketrans("EW","01"[::a])))))[:-1])[::a] for a in [-1,1]])))

Fixed submission:
from itertools import*
input();s = input()
b, c = [([0]+list(accumulate(map(int, s[::a].translate(str.maketrans("EW","01"[::a])))))[:-1])[::a] for a in [-1,1]]
print(min(x+y for x, y in zip(b, c)))

Buggy python submission (verdict: Runtime Error):
from itertools import*
_, s = open(0)
print(min(b+c for b, c in zip(*[([0]+list(accumulate(map(int, s[::a].translate(str.maketrans("EW","01"[::a])))))[:-1])[::a] for a in [-1,1]])))

Fixed submission:
from itertools import*
input();s = input()
b, c = [([0]+list(accumulate(map(int, s[::a].translate(str.maketrans("EW","01"[::a])))))[:-1])[::a] for a in [-1,1]]
print(min(x+y for x, y in zip(b, c)))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, k = map(int,input().split())
for _ in range(k):
  a, b, c = b+c, c+a, a+b
print("Unfair" if a-b>1e16 else a-b)

Fixed submission:
a, b, c, k = map(int, input().split())
print((a-b)*(-1)**k)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
l = len(s)
print(sorted(set(s[i:j] for i, j in combinations(range(l+1), 2) if j - i <= k))[k-1])

Fixed submission:
from itertools import*
s = input()
k = int(input())
l = len(s)
print(sorted(set(s[i:j] for i, j in combinations(range(l+1), 2) if j - i <= k))[k-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
P,*A=[2]
for L in range(3,9999):
 if len(A)==n:break
 if all(L%M for M in P):
  P+=L,
  if L%5>3:A+=L,
print(*A)

Fixed submission:
n = int(input())
P, A = [2], []
for L in range(3, 55556, 2):
  if len(A) == n:
    break
  if all(L % M for M in P):
    P += L,
    if L % 5 == 1:
      A += L,
print(*A)
Buggy python submission (verdict: Runtime Error):
print(700 + 100*input().count(o))

Fixed submission:
print(700 + 100*input().count("o"))
Buggy python submission (verdict: Runtime Error):
a, b, c = sorted(map(int, input().split()))
print(c - b + (b-a)//2 + (b-a)%2*2)

Fixed submission:
print("YNeos"[len(set(input()))!=3::2])
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
print(*[i for i in range(a, b+1) if i < a+k or i > b-k])

Fixed submission:
a, b, k = map(int, input().split())
print(*[i for i in range(a, b+1) if i < a+k or i > b-k], sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
print(*[i for i in range(a, b+1) if i < a+k or i > b-k], sep="\n")

Fixed submission:
a, b, k = map(int, input().split())
print(*[i for i in range(a, b+1) if i < a+k or i > b-k], sep="\n")
Buggy python submission (verdict: Runtime Error):
input()
print(sum(map(lambda x: bin(int(x))[::-1].find("1"), input().split())))

Fixed submission:
#!/usr/bin/env python3
a, b, c = sorted(map(int, input().split()))
d = b - a
print(c - b + d//2 + d%2*2)
Buggy python submission (verdict: Runtime Error):
from numpy import*
_,a=open(0)
a=array([0]+list(map(int,a.split()))+[0])
A=abs
c=sum(a[1:]-a[:-1])
for i,j,k in zip(a,a[1:],a[2:]):print(c-A(j-i)-A(k-j)+A(k-i))

Fixed submission:
*l, = map(int, open(0).read().split())
print(min(l[:2])+min(l[2:]))
Buggy python submission (verdict: Runtime Error):
import numpy as np
b = abs
n, *a = map(int, open(0).read().split())
a = np.array([0] + a + [0])
s = sum(map(b, a[1:] - a[:-1]))
for i in range(n):
    print(s + b(a[i+2] - a[i]) - b(a[i+1] - a[i]) - b(a[i+2] - a[i+1])

Fixed submission:
import numpy as np
b = abs
n, *a = map(int, open(0).read().split())
a = np.array([0] + a + [0])
s = sum(map(b, a[1:] - a[:-1]))
for i in range(n):
    print(s + b(a[i+2] - a[i]) - b(a[i+1] - a[i]) - b(a[i+2] - a[i+1]))
Buggy python submission (verdict: Runtime Error):
n, m = sorted(map(int, input.split()))
print(1 if n==m==1 else m-2 if n==1 else (n-2)*(m-2))

Fixed submission:
n, m = sorted(map(int, input().split()))
print(1 if n==m==1 else m-2 if n==1 else (n-2)*(m-2))
Buggy python submission (verdict: Runtime Error):
print("TFhoruere"[len(set(map(int, open(0).read().split())))-4::2])

Fixed submission:
print("TFhoruere"[len(set(open(0).read().split()))-4::2])

Buggy python submission (verdict: Runtime Error):
print("TFhoruere"[len(set(map(int, open(0).read().split())))-3::2])

Fixed submission:
print("TFhoruere"[len(set(open(0).read().split()))-4::2])
Buggy python submission (verdict: Runtime Error):
l = map(int, open(0).read().split())
print("YNeos"[4 != sum(sum(l[j]-l[0]+l[i] == l[i+j] for i in [1,2]) for j in [3,6])::2])

Fixed submission:
*l, = map(int, open(0).read().split())
print("YNeos"[4 != sum(sum(l[j]-l[0]+l[i] == l[i+j] for i in [1,2]) for j in [3,6])::2])
Buggy python submission (verdict: Runtime Error):
n = int(input())

def j(b):
    print(b)
    return b, input()[0]

def q(l, r, t):
    m, rm = j((l + r + 1) // 2)
    if (m - b)%2 == (rm != t):
        q(m, r, rm)
    else:
        q(l, m-1, t)

_, s = j(0)
q(0, n-1, s)

Fixed submission:
x, y = map(int,input().split())
print([x, -1][x%y==0])

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

n = int(input())

def j(b):
    print(b)
    i = input()[0]
    if i == "V": exit()
    return b, i

def q(l, r, t):
    m, rm = j((l + r + 1) // 2)
    if (m - b)%2 == (rm != t):
        q(m, r, rm)
    else:
        q(l, m-1, t)

_, s = j(0)
q(0, n-1, s)


Fixed submission:
x, y = map(int,input().split())
print([x, -1][x%y==0])

Buggy python submission (verdict: Runtime Error):
x, y = map(int,input().split())
print([x, -1][x%y])

Fixed submission:
x, y = map(int,input().split())
print([x, -1][x%y==0])

Buggy python submission (verdict: Runtime Error):
x, y = map(int,input().split())
print([-1, x][y%x])

Fixed submission:
x, y = map(int,input().split())
print([x, -1][x%y==0])
Buggy python submission (verdict: Runtime Error):
n, *p = map(int, open(0).read().split())
s = sum(j - i - max(0, i - j) - max(0, j - i)%2 for i, j in zip(p, p[n:]))
print("NO" if [s >= 0 == s%2 ::2] else "Yes")

Fixed submission:
n, *p = map(int, open(0).read().split())
s = sum(j - i - max(0, i - j) - max(0, j - i)%2 for i, j in zip(p, p[n:]))
print("Yes" if s >= 0 == s%2 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
 
def q(l, r, t):
    m = (l + r + 1) // 2
    print(m) ; rm = input()[0]
    if (m - b)%2 == (rm != t):
        q(m, r, rm)
    else:
        q(l, m-1, t)
 
print(0)
q(0, n-1, input()[0])

Fixed submission:
n = int(input())
q = lambda i:input('%d\n'%i)
i, j = 0, n - 1
a, b = q(i), q(j)
while True:
  k = (j - i + 1) // 2 + i
  c = q(k)
  if (k - i)%2 == (a==c):
    j = k
  else:
    a = c
    i = k

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

def j(b):
    print(b)
    return b, input()[0]

def q(l, r, t):
    m, rm = j((l + r + 1) // 2)
    if (m - b)%2 == (rm != t):
        q(m, r, rm)
    else:
        q(l, m-1, t)

_, s = j(0)
q(0, n-1, s)

Fixed submission:
n = int(input())
q = lambda i:input('%d\n'%i)
i, j = 0, n - 1
a, b = q(i), q(j)
while True:
  k = (j - i + 1) // 2 + i
  c = q(k)
  if (k - i)%2 == (a==c):
    j = k
  else:
    a = c
    i = k

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

def j(b):
    print(b)
    i = input()[0]
    if i == "V": exit()
    return b, i

def q(l, r, t):
    m, rm = j((l + r + 1) // 2)
    if (m - b)%2 == (rm != t):
        q(m, r, rm)
    else:
        q(l, m-1, t)

_, s = j(0)
q(0, n-1, s)

Fixed submission:
n = int(input())
q = lambda i:input('%d\n'%i)
i, j = 0, n - 1
a, b = q(i), q(j)
while True:
  k = (j - i + 1) // 2 + i
  c = q(k)
  if (k - i)%2 == (a==c):
    j = k
  else:
    a = c
    i = k

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

n = int(input())

def j(b):
    print(b)
    i = input()[0]
    if i == "V": exit()
    return b, i

def q(l, r, t):
    m, rm = j((l + r + 1) // 2)
    if (m - b)%2 == (rm != t):
        q(m, r, rm)
    else:
        q(l, m-1, t)

_, s = j(0)
q(0, n-1, s)

Fixed submission:
n = int(input())
q = lambda i:input('%d\n'%i)
i, j = 0, n - 1
a, b = q(i), q(j)
while True:
  k = (j - i + 1) // 2 + i
  c = q(k)
  if (k - i)%2 == (a==c):
    j = k
  else:
    a = c
    i = k
Buggy python submission (verdict: Runtime Error):
s = input();s[3] = "8";print(s)

Fixed submission:
print(input().replace("2017","2018"))
Buggy python submission (verdict: Time Limit Exceeded):
n,h,*d=map(int,open(0).read().split());a=max(d[::2]);b=sorted(d[1::2]);c=0
while 1:
 try:
  if(h>0)*(b[-1]>a):h-=b.pop();c+=1
 except:break
print(c-(-h//a)*(h>0))

Fixed submission:
#!/usr/bin/env python3
n, h, *d = map(int, open(0).read().split())
a = max(d[::2])
b = sorted(b for b in d[1::2] if b >= a)[::-1]
i = 0
for b in b:
    h -= b
    i += 1
    if h <= 0:
        print(i)
        exit()
print(i + 0--h // a)

Buggy python submission (verdict: Runtime Error):
n,h,*d=map(int,open(0).read().split());a=max(d[::2]);b=sorted(d[1::2]);c=0
while(h>0)*(b[-1]>a)and b:h-=b.pop();c+=1
c-=(-h//a)*(h>0)
print(c)

Fixed submission:
#!/usr/bin/env python3
n, h, *d = map(int, open(0).read().split())
a = max(d[::2])
b = sorted(b for b in d[1::2] if b >= a)[::-1]
i = 0
for b in b:
    h -= b
    i += 1
    if h <= 0:
        print(i)
        exit()
print(i + 0--h // a)
Buggy python submission (verdict: Runtime Error):
(n,),*d=[list(map(int,c.split()))for c in open(0)]
for i in range(n-1):t=0;exec("for j in range(i,n-1):c,s,f=d[j];t=[t+(f-t%f)%f,s][t<s]+c")print(t)
print(0)

Fixed submission:
#!/usr/bin/env python3
(n,), *d = [list(map(int, c.split())) for c in open(0)]
n -= 1
for i in range(n):
    t = 0
    for j in range(i, n):
        c, s, f = d[j]
        t = (s if t < s else t if t % f == 0 else t + f - t%f) + c
    print(t)
print(0)
Buggy python submission (verdict: Runtime Error):
def era(M):
    p = [1] * M
    p[0] = p[1] = 0
    for x in range(2, int(~-M**.5) + 1):
        if p[x]:
            for y in range(x*x, M, x):
                p[y] = 0
    return p
INF = 10**5 + 1
E = erat(INF)
Q = [0] * INF
from itertools import*
for i in range(INF):
    q[i] = i%2 * p[i] * p[-~i//2]
*a, = accumulate([0] + q)
for _ in [None] * int(input()):
    l, r = map(int, input().split())
    print(a[-~r] - a[l])

Fixed submission:
#!/usr/bin/env python3
from itertools import accumulate
def erat(m):
    p = [1] * m
    p[0] = p[1] = 0
    for x in range(2, int((~-m)**.5) + 1):
        if p[x]:
            for y in range(x*x, m, x):
                p[y] = 0
    return p

INF = 10**5 + 1
p = erat(INF)
q = [0] * INF
for n in range(INF):
    q[n] = n%2 * p[n] * p[-~n//2]
*a, = accumulate([0] + q)
for _ in [None] * int(input()):
    l, r = map(int, input().split())
    print(a[r + 1] - a[l])
Buggy python submission (verdict: Runtime Error):
s=input().replace(" ","+")
l,r=eval(s[:3]),eval(s[4:])
print("RLiegfhtt"[l>r::2] if l!=r else "Balanced")

Fixed submission:
a, b, c, d = map(int,input().split())
print(["RLiegfhtt"[a+b > c+d::2], "Balanced"][a+b == c+d])
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
print(len(str(bin(y//x))[2:]+1)

Fixed submission:
x, y = map(int, input().split())
print(len(bin(y//x)[2:]))
Buggy python submission (verdict: Runtime Error):
s=sorted;i=input
print("NYoe s"[s(i())<s(i())[::-1]::2])

Fixed submission:
print(-(-eval(input().replace(" ","+"))//2))
Buggy python submission (verdict: Time Limit Exceeded):
n, k, *a = map(int, open(0).read().split())
print(n - sum(sorted([a.count(i) for i in range(n)])[:-k-1:-1]))

Fixed submission:
from collections import Counter
n, k, *a = map(int, open(0).read().split())
_, c = zip(*Counter(a).most_common())
print(n - sum(c[:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k, *a = map(int, open(0).read().split())
print(n - sum(sorted([a.count(i) for i in range(n)])[:-k-1:-1]))

Fixed submission:
from collections import Counter
n, k, *a = map(int, open(0).read().split())
_, c = zip(*Counter(a).most_common())
print(n - sum(c[:k]))
Buggy python submission (verdict: Runtime Error):
class Imos:
    def __init__(self, n):
        self.B = [0] * n
        self.n = n
        from itertools import accumulate
        self.ac = accumulate

    def __call__(self, l, r):
        l, r = max(l, 0), min(r, self.n - 1)
        self.B[l] += 1
        if r + 1 != self.n:
            self.B[r + 1] -= 1

    def out(self):
        *res, = self.ac(self.B)
        return res

from collections import defaultdict
d = defaultdict(list)
imos = Imos(10 ** 5 + 1)

(N, C), *D = [[*map(int, o.split())] for o in open(0)]
for s, t, c in D:
    d[c] += (s, t),
for p in d.values():
    p.sort()
    ps, pt = p[0]
    for s, t in p[1:] + [[0,0]]:
        if pt == s:
            pt = t
        else:
            imos(ps, pt)
            ps, pt = s, t
print(max(imos.out()))

Fixed submission:
n, a, b = map(int,input().split())
print(min(n*a, b))
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
print(["<>"[a > b], "="][a = b])

Fixed submission:
a, b = input().split()
print(["<>"[a > b], "="][a == b])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import*
q=[(1,1)]
k=int(input())
m={}
while q:
 n,s=q.pop()
 if(n in m)-1:m[n]=s;q+=(n*10%k,s),;q=[(-~n%k,s+1)]+q
print(m[0])

Fixed submission:
#!/usr/bin/env python3
from collections import deque

INF = 10**9
k = int(input())

# (辺の伸びる先, コスト)
G = [((10 * i % k, 0), ((i + 1) % k, 1)) for i in range(k)]
s = 1

# 01 - BFS
dist = [INF] * k
S = deque([s])
T = deque()
dist[s] = 0

d = 0
while S:
    while S:
        v = S.popleft()
        for w, c in G[v]:
            if d + c < dist[w]:
                dist[w] = d + c
                if c:
                    T.append(w)
                else:
                    S.append(w)
    S, T = T, S
    d += 1

print(dist[0] + 1)
Buggy python submission (verdict: Runtime Error):
print(-int(input()) + int(input()*2)

Fixed submission:
print(-int(input()) + int(input())*2)
Buggy python submission (verdict: Runtime Error):
s,t=input(),input();l,m=len(s),len(t)
for i in range(l-m+1):
 if all(c in"?"+d for c,d in zip(S[-i-m:],t)):s=s.replace(*"?a");exit(print(s[:-i-m]+t+s[l-i:]))
print("UNRESTORABLE")

Fixed submission:
import re
s, t = input().replace('?', '.'), input()
l, m = len(s), len(t)

if l < m:
    print("UNRESTORABLE")
    exit()

can = []  # candidates
for i in range(l - m + 1):
    if re.match(s[i:i + m], t):
        can.append((s[:i] + t + s[i + m:]).replace('.', 'a'))
print(min(can) if can else "UNRESTORABLE")

Buggy python submission (verdict: Runtime Error):
import re
s, t = input().replace('?', '.'), input()
l, m = len(s), len(t)

if l < m:
    print("UNRESTORABLE")
    exit()

can = []  # candidates
for i in range(l - m + 1):
    if re.match(s[i:i + m], t)
        can.append((s[:i] + t + s[i + m:]).replace('.', 'a'))
print(min(can) if can else "UNRESTORABLE")

Fixed submission:
import re
s, t = input().replace('?', '.'), input()
l, m = len(s), len(t)

if l < m:
    print("UNRESTORABLE")
    exit()

can = []  # candidates
for i in range(l - m + 1):
    if re.match(s[i:i + m], t):
        can.append((s[:i] + t + s[i + m:]).replace('.', 'a'))
print(min(can) if can else "UNRESTORABLE")
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
c = 0
while s:
  if s[0] == s[-1]:
    s = s[1:-1]
  else:
    if s[0] == "x":
      s += ["x"]
      c += 1
    elif s[-1] == "x":
      s = ["x"] + s
      c += 1
    else:
      print(-1)
      exit()
print(c)

Fixed submission:
#!/usr/bin/env python3
s = input()
l, r = 0, len(s) - 1
c = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == "x":
        l += 1
        c += 1
    elif s[r] == "x":
        r -= 1
        c += 1
    else:
        print(-1)
        exit()
print(c)
Buggy python submission (verdict: Runtime Error):
from collections import*
i = eval("Counter(list(map(int, input().split()))),"*4)
print("YNEOS"[i[3]-i[1] != {}::2])

Fixed submission:
print(input()[:-8])
Buggy python submission (verdict: Runtime Error):
N = int(input())
for h in range(3500):
  for n in range(n):
    try:w = (N*h*n) / (4*n*h - N*n - N*h)
    except ZeroDivisionError: continue
    if w>0 and w.is_integer():
      print(h, n, int(w))
      exit()

Fixed submission:
N = int(input())
for h in range(3500):
  for n in range(h):
    try:w = (N*h*n) / (4*n*h - N*n - N*h)
    except ZeroDivisionError: continue
    if w>0 and w.is_integer():
      print(h, n, int(w))
      exit()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for h in range(3500):
  for n in range(3500):
    try:w = (N*h*n) / (4*n*h - N*n - N*h)
    except ZeroDivisionError: continue
    if w>0 and w.is_integer():
      print(h, n, int(w))
      exit()

Fixed submission:
N = int(input())
for h in range(3500):
  for n in range(h):
    try:w = (N*h*n) / (4*n*h - N*n - N*h)
    except ZeroDivisionError: continue
    if w>0 and w.is_integer():
      print(h, n, int(w))
      exit()

Buggy python submission (verdict: Runtime Error):
N = int(input())
for h in range(3500):
  for n in range(3500):
    w = (N*h*n) / (4*n*h - N*n - N*h)
    if w>0 and w.is_integer():
      print(h, n, int(w))

Fixed submission:
N = int(input())
for h in range(3500):
  for n in range(h):
    try:w = (N*h*n) / (4*n*h - N*n - N*h)
    except ZeroDivisionError: continue
    if w>0 and w.is_integer():
      print(h, n, int(w))
      exit()

Buggy python submission (verdict: Runtime Error):
N = int(input())
for h in range(3500):
  for n in range(3500):
    w = (N*h*n) / (4*n*h - N*n - N*h)
    if w>0 and w.is_integer:
      print(h, n, int(w))

Fixed submission:
N = int(input())
for h in range(3500):
  for n in range(h):
    try:w = (N*h*n) / (4*n*h - N*n - N*h)
    except ZeroDivisionError: continue
    if w>0 and w.is_integer():
      print(h, n, int(w))
      exit()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, *p = map(int, open(0).read().split())
c = 0
for i in range(n):
    if p[i] == i + 1:
        p[i], p[i+1] = p[i+1], p[i]
        c += 1
print(c)

Fixed submission:
#!/usr/bin/env python3
n, *p = map(int, open(0).read().split())
c = 0
for i in range(n):
    if p[i] == -~i:
        if i == ~-n:
            p[i], p[i-1] = p[i-1], p[i]
        else:
            p[i], p[i+1] = p[i+1], p[i]
        c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
def lcm(a,b):
    return a * b // gcd(a,b)
n = int(input())
print(reduce(lcm, [int(input()) for i in range(n)]))

Fixed submission:
from functools import reduce
from fractions import gcd
def lcm(a,b):
    return a * b // gcd(a,b)
n = int(input())
print(reduce(lcm, [int(input()) for i in range(n)]))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6);l=lambda:map(int, input().split());n=int(input());s=[0for _ in[0]*n];j=[[]for _ in[0]*n]
for _ in range(n-1):a,b,c=l();j[a-1].append([b-1,c]);j[b-1].append([a-1,c])
def f(v,p,d):
 s[v]=d
 for i,c in j[v]:
  if i==p:
   continue
  f(i,v,d+c)
q,k=l()
dfs(k-1,-1,0)
for _ in [0]*q:x,y=l();print(s[x-1]+s[y-1])

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())

dis = [ 0 for _ in range(n)]  # 距離
adj = [[] for _ in range(n)] # 隣接リスト

for _ in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1;b-= 1
    adj[a].append([b, c])
    adj[b].append([a, c])

# v; 現在の頂点
# p; vの親
# d; 現在の距離
def dfs(v, p, d):
    dis[v] = d
    for i, c in adj[v]:
        if i == p:
            continue
        dfs(i, v, d+c)

q, k = map(int, input().split())
k -= 1

dfs(k, -1, 0)

for _ in range(q):
    x, y = map(int, input().split())
    x -= 1;y -= 1
    print(dis[x] + dis[y])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6);l=lambda:map(int, input().split());n=int(input()):s=[0for _ in[0]*n];j=[[]for _ in[0]*n]
for _ in range(n-1):a,b,c=l();j[a-1].append([b-1,c]);j[b-1].append([a-1,c])
def f(v,p,d):
 s[v]=d
 for i,c in j[v]:
  if i==p:
   continue
  f(i,v,d+c)
q,k=l()
dfs(k-1,-1,0)
for _ in [0]*q:x,y=l();print(s[x-1]+s[y-1])

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())

dis = [ 0 for _ in range(n)]  # 距離
adj = [[] for _ in range(n)] # 隣接リスト

for _ in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1;b-= 1
    adj[a].append([b, c])
    adj[b].append([a, c])

# v; 現在の頂点
# p; vの親
# d; 現在の距離
def dfs(v, p, d):
    dis[v] = d
    for i, c in adj[v]:
        if i == p:
            continue
        dfs(i, v, d+c)

q, k = map(int, input().split())
k -= 1

dfs(k, -1, 0)

for _ in range(q):
    x, y = map(int, input().split())
    x -= 1;y -= 1
    print(dis[x] + dis[y])
Buggy python submission (verdict: Runtime Error):
n, *a = map(int, open(0).read().split())
s = [i%4 for a]
f, k = s.count(0), s.count(2)
print("YNeos"[n-f-k > f+(k>0)::2])

Fixed submission:
n, *a = map(int, open(0).read().split())
s = [i%4 for i in a]
f, t = s.count(0), s.count(2)
print("YNeos"[n-f-t+(t>0) > f+1::2])
Buggy python submission (verdict: Time Limit Exceeded):
n, *a = map(int, open(0).read().split())
s = sum(a)
print(min(abs(s - sum(a[:i])*2) for i in range(1, n)))

Fixed submission:
from itertools import*
_, *d = map(int, open(0).read().split())
*a, s = list(accumulate(d))
print(min(abs(s - x*2) for x in a))

Buggy python submission (verdict: Time Limit Exceeded):
n, *a = map(int, open(0).read().split())
print(min(abs(sum(a) - sum(a[:i])*2) for i in range(1, n)))

Fixed submission:
from itertools import*
_, *d = map(int, open(0).read().split())
*a, s = list(accumulate(d))
print(min(abs(s - x*2) for x in a))