Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
#import time
#from sys import stdin

#start = time.time()#計測始
def main():
  s = str(input())
  ss = reversed(s)
  n=len(s)
  mlist=deque([0])
  slist=""
  for sss in ss:
    slist = sss + slist
    m = int(slist)%2019
    mlist.append(m)

  ll=len(mlist)
  l=len(set(mlist))

  print(ll-l)
  
main()

Fixed submission:
import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

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

#start = time.time()#計測始
s = str(input())
#end = time.time()#計測終
n=len(s)
span=1
mlist=deque([0])
slist=""

while span<n+1:
  slist = s[n-span] + slist
  m = int(slist)%2019
  mlist.append(m)
  span+=1
  

ll=len(mlist)
l=len(set(mlist))
#print(set(mlist))

print(ll-l)

#print(f"{end-start}sec.")#計測出力

Fixed submission:
import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import time
start = time.time()#計測始
 
s = str(input())
n=len(s)
#span :int=1
mlist=deque("0")
slist :str=""
  
for span in range(n):
  slist = str(s[n-span-1]) + slist
  #print(str(slist))
  m = int(slist)%2019
  mlist.append(str(m))
  #span+=1
  
ll=len(mlist)
l=len(set(mlist))
print(ll-l)
end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

Fixed submission:
import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import time
start = time.time()#計測始

s = str(input())

n=len(s)
i :int=0
ss=deque()
while i<n:
  ss.insert(0,str(s[i]))
  i+=1
  #print(ss)
span :int=1
mlist=deque("0")
slist :str=""

for sss in ss:
  slist = str(sss) + slist
  m = int(slist)%2019
  mlist.append(str(m))
  #print(str(mlist))
  #span+=1

ll=len(mlist)
l=len(set(mlist))
print(ll-l)
end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

Fixed submission:
import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
#import time
#start = time.time()#計測始

s = str(input())
n=len(s)
span :int=1
mlist=deque("0")
slist :str=""

while span<int(n)+1:
  slist = str(s[n-span]) + slist
  #print(str(slist))
  m = int(slist)%2019
  mlist.append(str(m))
  span+=1

ll=len(mlist)
l=len(set(mlist))
print(ll-l)
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

Fixed submission:
import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

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

s = str(input())
n=len(s)
left :int=1
mlist=deque("0")
while left<int(n)+1:
  m = int(s[n-left:n])%2019
  mlist.append(str(m))
  left+=1

ll=len(mlist)
l=len(set(mlist))
print(ll-l)

Fixed submission:
import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
n=len(s)
left :int=1
mlist=[0]
while left<int(n)+1:
  m = int(s[n-left:n])%2019
  mlist.append(m)
  left+=1

ll=len(mlist)
l=len(set(mlist))
print(int(ll-l))

Fixed submission:
import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
n=len(s)
left :int=1
mlist=[0]
while left<int(n)+1:
  m = int(s[n-left:n])%2019
  mlist.append(m)
  left+=1

sorted_mlist = sorted(mlist)

i :int=0
count :int=0
while i<len(sorted_mlist):
  if sorted_mlist[i-1]==sorted_mlist[i]:
    count+=1
  i+=1

print(count)

Fixed submission:
import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力

Buggy python submission (verdict: Time Limit Exceeded):
N = str(input())
l=len(N)
count :int=0
ll=l
i :int=0
while i<int(ll)-3:
  span :int=4
  while span<int(l)+1:
    if int(N[i:i+span])%2019==0:
      count+=1
    span+=1
  i+=1
  l-=1

print(count)

Fixed submission:
import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力