Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
divisor = 10 ** 9 + 7
h, w, n = map(int, input().split())
a = [['.'] * w for _ in range(h)]
for _ in range(n):
  r, c = map(int, input().split())
  a[r - 1][c - 1] = '#'
for i in range(h):
  a[i] = ''.join(a[i])
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
dp0 = dp[0]
a0 = a[0]
for j in range(1, w):
  if a0[j] != '#':
    dp0[j] = dp0[j - 1]
for i in range(1, h):
  dpi = dp[i]
  dpi1 = dp[i - 1]
  ai = a[i]
  if ai[0] != '#':
    dpi[0] = dpi1[0]
  for j in range(1, w):
    if ai[j] != '#':
      dpi[j] = (dpi1[j] + dpi[j - 1]) % divisor
print(dp[h - 1][w - 1])


Fixed submission:
divisor = 10 ** 9 + 7
h, w = map(int, input().split())
a = [input() for _ in range(h)]
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
dp0 = dp[0]
a0 = a[0]
for j in range(1, w):
  if a0[j] != '#':
    dp0[j] = dp0[j - 1]
for i in range(1, h):
  dpi = dp[i]
  dpi1 = dp[i - 1]
  ai = a[i]
  if ai[0] != '#':
    dpi[0] = dpi1[0]
  for j in range(1, w):
    if ai[j] != '#':
      dpi[j] = (dpi1[j] + dpi[j - 1]) % divisor
print(dp[h - 1][w - 1])

Buggy python submission (verdict: Runtime Error):
divisor = 10 ** 9 + 7
h, w, n = map(int, input().split())
a = [['.'] * w for _ in range(h)]
for _ in range(n):
  r, c = map(int, input().split())
  a[r - 1][c - 1] = '#'
for i in range(h):
  a[i] = ''.join(a[i])
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
dp0 = dp[0]
a0 = a[0]
for j in range(1, w):
  if a0[j] != '#':
    dp0[j] = dp0[j - 1]
for i in range(1, h):
  dpi = dp[i]
  dpi1 = dp[i - 1]
  ai = a[i]
  if ai[0] != '#':
    dpi[0] = dpi1[0]
  for j in range(1, w):
    if ai[j] != '#':
      dpi[j] = (dpi1[j] + dpi[j - 1]) % divisor
print(dp[h - 1][w - 1])


Fixed submission:
divisor = 10 ** 9 + 7
h, w = map(int, input().split())
a = [input() for _ in range(h)]
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
dp0 = dp[0]
a0 = a[0]
for j in range(1, w):
  if a0[j] != '#':
    dp0[j] = dp0[j - 1]
for i in range(1, h):
  dpi = dp[i]
  dpi1 = dp[i - 1]
  ai = a[i]
  if ai[0] != '#':
    dpi[0] = dpi1[0]
  for j in range(1, w):
    if ai[j] != '#':
      dpi[j] = (dpi1[j] + dpi[j - 1]) % divisor
print(dp[h - 1][w - 1])

Buggy python submission (verdict: Runtime Error):
def main():
  divisor = 10 * 9 + 7
  h, w = map(int, input().split())
  a = [input() for _ in range(h)]
  dp = [[0] * w for _ in range(h)]
  dp[0][0] = 1
  for i in range(h):
    ai = a[i]
    ai1 = a[i + 1]
    dpi = dp[i]
    dpi1 = dp[i + 1]
    for j in range(w):
      if i + 1 < h and ai1[j] != '#':
        dpi1[j] = (dpi1[j] + dpi[j]) % divisor
      if j + 1 < w and ai[j + 1] != '#':
        dpi[j + 1] = (dpi[j + 1] + dpi[j]) % divisor
  print(dp[h - 1][w - 1])
main()

Fixed submission:
divisor = 10 ** 9 + 7
h, w = map(int, input().split())
a = [input() for _ in range(h)]
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
dp0 = dp[0]
a0 = a[0]
for j in range(1, w):
  if a0[j] != '#':
    dp0[j] = dp0[j - 1]
for i in range(1, h):
  dpi = dp[i]
  dpi1 = dp[i - 1]
  ai = a[i]
  if ai[0] != '#':
    dpi[0] = dpi1[0]
  for j in range(1, w):
    if ai[j] != '#':
      dpi[j] = (dpi1[j] + dpi[j - 1]) % divisor
print(dp[h - 1][w - 1])
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
alist = list(sorted(d.keys(), reverse = True))
amax = alist[0]
t = 1
power_of_two = []
while t < 2 * amax:
  t *= 2
  power_of_two.append(t)
result = 0
for a in alist:
  if d[a] == 0:
    continue
  t = power_of_two[bisect_right(power_of_two, a)] - a
  while True:
    if t not in d or d[t] == 0:
      break
    if a != t:
      i = min(d[a], d[t])
    else:
      i = d[a] // 2
    result += i
    d[a] -= i
    d[t] -= i
    if d[a] == 0:
      break
print(result)


Fixed submission:
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
t = 1
valids = []
while t < 2 * 10 ** 9:
  t *= 2
  valids.append(t)
result = 0
while True:
  prev = result
  keys = list(d.keys())
  keys.sort(reverse = True)
  for x in keys:
    if x not in d:
      continue
    t = valids[bisect_right(valids, x)] - x
    while True:
      if t not in d:
        break
      if x == t and d[x] == 1:
        break
      result += 1
      if d[x] == 1:
        del d[x]
      else:
        d[x] -= 1
      if d[t] == 1:
        del d[t]
      else:
        d[t] -= 1
      if x not in d:
        break
  if prev == result:
    break
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
t = 1
valids = []
while t < 2 * 10 ** 9:
  t *= 2
  valids.append(t)
result = 0
while True:
  prev = result
  keys = list(d.keys())
  keys.sort(reverse = True)
  for x in keys:
    t = valids[bisect_right(valids, x)] - x
    if t not in d:
      continue
    if x == t and d[x] == 1:
      continue
    result += 1
    if d[x] == 1:
      del d[x]
    else:
      d[x] -= 1
    if d[t] == 1:
      del d[t]
    else:
      d[t] -= 1
    break
  if prev == result:
    break
print(result)

Fixed submission:
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
t = 1
valids = []
while t < 2 * 10 ** 9:
  t *= 2
  valids.append(t)
result = 0
while True:
  prev = result
  keys = list(d.keys())
  keys.sort(reverse = True)
  for x in keys:
    if x not in d:
      continue
    t = valids[bisect_right(valids, x)] - x
    while True:
      if t not in d:
        break
      if x == t and d[x] == 1:
        break
      result += 1
      if d[x] == 1:
        del d[x]
      else:
        d[x] -= 1
      if d[t] == 1:
        del d[t]
      else:
        d[t] -= 1
      if x not in d:
        break
  if prev == result:
    break
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = t[p - 1].index(y) + 1
  print("%06d%06d" % (p, nth))


Fixed submission:
from bisect import bisect_left
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = bisect_left(t[p - 1], y) + 1
  print("%06d%06d" % (p, nth))

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = t[p - 1].index(y) + 1
  print("%06d%06d" % (p, nth))


Fixed submission:
from bisect import bisect_left
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = bisect_left(t[p - 1], y) + 1
  print("%06d%06d" % (p, nth))

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = bisect_left(t[p - 1], y) + 1
  print("%06d%06d" % (p, nth))


Fixed submission:
from bisect import bisect_left
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = bisect_left(t[p - 1], y) + 1
  print("%06d%06d" % (p, nth))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd


def lcm(x, y):
    return x // gcd(x, y) * y


N, M = map(int, input().split())
S = input()
T = input()

L = lcm(N, M)
X = {}

for i in range(0, L, L // N):
    X[i] = S[i]

for i in range(0, L, L // M):
    if i not in X:
        continue
    if X[i] != T[i]:
        print(-1)
        exit()
print(L)


Fixed submission:
from fractions import gcd


def lcm(x, y):
    return x // gcd(x, y) * y


N, M = map(int, input().split())
S = input()
T = input()

L = lcm(N, M)
X = {}

for i in range(N):
    X[(L // N) * i] = S[i]

for i in range(M):
    if (L // M) * i in X and X[(L // M) * i] != T[i]:
        print(-1)
        exit()
print(L)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())

print(max(A * 10 + B + C, A + N * 10 + C))

Fixed submission:
A, B, C = map(int, input().split())

t = sorted([A, B, C])
print(t[0] + t[1] + t[2] * 10)
Buggy python submission (verdict: Runtime Error):
from sys import exit
S = input()
T = input()
for i in range(26):
  c = chr(i + ord('a'))
  d[c] = '\0'
for i in range(len(S)):
  if d[S[i]] != '\0' or d[T[i]] != '\0':
    if d[S[i]] != T[i] or d[T[i]] != S[i]:
      print('No')
      exit()
  d[S[i]] = T[i]
  d[T[i]] = S[i]
print('Yes')


Fixed submission:
S = input()
T = input()

d = {}
for i in range(len(S)):
  d[S[i]] = T[i]

t = []
for i in range(len(S)):
  t.append(d[S[i]])

if ''.join(t) != T or len(d.values()) != len(set(d.values())):
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
from sys import exit
S = input()
T = input()
d = {}
for i in range(len(S)):
  if S[i] in d or T[i] in d:
    if d[S[i]] != T[i] or d[T[i]] != S[i]:
      print('No')
      exit()
  d[S[i]] = T[i]
  d[T[i]] = S[i]
print('Yes')


Fixed submission:
S = input()
T = input()

d = {}
for i in range(len(S)):
  d[S[i]] = T[i]

t = []
for i in range(len(S)):
  t.append(d[S[i]])

if ''.join(t) != T or len(d.values()) != len(set(d.values())):
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = list(map(int, input().split()))
p = n
for i in range(n):
  if x[i] > 0:
    p = i
    break
result = float('inf')
for i in range(max(p - k, 0), min(k - p, k + 1)):
  if i == 0:
    result = min(result, x[p + k - 1])
  elif i == k:
    result = min(result, -x[p - k])
  else:
    l = x[p - i]
    r = x[p + (k - i) - 1]
    result = min(result, r - 2 * l, r * 2 - l)
print(result)


Fixed submission:
n, k = map(int, input().split())
x = list(map(int, input().split()))
p = n
for i in range(n):
  if x[i] > 0:
    p = i
    break
result = float('inf')
for i in range(k + 1):
  if p - i < 0 or p + k - i > n:
    continue
  if i == 0:
    t = min(result, x[p + k - 1])
  elif i == k:
    t = min(result, abs(x[p - k]))
  else:
    t = min(result, abs(x[p - i]) * 2 + x[p + (k - i) - 1], abs(x[p - i]) + x[p + (k - i) - 1] * 2)
  result = min(result, t)
print(result)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

t = [0] * M
c = 0
for a in A:
    c += a
    c %= M
    t[c] += 1

result = t[0]
c = 0
for a in A:
    c += a
    c %= M
    t[c] -= 1
    result += t[c]
print(result)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))

t = {}
c = 0
for a in A:
    c += a
    c %= M
    if c in t:
        t[c] += 1
    else:
        t[c] = 1

result = 0
if 0 in t:
    result += t[0]
c = 0
for a in A:
    c += a
    c %= M
    t[c] -= 1
    result += t[c]
print(result)

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

t = {}
c = 0
for a in A:
    c += a
    c %= M
    if c in t:
        t[c] += 1
    else:
        t[c] = 1

result = t[0]
c = 0
for a in A:
    c += a
    c %= M
    t[c] -= 1
    result += t[c]
print(result)


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))

t = {}
c = 0
for a in A:
    c += a
    c %= M
    if c in t:
        t[c] += 1
    else:
        t[c] = 1

result = 0
if 0 in t:
    result += t[0]
c = 0
for a in A:
    c += a
    c %= M
    t[c] -= 1
    result += t[c]
print(result)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

ab = [0] * M
for _ in range(M):
    a, b = map(int, input().split())
    ab[a].append(b)

dp = [0] * (N + 1)
for i in range(1, N + 1):
    dp[i] = max(dp[i], dp[i - 1])
    for j in ab[i]:
        dp[j] = max(dp[j], dp[i] + 1)

print(dp[N])


Fixed submission:
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

result = 0
t = -1
for a, b in ab:
    a, b = a - 1, b - 1
    if a <= t < b:
        continue
    result += 1
    t = b - 1
print(result)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
t = list(sorted(a[i] - (i + 1) for i in range(n)))
if len(t) % 2 == 0:
  b = (t[len(t)] + t[len(t + 1)]) // 2
else:
  b = t[len(t) // 2]
print(sum(abs(a[i] - (b + i + 1)) for i in range(n)))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
t = list(sorted(a[i] - (i + 1) for i in range(n)))
b = t[len(t) // 2]
print(sum(abs(a[i] - (b + i + 1)) for i in range(n)))
Buggy python submission (verdict: Runtime Error):
n = input()
if int(n) % sum(map(int, n)) == 0:
  print('Yes')
else;
  print('No')


Fixed submission:
n = input()
if int(n) % sum(map(int, n)) == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input())
print(((n - 1) + (k - 2)) // (k - 1))


Fixed submission:
from sys import stdin
n, k, *a = map(int, stdin.read().split())
print(((n - 1) + (k - 2)) // (k - 1))
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())

if N == 100
    print(100 ** D * N + 1)
else:
    print(100 ** D * N)

Fixed submission:
D, N = map(int, input().split())

if N == 100:
    print(100 ** D * (N + 1))
else:
    print(100 ** D * N)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

print(max(len(set(S[:i]) & set(S[i:])) for i in range(1, N - 1)))


Fixed submission:
N = int(input())
S = input()

print(max(len(set(S[:i]) & set(S[i:])) for i in range(1, N)))
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
K = int(input())
result = sum(A, B, C)
t = max(A, B, C)
result += (t << K) - t
print(result)


Fixed submission:
A, B, C = map(int, input().split())
K = int(input())
result = sum([A, B, C])
t = max(A, B, C)
result += (t << K) - t
print(result)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
  c[i + 1] = c[i] + a[i]
d = {}
for i in range(1, n + 1):
  if c[i] not in d:
    d[c[i]] = 0
  d[c[i]] += 1
result = d[0]
for k in d:
  if d[k] != 1:
    result += d[k] * (d[k] - 1) // 2
print(result)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
  c[i + 1] = c[i] + a[i]
d = {}
for i in range(1, n + 1):
  if c[i] not in d:
    d[c[i]] = 0
  d[c[i]] += 1
result = 0
if 0 in d:
  result += d[0]
for k in d:
  if d[k] != 1:
    result += d[k] * (d[k] - 1) // 2
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
  c[i + 1] = c[i] + a[i]
result = 0
for i in range(1, n + 1):
  for j in range(i):
    if c[i] - c[j] == 0:
      result += 1
print(result)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
  c[i + 1] = c[i] + a[i]
d = {}
for i in range(1, n + 1):
  if c[i] not in d:
    d[c[i]] = 0
  d[c[i]] += 1
result = 0
if 0 in d:
  result += d[0]
for k in d:
  if d[k] != 1:
    result += d[k] * (d[k] - 1) // 2
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
  c[i + 1] = c[i] + a[i]
result = 0
for i in range(1, n + 1):
  for j in range(i):
    if c[i] - c[j] == 0:
      result += 1
print(result)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
  c[i + 1] = c[i] + a[i]
d = {}
for i in range(1, n + 1):
  if c[i] not in d:
    d[c[i]] = 0
  d[c[i]] += 1
result = 0
if 0 in d:
  result += d[0]
for k in d:
  if d[k] != 1:
    result += d[k] * (d[k] - 1) // 2
print(result)
Buggy python submission (verdict: Runtime Error):
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

d = {}
for y in range(H):
    for x in range(W):
        d[A[y][x]] = (y, x)

t = [[0] * (H * W // D + 1) for _ in range(D)]
for i in range(D):
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        t[i][j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(len(H * W // D + 1) - 1):
        t[i][j + 1] += t[i][j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])


Fixed submission:
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

d = {}
for y in range(H):
    Ay = A[y]
    for x in range(W):
        d[Ay[x]] = (y, x)

t = [[0] * ((H * W + D - 1) // D + 1) for _ in range(D)]
for i in range(D):
    ti = t[i]
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        ti[j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(len(ti) - 1):
        ti[j + 1] += ti[j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])

Buggy python submission (verdict: Runtime Error):
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

d = {}
for y in range(H):
    Ay = A[y]
    for x in range(W):
        d[Ay[x]] = (y, x)

t = [[0] * ((H * W + D - 1) // D) for _ in range(D)]
for i in range(D):
    ti = t[i]
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        ti[j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(len(ti) - 1):
        ti[j + 1] += ti[j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])


Fixed submission:
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

d = {}
for y in range(H):
    Ay = A[y]
    for x in range(W):
        d[Ay[x]] = (y, x)

t = [[0] * ((H * W + D - 1) // D + 1) for _ in range(D)]
for i in range(D):
    ti = t[i]
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        ti[j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(len(ti) - 1):
        ti[j + 1] += ti[j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])
Buggy python submission (verdict: Runtime Error):
from math import log10
N = input()
n = int(N)
t = n % 10 ** int(log10(n)) + 1
if n == 0:
  print(0)
else:
  print(max(sum(map(int, N)), sum(map(int, str(n - t)))))


Fixed submission:
N = input()
n = int(N)
t = n % 10 ** (len(N) - 1) + 1
print(max(sum(map(int, N)), sum(map(int, str(n - t)))))

Buggy python submission (verdict: Runtime Error):
from math import log10
N = input()
n = int(N)
t = n % 10 ** int(log10(n)) + 1
print(max(sum(map(int, N)), sum(map(int, str(n - t)))))


Fixed submission:
N = input()
n = int(N)
t = n % 10 ** (len(N) - 1) + 1
print(max(sum(map(int, N)), sum(map(int, str(n - t)))))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

result = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      if i * 500 + j * 100 + k * 50 == x:
        result += 1

print(result)


Fixed submission:
x = int(input())
a = int(input())
b = int(input())
print((x - a) % b)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
elif (B - A) % 2 == 0:
  print('Alice')
else:
  print('Borys')


Fixed submission:
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
  print('Alice')
else:
  print('Borys')
Buggy python submission (verdict: Runtime Error):
from sys import stdin
def main():
  from math import sqrt
  readline = stdin.readline
  p = [True] * (10 ** 5 + 1)
  p[0] = False
  p[1] = False
  n = int(sqrt(10 ** 5 + 1)) + 1
  for j in range(4, n, 2):
    p[j] = False
  for i in range(3, n, 2):
    if p[i]:
      for j in range(i + i, n, i):
        p[j] = False
  c = [0] * (10 ** 5 + 1)
  for i in range(2, 10 ** 5 + 1):
    c[i] = c[i - 1]
    if p[i - 2] and p[(i - 1) // 2]:
      c[i] += 1
  q = int(readline())
  for _ in range(q):
    l, r = map(int, readline().split())
    print(c[r + 2] - c[l + 1])
main()


Fixed submission:
from sys import stdin
def main():
  from math import sqrt
  readline = stdin.readline
  p = [True] * (10 ** 5 + 1)
  p[0] = False
  p[1] = False
  n = int(sqrt(10 ** 5)) + 1
  for j in range(4, 10 ** 5 + 1, 2):
    p[j] = False
  for i in range(3, n + 1, 2):
    if p[i]:
      for j in range(i + i, 10 ** 5 + 1, i):
        p[j] = False
  c = [0] * (10 ** 5 + 2)
  for i in range(2, 10 ** 5 + 2):
    c[i] = c[i - 1]
    if p[i - 2] and p[(i - 1) // 2]:
      c[i] += 1
  q = int(readline())
  for _ in range(q):
    l, r = map(int, readline().split())
    print(c[r + 2] - c[l + 1])
main()
Buggy python submission (verdict: Runtime Error):
N, C = map(int, input().split())

tt = [[0] * (10 ** 5 + 1) for _ in range(C)]
for _ in range(N):
    s, t, c = map(int, input().split())
    for i in range(s - 1, t):
        tt[c - 1] = 1

ct = [0] * (10 ** 5 + 1)
for i in range(C):
    for j in range(10 ** 5 + 1):
        ct[j] += tt[i][j]

print(max(ct))


Fixed submission:
N, C = map(int, input().split())

tt = [[0] * (2 * 10 ** 5 + 1) for _ in range(30)]
for _ in range(N):
    s, t, c = map(int, input().split())
    ttc = tt[c - 1]
    for i in range(s * 2 - 1, t * 2):
        ttc[i] = 1

ct = [0] * (2 * 10 ** 5 + 1)
for i in range(30):
    tti = tt[i]
    for j in range(2 * 10 ** 5 + 1):
        ct[j] += tti[j]

print(max(ct))
Buggy python submission (verdict: Time Limit Exceeded):
# 二分探索
from bisect import bisect_right

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

for x in [A, B, C]:
    x.sort()

result = 0
for i in A:
    for j in B[bisect_right(B, i):]:
        result += N - bisect_right(C, j)
print(result)


Fixed submission:
# 二分探索, 累積和
from bisect import bisect_right

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

for x in [A, B, C]:
    x.sort()

t = [0] * (N + 1)  # 中部のパーツのサイズが Bi 以上のときの B と C の組み合わせの数
for i in range(N):
    t[i] = N - bisect_right(C, B[i])
for i in range(N - 1, -1, -1):
    t[i] += t[i + 1]

result = 0
for a in A:
    result += t[bisect_right(B, a)]
print(result)
Buggy python submission (verdict: Runtime Error):
A, B, C, D map(int, input().split())

print(max(min(B, D) - max(A, C), 0))


Fixed submission:
A, B, C, D = map(int, input().split())

print(max(min(B, D) - max(A, C), 0))