Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
li_a = []
b=0
for i in range(n):
    temp = input()
    if temp == "2":
        li_a.sort()
        if len(li_a)%2 == 0:
            ans_a = li_a[len(li_a)//2-1]
        else:
            ans_a = li_a[(len(li_a)-1)//2]
        ans_b = 0
        for a in li_a:
            ans_b += abs(a-ans_a)
        ans_b += b
        print(ans_a,ans_b)
    else:
        z,aa,bb=temp.split(" ")
        li_a.append(int(aa))
        b+=int(bb)


Fixed submission:
from collections import deque

a,b = map(int,input().split()) 
a=sorted(list(map(int,input().split())))
di = {}
for i in range(b):
    x,y = map(int,input().split()) 
    if y in di:
        di[y] += x
    else:
        di[y] = x
keys = sorted(list(di.keys()))
keys.reverse()
# print(keys)
ichi = 0
# print(a)
for i in range(len(a)):
    try:
        if keys[ichi] > a[i]:
            a[i] = keys[ichi]
            di[keys[ichi]] -= 1
        else:
            break
        if di[keys[ichi]] == 0:
            ichi += 1
    except:
        pass
# print(a)
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
rr=0
ans=0
while rr*r<=n:
    gg=0
    while rr*r+gg*g<=n:
        if (n-(rr*r+gg*g))%b == 0:
            ans+=1
        gg+=1
    rr+=1
print(ans)

Fixed submission:
r,g,b,n=map(int,input().split())
rr=0
ans=0
while rr*r<=n:
    gg=0
    while rr*r+gg*g<=n:
        if (n-(rr*r+gg*g))%b == 0:
            ans+=1
        gg+=1
    rr+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = input()
nl = list(n)
ans = 1000000
for i in range(len(n)+1):
    test = []
    temp = 0
    for c in range(i):
        test.append("E")
    for c in range(len(n)-i):
        test.append("W")
    for j in range(len(n)):
        if nl[j] != test[j]:
            temp += 1
    if ans > temp:
        ans = temp
    # print(nl,test,temp)
print(ans)

Fixed submission:
n = input()
n = input()
nl = list(n)
w = [0 for i in range(len(n))]
e = [0 for i in range(len(n))]
w[0] = 1 if nl[0] == "W" else 0
e[0] = 1 if nl[0] == "E" else 0
for i in range(len(n)-1):
    w[i+1] = w[i] + 1 if nl[i+1] == "W" else w[i]
    e[i+1] = e[i] + 1 if nl[i+1] == "E" else e[i]
wr = [0 for i in range(len(n))]
er = [0 for i in range(len(n))]
ans = [0 for i in range(len(n))]
for i in range(len(n)):
    wr[i] = w[len(n)-1] - w[i]
    er[i] = e[len(n)-1] - e[i]
for i in range(len(n)):
    temp = w[i] - 1 if nl[i] == "W" else w[i]
    ans[i] = temp + er[i]
# print(w)
# print(e)
# print(wr)
# print(er)
# print(ans)
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split(" ")))
b = [0 for a in range(n)]
b[0] = a[0]
answer = 0
for i in range(n-1):
    b[i+1] = b[i] + a[i+1]
# print(b)
for i in b:
    if i == 0:
        answer += 1;
minimum = min(b)
for i in range(n):
    b[i] -= minimum
# print(b)
c = [0 for a in range(max(b)+1)]
for i in range(n):
    c[b[i]] += 1

for i in c:
    if i > 1:
        answer += i * (i-1) // 2
# print(c)
# print(sum(c))
print(answer)

Fixed submission:
n = int(input())
a = list(map(int,input().split(" ")))
b = [0 for a in range(n)]
b[0] = a[0]
answer = 0
for i in range(n-1):
    b[i+1] = b[i] + a[i+1]
# print(b)
for i in b:
    if i == 0:
        answer += 1;
minimum = min(b)
for i in range(n):
    b[i] -= minimum
# print(b)
# c = [0 for a in range(max(b)+1)]
setb = set(b)
# print(setb)
c = {}
for key in setb:
    c[str(key)] = 0

for i in range(n):
    c[str(b[i])] += 1

for v in c.values():
    if v > 1:
        answer += v * (v-1) // 2
# print(c)
# print(sum(c))
print(answer)
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2)

Fixed submission:
import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,list(input()))
print(min(a*b,c))


Fixed submission:
a,b,c=map(int,input().split())
print(min(a*b,c))
Buggy python submission (verdict: Runtime Error):
a=map(int,list(input()))
print("Yes" if a[0]==a[1] and a[1]==a[2] or a[3]==a[1] and a[1]==a[2] else "No")

Fixed submission:
a=list(map(int,list(input())))
print("Yes" if a[0]==a[1] and a[1]==a[2] or a[3]==a[1] and a[1]==a[2] else "No")

Buggy python submission (verdict: Runtime Error):
a=map(int,list(input()))
print("Yes" if a[0]==a[1]==a[2] or a[3]==a[1]==a[2] else "No")

Fixed submission:
a=list(map(int,list(input())))
print("Yes" if a[0]==a[1] and a[1]==a[2] or a[3]==a[1] and a[1]==a[2] else "No")
Buggy python submission (verdict: Runtime Error):
a=int(input())
print(a**2-int(input())

Fixed submission:
a=int(input())
print(a**2-int(input()))
Buggy python submission (verdict: Runtime Error):
a = list(input())
b = []
for i in range(a):
  if i % 2 == 0:
    b.append(a[i])
print("".join(b))
  

Fixed submission:
temp = input().split(" ")
mojis = list(temp[0])
ans = ""
for a in range(len(mojis)):
    if a % 2 == 0:
        ans = ans + mojis[a]
print(ans)

Buggy python submission (verdict: Runtime Error):
a = list(input())
b = []
for i in range(a):
  if i % 2 == 0:
    b.push(a[i])
print("".join(b))
  

Fixed submission:
temp = input().split(" ")
mojis = list(temp[0])
ans = ""
for a in range(len(mojis)):
    if a % 2 == 0:
        ans = ans + mojis[a]
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print("H" if a==b else "D")

Fixed submission:
a,b=input().split()
print("H" if a==b else "D")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(_) for _ in input().split()]
Q = int(input())
b_to_c = [[int(_) for _ in input().split()] for i in range(Q)]

sum = 0
memo = [0] * (10 ** 5)
for i in A:
    memo[i] += 1
    sum += i

for bc in b_to_c:
    b = bc[0]
    c = bc[1]
    sum -= (b * memo[b])
    sum += (c * memo[b])
    memo[c] += memo[b]
    memo[b] = 0
    print(sum)


Fixed submission:
N = int(input())
A = [int(_) for _ in input().split()]
Q = int(input())
b_to_c = [[int(_) for _ in input().split()] for i in range(Q)]

sum = 0
memo = [0] * (10 ** 5 + 1)
for i in A:
    memo[i] += 1
    sum += i

for bc in b_to_c:
    b = bc[0]
    c = bc[1]
    sum -= (b * memo[b])
    sum += (c * memo[b])
    memo[c] += memo[b]
    memo[b] = 0
    print(sum)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

N, M = [int(_) for _ in input().split()]
S, C = np.array([[int(_) for _ in input().split()] for i in range(M)]).T

print("no")
# ans = [-1] * N

# for i in range(M):
#     j = int(S[i]) - 1
#     if ans[j] == -1 or ans[j] == C[i]:
#         ans[j] = C[i]
#     else:
#         print("-1")
#         sys.exit()

# if ans[0] == -1:
#     ans[0] = 1

# for i in range(1, N):
#     if ans[i] == -1:
#         ans[i] = 0

# s = "".join(map(str, ans))

# if int(s) == 0:
#     print("-1")
# else:
#     print(s)


Fixed submission:
import sys
import numpy as np

N, M = [int(_) for _ in input().split()]

if M == 0:
    if N == 1:
        print("0")
    else:
        ans = [0] * N
        ans[0] = 1
        print("".join(map(str, ans)))
    sys.exit()

S, C = np.array([[int(_) for _ in input().split()] for i in range(M)]).T

ans = [-1] * N

for i in range(M):
    j = int(S[i]) - 1
    if ans[j] == -1 or ans[j] == C[i]:
        ans[j] = C[i]
    else:
        print("-1")
        sys.exit()

if N >= 2 and ans[0] == 0:
    print("-1")
    sys.exit()

if N >= 2 and ans[0] == -1:
    ans[0] = 1

for i in range(1, N):
    if ans[i] == -1:
        ans[i] = 0

s = "".join(map(str, ans))
print(s)

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

N, M = [int(_) for _ in input().split()]
S, C = np.array([[int(_) for _ in input().split()] for i in range(M)]).T

ans = [-1] * N

for i in range(M):
    j = int(S[i]) - 1
    if ans[j] == -1 or ans[j] == C[i]:
        ans[j] = C[i]
    else:
        print("-1")
        sys.exit()

if ans[0] == -1:
    ans[0] = 1

for i in range(1, N):
    if ans[i] == -1:
        ans[i] = 0

s = "".join(map(str, ans))

if int(s) == 0:
    print("-1")
else:
    print(s)


Fixed submission:
import sys
import numpy as np

N, M = [int(_) for _ in input().split()]

if M == 0:
    if N == 1:
        print("0")
    else:
        ans = [0] * N
        ans[0] = 1
        print("".join(map(str, ans)))
    sys.exit()

S, C = np.array([[int(_) for _ in input().split()] for i in range(M)]).T

ans = [-1] * N

for i in range(M):
    j = int(S[i]) - 1
    if ans[j] == -1 or ans[j] == C[i]:
        ans[j] = C[i]
    else:
        print("-1")
        sys.exit()

if N >= 2 and ans[0] == 0:
    print("-1")
    sys.exit()

if N >= 2 and ans[0] == -1:
    ans[0] = 1

for i in range(1, N):
    if ans[i] == -1:
        ans[i] = 0

s = "".join(map(str, ans))
print(s)
Buggy python submission (verdict: Runtime Error):
N, Q = [int(_) for _ in input().split()]
edge = [[] for _ in range(N)]

for i in range(N-1):
    a, b = [int(_) for _ in input().split()]
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)


vertex = [0] * N
for i in range(Q):
    p, x = [int(_) for _ in input().split()]
    p -= 1
    vertex[p] += x


def dfs(n, parent):
    for to in edge[n]:
        if to == parent:
            continue
        vertex[to] += vertex[n]
        dfs(to, n)


dfs(0, -1)
print(*vertex)


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

N, Q = [int(_) for _ in input().split()]
edge = [[] for _ in range(N)]

for i in range(N-1):
    a, b = [int(_) for _ in input().split()]
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)


vertex = [0] * N
for i in range(Q):
    p, x = [int(_) for _ in input().split()]
    p -= 1
    vertex[p] += x


def dfs(n, parent):
    for to in edge[n]:
        if to == parent:
            continue
        vertex[to] += vertex[n]
        dfs(to, n)


dfs(0, -1)
print(*vertex)
Buggy python submission (verdict: Runtime Error):
import pandas as pd
import math

N = int(input())
print("No")

Fixed submission:
import math
from itertools import groupby

N = int(input())
S = ["".join(sorted(input())) for i in range(N)]
sizes = [len(list(v)) for k, v in groupby(sorted(S))]


def combinations_count(n, r):
    if n == 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


ans = sum([combinations_count(size, 2) for size in sizes])
print(ans)

Buggy python submission (verdict: Runtime Error):
import pandas as pd
import math

N = int(input())
S = ["".join(sorted(input())) for i in range(N)]
df = pd.DataFrame(S, columns=["value"])


def combinations_count(n, r):
    if n == 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


grouped = df.groupby("value")
sizes = grouped.size().values
ans = sum([combinations_count(size, 2) for size in sizes])
print(ans)


Fixed submission:
import math
from itertools import groupby

N = int(input())
S = ["".join(sorted(input())) for i in range(N)]
sizes = [len(list(v)) for k, v in groupby(sorted(S))]


def combinations_count(n, r):
    if n == 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


ans = sum([combinations_count(size, 2) for size in sizes])
print(ans)
Buggy python submission (verdict: Runtime Error):
L, R = [int(_) for _ in input().split()]

diff = R - L
if diff >= 2019:
    print("0")
else:
    ans = min([i * j % 2019 for j in range(L + 1, R) for i in range(L, R)])
    print(ans)


Fixed submission:
L, R = [int(_) for _ in input().split()]

diff = R - L
if diff >= 2019:
    print("0")
else:
    ans = min([i * j % 2019 for j in range(L + 1, R + 1) for i in range(L, R)])
    print(ans)
Buggy python submission (verdict: Runtime Error):
from typing import List


class Work:
    require = 0
    limit = 0
    def __init__(self, require, limit) -> None:
        self.require = require
        self.limit = limit

def from_list(xs: List[int]) -> Work: 
    return Work(xs[0], xs[1])

N = int(input())

works = [from_list([int(_) for _ in input().split()]) for i in range(N)]

def solve(works):
    works.sort(key=lambda x: x.limit)
    acc = 0
    for w in works:
        acc += w.require
        if acc > w.limit:
            return "No"
    return "Yes"

print(solve(works))

Fixed submission:
N = int(input())

Works = [dict(zip(["require", "limit"], [int(_) for _ in input().split()])) for i in range(N)]

def solve(Works):
    Works.sort(key=lambda x: x["limit"])
    acc = 0
    for w in Works:
        acc += w["require"]
        if acc > w["limit"]:
            return "No"
    return "Yes"

print(solve(Works))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
  N = int(input())
  P = stdin.readline().rstrip().split()
  # print(P)
  ans = 1
  for a in P:
    ans *= int(a)
  if ans > 1000000000000000000:
    print(-1)
    return
  print(ans)

main()


Fixed submission:
from sys import stdin

def main():
  N = int(input())
  P = stdin.readline().rstrip().split()
  if '0' in P:
    print(0)
    return
  # print(P)
  ans = 1
  for a in P:
    ans *= int(a)
    if ans > 1000000000000000000:
      print(-1)
      return
  print(ans)

main()
Buggy python submission (verdict: Runtime Error):
i = input()
ans = ""

while i = 0:
	nexti = i // 26
	mod = i % 26
    if mod = 0:
		nextans = "z" + ans
		nextii = nexti - 1
        nexti = nextii
    elif mod = 1:
		nextans = "a" + ans
    elif mod = 2:
		nextans = "b" + ans
    elif mod = 3:
		nextans = "c" + ans
    elif mod = 4:
		nextans = "d" + ans
    elif mod = 5:
		nextans = "e" + ans
    elif mod = 6:
		nextans = "f" + ans
    elif mod = 7:
		nextans = "g" + ans
    elif mod = 8:
		nextans = "h" + ans
    elif mod = 9:
		nextans = "i" + ans
    elif mod = 10:
		nextans = "j" + ans
    elif mod = 11:
		nextans = "k" + ans
    elif mod = 12:
		nextans = "l" + ans
    elif mod = 13:
		nextans = "m" + ans
    elif mod = 14:
		nextans = "n" + ans
    elif mod = 15:
		nextans = "o" + ans
    elif mod = 16:
		nextans = "p" + ans
    elif mod = 17:
		nextans = "q" + ans
    elif mod = 18:
		nextans = "r" + ans
    elif mod = 19:
		nextans = "s" + ans
    elif mod = 20:
		nextans = "t" + ans
    elif mod = 21:
		nextans = "u" + ans
    elif mod = 22:
		nextans = "v" + ans
    elif mod = 23:
		nextans = "w" + ans
    elif mod = 24:
		nextans = "x" + ans
    elif mod = 25:
		nextans = "y" + ans
	ans = nextans
	i = nexti
print(ans)

Fixed submission:
i = int(input())
nexti = 0
nextii = 0
ans = str()
nextans = str()


while i > 0:
  nexti = i // 26
  mod = i % 26
  if mod == 0:
    nextans = "z" + ans
    nextii = nexti-1
    nexti = nextii
  elif mod == 1:
    nextans = "a" + ans
  elif mod == 2:
    nextans = "b" + ans
  elif mod == 3:
    nextans = "c" + ans
  elif mod == 4:
    nextans = "d" + ans
  elif mod == 5:
    nextans = "e" + ans
  elif mod == 6:
    nextans = "f" + ans
  elif mod == 7:
    nextans = "g" + ans
  elif mod == 8:
    nextans = "h" + ans
  elif mod == 9:
    nextans = "i" + ans
  elif mod == 10:
    nextans = "j" + ans
  elif mod == 11:
    nextans = "k" + ans
  elif mod == 12:
    nextans = "l" + ans
  elif mod == 13:
    nextans = "m" + ans
  elif mod == 14:
    nextans = "n" + ans
  elif mod == 15:
    nextans = "o" + ans
  elif mod == 16:
    nextans = "p" + ans
  elif mod == 17:
    nextans = "q" + ans
  elif mod == 18:
    nextans = "r" + ans
  elif mod == 19:
    nextans = "s" + ans
  elif mod == 20:
    nextans = "t" + ans
  elif mod == 21:
    nextans = "u" + ans
  elif mod == 22:
    nextans = "v" + ans
  elif mod == 23:
    nextans = "w" + ans
  elif mod == 24:
    nextans = "x" + ans
  elif mod == 25:
    nextans = "y" + ans
  ans = nextans
  i = nexti
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = input()
inp = map(int, input().split())
dic = dict(collections.Counter(inp))
wa = 0
for i in range(len(dic)):
    wa += list(dic.keys())[i] * list(dic.values())[i]
se = set(dic.keys())
for i in range(int(input())):
    a, b = map(int, input().split())
    if a in se:
        wa += dic[a] * (b-a)
        if b in se:
            pass
        else:
            dic[b] = 0
        se.add(b)
        dic[b] += dic[a]
        dic[a] = 0
    print(wa)

Fixed submission:
import collections
N = int(input())
inp = list(map(int,input().split()))
dic = dict(collections.Counter(inp))
wa = 0
for i, j in dic.items():
	wa += i * j
se = set(dic.keys())
for i in range(int(input())):
	a, b = map(int,input().split())
	if a in se:
		wa += dic[a] * (b-a)
		if b in se:
			pass
		else:
			dic[b] = 0
		se.add(b)
		dic[b] += dic[a]
		dic[a] = 0
	print(wa)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = input()
inp = map(int, input().split())
dic = dict(collections.Counter(inp))
wa = 0
for i in range(len(dic)):
    wa += list(dic.keys())[i] * list(dic.values())[i]
for i in range(int(input())):
    a, b = map(int, input().split())
    se = set(dic.keys())
    if a in se:
        wa += dic[a] * (b-a)
        if b in se:
            pass
        else:
            dic[b] = 0
        dic[b] += dic[a]
        dic[a] = 0
    print(wa)

Fixed submission:
import collections
N = int(input())
inp = list(map(int,input().split()))
dic = dict(collections.Counter(inp))
wa = 0
for i, j in dic.items():
	wa += i * j
se = set(dic.keys())
for i in range(int(input())):
	a, b = map(int,input().split())
	if a in se:
		wa += dic[a] * (b-a)
		if b in se:
			pass
		else:
			dic[b] = 0
		se.add(b)
		dic[b] += dic[a]
		dic[a] = 0
	print(wa)
Buggy python submission (verdict: Runtime Error):
inp = input().split(" ")
N,A,B = inp
if (N%(A+B)) <= A:
  print((N/(A+B))*A + (N%(A+B)))
else:
  print((N/(A+B))*A + A)

Fixed submission:
inp = input().split(" ")
N, A, B = (int(inp[0]), int(inp[1]), int(inp[2]))
if int(N % (A + B)) <= A:
    print(int(N / (A + B)) * A + int(N % (A + B)))
else:
    print(int(N / (A + B)) * A + A)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 1:
	print(0)
else:
	ans = 0
	if N <= 9:
		pass
	else:
		ans += N//10
		N = int(N/10)
		while N >= 5:
			ans += N//5
			N = int(N/5)
print(ans)

Fixed submission:
from decimal import getcontext, Decimal
getcontext().prec = 1

N = int(input())
if N % 2 == 1:
	print(0)
else:
	ans = 0
	if N <= 9:
		pass
	else:
		ans += N//10
		N //= 10
		while N >= 5:
			ans += N//5
			N //= 5
	print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
kosuu = int(input())
dp = list(map(int,input().split()))
ans = []
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
for i in range(kosuu):
	hako = kosuu - i
	if dp[hako-1] == 1:
		for j in make_divisors(hako)[:-1]:
			dp[j-1] ^= 1
		ans.append(hako)
print(len(ans))
finalans = ''
for i in ans[::-1]:
	finalans += str(i) + ' '
print(finalans[:-1])

Fixed submission:
kosuu = int(input())
dp = list(map(int,input().split()))
ans = []
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return set((lower_divisors + upper_divisors[::-1])[:-1])
for i in range(kosuu):
	hako = kosuu - i
	if dp[hako-1] == 1:
		for j in make_divisors(hako):
			dp[j-1] ^= 1
		ans.append(str(hako))
print(len(ans))
print(' '.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))

    d = defaultdict(list)
    for _ in range(m):
        ai, bi = map(lambda x: int(x) - 1, input().split())
        d[ai].append(bi)
        d[bi].append(ai)

    bad = []
    ans = 0
    for i in range(n):
        if i in bad:
            continue
        flg = True
        for nei_peak in d[i]:
            if h[i] <= h[nei_peak]:
                flg = False
                break

        if flg:
            ans += 1
            for nei_peak in d[i]:
                bad.append(nei_peak)


    print(ans)
    
resolve()

Fixed submission:
from collections import defaultdict
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))

    d = defaultdict(list)
    for _ in range(m):
        ai, bi = map(lambda x: int(x) - 1, input().split())
        d[ai].append(bi)
        d[bi].append(ai)

    bad = []
    ans = 0
    for i in range(n):
        if -1 in d[i]:
            continue
        flg = True
        for nei_peak in d[i]:
            if h[i] <= h[nei_peak]:
                flg = False
                break

        if flg:
            ans += 1
            for nei_peak in d[i]:
                d[nei_peak] = [-1]

    print(ans)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import Counter

def resolve():
    s = input()

    mod_table = np.zeros(shape=len(s), dtype=int)
    for i in reversed(range(len(s) - 1)):
        mod_table[i] = int(s[i:]) % 2019

    count = Counter(mod_table)
    vals = np.array(list(count.values()))

    ans = sum((vals * (vals - 1)) / 2)
    print(int(ans))
resolve()

Fixed submission:
def resolve():
    s = [int(i) for i in input()]
    p_cnt = 0

    p = 2019

    s = s[::-1]
    div_dic = dict(zip(range(p), [0] * p))
    tmp = 0

    for i in range(len(s)):
        tmp += s[i] * pow(10, i, p)
        tmp %= p
        div_dic[tmp] += 1

    for v in div_dic.values():
        p_cnt += v * (v - 1)
    p_cnt //= 2
    p_cnt += div_dic.get(0)


    print(p_cnt)
    
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import Counter

def resolve():
    s = input()

    mod_table = np.zeros(shape=len(s), dtype=int)
    for i in reversed(range(len(s) - 1)):
        mod_table[i] = int(s[i:]) % 2019

    count = Counter(mod_table)

    ans = 0
    for num_dup in count.values():
        if num_dup >= 2:
            ans += (num_dup * (num_dup - 1)) / 2

    print(int(ans))
    
resolve()

Fixed submission:
def resolve():
    s = [int(i) for i in input()]
    p_cnt = 0

    p = 2019

    s = s[::-1]
    div_dic = dict(zip(range(p), [0] * p))
    tmp = 0

    for i in range(len(s)):
        tmp += s[i] * pow(10, i, p)
        tmp %= p
        div_dic[tmp] += 1

    for v in div_dic.values():
        p_cnt += v * (v - 1)
    p_cnt //= 2
    p_cnt += div_dic.get(0)


    print(p_cnt)
    
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    a_list = list(map(int,input().split()))
    b_list = list(map(int,input().split()))
    c_list = list(map(int,input().split()))
    arr = np.array([a_list, b_list, c_list])

    n = int(input())
    for _ in range(n):
        num = int(input())
        arr = np.where(arr == num, 0, arr)

    if True in np.all(arr == 0, axis=0):
        print('Yes')
        return

    elif True in np.all(arr == 0, axis=1):
        print('Yes')
        return

    elif arr[0, 0] == 0 and arr[1, 1] == 0 and arr[2, 2] == 0:
        print('Yes')
        return

    elif arr[2, 0] == 0 and arr[1, 1] == 0 and arr[0, 2] == 0:
        print('Yes')
        return

    else:
        print('No')
        return
      
resolve()

Fixed submission:
import numpy as np


def resolve():
    a_list = list(map(int,input().split()))
    b_list = list(map(int,input().split()))
    c_list = list(map(int,input().split()))
    arr = np.array([a_list, b_list, c_list])

    n = int(input())
    for _ in range(n):
        num = int(input())
        arr = np.where(arr == num, 0, arr)

    if True in np.all(arr == 0, axis=0):
        print('Yes')
        return

    elif True in np.all(arr == 0, axis=1):
        print('Yes')
        return

    elif arr[0, 0] == 0 and arr[1, 1] == 0 and arr[2, 2] == 0:
        print('Yes')
        return

    elif arr[2, 0] == 0 and arr[1, 1] == 0 and arr[0, 2] == 0:
        print('Yes')
        return

    else:
        print('No')
        return
      
resolve()