Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
D = list(map(int, input().split()))

f = [1] + [0 for i in range(1, H+1)]
flag = 0
for i in range(N):
  for j in range(H-D[i], -1, -1):
    if f[j] == 1:
      f[j+D[i]] = 1
  if f[-1] == 1:
    print("Yes")
    flag = 1
    break
if flag == 0:
  print("No")

Fixed submission:
H, N = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) >= H:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
D = list(map(int, input().split()))
p = [0]
flag = 0
for d in D:
  p = p + [i+d for i in p]
  if H in p:
    flag = 1
    break
if flag == 1:
  print("Yes")
else:
  print("No")

Fixed submission:
H, N = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) >= H:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
D = list(map(int, input().split()))
flag = 0

def f(h, d, s):
  if h == 0:
    return 1
  if len(d) == 0 or h > s:
    return 0
  a = f(h-d[0], [d[i] for i in range(1, len(d))], s-d[0])
  if a == 1:
    return 1
  a = f(h, [d[i] for i in range(1, len(d))], s-d[0])
  return a

if f(H, D, sum(D)) == 1:
  print("Yes")
else:
  print("No")


Fixed submission:
H, N = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) >= H:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
D = list(map(int, input().split()))
flag = 0

def f(h, d):
  if h == 0:
    return 1
  if len(d) == 0:
    return 0
  a = f(h-d[0], [d[i] for i in range(1, len(d))])
  if a == 1:
    return 1
  a = f(h, [d[i] for i in range(1, len(d))])
  return a

if f(H, D) == 1:
  print("Yes")
else:
  print("No")

Fixed submission:
H, N = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) >= H:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
print(sum(H[N-K]))

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
if N <= K:
  print(0)
else:
  print(sum(H[:N-K]))
Buggy python submission (verdict: Runtime Error):
A, N = map(int, input().split())
print(max(A-2*B, 0))

Fixed submission:
A, B = map(int, input().split())
print(max(A-2*B, 0))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N):
  B.append([A[i], i])
B.sort()
ANS = ""
for i in range(N):
  ANS += str(B[i][1]+1)
  if i != N-1:
    ANS += " "
print(ANS)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(N)]
for i in range(N):
  B[A[i]-1] = i
for b in B:
  print(b+1)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
A, B = map(int, input().split())
g = gcd(A, B)
ans = 1
n = 2
while g > 1:
  if g % n == 0:
    ans += 1
  while g % n == 0:
    g //= n
  n += 1
print(ans)

Fixed submission:
from fractions import gcd
A, B = map(int, input().split())
g = gcd(A, B)
ans = 1
n = 2
while g > 1:
  if n * n > g:
    ans += 1
    break
  if g % n == 0:
    ans += 1
  while g % n == 0:
    g //= n
  n += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
for i in range(M):
  a = A.pop(0) // 2
  f = 0
  for j in range(N-2):
    if A[j] >= a >= A[j+1]:
      A.insert(j+1, a)
      f = 1
      break
  if f == 0:
    A.append(a)
print(sum(A))

Fixed submission:
import heapq
N, M = map(int, input().split())
A = list(list(map(lambda x: int(x) * (-1), input().split())))
heapq.heapify(A)
for i in range(M):
  heapq.heappush(A, (-1) * ((-1 * heapq.heappop(A)) // 2))
print(-1 * sum(A))
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()
if a >= 3200:
  print("red")
esle:
  print(s)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")
Buggy python submission (verdict: Runtime Error):
S = input()
L = len(S)
A = [0 for i in range(L)]
f = 0
c = 0
P = 0
for i in range(L):
  if S[i] == "R":
    if f == 0:
      c += 1
    else:
      A[P] += c // 2
      A[P+1] += (c+1) // 2
      c = 1
      f = 0
  else:
    if f == 1:
      c += 1
    else:
      P = i-1
      A[P] += (c+1) // 2
      A[P+1] += c // 2
      c = 1
      f = 1
A[P] += c // 2
A[P+1] += (c+1) // 2
ans = str(A[0])
for i in range(1, N):
  ans = ans + " " + str(A[i])
print(ans)

Fixed submission:
S = input()
L = len(S)
A = [0 for i in range(L)]
f = 0
c = 0
P = 0
for i in range(L):
  if S[i] == "R":
    if f == 0:
      c += 1
    else:
      A[P] += c // 2
      A[P+1] += (c+1) // 2
      c = 1
      f = 0
  else:
    if f == 1:
      c += 1
    else:
      P = i-1
      A[P] += (c+1) // 2
      A[P+1] += c // 2
      c = 1
      f = 1
A[P] += c // 2
A[P+1] += (c+1) // 2
for a in A:
  print(a)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input())
if (A - B) % 2 == 1:
  print("IMPOSSIBLE")
else:
  print((A+B)//2)

Fixed submission:
A, B = map(int, input().split())
if (A - B) % 2 == 1:
  print("IMPOSSIBLE")
else:
  print((A+B)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)
for i in range(M):
  b, c = map(int, input().split())
  for j in range(b):
    a = heapq.heappop(A)
    if a < c:
      heapq.heappush(A, c)
    else:
      heapq.heappush(A, a)
      break
print(sum(A))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
B = []
for i in range(M):
  b, c = map(int, input().split())
  B.append([c, b])
B.sort(reverse=True)
i = 0
f = 0
for j in range(M):
  while B[j][1]:
    if A[i] < B[j][0]:
      A[i] = B[j][0]
      B[j][1] -= 1
      i += 1
      if i >= N:
        f = 1
        break
    else:
      f = 1
      break
  if f == 1:
    break
print(sum(A))
Buggy python submission (verdict: Runtime Error):
M = 0
ans = 0
for i in range(5):
  a = append(int(input()))
  b = ((a + 9) // 10) * 10
  M = max(M, b-a)
  ans += b
print(ans - M)

Fixed submission:
M = 0
ans = 0
for i in range(5):
  a = int(input())
  b = ((a + 9) // 10) * 10
  M = max(M, b-a)
  ans += b
print(ans - M)
Buggy python submission (verdict: Runtime Error):
l = list(map(input().split()))
if l[0] == l[1] == l[2]:
  print("Yes")
else:
  print("No")

Fixed submission:
l = list(map(int,input().split()))
if l[0] == l[1] and l[1] == l[2]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for i in range(Q):
  l, r = map(lambda x: int(x)-1, input().split())
  ans = 0
  for i in range(l, r):
    if S[i] == "A" and S[i+1] == "C":
      ans += 1
  print(ans)

Fixed submission:
N, Q = map(int, input().split())
S = input()
A = []
for i in range(N - 1):
  if S[i] == "A" and S[i+1] == "C":
    A.append(i+1)
lA = len(A)
for i in range(Q):
  l, r = map(int, input().split())
  L1 = -1
  R1 = lA
  while L1 + 1 < R1:
    C1 = (L1 + R1) // 2
    if A[C1] < l:
      L1 = C1
    else:
      R1 = C1
  L2 = -1
  R2 = lA
  while L2 + 1 < R2:
    C2 = (L2 + R2) // 2
    if A[C2] < r:
      L2 = C2
    else:
      R2 = C2
  print(L2 - L1)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
print(min(B // A), C)

Fixed submission:
A, B, C = map(int, input().split())
print(min(B // A, C))
Buggy python submission (verdict: Time Limit Exceeded):
N, P = map(int, input().split())
i = 2
ans = 1
while P > 1:
  x = 0
  while P % i == 0:
    x += 1
    P //= i
  ans *= i ** (x // N)
  i += 1
print(ans)

Fixed submission:
N, P = map(int, input().split())
i = 2
ans = 1
while P > 1:
  if i * i > P:
    if N == 1:
      ans *= P
    break
  x = 0
  while P % i == 0:
    x += 1
    P //= i
  ans *= i ** (x // N)
  i += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
m = A
for i in range(N):
  if m > abs(0.1 * T - H[i] * 0.006 - 0.1 * A):
    m = abs(0.1 * T - H[i] * 0.006 - 0.1 * A)
    ans = i + 1
print(ans)


Fixed submission:
N, M = map(int, input().split())
A = []
B = [[] for i in range(N)]
for i in range(M):
  P, Y = map(int, input().split())
  A.append([P, Y])
  B[P-1].append(Y)
for i in range(N):
  B[i].sort()
d = {}
for i in range(N):
  for y in range(len(B[i])):
    d[(i+1, B[i][y])] = y + 1
for i in range(M):
  print('{:0=6}'.format(A[i][0]) + '{:0=6}'.format(d[(A[i][0], A[i][1])]))
Buggy python submission (verdict: Runtime Error):
N = int(raw_input().split())
if N <= 999:
 print "ABC"
else:
 print "ABD"

Fixed submission:
N = int(raw_input())
if N <= 999:
 print "ABC"
else:
 print "ABD"
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
if a <= b:
  print(a)
else:
  print(a-1)

Fixed submission:
a, b = map(int, input().split())
if a <= b:
  print(a)
else:
  print(a-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
d = {}
x = 0
for i in range(N):
  x += A[i]
  d[x] = d.get(x, 0) + 1
print(N - len(d) + d[0])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
d = {}
x = 0
for i in range(N):
  x += A[i]
  d[x] = d.get(x, 0) + 1
ans = d.get(0, 0)
for x in d.values():
  ans += x * (x-1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
print(700 + 100 * S.count(o))

Fixed submission:
S = input()
print(700 + 100 * S.count("o"))
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
Y //= 1000
i = 0
f = 0
whlie 1:
  if 10 * i > Y:
    break
  y = Y - 10 * i
  n = N - i
  if n <= y <=  5 * n and (y - n) % 4 == 0:
    print(str(i) + " " + str((y-n)//4) + " " + str((5 * n - y) // 4))
    f = 1
  i += 1
if f == 0:
  print("-1 -1 -1")

Fixed submission:
N, Y = map(int, input().split())
Y //= 1000
i = 0
f = 0
while 1:
  if 10 * i > Y:
    break
  y = Y - 10 * i
  n = N - i
  if n <= y <=  5 * n and (y - n) % 4 == 0:
    print(str(i) + " " + str((y-n)//4) + " " + str((5 * n - y) // 4))
    f = 1
    break
  i += 1
if f == 0:
  print("-1 -1 -1")
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
  x = sum(list(map(int, str(i))))
  if A <= X <= B:
    ans += i
print(ans)

Fixed submission:
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
  x = sum(list(map(int, str(i))))
  if A <= x <= B:
    ans += i
print(ans)

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
  x = sum(list(map(str, i)))
  if A <= X <= B:
    ans += i
print(ans)

Fixed submission:
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
  x = sum(list(map(int, str(i))))
  if A <= x <= B:
    ans += i
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
s.sort()
t.sort(reverse = True)
if s < t:
  print("Yes")
else:
  print("No")

Fixed submission:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
if s < t:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())A, B, C, D, E, F = map(int, input().split())
perc = 0.0
ans = [0, 0]
op = [0, 0, 0, 0]
a = 0
while 100 * a <= F:
  b = 0
  while 100 * (a + b) <= F:
    c = 0
    while 100 * (a + b) + c <= F:
      if c > (a + b) * E:
        break
      d = 0
      while 100 * (a + b) + c + d <= F:
        if c + d > (a + b) * E:
          break
        if a == b == c == d == 0:
          break
        p = (c + d) * 1.0 / (100 * (a + b) + c + d)
        if p > perc:
          perc = p
          ans = [100 * (a + b) + c + d, c + d]
          op = [a, b, c, d]
        d += D
      c += C
    b += B
  a += A
print(str(ans[0]) + " " + str(ans[1]))

Fixed submission:
A, B, C, D, E, F = map(int, input().split())
perc = 0.0
ans = [0, 0]
op = [0, 0, 0, 0]
a = 0
while 100 * a <= F:
  b = 0
  while 100 * (a + b) <= F:
    c = 0
    while 100 * (a + b) + c <= F:
      if c > (a + b) * E:
        break
      d = 0
      while 100 * (a + b) + c + d <= F:
        if c + d > (a + b) * E:
          break
        if a == b == c == d == 0:
          break
        p = (c + d) * 1.0 / (100 * (a + b) + c + d)
        if p >= perc:
          perc = p
          ans = [100 * (a + b) + c + d, c + d]
          op = [a, b, c, d]
        d += D
      c += C
    b += B
  a += A
print(str(ans[0]) + " " + str(ans[1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(N):
  l, r = map(int. input().split())
  ans += (r - l + 1)
print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(N):
  l, r = map(int, input().split())
  ans += (r - l + 1)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
d = {}
for a in A:
  for i in range(a - 1, a + 2)
  d[i] = d.get(i, 0) + 1
x = sorted(d.values())
print(max(x))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
d = {}
for a in A:
  for i in range(a - 1, a + 2):
    d[i] = d.get(i, 0) + 1
x = sorted(d.values())
print(max(x))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = ""
if N % 2 == 0:
  for i in range(N-1, -1, -2):
    ans += str(A[i])
    ans += " "
  for i in range(0, N, 2):
    ans += str(A[i])
    if i != N - 2:
      ans += " "
else:
  for i in range(N-1, -2, -2):
    ans += str(A[i])
    ans += " "
  for i in range(1, N, 2):
    ans += str(A[i])
    if i != N - 2:
      ans += " "
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
  for i in range(N-1, -1, -2):
    print(A[i], end = "")
    print(" ", end = "")
  for i in range(0, N, 2):
    print(A[i], end = "")
    if i != N - 2:
      print(" ", end = "")
    else:
      print("")
else:
  for i in range(N-1, -2, -2):
    print(A[i], end = "")
    print(" ", end = "")
  for i in range(1, N, 2):
    print(A[i], end = "")
    if i != N - 2:
      print(" ", end = "")
    else:
      print("")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
X = [0 for i in range(8)]
cnt = 0
for a in A:
  if a == 3200:
    cnt += 1
  else:
    X[a // 400] = 1
s = sum(X)
if s == 0:
  print(str(1) + " " + str(min(8, cnt)))
else:
  print(str(s) + " " + str(min(8, s + cnt)))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
X = [0 for i in range(8)]
cnt = 0
for a in A:
  if a >= 3200:
    cnt += 1
  else:
    X[a // 400] = 1
s = sum(X)
if s == 0:
  print(str(1) + " " + str(cnt))
else:
  print(str(s) + " " + str(s + cnt))
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
A = list(map(int, input().split()))
ans = T
for i in range(1, N):
  if A[i] - A[i-1] >= T:
    ans += T
  else:
    ans += (A[i] - A[i+1])
print(ans)

Fixed submission:
N, T = map(int, input().split())
A = list(map(int, input().split()))
ans = T
for i in range(1, N):
  if A[i] - A[i-1] >= T:
    ans += T
  else:
    ans += (A[i] - A[i-1])
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input())
if N * 2 >= M:
  print(M // 2)
else:
  print(N + (M - N * 2) // 3)

Fixed submission:
N, M = map(int, input().split())
if N * 2 >= M:
  print(M // 2)
else:
  print(N + (M - N * 2) // 4)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A == B:
  print("Draw")
elif A == 1 and :
  print("Alice")
elif B == 1:
  print("Bob")
elif A > B:
  print("Alice")
else:
  print("Bob")

Fixed submission:
A, B = map(int, input().split())
if A == B:
  print("Draw")
elif A == 1:
  print("Alice")
elif B == 1:
  print("Bob")
elif A > B:
  print("Alice")
else:
  print("Bob")
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
  A.append(input())
for i in range(N):
  B.append(input())
f = 0
for i in range(N - M + 1):
  for j in range(N - M + 1):
    g = 0
    for k in range(M):
      for l in range(M):
        if A[i+k][j+l] != B[k][l]:
          g = 1
          break
      if g == 1:
        break
    if g == 0:
      print("Yes")
      f = 1
      break
  if f == 1:
    break
if f == 0:
  print("No")

Fixed submission:
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
  A.append(input())
for i in range(M):
  B.append(input())
f = 0
for i in range(N - M + 1):
  for j in range(N - M + 1):
    g = 0
    for k in range(M):
      for l in range(M):
        if A[i+k][j+l] != B[k][l]:
          g = 1
          break
      if g == 1:
        break
    if g == 0:
      print("Yes")
      f = 1
      break
  if f == 1:
    break
if f == 0:
  print("No")
Buggy python submission (verdict: Runtime Error):
A, B, C = input().split()
if B == "+":
  print(int(A) + int(B))
else:
  print(int(A) - int(B))

Fixed submission:
A, B, C = input().split()
if B == "+":
  print(int(A) + int(C))
else:
  print(int(A) - int(C))
Buggy python submission (verdict: Runtime Error):
a, b, x = input().split()
print(b // x - (a - 1) // x)

Fixed submission:
a, b, x = map(int, input().split())
print(b // x - (a - 1) // x)
Buggy python submission (verdict: Runtime Error):
a, b, h = map(int, input().split())
print((a + b) * h // 2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2)
Buggy python submission (verdict: Runtime Error):
w = input()
X = [0 for i in range(26)]
for i in range(len(w)):
  X[ord(w[i]) - 97] ^= 1
if sum(X) == 0:
  print("Yes")
else:
  print("No)

Fixed submission:
w = input()
X = [0 for i in range(26)]
for i in range(len(w)):
  X[ord(w[i]) - 97] ^= 1
if sum(X) == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(0, 2 * N + 1, 2):
  ans += A[i]
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(0, 2 * N, 2):
  ans += A[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split()))
dp = [-1] * (N+1)

def rec(i):
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    dp[i] = 2**60 # 十分大きな値
    if i - 1 >= 0:
        dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i]))
    if i - 2 >= 0:
        dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i]))
    return dp[i]

print(rec(N-1))


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

N = int(input())
h = list(map(int, input().split()))
dp = [-1] * (N+1)

def rec(i):
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    dp[i] = 2**60 # 十分大きな値
    if i - 1 >= 0:
        dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i]))
    if i - 2 >= 0:
        dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i]))
    return dp[i]

print(rec(N-1))

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

template<class T> void chmin(T &a, T b) {
    if (a > b) a = b;
}

const long long INF = 1LL<<60;

int main() {
    int N; cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];
    
    vector<long long> dp(N, INF);
    dp[0] = 0;
    
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) {
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }   
    }
    
    cout << dp[N-1] << endl;
}

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

N = int(input())
h = list(map(int, input().split()))
dp = [-1] * (N+1)

def rec(i):
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    dp[i] = 2**60 # 十分大きな値
    if i - 1 >= 0:
        dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i]))
    if i - 2 >= 0:
        dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i]))
    return dp[i]

print(rec(N-1))
Buggy python submission (verdict: Runtime Error):
def isAC(S):
    if S[0] != 'A':
        return False
    if S[2:-1].count('C') != 1:
        return False
    S = S.remove('C')
    if not all('a' <= x <= 'z' for x in S):
        return False
    return True

print('AC' if isAC(input()) else 'WA')

Fixed submission:
def isAC(S):
    if S[0] != 'A':
        return False
    if S[2:-1].count('C') != 1:
        return False
    S = S[1:].replace('C', '')
    if not all('a' <= x <= 'z' for x in S):
        return False
    return True

print('AC' if isAC(input()) else 'WA')
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, split().input())
print(A - B if K % 2 == 0 else B - A)

Fixed submission:
A, B, C, K = map(int, input().split())
print(A - B if K % 2 == 0 else B - A)
Buggy python submission (verdict: Runtime Error):
import collections
n,x,m=map(int,input().split())
if n==1 or x==0:
  print(x)
  exit()
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=start-1+(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)


Fixed submission:
s=input()
if s[len(s)-1]=="s":
  print(s+"es")
else:
  print(s+"s")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(i+1,n):
    ans=(ans+a[i]*a[j])%(10**9+7)
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
wa=sum(a)
for i in range(n):
  wa-=a[i]
  ans=(ans+(wa*a[i]))%(10**9+7)
print(ans)
Buggy python submission (verdict: Runtime Error):
x,k,d=map(int,input().split())
x=abs(x)
sa=x//d
ans=x
pbk,mbk=0,0
bk1,bk2,bk3=1,1,1
mansbk,pansbk=0,0
if sa>=k:
  ans=x-d*k
else:
  ans=x-d*sa
  k=k-sa
  for i in range(k):
    mansbk=abs(ans-d)
    pansbk=abs(ans+d)
    if mansbk!=pansbk:
      ans=min(mansbk,pansbk)
      if bk3!=1:
        bk1=min(mansbk,pansbk)
        bk2=max(mansbk,pansbk)
        ans=ans if (k-i)%2==0 else bk1
        break
      else:
        bk3=max(mansbk,pansbk) 
    else:
      ans=0 if (k-i)%2==0 else d
      break
    pbk=max(mansbk,pansbk)
    mbk=min(mansbk,pansbk)
print(ans)

Fixed submission:
s=input()
ans=0
bk=0
for i in range(3):
  if s[i]=="R":
    bk+=1
  else:
    if ans<bk:
      ans=bk
    bk=0
if ans<bk:
  ans=bk
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
ai=0
bi=0
for i in range(n+m):
  ans+=1
  if n-ai==0:
    k-=b[bi]
    bi+=1
  elif m-bi==0:
    k-=a[ai]
    ai+=1
  elif a[ai]>b[bi]:
    k-=b[bi]
    bi+=1
  elif b[bi]>a[ai]:
    k-=a[ai]
    ai+=1
  else:
    if n==ai+2:
      k-=b[bi]
      bi+=1
    elif m==bi+2:
      k-=a[ai]
      ai+=1
    elif a[ai+1]>=b[bi+1]:
      k-=b[bi]
      bi+=1
    elif a[ai+1]<b[bi+1]:
      k-=a[ai]
      ai+=1
  if k<0:
    ans-=1
    break
print(ans)

Fixed submission:
n,m,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
b=list(map(int,input().split()))
t=sum(b)
j=m-1
ans=0
for i in range(n+1):
  t+=a[i]
  while j>=0 and t>k:
    t-=b[j]
    j-=1
  if t>k:
    break
  ans=max(ans,j+i+1) 
print(ans)