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

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10


ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

Fixed submission:
from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

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

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10

cou=dict(Counter(lst))
ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

Fixed submission:
from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

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

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10

cou=dict(Counter(lst))
for x in cou.values():
    ans+=x*(x-1)/2
print(int(ans))

Fixed submission:
from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

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

s=input()[::-1]
ans=0
lst=[]
num=0
for j in range(len(s)):
    
    lst.append(num%2019)
    num+=int(s[j])*10**(j)
lst.append(num%2019)

cou=dict(Counter(lst))
for x in cou.values():
    ans+=x*(x-1)/2
print(int(ans))

Fixed submission:
from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s=list(input())
lst=[]  #sのリバース
lst2=[] #累積和を2019で割ったあまり

num=0
for j in reversed(range(0,len(s))):
    
    lst2.append(num%2019)
    num+=int(s[j])*10**(len(s)-j-1)
lst2.append(num%2019)

ans=0
cou=dict(Counter(lst2))
for x in cou.values():
    ans+=x*(x-1)/2
print(int(ans))


Fixed submission:
from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s=list(input())
lst=[]  #sのリバース
lst2=[] #累積和を2019で割ったあまり
for i in range(len(s)):
    lst.append(s.pop())

num=0
for j in range(len(lst)):
    lst2.append(num%2019)
    num+=int(lst[j])*10**(j)
lst2.append(num%2019)
ans=0
cou=dict(Counter(lst2))
for x in cou.values():
    ans+=x*(x-1)/2
print(int(ans))


Fixed submission:
from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s=list(input())
lst=[]  #sのリバース
lst2=[] #累積和を2019で割ったあまり
for i in range(len(s)):
    lst.append(s.pop())

num=0
for j in range(len(lst)):
    lst2.append(num)
    num+=int(lst[j])*10**(j)
lst2.append(num)
for k in range(len(lst2)):
    lst2[k]=lst2[k]%2019
ans=0
cou=dict(Counter(lst2))
for x in cou.values():
    ans+=x*(x-1)/2
print(int(ans))

Fixed submission:
from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

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

Fixed submission:
from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)