Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*(10**(n-i-1))
    x%=2019
    N[x%2019]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)

Fixed submission:
from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*pow(10,(n-i-1),2019)
    x%=2019
    N[x]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
N=[0]*2020
x=0
for i in reversed(range(n)):
    x+=int(s[i])*(10**(n-i-1))
    x%=2019
    N[x%2019]+=1
ans=N[0]
for j in N:
    ans+=j*(j-1)//2
print(ans)

Fixed submission:
from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*pow(10,(n-i-1),2019)
    x%=2019
    N[x]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
N=[0]*2020
x=0
for i in reversed(range(n)):
    x+=int(s[i])*(10**(n-i-1))
    N[x%2019]+=1
ans=0
ans+=N[0]
for j in N:
    ans+=j*(j-1)//2
print(ans)

Fixed submission:
from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*pow(10,(n-i-1),2019)
    x%=2019
    N[x]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
N=[0]*2020
x=0
for i in reversed(range(n)):
    x+=int(s[i])*(10**(n-i-1))
    N[x%2019]+=1
ans+=N[0]
for j in N:
    ans+=j*(j-1)//2
print(ans)

Fixed submission:
from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*pow(10,(n-i-1),2019)
    x%=2019
    N[x]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
N=[0]*2020
x=0
for i in reversed(range(n)):
    x+=int(s[i])*(10**(n-i-1))
    x%=2019
    N[x]+=1
ans=s.count('0')
ans+=N[0]
for j in N:
    ans+=j*(j-1)//2
print(ans)

Fixed submission:
from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*pow(10,(n-i-1),2019)
    x%=2019
    N[x]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
N=[0]*2020
x=0
for i in reversed(range(n)):
    x+=int(s[i])*(10**(n-i-1))
    N[x%2019]+=1
ans=s.count('0')
ans+=N[0]
for j in N:
    ans+=j*(j-1)//2
print(ans)

Fixed submission:
from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*pow(10,(n-i-1),2019)
    x%=2019
    N[x]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
N=[0]*2020
x=0
for i in reversed(range(n)):
    x+=int(s[i])*(10**(n-i-1))
    N[x%2019]+=1
ans=s.count('0')
ans+=N[0]
for j in N:
    ans+=j*(j-1)//2
print(ans)

Fixed submission:
from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*pow(10,(n-i-1),2019)
    x%=2019
    N[x]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
N=[0]*2020
for i in reversed(range(n)):
    N[int(s[i:])%2019]+=1
ans=s.count('0')
ans+=N[0]
for j in N:

    ans+=j*(j-1)//2
print(ans)

Fixed submission:
from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*pow(10,(n-i-1),2019)
    x%=2019
    N[x]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)