Buggy python submission (verdict: Runtime Error):
from collections import deque
s = deque(input())
n = len(s)

temp = [0]*2019
t = 1
num = 0
for i in range(n):
    num += int(s.pop())*t % 2019
    temp[num] += 1
    t *= 10

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s = deque(input())
n = len(s)

temp = [0]*2019
t = 1
num = 0
for i in range(n):
    num += int(s.pop())*t
    temp[num % 2019] += 1
    t *= 10

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s = deque(input())
n = len(s)

temp = [0]*2019
num = 0
for i in range(n):
    num += int(s.pop())*pow(10,i)
    temp[num % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s = deque(input())
n = len(s)

temp = [0]*2019
num = 0
for i in range(n):
    num += int(s.pop())*10**(i)
    temp[num % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
s = [int(s) for s in S]
n = len(s)

temp = [0]*2019
num = 0
for i in range(n):
    num += s.pop()*10**(i)
    temp[num % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)

temp = [0]*2019
num = 0
for i in range(n):
    num += int(s.pop())*10**(i)
    temp[num % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)

temp = [0]*2019
num = 0
for i in range(n):
    num += int(s[n-i-1])*10**(i)
    temp[num % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)

temp = [0]*2019
num = 0
for i in range(n):
    num += int(s[n-i-1])*10**(i)
    temp[num % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))


Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
num = len(s)

dp = [0]*num
temp = [0]*2019
for i in range(num):
    temp[int(s[i:]) % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Runtime Error):
s = input()
num = len(s)

dp = [0]*num
temp = [0]*2019
for i in range(num):
    temp[i] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
s = input()
num = len(s)

dp = [0]*num
temp = [0]*2019
for i in range(num):
    temp[int(s[i:]) % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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

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

print(ans)


Fixed submission:
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

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