Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])*10**i%mod)%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Fixed submission:
from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])%mod*pow(10,i,mod))%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s=input()
n=len(s)
M=[0]*(n+1)
mod=2019
for i in range(n):
	M[n-1-i]=(M[n-i]+int(s[n-1-i])*10**i%mod)%mod
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Fixed submission:
from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])%mod*pow(10,i,mod))%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s=input()
n=len(s)
M=[0]*(n+1)
mod=2019
for i in range(n):
	M[n-1-i]=(M[n-i]+int(s[n-1-i])*10**i%mod)%mod
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Fixed submission:
from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])%mod*pow(10,i,mod))%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s=input()
n=len(s)
M=[0]*(n+1)
mod=2019
for i in range(n):
	M[n-1-i]=int(s[n-1-i:])%mod
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Fixed submission:
from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])%mod*pow(10,i,mod))%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s=input()
n=len(s)
M=[0]*(n+1)
mod=2019
for i in range(n):
	M[n-1-i]=int(s[n-1-i:])%mod
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Fixed submission:
from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])%mod*pow(10,i,mod))%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s=input()
n=len(s)
M=[0]*(n+1)
mod=2019
for i in range(n):
	M[n-1-i]=int(s[n-1-i:])%mod
MC=Counter(M)
r=0
for v in MC.values():
	r+=v*(v-1)//2
print(r)

Fixed submission:
from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])%mod*pow(10,i,mod))%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
c=0
for i in range(n):
    for j in range(i+1,n+1):
        if int(s[i:j])%2019==0:
            c+=1
print(c)

Fixed submission:
from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])%mod*pow(10,i,mod))%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)