Buggy python submission (verdict: Runtime Error):
M=2019
a,i,*d=[0]*M
p=1
for j in input():d[i%M]+=1;i+=int(j)*p;a+=d[i%M];p=p*202%M
print(a)

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
M=2019
a=i=0
d=[0]*M
p=1
for j in input()[::-1]:d[i%M]+=1;i-=int(j)*p;a+=d[i%M];p*=10
print(a)

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    s = input()
    n = len(s)
    counter = [0] * 2019
    counter[0] += 1
    temp = ""
    for i, c in enumerate(s[::-1], 1):
        temp = c + temp
        counter[int(temp) % 2019] += 1

    ans = 0
    for i in counter:
        ans += (i * (i - 1)) // 2

    print(ans)
resolve()

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Runtime Error):
def resolve():
    s = input()
    n = len(s)
    counter = [0] * 2019
    counter[0] += 1
    temp = ""
    for i, c in enumeate(s[::-1], 1):
        temp = c + temp
        counter[int(temp) % 2019] += 1

    ans = 0
    for i in counter:
        ans += (i * (i - 1)) // 2

    print(ans)
resolve()

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
p,*d,a,i=[1,1]+[0]*2020
for j in input()[::-1]:
  i=(i+int(j)*p)%2019
  a+=d[i]
  d[i]+=1
  p*=10
print(a)

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
p,*d,a,i=[1,1]+[0]*2020
for j in input()[::-1]:
  i=(i+int(j)*p)%2019
  a+=d[i]
  d[i]+=1
  p*=10
print(a)

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
from numba import njit
from numpy import int32,zeros,arange
@njit('i4(i4[:])')
def solve(s):
    a=0
    d=zeros(2019,int32)
    for i in s:
        p=zeros(2019,int32)
        p[(arange(2019)*10+i)%2019]+=d[arange(2019)]
        d=p
        d[i]+=1
        a+=d[0]
    return a
print(solve(int32([*input()])))

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
from numpy import int32,zeros,arange
def solve(s):
    a=0
    d=zeros(2019,int32)
    for i in s:
        p=zeros(2019,int32)
        p[(arange(2019)*10+i)%2019]+=d[arange(2019)]
        d=p
        d[i]+=1
        a+=d[0]
    return a
print(solve(int32([*input()])))

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
from numpy import*
s=int_([*input()])
dp=zeros((len(s)+1,2019),int)
r=arange(2019)
a=0
for i,c in enumerate(s):
  dp[i+1,(r*10+c)%2019]+=dp[i,r]
  dp[i+1,c]+=1
print(sum(dp[:,0]))

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
from numpy import*
*s,=map(int,input())
dp=zeros((len(s)+1,2019),int)
r=arange(2019)
a=0
for i,c in enumerate(s):
  dp[i+1,(r*10+c)%2019]+=dp[i,r]
  dp[i+1,c]+=1
print(sum(dp[:,0]))

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
from numpy import*
d=zeros(2019,int)
r=arange(2019)
a=0
for i in map(int,input()):
  p=zeros(2019,int)
  p[(r*10+i)%2019]+=d[r]
  d=p
  d[i]+=1
  a+=d[0]
print(a)

Fixed submission:
a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)