Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i))%2019
  mod[s]+=1
answer=0
for i in mod:
  answer+=i*(i-1)//2
print(answer)

Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))


Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=s+int(string[-1-i])*pow(10,i)
  mod[s%2019]+=1
print(sum([i*(i-1)//2 for i in mod]))

Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[1]+[0]*2018
while length > 0:
  mod[int(string[length-1:])%2019]+=1
  length-=1
print(sum([i*(i-1)//2 for i in mod]))

Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[1]+[0]*2018
while length > 0:
  mod[int(string[length-1:])%2019]+=1
  length-=1
print(int(sum([(i*(i-1))/2 for i in mod if i > 1])))


Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input() #入力文字列
length=len(string) #入力文字列の長さ
mod=[1]+[0]*2018 #出てきたmod値を加算するようの箱
while length > 0: #後ろから頭まで
  s = int(string[length-1:]) 
  mod[s%2019]+=1
  length-=1
answer=0
for i in mod:
  answer+=int(i*(i-1)/2)
print(answer)


Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[1]+[0]*2018
while length > 0:
  mod[int(string[length-1:])%2019]+=1
  length-=1
print(int(sum([(i*(i-1))/2 for i in mod])))


Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[0]*2019
mod[0]=1
while length > 0:
  mod[int(string[length-1:])%2019]+=1
  length-=1
print(int(sum([(i*(i-1))/2 for i in mod])))


Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[0]*2019
mod[0]=1
d=1
s=0
while length > 0:
  s+=int(string[length-1])*d
  mod[s%2019]+=1
  d*=10
  length-=1
print(int(sum([(i*(i-1))/2 for i in mod])))

Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[0]*2019
while length > 0:
  mod[int(string[length-1:])%2019]+=1
  length-=1
print(int(sum([(i*(i-1))/2 for i in mod]))+mod[0])


Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[0]*2019
s=''
while length > 0:
  s=string[length-1]+s
  mod[int(s)%2019]+=1
  length-=1
print(int(sum([(i*(i-1))/2 for i in mod]))+mod[0])

Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
length=len(string)
mod=[0]*2019
while length > 0:
  mod[int(string[length-1:])%2019]+=1
  length-=1
print(int(sum([(i*(i-1))/2 for i in mod]))+mod[0])

Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
string=input()
count=0
times=1
length=4
while len(string) > 3:
  target=int(string[:length])
  if target % 2019 == 0:
    count+=1
  length+=1
  if length == 2000000 or len(string) < length:
    length=4
    string=string[1:]
  times+=1
print(count)


Fixed submission:
string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))