Buggy python submission (verdict: Time Limit Exceeded):
S = input()[::-1]
L = len(S)
ans = 0
now = 0
A = [0] * 2019
A[0] = 1
d = 0
for i in range(L):
    now = now + int(S[i]) * 10**d % 2019
    now %= 2019
    d += 1
    A[now] += 1

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

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()[::-1]
L = len(S)
ans = 0
now = 0
A = [0] * 2019
A[0] = 1
d = 0
for i in range(L):
    now = now + int(S[i]) * 10**d
    now %= 2019
    d += 1
    A[now] += 1

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

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
L = len(S)
ans = 0
C = [0] * (L+1)
A = [0] * 2020
A[0] = 1
for i in range(L-1, -1, -1):
    C[i] = (int(S[i]) * 10**(L-1-i) % 2019 + C[i+1])%2019
    A[C[i]] += 1

for i in A:
    ans += int(i * (i-1) / 2)

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
L = len(S)
ans = 0
A = [0] * 2020
A[0] = 1
for i in range(L):
     x = int(S[i:]) % 2019
     A[x] += 1

for i in A:
    ans += int(i * (i-1) / 2)

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0
A = [0] * 2020
A[0] = 1
for i in range(len(S)):
     x = int(S[-i-1:]) % 2019
     A[x] += 1

while 0 in A:
    A.remove(0)

while 1 in A:
    A.remove(1)

for i in A:
    ans += int(i * (i-1) / 2)

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0
A = [0] * 2020
A[0] = 1
for i in range(len(S)):
     x = int(S[-i-1:]) % 2019
     A[x] += 1

for i in A:
    ans += int(i * (i-1) / 2)

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0
A = [0] * 2020
A[0] = 1
for i in range(len(S)):
     x = int(S[-i-1:]) % 2019
     A[x] += 1

for i in A:
    ans += int(i * (i-1) / 2)

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0
A = [0] * (len(S) + 1)
for i in range(len(S)):
    A[i+1] = int(S[-i:]) % 2019

for i in range(2020):
    num = A.count(i)
    ans += int(num * (num-1) / 2)

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0

for i in range(len(S)):
    for j in range(i + 4, len(S)):
        if int(S[i:j + 1]) % 2019 == 0:
            ans += 1

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0

for i in range(len(S)):
    for j in range(i, len(S)):
        if int(S[i:j+1]) % 2019 == 0:
            ans += 1

print(ans)

Fixed submission:
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=d+int(j)*pow(10,i,p)
	z[d%p]+=1
r=z[0]
for i in z:
	r+=i*(i-1)//2
print(r)