Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def precompute(S):
    H, W = S.shape
    V = np.zeros((H + 1, W + 1), np.int32)
    V[1:, 1:] = np.cumsum(S, axis=0).cumsum(axis=1)
    Ex = np.zeros((H, W + 1), np.int32)
    Ex[1:, 1:] = np.cumsum(S[:-1] & S[1:], axis=0).cumsum(axis=1)
    Ey = np.zeros((H + 1, W), np.int32)
    Ey[1:, 1:] = np.cumsum(S[:, :-1] & S[:, 1:], axis=0).cumsum(axis=1)
    return V, Ex, Ey

def main(V, Ex, Ey, query):
    for i in range(len(query) // 4):
        a, b, c, d = query[4 * i:4 * i + 4]
        v = V[c, d] + V[a - 1, b - 1] - V[a - 1, d] - V[c, b - 1]
        e1 = Ex[c - 1, d] + Ex[a - 1, b - 1] - Ex[a - 1, d] - Ex[c - 1, b - 1]
        e2 = Ey[c, d - 1] + Ey[a - 1, b - 1] - Ey[a - 1, d - 1] - Ey[c, b - 1]
        print(v - e1 - e2)

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i4 = numba.from_dtype(np.int64)
    signature = (i4[:, :], i4[:, :], i4[:, :], i4[:])

    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

H, W, Q = map(int, readline().split())
S = []
for _ in range(H):
    S.append(list(readline().rstrip()))
query = np.array(read().split(), np.int32)

S = (np.concatenate(S) - ord('0')).reshape(H, W)
V, Ex, Ey = precompute(S)

main(V, Ex, Ey, query)

Fixed submission:
import sys
input = sys.stdin.readline

import numpy as np

N,M,Q = map(int,sys.stdin.readline().split())
rows = sys.stdin.readlines()
S = np.zeros((N+2,M+2),dtype='U1')
S[1:-1,1:-1] = np.array([list(row) for row in rows[:N]],dtype='U1')[:,:M]
query = np.array([row.split() for row in rows[N:]],dtype=np.int32)

count_one = (S=='1').cumsum(axis=0).cumsum(axis=1)

# 左上ごとに
count_edge_x = ((S[:-1]=='1')&(S[1:]=='1')).cumsum(axis=0).cumsum(axis=1)
count_edge_y = ((S[:,:-1]=='1')&(S[:,1:]=='1')).cumsum(axis=0).cumsum(axis=1)

x1,y1,x2,y2 = query.T

answer = count_one[x2,y2] - count_one[x2,y1-1] - count_one[x1-1,y2] + count_one[x1-1,y1-1]

answer -= count_edge_x[x2-1,y2] - count_edge_x[x2-1,y1-1] - count_edge_x[x1-1,y2] + count_edge_x[x1-1,y1-1]
answer -= count_edge_y[x2,y2-1] - count_edge_y[x1-1,y2-1] - count_edge_y[x2,y1-1] + count_edge_y[x1-1,y1-1]

print('\n'.join(answer.astype(str)))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

A = int(readline())
B = int(readline())

def can_make(A,B):
    # [A,B] の元のorで、{B} 以外の方法でBを作れるかどうか。たいていTrue
    if A == B:
        return False
    if B%2 == 0:
        return can_make((A+1)//2,B//2)
    # Bが奇数なら、{B-1,B}が満たす
    return True

def F(A,B):
    if A==B:
        return 1
    # 偶数の作り方
    ev = F((A+1)//2,B//2)
    # 奇数の作り方
    if A%2==0:
        A += 1
    if B%2 == 1:
        od = F(A//2,B//2)
    else:
        # 上位の桁では基本的にはA//2～B//2が使える。
        # ただし、{B} 以外でないといけない
        od = F(A//2,B//2)
        if not can_make(A//2,B//2):
            od -= 1
    return ev + od

answer = F(A,B)
print(answer)

Fixed submission:
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from functools import lru_cache

A = int(readline())
B = int(readline())

@lru_cache(None)
def can_make(A,B):
    # [A,B] の元のorで、{B} 以外の方法でBを作れるかどうか。たいていTrue
    if A == B:
        return False
    if B%2 == 0:
        return can_make((A+1)//2,B//2)
    # Bが奇数なら、{B-1,B}が満たす
    return True

@lru_cache(None)
def F(A,B):
    if A==B:
        return 1
    # 偶数の作り方
    ev = F((A+1)//2,B//2)
    # 奇数の作り方
    if A%2==0:
        A += 1
    if B%2 == 1:
        od = F(A//2,B//2)
    else:
        # 上位の桁では基本的にはA//2～B//2が使える。
        # ただし、{B} 以外でないといけない
        od = F(A//2,B//2)
        if not can_make(A//2,B//2):
            od -= 1
    return ev + od

answer = F(A,B)
print(answer)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

answer = ''
if a > b:
  answer = 'GREATER'
elif a == b:
  answer = 'EQUAL'
else:
  answer = 'LESS'

print(answer)

Fixed submission:
a = int(input())
b = int(input())

answer = ''
if a > b:
  answer = 'GREATER'
elif a == b:
  answer = 'EQUAL'
else:
  answer = 'LESS'

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
UV = zip(m,m)

if N == 1:
    print(0)
    exit()

graph = [[] for _ in range(N+1)]
for u,v in UV:
    graph[u].append(v)
    graph[v].append(u)

deg = [len(x) for x in graph]

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

parent,order

# dp1：その頂点に上から辿り着いてきたとする。残り回数期待値
dp1 = [0.0]*(N+1)
for v in order[::-1]:
    d = deg[v]
    if v != root and d == 1:
        continue
    x = sum(dp1[c] for c in graph[v])
    if v == root:
        dp1[v] = x/deg[v] + 1
    else:
        dp1[v] = x/(deg[v]-1) + 1

# dp2：その頂点から上に進んだとする。残り回数期待値。上移動を含まない。
dp2 = [0.0] * (N+1)
for v in order:
    d = deg[v]
    n_child = d if v == root else d-1
    S = dp1[v] * n_child # 子に進んだ場合の値の総和
    if v != root:
        S += dp2[v]+1# あらゆる移動の値の総和
    for c in graph[v]:
        if c == parent[v]:
            continue
        if d == 1:
            dp2[c] = 0
        else:
            dp2[c] = (S-dp1[c]-1) / (d-1)

answer = []
for v in range(1,N+1):
    d = deg[v]
    n_child = d if v == root else d-1
    S = dp1[v] * n_child
    if v != root:
        S += dp2[v]+1# あらゆる移動の値の総和
    answer.append(S/d)

print('\n'.join(map(str,answer)))

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
UV = zip(m,m)

if N == 1:
    print(0)
    exit()

graph = [[] for _ in range(N+1)]
for u,v in UV:
    graph[u].append(v)
    graph[v].append(u)

deg = [len(x) for x in graph]

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

parent,order

# dp1：その頂点に上から辿り着いてきたとする。残り回数期待値
dp1 = [0.0]*(N+1)
for v in order[::-1]:
    d = deg[v]
    if v != root and d == 1:
        continue
    x = sum(dp1[c] for c in graph[v])
    if v == root:
        dp1[v] = x/deg[v] + 1
    else:
        dp1[v] = x/(deg[v]-1) + 1

# dp2：その頂点から上に進んだとする。残り回数期待値。上移動を含まない。
dp2 = [0.0] * (N+1)
for v in order:
    d = deg[v]
    n_child = d if v == root else d-1
    S = dp1[v] * n_child # 子に進んだ場合の値の総和
    if v != root:
        S += dp2[v]+1# あらゆる移動の値の総和
    for c in graph[v]:
        if c == parent[v]:
            continue
        if d == 1:
            dp2[c] = 0
        else:
            dp2[c] = (S-dp1[c]-1) / (d-1)

answer = []
for v in range(1,N+1):
    d = deg[v]
    n_child = d if v == root else d-1
    S = dp1[v] * n_child
    if v != root:
        S += dp2[v]+1# あらゆる移動の値の総和
    answer.append(S/d)

print('\n'.join(map(str,answer)))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+1)
dp_cum = [0] * (N+1)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[-1] + 1
answer %= MOD
print(answer)

Fixed submission:
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+10)
dp_cum = [0] * (N+10)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[N] + 1
answer %= MOD
print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

from collections import deque

N = int(input())

# empty
N -= 1

if N == 0:
    print(1)
    print(1,1)
    exit()

bit = [i for i in range(60) if N&(1<<i)]

n = bit[-1]
left = deque(range(n,0,-1))
right = deque()
x = n+1

for i in range(n,0,-1):
    right.append(i)
    if i-1 in bit:
        right.append(x)
        left.appendleft(x)
        x += 1

S = left + right
print(len(S))
print(' '.join(map(str,S)))

Fixed submission:
import sys
input = sys.stdin.readline

from collections import deque

N = int(input())

# empty
N += 1

bit = [i for i in range(60) if N&(1<<i)]

n = bit[-1]
left = deque(range(n,0,-1))
right = deque()
x = n+1

for i in range(n,0,-1):
    right.append(i)
    if i-1 in bit:
        right.append(x)
        left.appendleft(x)
        x += 1

S = list(left) + list(right)
print(len(S))
print(' '.join(map(str,S)))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

from collections import deque

N = int(input())

bit = [i for i in range(60) if N&(1<<i)]

n = bit[-1]
left = deque(range(n,0,-1))
right = deque()
x = n+1

left,right

for i in range(n,0,-1):
    right.append(i)
    if i-1 in bit:
        right.append(x)
        left.appendleft(x)
        x += 1

S = left + right
print(len(S))
print(' '.join(map(str,S)))

Fixed submission:
import sys
input = sys.stdin.readline

from collections import deque

N = int(input())

# empty
N += 1

bit = [i for i in range(60) if N&(1<<i)]

n = bit[-1]
left = deque(range(n,0,-1))
right = deque()
x = n+1

for i in range(n,0,-1):
    right.append(i)
    if i-1 in bit:
        right.append(x)
        left.appendleft(x)
        x += 1

S = list(left) + list(right)
print(len(S))
print(' '.join(map(str,S)))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
ans = (a+b)%24
print(ans)

Fixed submission:
a,b = map(int,input().split())
ans = (a+b)%24
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

"""
・「必要」とは～～が存在
・x を含まない、[K-x,K) 内の総和が存在
・集合を指定すると、ある値段より上側
・全体としても単調性がある
"""

N,K,*A = map(int,read().split())

A.sort()
A = [x if x <= K else K + 1 for x in A]

mask = (1 << K) - 1

def test(x):
    # x番目は必要
    if A[x] > K:
        return True
    dp = 1
    for a in itertools.chain(A[:x], A[x+1:]):
        dp |= (dp << a)
        dp &= mask
    dp >>= (K - x)
    return (dp > 0)

left = -1 # 必要
right = N # 不要
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = left + 1
print(answer)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

"""
・「必要」とは～～が存在
・x を含まない、[K-x,K) 内の総和が存在
・集合を指定すると、ある値段より上側
・全体としても単調性がある
"""

N,K,*A = map(int,read().split())

A = [x if x <= K else K + 1 for x in A]
A.sort()

mask = (1 << K) - 1

def test(x):
    # x番目は必要
    if A[x] > K:
        return True
    dp = 1
    for a in itertools.chain(A[:x], A[x+1:]):
        dp |= (dp << a)
        dp &= mask
    dp >>= (K - A[x])
    return (dp > 0)

left = -1 # 必要
right = N # 不要
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = left + 1
print(answer)

Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

"""
・「必要」とは～～が存在
・x を含まない、[K-x,K) 内の総和が存在
・集合を指定すると、ある値段より上側
・全体としても単調性がある
"""

N,K,*A = map(int,read().split())

A.sort()
A = [x if x <= K else K + 1 for x in A]

mask = (1 << K) - 1

def test(x):
    # x 番目を抜いて
    dp = 1
    for a in itertools.chain(A[:x], A[x+1:]):
        dp |= (dp << a)
        dp &= mask
    dp >>= (K - x)
    return (dp > 0)

left = -1 # 必要
right = N # 不要
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = right
print(answer)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

"""
・「必要」とは～～が存在
・x を含まない、[K-x,K) 内の総和が存在
・集合を指定すると、ある値段より上側
・全体としても単調性がある
"""

N,K,*A = map(int,read().split())

A = [x if x <= K else K + 1 for x in A]
A.sort()

mask = (1 << K) - 1

def test(x):
    # x番目は必要
    if A[x] > K:
        return True
    dp = 1
    for a in itertools.chain(A[:x], A[x+1:]):
        dp |= (dp << a)
        dp &= mask
    dp >>= (K - A[x])
    return (dp > 0)

left = -1 # 必要
right = N # 不要
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = left + 1
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""
・1,11,111,...に分解して9個ずつまとめる
・9倍して考える。9N+x の digit sum <= x となる最小のxが知りたい
・xが満たせばx+1も満たすので、二分探索できる
"""

N = int(read())

N *= 9

def digit_sum(N):
    return sum(map(int,str(N)))

def test(N,x):
    return digit_sum(N + x) <= x

left = 0
right = len(str(N)) * 9 + 100
while left + 1 < right:
    x = (left + right) // 2
    if test(N,x):
        right = x
    else:
        left = x

answer = (right + 8) // 9
print(answer)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""
・1,11,111,...に分解して9個ずつまとめる
・9倍して考える。9N+x の digit sum <= x となる最小のxが知りたい
・xが満たせばx+1も満たすので、二分探索できる
"""

N = [x - ord('0') for x in map(int,read().rstrip())][::-1]

# とりあえず 9 倍
N = [9 * x for x in N] + [0] * 10
L = len(N)

for i in range(L-1):
    q,r = divmod(N[i],10)
    N[i] = r
    N[i+1] += q

high1 = sum(N[10:])
N[10] += 1
for i in range(10,L-1):
    if N[i] == 10:
        N[i] = 0
        N[i+1] += 1
high2 = sum(N[10:])
low = N[:10]

low = sum(x * 10 ** i for i,x in enumerate(N[:10]))

A = 10 ** 10

def digit_sum(N):
    return sum(map(int,str(N)))

def test(x):
    if low + x >= A:
        return digit_sum(low + x) - 1 + high2 <= x
    return digit_sum(low + x) + high1 <= x

left = 0
right = 10 ** 10
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = (right + 8) // 9
print(answer)
Buggy python submission (verdict: Runtime Error):
import itertools
N,M = map(int,input().split())
edges = set()
for _ in range(N):
  a,b = map(int,input().split())
  edges.add((a,b))
  edges.add((b,a))

answer = 0

for p in itertools.permutations(range(1,N+1)):
  if p[0] != 1:
    continue
  bl = True
  for i in range(N-1):
    if (p[i], p[i+1]) not in edges:
      bl = False
      break
  if bl:
    answer += 1

print(answer)

Fixed submission:
import itertools
N,M = map(int,input().split())
edges = set()
for _ in range(M):
  a,b = map(int,input().split())
  edges.add((a,b))
  edges.add((b,a))

answer = 0

for p in itertools.permutations(range(1,N+1)):
  if p[0] != 1:
    continue
  bl = True
  for i in range(N-1):
    if (p[i], p[i+1]) not in edges:
      bl = False
      break
  if bl:
    answer += 1

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

uninity = [0] * (N+1)
dp = [np.zeros(30,np.int64) for _ in range(N+1)]
answer = -1
for x in order[::-1]:
    p = parent[x]
    A = dp[x]
    twice = (A >= 2)
    if np.any(twice):
        k = np.where(twice)[0].max()
        A[:k] = 1
    lsb = np.where(A == 0)[0].min()
    if answer < lsb:
        answer += 1
    uninity[x] = lsb
    A[lsb] = 1
    A[:lsb] = 0
    A[A>0] = 1
    dp[p] += A

print(answer)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

full = (1 << 60) - 1
uninity = [0] * (N+1)
dp = [0] * (N+1)
twice = [0] * (N+1)
for x in order[::-1]:
    p = parent[x]
    n = twice[x].bit_length() - 1
    if n >= 0:
        dp[x] |= (1 << (n+1)) - 1
    can_use = full & (~dp[x])
    lsb = can_use & (-can_use)
    uninity[x] = lsb
    dp[x] |= lsb
    dp[x] &= full & ~(lsb - 1)
    
    twice[p] |= (dp[x] & dp[p])
    dp[p] |= dp[x]

x = max(uninity)
answer = x.bit_length() - 1
print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i8,i8,i8[:])', cache=True)
def main(N, K, A):
    B = np.maximum(A, 0)
    Acum = np.zeros(len(A) + 1, np.int64)
    Bcum = np.zeros(len(A) + 1, np.int64)
    Acum[1:] = np.cumsum(A)
    Bcum[1:] = np.cumsum(B)
    ret = -(10**18)
    for l in range(N - K + 1):
        r = l + K
        sum1 = Bcum[l]
        sum2 = Bcum[-1] - Bcum[r]
        sum3 = Acum[r] - Acum[l]
        x = sum1 + sum2 + max(sum3, 0)
        ret = max(ret, x)
    return ret

N, K = map(int, readline().split())
A = np.array(read().split(), np.int64)

print(main(N, K, A))


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

import numpy as np

# どこかの長さKは最後に単色で残る
# そこを残すと決めると他は自由に設定できる

N,K = map(int,input().split())
A = np.array(input().split(), dtype=np.int64)

Acum = A.cumsum()
range_sum = Acum[K-1:] - Acum[:N-(K-1)] + A[:N-(K-1)]

# 各地点を左端として、長さKの区間の合計を求める
Acum = A.cumsum()
range_sum = Acum[K-1:] - Acum[:N-(K-1)] + A[:N-(K-1)]
best = np.maximum(A,0)
best_cum = best.cumsum()
best_range_sum = best_cum[K-1:] - best_cum[:N-(K-1)] + best[:N-(K-1)]

min_loss = (best_range_sum - np.maximum(range_sum,0)).min()

answer = best.sum() - min_loss
print(answer)
Buggy python submission (verdict: Runtime Error):
# そもそも人数分布は一意。
import numpy as np
MOD = 10**9 + 7
N = int(input())
A = np.array([int(x) for x in input().split()])

left = np.arange(N)
right = N-1-left
cnt_1 = np.bincount(np.abs(left-right))
cnt_2 = np.bincount(A)

if (cnt_1 != cnt_2).any():
  answer = 0
else:
  answer = pow(2, N//2, MOD)
  
print(answer)

Fixed submission:
# そもそも人数分布は一意。
import numpy as np
MOD = 10**9 + 7
N = int(input())
A = np.array([int(x) for x in input().split()])

left = np.arange(N)
right = N-1-left
cnt_1 = np.bincount(np.abs(left-right))
cnt_2 = np.bincount(A)

if cnt_1.shape != cnt_2.shape or (cnt_1 != cnt_2).any():
  answer = 0
else:
  answer = pow(2, N//2, MOD)
  
print(answer)
Buggy python submission (verdict: Runtime Error):
S = input()

while True:
  if S[-5:] == 'dream':
    S = S[:-5]
    continue
  elif S[:-7] == 'dreamer':
    S = S[:-7]
    continue
  elif S[-5:] == 'erase':
    S = S[:-5]
    continue
  elif S[-7:] == 'eraser':
    S = S[:-7]
    continue
  break

answer = 'YES' if not S else 'NO
print(answer)

Fixed submission:
S = input()

while True:
  if S[-5:] == 'dream':
    S = S[:-5]
    continue
  elif S[-7:] == 'dreamer':
    S = S[:-7]
    continue
  elif S[-5:] == 'erase':
    S = S[:-5]
    continue
  elif S[-6:] == 'eraser':
    S = S[:-6]
    continue
  break

answer = 'YES' if not S else 'NO'
print(answer)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input())

ans = b//c - (a-1)//c
print(ans)

Fixed submission:
a,b,c = map(int,input().split())

ans = b//c - (a-1)//c
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
from scipy.sparse.csgraph import *

xs,ys,xt,yt = map(int,input().split())
N = int(input())
XYR = np.empty((3,N+2),dtype=np.int64)
XYR[:,:2] = [[xs,xt],[ys,yt],[0,0]]

XYR[:,2:] = np.array([input().split() for _ in range(N)], dtype=np.int64).T

X,Y,R = XYR

dist = np.sqrt(np.square(X[:,None] - X[None,:]) + np.square(Y[:,None] - Y[None,:])) # euclid
dist -= R[:,None] + R[None,:]
np.maximum(dist, 0, out = dist)
dist[range(N+2), range(N+2)] = np.inf

graph = csgraph_from_dense(dist, null_value = np.inf)

answer = dijkstra(graph, indices = 0)[1]

print(answer)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra

xs,ys,xt,yt = map(int,input().split())
N = int(input())
XYR = np.empty((3,N+2),dtype=np.int64)
XYR[:,:2] = [[xs,xt],[ys,yt],[0,0]]

XYR[:,2:] = np.array([input().split() for _ in range(N)], dtype=np.int64).T

X,Y,R = XYR

dist = np.sqrt(np.square(X[:,None] - X[None,:]) + np.square(Y[:,None] - Y[None,:])) # euclid
dist -= R[:,None] + R[None,:]
np.maximum(dist, 0, out = dist)
dist[range(N+2), range(N+2)] = np.inf

graph = csgraph_from_dense(dist, null_value = np.inf)

answer = dijkstra(graph, indices = 0)[1]

print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

"""
・2,3^n,2
・3(1)
・1
・333
"""

import numpy as np

MOD = 10**9 + 7

N,A,B,C = map(int,readline().split())

if B&1:
    print(0)
    exit()

def cumprod(arr):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

U = 10**5
x = np.arange(U,dtype=np.int64); x[0] = 1
fact = cumprod(x)
x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
fact_inv = cumprod(x)[::-1]

"""
・2,3^n,2：B2個
・3113：A-n個
・11：n個
・333333：m個
"""

B2 = B//2

answer = 0
for m in range(C//3+1):
    n_min = max(0,A-C+3*m)
    # (B2+A+m)! / (B2)!(A-n)!(n)!(m)!
    x = fact[B2+A+m] * fact_inv[m] % MOD * fact_inv[B2] % MOD
    x *= fact_inv[A-n_min::-1]; x %= MOD
    x *= fact_inv[n_min:A+1]; x %= MOD
    # 2,3^n,2のところの3の振り分けを決める。B2個の非負整数の和がC-3m-(A-n)
    # (B2+A+m)! / (B2)!(A-n)!(n)!(m)!
    y = fact[B2-1+C-3*m-A+n_min:B2+C-3*m] * fact_inv[B2-1] % MOD
    y *= fact_inv[C-3*m-A+n_min:C-3*m+1]; y %= MOD
    answer += (x*y%MOD).sum()

answer %= MOD

print(answer)

Fixed submission:
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

"""
・2,3^n,2
・3(1)
・1
・333
"""

import numpy as np

MOD = 10**9 + 7

N,A,B,C = map(int,readline().split())

if B&1:
    print(0)
    exit()

def cumprod(arr):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

U = 10**5
x = np.arange(U,dtype=np.int64); x[0] = 1
fact = cumprod(x)
x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
fact_inv = cumprod(x)[::-1]

"""
・2,3^n,2：B2個
・3113：A-n個
・11：n個
・333333：m個
"""

B2 = B//2

answer = 0
for m in range(C//3+1):
    if B2 == 0:
        a = C-3*m; b = m; c = A-a
        if a < 0 or c < 0:
            continue
        x = fact[a+b+c] * fact_inv[a] % MOD
        x *= fact_inv[b]; x %= MOD
        x *= fact_inv[c]; x %= MOD
        answer += x
        continue
    n_min = max(0,A-C+3*m)
    # (B2+A+m)! / (B2)!(A-n)!(n)!(m)!
    x = fact[B2+A+m] * fact_inv[m] % MOD * fact_inv[B2] % MOD
    x *= fact_inv[A-n_min::-1]; x %= MOD
    x *= fact_inv[n_min:A+1]; x %= MOD
    # 2,3^n,2のところの3の振り分けを決める。B2個の非負整数の和がC-3m-(A-n)
    # (B2+A+m)! / (B2)!(A-n)!(n)!(m)!
    y = fact[B2-1+C-3*m-A+n_min:B2+C-3*m] * fact_inv[B2-1] % MOD
    y *= fact_inv[C-3*m-A+n_min:C-3*m+1]; y %= MOD
    answer += (x*y%MOD).sum()

answer %= MOD

print(answer)