Buggy python submission (verdict: Time Limit Exceeded):
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
#  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)


Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
s.reverse()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in s:
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)


Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
s.reverse()
MOD = 2019
b = {}
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in s:
  c = (c_+int(i)*t)%MOD
  b[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
s = list(str(input()))
b = {}
b[0] = 1
c_ = 0
ans = 0
s.reverse()
for i in s:
  c = (c_+int(i))%2019
  if c in b:
    ans += b[c]
    b[c] += 1
    ans += 
  else:
    b[c] = 1
  c_ = c
print(ans)

Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))
b = {}
b[0] = 1
c_ = 0
s.reverse()
for num,i in enumerate(s):
  c = (c_+int(i)*10**num)%2019
  if c in b:
    b[c] += 1
  else:
    b[c] = 1
  c_ = c
ans = 0
for i in b.values():
  ans += i*(i-1)//2
print(ans)

Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))
b = {}
b[0] = 1
c_ = 0
s.reverse()
for num,i in enumerate(s):
  c = (c_+int(i)*10**num)%2019
  if c in b:
    b[c] += 1
  else:
    b[c] = 1
  c_ = c
ans = 0
for i in b.values():
  ans += i*(i-1)//2
print(ans)


Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
s = list(str(input()))
b = {}
b[0] = 1
c_ = 0
s = s.reverse()
for i in s:
  c = (c_+int(i)*10**num)%2019
  if c in b:
    b[c] += 1
  else:
    b[c] = 1
  c_ = c
ans = 0
for i in b.values():
  ans += i*(i-1)//2
print(ans)

Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()) )
b = {}
b[0] = 1
c_ = 0
for num,i in enumerate(reversed(s)):
  c = c_+int(i)*10**num
  if c%2019 in b: 
    b[c%2019] += 1
  else:
    b[c%2019] = 1
  c_ = c
ans = 0
for i in b.values():
  ans += i*(i-1)//2
print(ans)

Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()) )
a = [0]
b = {}
b[0] = 1
for num,i in enumerate(reversed(s)):
  a.append(a[num]+int(i)*10**num)
  if (a[num+1])%2019 in b: 
    b[(a[num+1])%2019] += 1
  else:
    b[(a[num+1])%2019] = 1
ans = 0
for i in b.values():
  ans += i*(i-1)//2
print(ans)

Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))
a = [0]
b = [0]*2019
b[0] += 1
for num,i in enumerate(reversed(s)):
  a.append(a[num]+int(i)*10**num)
  b[(a[num+1])%2019] += 1
ans = 0
for i in b:
  ans += i*(i-1)//2
print(ans)


Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))
a = [0]
b = [0]*2019
b[0] += 1
for num,i in enumerate(reversed(s)):
  a.append(a[num]+int(i)*10**num)
  b[(a[num+1])%2019] += 1
ans = 0
for i in b:
  ans += i*(i-1)//2
print(ans)

Fixed submission:
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)