Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
*H, = map(int, input().split())
INF = 1 << 30
dp = [INF]*N
dp[0] = 0
for i, (d, h) in enumerate(zip(dp, H)):
    for k in range(1, K+1):
        if i+k >= N:
            break
        dp[i+k] = min(dp[i+k], d + abs(H[i+k]-h))

print(dp[-1])


Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [1<<30]*(N)
dp[0] = 0
 
for i in range(1, N):
  dp[i] = min((dp[j]+abs(h[i]-h[j])) for j in range(max(0, i-K), i))
 
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = [1<<30]*N
dp[0] = 0

for i in range(1, N):
  dp[i] = min((dp[j]+abs(h[i]-h[j])) for j in range(max(0, i-K), i))

print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [1<<30]*(N)
dp[0] = 0
 
for i in range(1, N):
  dp[i] = min((dp[j]+abs(h[i]-h[j])) for j in range(max(0, i-K), i))
 
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [1<<30]*(N)
dp[0] = 0

for i in range(1, N):
  dp[i] = min((dp[j]+abs(h[i]-h[j])) for j in range(max(0, i-K), i))

print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [1<<30]*(N)
dp[0] = 0
 
for i in range(1, N):
  dp[i] = min((dp[j]+abs(h[i]-h[j])) for j in range(max(0, i-K), i))
 
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [1<<30]*(N)
dp[0] = 0

for i in range(0, N):
  for k in range(K+1):
    if i+k >= N:
      continue
    dp[i+k] = min(dp[i+k], dp[i]+abs(h[i+k]-h[i]))

print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [1<<30]*(N)
dp[0] = 0
 
for i in range(1, N):
  dp[i] = min((dp[j]+abs(h[i]-h[j])) for j in range(max(0, i-K), i))
 
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W, *A = map(int, open(0).read().split())
A = zip(*[iter(A)]*2)

# dp[i][j] iまでの品物からいくつか選んで残り容量がjのときの価値の最大値
dp = [[0]*(W+1) for _ in range(N+1)]

for i, (w, v) in enumerate(A):
    for j in range(W+1):
        if j < w:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)

print(max(dp[N]))

Fixed submission:
N, W, *A = map(int, open(0).read().split())
A = zip(*[iter(A)]*2)

# dp[i][j] iまでの品物からいくつか選んで重さの総和がjのときの価値の最大値
dp = [[0]*(W+1) for _ in range(N+1)]

for i, (w, v) in enumerate(A):
    for j in range(W+1):
        if j < w:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)

print(max(dp[N]))
Buggy python submission (verdict: Time Limit Exceeded):
X = input()
Y = input()

dp = [[0]*(len(Y)+1) for _ in [0]*(len(X)+1)]

for i, x in enumerate(X):
    i += 1
    for j, y in enumerate(Y):
        j += 1
        dp[i][j] = max(dp[i-1][j-1]+int(x == y),
                       dp[i-1][j], dp[i][j-1])

ans = []
cnt = dp[-1][-1]
x = y = -1
while cnt:
    while dp[x-1][y] == cnt:
        x -= 1
    while dp[x][y-1] == cnt:
        y -= 1
    ans.append(X[x])
    cnt -= 1
    x -= 1
    y -= 1
ans = ''.join(ans)[::-1]
print(ans)


Fixed submission:
X = input()
Y = input()

dp = [[0]*(len(Y)+1) for _ in [0]*(len(X)+1)]

for i, x in enumerate(X):
    i += 1
    for j, y in enumerate(Y):
        j += 1
        dp[i][j] = max(dp[i-1][j-1]+int(x == y),
                       dp[i-1][j], dp[i][j-1])

ans = []
cnt = dp[-1][-1]
x = y = -1
while cnt:
    while dp[x-1][y] == cnt:
        x -= 1
    while dp[x][y-1] == cnt:
        y -= 1
    ans.append(X[x])
    cnt -= 1
    x -= 1
    y -= 1
ans = ''.join(ans)[::-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, P = map(int, input().split())
dic = defaultdict(int)

MAX = int(P**0.5)+1
for p in range(2, MAX):
    while P % p == 0:
        dic[p] += 1
        P //= p
    if P:
        dic[P] += 1

ans = 1
print(dic)1
for p, cnt in dic.items():
    ans *= pow(p, cnt//N)
print(ans)

Fixed submission:
from collections import defaultdict

N, P = map(int, input().split())
dic = defaultdict(int)

MAX = int(P**0.5)+1
for p in range(2, MAX):
    while P % p == 0:
        dic[p] += 1
        P //= p
if P > 1:
    dic[P] += 1

ans = 1
for p, cnt in dic.items():
    ans *= pow(p, cnt//N)
print(ans)
Buggy python submission (verdict: Runtime Error):
# AtCoder Beginner Contest 111
# C - /\/\/\/
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter

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

ev = A[0::2]
od = A[1::2]

ev_C = Counter(ev)
od_C = Counter(od)

if ev == od and ev_C.most_common()[0][0]==N//2:
    print(N//2)
else:
    ans = N
    ev_common = ev_C.most_common()
    od_common = od_C.most_common()
    ev_most = ev_common[0][1]
    od_most = od_common[0][1]
    if ev_common[0][0] == od_common[0][0]:
        ev_second = ev_common[1][1]
        od_second = od_common[1][1]
        ans = min(ans, N-ev_most-od_second)
        ans = min(ans, N-ev_second-od_most)
    else:
        ans = min(ans, N-ev_most-od_most) 

    print(ans)

Fixed submission:
# AtCoder Beginner Contest 111
# C - /\/\/\/
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter

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

ev = A[0::2]
od = A[1::2]

ev_C = Counter(ev)
od_C = Counter(od)


if ev == od and ev_C.most_common()[0][1] == N//2:
    print(N//2)
else:
    ans = N
    ev_common = ev_C.most_common()
    od_common = od_C.most_common()
    ev_most = ev_common[0][1]
    od_most = od_common[0][1]
    if ev_common[0][0] == od_common[0][0]:
        ev_second = ev_common[1][1]
        od_second = od_common[1][1]
        ans = min(ans, N-ev_most-od_second)
        ans = min(ans, N-ev_second-od_most)
    else:
        ans = min(ans, N-ev_most-od_most)

    print(ans)

Buggy python submission (verdict: Runtime Error):
# AtCoder Beginner Contest 111
# C - /\/\/\/
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter

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

ev = A[0::2]
od = A[1::2]

ev_C = Counter(ev)
od_C = Counter(od)

ev_most = ev_C.most_common()[0][1]
od_most = od_C.most_common()[0][1]
ev_second = ev_C.most_common()[1][1]
od_second = od_C.most_common()[1][1]


if ev == od:
    print(N//2)
else:
    print(min(
        N-ev_most-od_most,
        N-ev_most-od_second,
        N-ev_second-od_most
    ))


Fixed submission:
# AtCoder Beginner Contest 111
# C - /\/\/\/
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter

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

ev = A[0::2]
od = A[1::2]

ev_C = Counter(ev)
od_C = Counter(od)


if ev == od and ev_C.most_common()[0][1] == N//2:
    print(N//2)
else:
    ans = N
    ev_common = ev_C.most_common()
    od_common = od_C.most_common()
    ev_most = ev_common[0][1]
    od_most = od_common[0][1]
    if ev_common[0][0] == od_common[0][0]:
        ev_second = ev_common[1][1]
        od_second = od_common[1][1]
        ans = min(ans, N-ev_most-od_second)
        ans = min(ans, N-ev_second-od_most)
    else:
        ans = min(ans, N-ev_most-od_most)

    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
A = [tuple(map(int, line.split())) for line in sys.stdin.buffer.readlines()]
A.sort()
cnt = 0
R = 0
for a, b in A:
    if R <= a:
        cnt += 1
        R = b
    elif b < R:
        R = b
print(cnt)


Fixed submission:
N, M, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*2)
A.sort()
cnt = 0
R = 0
for a, b in A:
    if R <= a:
        cnt += 1
        R = b
    elif b < R:
        R = b
print(cnt)
Buggy python submission (verdict: Runtime Error):
def main():
    H, W = map(int, input().split())
    S = ['.'*W]+['.'+input()+'.' for _ in range(H)]+['.'*W]

    for h in range(1, H+1):
        for w in range(1, W+1):
            if S[h][w] == '#':
                if S[h-1][w] == '.' and S[h+1][w] == '.' and S[h][w+1] == '.' and S[h][w-1] == '.':
                    return False
    return True


print('Yes' if main() else 'No')


Fixed submission:
def main():
    H, W = map(int, input().split())
    S = ['.'*(W+2)]+['.'+input()+'.' for _ in range(H)]+['.'*(W+2)]

    for h in range(1, H+1):
        for w in range(1, W+1):
            if S[h][w] == '#':
                if S[h-1][w] == '.' and S[h+1][w] == '.' and S[h][w+1] == '.' and S[h][w-1] == '.':
                    return False
    return True


print('Yes' if main() else 'No')
Buggy python submission (verdict: Runtime Error):
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
import numpy as np
N = int(input())
A = np.loadtxt(open(0), dtype=np.int)
D = csgraph_from_dense(A)
D = floyd_warshall(D, directed=False)


if (A == D).all():
    ans = 0
    D += np.identity(N, int) * (1 << 60)
    for i in range(N):
        for j in range(i+1, N):
            a = np.min(D[i]+D[j])
            if a > D[i, j]:
                ans += D[i, j]
    print(int(ans))
else:
    print(-1)


Fixed submission:

def warshall_floyd(cost):
    ret = [[1]*N for _ in [0]*N]
    for k in range(N):
        for i, c_left in enumerate(cost[i][k] for i in range(N)):
            for j, (c_now, c_right) in enumerate(zip(cost[i], cost[k])):
                if c_left + c_right < c_now:
                    print(-1)
                    exit()
                if i == j or j == k or k == i:
                    continue
                if c_left + c_right == c_now:
                    ret[i][j] = ret[j][i] = 0
    return ret


INF = 10**10
N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*N)


E = []
for i in range(N):
    for j in range(i+1, N):
        E.append((A[i][j], i, j))
E.sort()

road = warshall_floyd(A)
ans = 0
for cost, i, j in E:
    if not road[i][j]:
        continue
    ans += cost

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

def warshall_floyd(cost):
    ret = [[1]*N for _ in [0]*N]
    for k in range(N):
        for i, c_left in enumerate(cost[i][k] for i in range(N)):
            for j, (c_now, c_right) in enumerate(zip(cost[i], cost[k])):
                if c_left + c_right < c_now:
                    print(-1)
                    exit()
                if i == j or j == k or k == i:
                    continue
                if c_left + c_right == c_now:
                    ret[i][j] = ret[j][i] = 0
    return ret


INF = 10**10
N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*N)


E = []
for i in range(N):
    for j in range(i+1, N):
        E.append((A[i][j], i, j))
E.sort()

road = warshall_floyd(A)
ans = 0
for cost, i, j in E:
    if not road[i][j]:
        continue
    ans += cost

print(ans)


Fixed submission:

def warshall_floyd(cost):
    ret = [[1]*N for _ in [0]*N]
    for k in range(N):
        for i, c_left in enumerate(cost[i][k] for i in range(N)):
            for j, (c_now, c_right) in enumerate(zip(cost[i], cost[k])):
                if c_left + c_right < c_now:
                    print(-1)
                    exit()
                if i == j or j == k or k == i:
                    continue
                if c_left + c_right == c_now:
                    ret[i][j] = ret[j][i] = 0
    return ret


INF = 10**10
N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*N)


E = []
for i in range(N):
    for j in range(i+1, N):
        E.append((A[i][j], i, j))
E.sort()

road = warshall_floyd(A)
ans = 0
for cost, i, j in E:
    if not road[i][j]:
        continue
    ans += cost

print(ans)
Buggy python submission (verdict: Runtime Error):
n, *A = map(int, open(0).read().split())
c = [0]*9
for a in A:
  c[min(8, a//400)] += 1

cl = 8-c[:-1].count(0)
cmin = max(1, cl)
cmax = min(cl+c[8])
print(cmin, cmax)

Fixed submission:
n, *A = map(int, open(0).read().split())
c = [0]*9
for a in A:
  c[min(8, a//400)] += 1

cl = 8-c[:-1].count(0)
cmin = max(1, cl)
cmax = cl+c[8]
print(cmin, cmax)

Buggy python submission (verdict: Runtime Error):
n, *A = map(int, open(0).read().split())
c = [0]*9
for a in A:
  c[min(8, a//400)] += 1

print(8-c[:-1].count(0))
print(c[8])
cl = 8-c[:-1].count(0)
cmin = max(1, cl)
cmax = min(cl+c[8])
print(cmin, cmax)

Fixed submission:
n, *A = map(int, open(0).read().split())
c = [0]*9
for a in A:
  c[min(8, a//400)] += 1

cl = 8-c[:-1].count(0)
cmin = max(1, cl)
cmax = cl+c[8]
print(cmin, cmax)

Buggy python submission (verdict: Runtime Error):
n, *A = map(int, open(0).read().split())
c = [0]*9
for a in A:
  c[min(8, a//400)] += 1

print(c)
cmin = max(1, 8-[c::-1].count(0))
cmax = min(8, cmin+c[8])
print(cmin, cmax)

Fixed submission:
n, *A = map(int, open(0).read().split())
c = [0]*9
for a in A:
  c[min(8, a//400)] += 1

cl = 8-c[:-1].count(0)
cmin = max(1, cl)
cmax = cl+c[8]
print(cmin, cmax)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
arr = []
for i in range(N):
  a, b = map(int, input().split())
  arr += [a]*b

arr.sort()
print(arr[K-1])

Fixed submission:
N, K = map(int, input().split())
cnt = [0]*100001
S = set()
for i in range(N):
  a, b = map(int, input().split())
  cnt[a-1] += b
  S.add(a)

acc = 0
for s in sorted(S):
  acc += cnt[s-1]
  if acc >= K:
    print(s)
    break
Buggy python submission (verdict: Runtime Error):
# AtCoder Regular Contest 073
# D - Simple Knapsack
# https://atcoder.jp/contests/arc073/tasks/arc073_b
from itertools import combinations_with_replacement, accumulate
N, W, *A = map(int, open(0).read().split())
w0 = A[0]
T = [[] for _ in [0]*4]
M = [0]*4

for w, v in zip(*[iter(A)]*2):
    T[w-w0].append(v)
    M[w-w0] += 1
for t in T:
    t.sort()

acm = [tuple(accumulate(t)) for t in T]


def rec(w=0, k=0, c=()):
    if k == 4:
        C.append(c)
        return
    for i in range(M[k]+1):
        w1 = w + i*(w0+k)
        if w1 > W:
            break
        rec(w1, k+1, (*c, i))


C = []
rec()

ans = 0
for c in C:
    ans = max(ans, sum(acm[i][n-1] if n > 0 else 0 for i, n in enumerate(c)))

print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in [0]*N]
w0 = A[0][0]
A = [(w-w0, v) for w, v in A]

dp = [[0]*(3*N) for _ in [0]*(N+1)]
ans = 0
sumw = 0
for k, (w, v) in enumerate(A):
    for i in range(k, -1, -1):
        for j in range(sumw, -1, -1):
            if 0 <= i < N and 0 <= j+w < 3*N and (i+1)*w0+j+w <= W:
                dp[i+1][j+w] = max(dp[i][j]+v, dp[i+1][j+w])
    sumw += w

for d in dp:
    ans = max(ans, *d)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input(input().split()))
print('YES' if b-a==c-b else 'NO')

Fixed submission:
a, b, c = map(int, input().split())
print('YES' if b-a==c-b else 'NO')
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(800*n - 200(n//15))

Fixed submission:
n = int(input())
print(800*n - 200*(n//15))
Buggy python submission (verdict: Runtime Error):
n = int(input)

p = 1
for i in range(2, n+1):
  p = p*i%(10**9+7)
print(p)

Fixed submission:
n = int(input())
 
p = 1
for i in range(2, n+1):
  p = p*i%(10**9+7)
print(p)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
G = [[] for _ in range(n)]

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

flag = (1<<n)-1

def dfs(v=0, visited=1):
    if visited == flag:
        return 1

    cnt = 0
    for to in G[v]:
        if visited & 1<<to:
            continue
        cnt += dfs(to, visited^(1<<to))
    return cnt

print(dfs())

Fixed submission:
n, m = map(int, input().split())
G = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a-=1; b-=1
    G[a].append(b)
    G[b].append(a)

flag = (1<<n)-1

def dfs(v=0, visited=1):
    if visited == flag:
        return 1

    cnt = 0
    for to in G[v]:
        if visited & (1<<to):
            continue
        cnt += dfs(to, visited^(1<<to))
    return cnt

print(dfs())

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
G = [[] for _ in range(n)]

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

flag = (1<<n)-1

def dfs(v=0, visited=1):
    if visited == flag:
        return 1

    cnt = 0
    for to in G[v]:
        if visited & 1<<to:
            continue
        cnt += dfs(to, visited^(1<<to))
    return cnt

print(dfs())

Fixed submission:
n, m = map(int, input().split())
G = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a-=1; b-=1
    G[a].append(b)
    G[b].append(a)

flag = (1<<n)-1

def dfs(v=0, visited=1):
    if visited == flag:
        return 1

    cnt = 0
    for to in G[v]:
        if visited & (1<<to):
            continue
        cnt += dfs(to, visited^(1<<to))
    return cnt

print(dfs())
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

li = [0]*((N+1) >> 1)


def mod(b, x, n):
    acc = b
    for i in range(1, x):
        acc = (acc * b) % n
    return int(acc)


for a in A:
    if li[a >> 1] >= 2:
        print(0)
        break
    else:
        li[a >> 1] += 1

if N & 1:
    if li[0] != 1:
        print(0)
    elif li.count(1) > 1:
        print(0)
    else:
        c = li.count(2)
        print(mod(2, c, 10E9-7))
else:
    if li.count(1) > 0:
        print(0)
    else:
        c = li.count(2)
        print(mod(2, c, 10E9-7))



Fixed submission:
a, op, b = input().split()

a = int(a)
b = int(b)

if op == "+":
  print(a+b)
else:
  print(a-b)
Buggy python submission (verdict: Runtime Error):

def mod_(b, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * b % mod
        b = b * b % mod
        n >>= 1
    return int(res)

def main():

    N = int(input())
    A = list(map(int, input().split()))

    n = ((N+1) >> 1)
    li = [0]*n



    for a in A:
        if li[a >> 1] >= 2:
            print(0)
            break
        else:
            li[a >> 1] += 1

    if N & 1:
        if li[0] != 1:
            print(0)
        elif li.count(2) != n-1:
            print(0)
        else:
            c = n-1
            print(2 ** c % (1E9+7))
    else:
        if li.count(2) != n:
            print(0)
        else:
            c = n
            print(2 ** c % (1E9+7))

main()

Fixed submission:

def mod_(b, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * b % mod
        b = b * b % mod
        n >>= 1
    return int(res)

def main():

    N = int(input())
    A = list(map(int, input().split()))

    n = ((N+1) >> 1)
    li = [0]*n



    for a in A:
        li[a >> 1] += 1

    if N & 1:
        if li[0] != 1:
            print(0)
        elif li.count(2) != n-1:
            print(0)
        else:
            c = n-1
            print(2 ** c % (10**9+7))
    else:
        if li.count(2) != n:
            print(0)
        else:
            c = n
            print(2 ** c % (10**9+7))

main()

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

li = [0]*((N+1) >> 1)

for a in A:
    if li[a >> 1] >= 2:
        print(0)
        break
    else:
        li[a >> 1] += 1

if N & 1:
    if li[0] != 1:
        print(0)
    elif li.count(1) > 1:
        print(0)
    else:
        c = li.count(2)
        print(int(2**c % (10E9 - 7)))
else:
    if li.count(1) > 0:
        print(0)
    else:
        c = li.count(2)
        print(int(2**c % (10E9 - 7)))


Fixed submission:

def mod_(b, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * b % mod
        b = b * b % mod
        n >>= 1
    return int(res)

def main():

    N = int(input())
    A = list(map(int, input().split()))

    n = ((N+1) >> 1)
    li = [0]*n



    for a in A:
        li[a >> 1] += 1

    if N & 1:
        if li[0] != 1:
            print(0)
        elif li.count(2) != n-1:
            print(0)
        else:
            c = n-1
            print(2 ** c % (10**9+7))
    else:
        if li.count(2) != n:
            print(0)
        else:
            c = n
            print(2 ** c % (10**9+7))

main()
Buggy python submission (verdict: Runtime Error):
# dfs

C = ['dream', 'dreamer', 'erase', 'eraser']
S = input()
L = len(S)


def dfs(x):
    l = len(x)
    if l >= L:
        if S == x:
            return True
        else:
            return False

    match = S[l:l+7]
    for c in C:
        if match.find(c) == 0:
            if dfs(x+c):
                return True
    return False


print('YES' if dfs('') else 'NO')


Fixed submission:
def main():
  s = input()
  dream = False
  erase = False

  while s:
    if s.startswith('dream'):
      s = s[5:]
      dream = True
      erase = False
    elif s.startswith('erase'):
      s = s[5:]
      dream = False
      erase = True
    elif s.startswith('er') and dream:
      s = s[2:]
      dream = False
    elif s.startswith('r') and erase:
      s = s[1:]
      erase = False
    else:
      return False
  
  return True

if main():
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
A, S, C = input()
print(A+S[0]+C)

Fixed submission:
a, s, c = input().split()
print('A'+s[0]+'C')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(99999999)

a, b, x = map(int,input().split())

r = 0

for i in range(a, b+1):
    if i % x ==0:
        r += 1

print(r)


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

r = b // x - (a-1) // x

print(r)

Buggy python submission (verdict: Runtime Error):
a, b, x = map(int,input().split())

r = 0

for i in xrange(a, b+1):
    if i % x ==0:
        r += 1

print(r)


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

r = b // x - (a-1) // x

print(r)
Buggy python submission (verdict: Runtime Error):
import numpy as np

W, H, N = map(int, input().split())

ze = np.ones(W+1, H+1)
for i in range(N):
    x, y, a = map(int, input().split())
    
    if a == 1:
        ze[:x, :] = 0
    elif a == 2:
        ze[x+1:, :] = 0
    elif a == 3:
        ze[:, :y] = 0
    elif a == 4:
        ze[:, y+1:] = 0

print(np.sum(ze))

Fixed submission:
import numpy as np

W, H, N = map(int, input().split())

ze = np.ones((W, H))

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        ze[:x, :] = 0
    elif a == 2:
        ze[x:, :] = 0
    elif a == 3:
        ze[:, :y] = 0
    elif a == 4:
        ze[:, y:] = 0

print(np.sum(ze))

Buggy python submission (verdict: Runtime Error):
W, H, N = map(int, input().split())

for Nimport numpy as np

W, H, N = map(int, input().split())

ze = np.ones(W+1, H+1)
for i in range(N):
    li = [x, y, a = map(int, input().split()) for i in range(N)]
    
    if a == 1:
        ze[:x, :] = 0
    elif a == 2:
        ze[x+1:, :] = 0
    elif a == 3:
        ze[:, :y] = 0
    elif a == 4:
        ze[:, y+1:] = 0

print(np.sum(ze))

Fixed submission:
import numpy as np

W, H, N = map(int, input().split())

ze = np.ones((W, H))

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        ze[:x, :] = 0
    elif a == 2:
        ze[x:, :] = 0
    elif a == 3:
        ze[:, :y] = 0
    elif a == 4:
        ze[:, y:] = 0

print(np.sum(ze))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]

T = A = 0
for t, a in TA:
  _t, _a = t, a
  while t<T or a<A:
    t += _t; a += _a
  T = t; A = a
print(T+A)

Fixed submission:
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]

T = A = 1
for t, a in TA:
  r = max(A//a, T//t)
  if r*a >= A and r*t >= T:
    A = r*a; T = r*t
  else:
    A = (r+1)*a; T = (r+1)*t

print(T+A)