Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)

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

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

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

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0

for c in s[::-1]:
    d=(int(c)*10**len(str(d)) + d)
    amari[d%2019]+=1


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

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

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

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=int(s[-1])

for i in range(1,l+1):
    nd=int(s[l-i-1])
    d=(nd*10**len(str(d)) + d)
    amari[d%2019]+=1

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

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

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

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

for i in range(1,l+1):
    amari[int(s[l-i:])%2019]+=1

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

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

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

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
amari=[0]*(l+1)
for i in range(1,l+1):
    amari[i]=int(s[l-i:])%2019

from collections import Counter
myc = Counter(amari)
val=list(myc.values())

ans=0
for i in range(len(val)):
    ans+=val[i]*(val[i]-1)//2
print(ans)

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

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

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
amari=[0]*(l+1)
for i in range(1,l+1):
    amari[i]=int(s[l-i:])%2019

from collections import Counter
myc = Counter(amari)
val=list(myc.values())

ans=0
for i in range(len(val)):
    ans+=val[i]*(val[i]-1)//2
print(ans)

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

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

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

print(ans)

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

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

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
        
ngram=[]
for i in range(4,len(s)):
    for j in range(len(s)-i+1):
         ngram.append(s[j:j+i])

ans=0
for i in range(len(ngram)):
    if int(ngram[i])%2019==0:
        ans+=1
print(ans)

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

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

Buggy python submission (verdict: Runtime Error):
s=input()
        
ngram=[]
for i in range(4,len(s)):
    for j in range(len(s)-i+1):

ans=0
for i in range(len(ngram)):
    if int(ngram[i])%2019==0:
        ans+=1
print(ans)

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

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