Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = input()


def get_sum(n):
    s = str(n)
    arr = list(map(int, list(s)))
    return sum(arr)

ans = get_sum(n)
i = 1
for i in range(1, 10000):
    m = get_sum(n * i)
    if ans > m:
        ans = m

print(ans)


Fixed submission:
import collections


def ans(n):
    dist = [10 ** 5] * n
    dist[1] = 1
    d = collections.deque()
    d.append(1)
    while not d.count == 0:
        u = d.popleft()
        if u == 0:
            return dist[u]
        if dist[u] < dist[(u * 10) % n]:
            dist[(u * 10) % n] = dist[u]
            d.appendleft((u * 10) % n)
        if dist[u] < dist[(u + 1) % n]:
            dist[(u + 1) % n] = dist[u] + 1
            d.append((u + 1) % n)

n = int(input())
print(ans(n))
Buggy python submission (verdict: Runtime Error):
import math

K, N = map(int, input().split())
ans = []

if K % 2 == 0:
    for i in range(N):
        if i == 0:
            ans[i] = K // 2
        else:
            ans[i] = K
elif K == 1:
    n2 = math.ceil(N / 2)
    for i in range(n2):
        ans.append(1)
else:
    K2 = math.ceil(K / 2)
    n2 = math.floor(N / 2)
    ans = [K2] * N
    i = 0
    nx = 0
    last = True
    while n2 > 0:
        i += 1
        ans[N - i] = max(K2 - n2 % (K + 1) - nx, 0)
        if ans[N - i] == 0 and last:
            ans.pop()
        else:
            last = False
        n2 //= K + 1
        if K2 - n2 % (K + 1) - nx < 0:
            nx = 1
        else:
            nx = 0

print(' '.join(map(str, ans)))


Fixed submission:
import math


def main(K, N):
    ans = []

    if K % 2 == 0:
        for i in range(N):
            if i == 0:
                ans.append(K // 2)
            else:
                ans.append(K)
    elif K == 1:
        n2 = math.ceil(N / 2)
        for i in range(n2):
            ans.append(1)
    else:
        K2 = math.ceil(K / 2)
        ans = [K2] * N
        n = N // 2
        for i in range(n):
            if ans[-1] == 1:
                ans.pop()
            else:
                ans[-1] -= 1
                while len(ans) < N:
                    ans.append(K)

    return ' '.join(map(str, ans))


K, N = map(int, input().split())
print(main(K, N))
Buggy python submission (verdict: Runtime Error):
import string

ALPHABETS = string.ascii_lowercase

s = input()
N = len(s)
MAX = 2 * 10 ** 5
a = [0] * (N + 1)
for i, c in enumerate(s):
    idx = ALPHABETS.index(c)
    a[i+1] = a[i] ^ (2 ** idx)

opt = [0] * (N + 1)
dp = {}
dp[0] = 0
for i in range(1, N + 1):
    dp[a[i]] = min(dp.get(a[i], MAX), min([dp.get(a[i] ^ 2 ** j, MAX) if not j == -1 else dp.get(a[i] ^ 0, MAX) for j in range(-1, 26)]) + 1)

print(dp[a[N]] if dp[a[N]] != 0 else 1)


Fixed submission:
s = input()
found = False
for i in range(len(s)-1):
    if s[i] == 'A' and s[i+1] == 'C':
        print('Yes')
        found = True
        break
if not found:
    print('No')

Buggy python submission (verdict: Runtime Error):
import string

ALPHABETS = string.ascii_lowercase


def is_avairable(a):
    return bin(a).count('1') <= 1

s = input()
N = len(s)
a = [0] * (N + 1)
for i, c in enumerate(s):
    idx = ALPHABETS.index(c)
    a[i+1] = a[i] ^ (2 ** idx)

opt = [0] * (N + 1)
dp = [2 * (10 ** 5) + 1] * (2 ** 26)
dp[0] = 0
for i in range(1, N + 1):
    ns = [dp[a[i] ^ 2 ** j] if not j == -1 else dp[a[i] ^ 0] for j in range(-1, 26)]
    mn = min(ns)
    opt[i] = mn + 1
    if dp[a[i]] > opt[i]:
        dp[a[i]] = opt[i]

print(opt[N])


Fixed submission:
s = input()
found = False
for i in range(len(s)-1):
    if s[i] == 'A' and s[i+1] == 'C':
        print('Yes')
        found = True
        break
if not found:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys

s = input()
s_no_x = s.replace('x', '')
s_no_x_inv = s_no_x[::-1]

if not s_no_x == s_no_x_inv:
    print(-1)
    sys.exit()

count = 0
for i in range(len(s)):
    if i > len(s):
        break
    if not s[i] == s[len(s) - 1 - i]:
        count += 1
        if s[i] == 'x':
            s = s[:len(s) - i] + 'x' + s[len(s) - i:]
        else:
            s = s[:i] + 'x' + s[i:]
print(count)


Fixed submission:
import sys

s = input()
s_no_x = s.replace('x', '')
s_no_x_inv = s_no_x[::-1]

if not s_no_x == s_no_x_inv:
    print(-1)
    sys.exit()

count = 0
l = 0
r = len(s) - 1
while l < r:
    if l >= r:
        break
    if s[l] == s[r]:
        l += 1
        r -= 1
    if not s[l] == s[r]:
        count += 1
        if s[l] == 'x':
            l += 1
        else:
            r -= 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
x = []
y = []
for i in range(N):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
x_sorted = sorted(x)
y_sorted = sorted(y)


def included(xmin, xmax, ymin, ymax):
    count = 0
    for i in range(N):
        if xmin <= x[i] <= xmax and ymin <= y[i] <= ymax:
            count += 1
    return count


ans = 4 * 10 ** 18
for i in range(N):
    for j in range(i + 1, N):
        for k in range(N):
            for l in range(k + 1, N):
                num = included(x_sorted[i], x_sorted[j], y_sorted[k], y_sorted[l])
                if num > K:
                    break
                elif num == K:
                    s = (x_sorted[j] - x_sorted[i]) * (y_sorted[l] - y_sorted[k])
                    if ans > s:
                        ans = s
                else:
                    continue
print(ans)


Fixed submission:
N, K = map(int, input().split())
x = []
y = []
for i in range(N):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
x_sorted = sorted(x)
y_sorted = sorted(y)

S_l = [[0 for i in range(N)] for j in range(N)]
S_rs = [[0 for i in range(N)] for j in range(N)]
S_ts = [[0 for i in range(N)] for j in range(N)]
S_s = [[0 for i in range(N)] for j in range(N)]
for i in range(N):
    for j in range(N):
        count_l = 0
        count_rs = 0
        count_ts = 0
        count_s = 0
        for k in range(N):
            if -10 ** 9 <= x[k] <= x_sorted[i] and -10 ** 9 <= y[k] <= y_sorted[j]:
                count_l += 1
            if -10 ** 9 <= x[k] < x_sorted[i] and -10 ** 9 <= y[k] <= y_sorted[j]:
                count_rs += 1
            if -10 ** 9 <= x[k] <= x_sorted[i] and -10 ** 9 <= y[k] < y_sorted[j]:
                count_ts += 1
            if -10 ** 9 <= x[k] < x_sorted[i] and -10 ** 9 <= y[k] < y_sorted[j]:
                count_s += 1
        S_l[i][j] = count_l
        S_rs[i][j] = count_rs
        S_ts[i][j] = count_ts
        S_s[i][j] = count_s


def included(i, j, k, l):
    return S_l[j][l] - S_rs[i][l] - S_ts[j][k] + S_s[i][k]

ans = 4 * 10 ** 18
for i in range(N):
    for j in range(i + 1, N):
        for k in range(N):
            for l in range(k + 1, N):
                num = included(i, j, k, l)
                if num > K:
                    break
                elif num == K:
                    s = (x_sorted[j] - x_sorted[i]) * (y_sorted[l] - y_sorted[k])
                    if ans > s:
                        ans = s
                else:
                    continue
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(input().split())
if a==b:
    print("Yes")
else:
    print("No")    
    

Fixed submission:
a,b=map(int,input().split())
if a==b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b=int(input())
if (a+b)%2==0:
    print((a+b)/2)
else:
    print("IMPOSSIBLE")

Fixed submission:
a,b=map(int,input().split())
if (a+b)%2==0:
    print((a+b)//2)
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
a=int(input())
s=list(map(int,input().split()))
s.sort()
print(s[a/2]-a[a/2-1])

Fixed submission:
a=int(input())
n=sorted(list(map(int,input().split())))
print(n[a//2]-n[a//2-1])
Buggy python submission (verdict: Runtime Error):
a=int(input())
s=input()
s=s.count(R)
if a-s<s:
    print("Yes")
else:
    print("No")


Fixed submission:
a=int(input())
s=list(input())
x=s.count("R")
y=a-x
if x>y:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a=int(input())
s=char(input())
r=s.count(R)
if a-r<r:
    print("Yes")
else:
    print("No")

    

Fixed submission:
a=int(input())
s=list(input())
x=s.count("R")
y=a-x
if x>y:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a=int(input())
s=input()
r=s.count(R)
if a-r<r:
    print("Yes")
else:
    print("No")

    

Fixed submission:
a=int(input())
s=list(input())
x=s.count("R")
y=a-x
if x>y:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a=int(input())
s=input()
x=s.count(R)
y=a-x
if x>y:
    print("Yes")
else:
    print("No")

Fixed submission:
a=int(input())
s=list(input())
x=s.count("R")
y=a-x
if x>y:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a=int(input())
a=25-a
print("Christmas ", end="")
for i in a:
  print("Eve ", end="")

Fixed submission:
a=int(input())
a=25-a
print("Christmas ", end="")
for i in range(a):
  print("Eve ", end="")
Buggy python submission (verdict: Runtime Error):
a=0
s=input()
for i in s:
    if s[i]=='-':
        a-=1
    else:
        a+=1
print(a)

Fixed submission:
a=0
s=input()
for i in range(4):
    if s[i]=="-":
        a-=1
    else:
        a+=1
print(a)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
d = input()

a = int(a)
b = int(b)
c = int(c)
d = int(d)

n = b - a
m = c - b

if (n <= d)and(m <= d):
    print("Yes")
else:
    print("No")


Fixed submission:
a,b,c,d=map(int,input().split())
if abs(b-a)<=d and abs(c-b)<=d or abs(c-a)<=d:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=a%500
if b>=c:
    print(Yes)
else:
    print(No)



Fixed submission:
a=int(input())
b=int(input())
c=a%500
if b>=c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print((a-b)%c)


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
print((a-b)%c)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if a+b>c+d:
    print("Left")
elif a+b=c+d:
    print("Balanced")
else:
    print("Right")        

Fixed submission:
a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l > r:
    print("Left")
elif l == r:
    print("Balanced")
else:
    print("Right")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
l = 0
r = n-1
c = 0
while l < r:
  for i in range(l, r):
    if s[i] == "W":
      l = i
      break
  else:
    l = r
  for i in range(r, l, -1):
    if s[i] == "R":
      r = i
      break
  else:
    r = l
  if l < r:
    c += 1
print(c)
      
    

Fixed submission:
n = int(input())
s = list(input())
l = 0
r = n-1
c = 0
while l < r:
  for i in range(l, r):
    if s[i] == "W":
      c += 1
      l = i+1
      break
  else:
    l = r
  for i in range(r, l-1, -1):
    if s[i] == "R":
      r = i-1
      c += 1
      break
  else:
    r = l

print(c//2)
Buggy python submission (verdict: Runtime Error):
h,w,k=map(int, input().split())
mat = []
for i in range(h):
  s = input()
  mat.append(s)
total = 0
for y in range(2**h):
  for x in range(2**w):
    mat2 = mat.copy()
    y_bin = bin(y)[2:]
    x_bin = bin(x)[2:]
    for r in y_bin:
      if r == "1":
        mat2[r] = "."*w
    for c in x_bin:
      if c == "1":
        for r in range(h):
          mat2[r][c] = "."
    count = 0
    for r in range(h):
      for c in range(w):
        if mat2[r][c] == "#":
          count += 1
    if count == k:
      total += 1
print(total)

Fixed submission:
import copy
h,w,k=map(int, input().split())
mat = []
for i in range(h):
  s = list(input())
  mat.append(s)
total = 0
for y in range(2**h):
  for x in range(2**w):
    mat2 = copy.deepcopy(mat)
    y_bin = bin(y)[2:].zfill(h)
    x_bin = bin(x)[2:].zfill(w)
    # print(y_bin, x_bin)
    for r in range(len(y_bin)):
      if y_bin[r] == "1":
        for c in range(w):
          mat2[r][c] = "."
    for c in range(len(x_bin)):
      if x_bin[c] == "1":
        for r in range(h):
          mat2[r][c] = "."
    count = 0
    for r in range(h):
      for c in range(w):
        if mat2[r][c] == "#":
          count += 1
          # print(r, c)
    if count == k:
      total += 1
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

n = int(input())
s = 0
for i in range(2, n+1):
  s += i*num_divisors_table(i)[-1]
print(s+1)
  

Fixed submission:
n = int(input())
ans = 0
for j in range(1, n+1):
  count = n//j
  ans += count*((count * j) + j)//2


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b = list(map(int, input().split()))
c = 1
for i in range(a):
  c *= b[i]

if c > 10**18:
  print("-1")
else:
  print(c)

Fixed submission:
a = int(input())
b = list(map(int, input().split()))
c = 1
if 0 in b:
  print(0)
  exit()
for i in range(a):
  c *= b[i]
  if c > 10**18:
    print(-1)
    break
else:
  print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]

a = sorted(l, key=lambda x:x[0])
b = sorted(l, key=lambda x:x[1])

if n % 2 == 1:
  print(b[n//2] - a[n//2] +1)
else:
  print((b[n//2][1] - a[n//2-1][0]+1)*(b[n//2][1] - a[n//2-1][0])//2)

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

a = sorted(l, key=lambda x:x[0])
b = sorted(l, key=lambda x:x[1])

if n % 2 == 1:
  print(b[n//2][1] - a[n//2][0] +1)
else:
  print((b[n//2][1]+b[n//2-1][1])-(a[n//2][0]+a[n//2-1][0])+1)
Buggy python submission (verdict: Time Limit Exceeded):
import queue
q = queue.Queue()
n, m = map(int, input().split())
mat = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  mat[a-1].append((a-1,b-1))
  mat[b-1].append((b-1,a-1))

d_list = [(-1,-1)]*n

d_list[0] = (0,0)
while len(mat[0]) > 0:
  q.put(mat[0].pop())

while not q.empty():
  u,v = q.get()

  if d_list[v][1] != -1 and d_list[v][1] <= d_list[u][1]+1:
    pass
  else:
    d_list[v] = (u, d_list[u][1]+1)
    while len(mat[v]) > 0:
      q.put(mat[v].pop())
print("Yes")
for i in range(1,n):
  print(d_list[i][0]+1)

Fixed submission:
import queue
q = queue.Queue()
n, m = map(int, input().split())
mat = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  mat[a-1].append((a-1,b-1))
  mat[b-1].append((b-1,a-1))

d_list = [(-1,-1)]*n

d_list[0] = (0,0)
while len(mat[0]) > 0:
  q.put(mat[0].pop())

while not q.empty():
  u,v = q.get()

  if d_list[v][1] != -1 and d_list[v][1] <= d_list[u][1]+1:
    pass
  else:
    d_list[v] = (u, d_list[u][1]+1)
    while len(mat[v]) > 0:
      q.put(mat[v].pop())
print("Yes")
for i in range(1,n):
  print(d_list[i][0]+1)
Buggy python submission (verdict: Runtime Error):
def modpow(a, n, p):
  if n == 0:
    return 1
  if n == 1:
    return a % p 
  elif n % 2 == 1:
    return a * modpow(a, n-1, p) % p
  else:
    return modpow(a, n//2, p) **2 % p
MOD = 1000000007
n = input()
dct1 = {}
dct2 = {}
l = []
for i in range(n):
  a, b = map(int, input().split())
  l.append((a, b))
  if a == 0:
    dct1["a0"] = dct1.get("a0", 0) + 1
  elif b == 0:
    dct1["b0"] = dct1.get("b0", 0) + 1
  else:
    dct1[a/b] = dct1.get(a/b, 0) + 1
    dct2[-b/a] = dct2.get(-b/a, 0) + 1

count = 0
for i in range(n):
  a, b = l[i]
    l.append((a, b))
  if a == 0:
    count += modpow(2, n-1-i-dct1["b0"], MOD)
  elif b == 0:
    count += modpow(2, n-1-i-dct1["a0"], MOD)
  else:
    count += modpow(2, n-1-i-dct2[a/b], MOD)
print(count % MOD)
    
  

Fixed submission:
import math
def modpow(a, n, p):
  if n == 0:
    return 1
  if n == 1:
    return a % p 
  elif n % 2 == 1:
    return a * modpow(a, n-1, p) % p
  else:
    return modpow(a, n//2, p) **2 % p
MOD = 1000000007
n = int(input())
#初期値が0の辞書
from collections import defaultdict
pp = defaultdict(lambda: 0) 
pm = defaultdict(lambda: 0) 
def seiki(x,y):
    tmp=math.gcd(x,y)
    return (x//tmp,y//tmp)

a0b0 = 0

for i in range(n):
  a, b = map(int, input().split())

  if a == 0 and b == 0:
    a0b0 += 1
  elif a == 0:
    pp[(0,1)] += 1

  elif b == 0:
    pm[(0,1)] += 1

  elif a*b>0:
    tmp = seiki(abs(a),abs(b))
    pp[tmp] += 1

  else:
    tmp = seiki(abs(b),abs(a))
    pm[tmp] += 1

ans = 1
for key in set(pp.keys()) | set(pm.keys()):
    pp_v=pp[key]
    pm_v=pm[key]
    ans*=(modpow(2,pm_v,MOD)+modpow(2,pp_v,MOD)-1)
    ans%=MOD

ans = (ans+a0b0-1) % MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
for a in range(-10000, 10001):
  for b in range(-10000, 10001):
    if a**5 - b**5 == x:
      print(a, b)
      exit()

Fixed submission:
x = int(input())
for a in range(-1000, 1001):
  for b in range(-1000, 1001):
    if a**5 - b**5 == x:
      print(a, b)
      exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
m = min(a)
l = []
for i in range(n):
  if a[i] < n-m:
    l.append((i, a[i]))
count = 0

for i in range(len(l)-1):
  for j in range(i+1, len(l)):
    if l[j][0]-l[i][0] == l[j][1]+l[i][1]:
      count += 1

print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

lr = [[0,0] for i in range(n)]

for i in range(n):
  l = i+a[i]
  if l < n:
    lr[l][0] += 1
  r = i-a[i]
  if r > 0:
    lr[r][1] += 1
count = 0
for i in range(n):
  count += lr[i][0] * lr[i][1]
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
m = min(a)
l = []
for i in range(n):
  if a[i] < 2*10**5-m:
    l.append((i, a[i]))
count = 0

for i in range(len(l)-1):
  for j in range(i+1, len(l)):
    if l[j][0]-l[i][0] == l[j][1]+l[i][1]:
      count += 1

print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

lr = [[0,0] for i in range(n)]

for i in range(n):
  l = i+a[i]
  if l < n:
    lr[l][0] += 1
  r = i-a[i]
  if r > 0:
    lr[r][1] += 1
count = 0
for i in range(n):
  count += lr[i][0] * lr[i][1]
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
l = []
for i in range(n):
  if a[i] < 2*10**5-1:
    l.append((i, a[i]))
count = 0
for i in range(len(l)-1):
  for j in range(i+1, len(l)):
    if l[j][0]-l[i][0] == l[j][1]+l[i][1]:
      count += 1
print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

lr = [[0,0] for i in range(n)]

for i in range(n):
  l = i+a[i]
  if l < n:
    lr[l][0] += 1
  r = i-a[i]
  if r > 0:
    lr[r][1] += 1
count = 0
for i in range(n):
  count += lr[i][0] * lr[i][1]
print(count)
Buggy python submission (verdict: Runtime Error):

n, m , q = map(int, input().split())
 
l = []
for i in range(q):
  a,b,c,d = map(int, input().split())
  l.append((a,b,c,d))
max_score = 0
comb = [[1]]
while len(comb[0]) > 0:
  seed = comb.pop()
  if len(seed) == n:
    score = 0
    for j in l:
      if seed[j[1]-1]-seed[j[0]-1]==j[2]:
      
        score += j[3]
    if score > max_score:
      max_score = score
  else:
    for k in range(seed[-1], m+1):
      comb.append(seed.copy().append(k))
print(max_score)

Fixed submission:
import itertools
n, m , q = map(int, input().split())

l = []
for i in range(q):
  a,b,c,d = map(int, input().split())
  l.append((a,b,c,d))
  
comb = itertools.combinations_with_replacement(range(1,m+1), n)

max_score = 0
for e in comb:
  score = 0
  for j in l:
    if e[j[1]-1]-e[j[0]-1]==j[2]:
      
      score += j[3]
  if score > max_score:
    max_score = score
print(max_score)

Buggy python submission (verdict: Runtime Error):
n, m , q = map(int, input().split())
import itertools
n, m , q = map(int, input().split())

l = []
for i in range(q):
  a,b,c,d = map(int, input().split())
  l.append((a,b,c,d))
  
comb = itertools.combinations_with_replacement(range(1,m+1), n)

max_score = 0
for e in comb:
  score = 0
  for j in l:
    if e[j[1]-1]-e[j[0]-1]==j[2]:
      
      score += j[3]
  if score > max_score:
    max_score = score
print(max_score)

Fixed submission:
import itertools
n, m , q = map(int, input().split())

l = []
for i in range(q):
  a,b,c,d = map(int, input().split())
  l.append((a,b,c,d))
  
comb = itertools.combinations_with_replacement(range(1,m+1), n)

max_score = 0
for e in comb:
  score = 0
  for j in l:
    if e[j[1]-1]-e[j[0]-1]==j[2]:
      
      score += j[3]
  if score > max_score:
    max_score = score
print(max_score)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
mod_list = [0]*2019
mod_list[0] = 1
t = 0
for i in range(n-1, -1, -1):
  t = int(s[i])*10**(n-1-i)+t
  mod_list[t%2019]+= 1
count = 0
for k in range(2019):
  count += mod_list[k] * (mod_list[k]-1)//2
print(count)

Fixed submission:
s = input()

n = len(s)
mod_list = [0]*2019
mod_list[0] = 1
t = 0
keisu = 1
for i in range(n):
  t = (int(s[n-1-i])*keisu+t) %2019
  keisu = keisu*10 %2019
  mod_list[t]+= 1
count = 0
for k in range(2019):
  count += mod_list[k] * (mod_list[k]-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
mod_list = [0]*2019
mod_list[0] = 1
t = 0
for i in range(n-1, -1, -1):
  t = int(s[i])*10**(n-1-i)+t
  mod_list[t%2019]+= 1
count = 0
for k in range(2019):
  count += mod_list[k] * (mod_list[k]-1)//2
print(count)

Fixed submission:
s = input()

n = len(s)
mod_list = [0]*2019
mod_list[0] = 1
t = 0
keisu = 1
for i in range(n):
  t = (int(s[n-1-i])*keisu+t) %2019
  keisu = keisu*10 %2019
  mod_list[t]+= 1
count = 0
for k in range(2019):
  count += mod_list[k] * (mod_list[k]-1)//2
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(1, n):
  b[a[i]] += 1

for e in b:
  print(e)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n-1):
  b[a[i]-1] += 1
  
for e in b:
  print(e)
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
s = 0
for a in range(1, k+1):
  for b in range(1, k+1):
    for c in range(1, k+1):
      s += math.gcd(math.gcd(a, b), c)

print(s)

Fixed submission:
import math
k = int(input())
s = 0
for a in range(1, k+1):
  for b in range(1, k+1):
    for c in range(1, k+1):
      s += math.gcd(math.gcd(a, b), c)

print(s)