Buggy python submission (verdict: Time Limit Exceeded):
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   d=0
   for i,j in enumerate(reversed(tmp)):
      d+=int(j)%2019*10**(i)%2019
      cnt[d%2019]+=1
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   d=0
   for i,j in enumerate(reversed(tmp)):
      d+=int(j)*10**(i)
      cnt[d%2019]+=1
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   d=0
   for i,j in enumerate(reversed(tmp)):
      d+=int(j)*10**(i)
      cnt[d%2019]+=1
   cnt=collections.Counter(cnt).items()
   for i,j in cnt:
      if i > 1:
         ans+=i*(i-1)//2*j
   print(ans)
if __name__ == "__main__":
    main()

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   cnt=[0]*2019
   cnt[0]+=1
   for i in reversed(range(len(tmp))):
      cnt[int(tmp[i:])%2019] += 1
   import collections
   cnt=collections.Counter(cnt).items()
   ans=0
   for i,j in cnt:
      if i > 1:
         ans+=i*(i-1)//2*j
   print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import collections
tmp=sys.stdin.readline()
def main():
   cnt=[0]*2019
   cnt[0]+=1
   for i in reversed(range(len(tmp))):
      cnt[int(tmp[i:])%2019] += 1
   cnt=collections.Counter(cnt).items()
   ans=0
   for i,j in cnt:
      if i > 1:
         ans+=i*(i-1)//2*j
   print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
tmp=sys.stdin.readline()
def main():
   cnt=[0]*2019
   cnt[0]+=1
   for i in reversed(range(len(tmp))):
      cnt[int(tmp[i:])%2019] += 1
   import collections
   cnt=collections.Counter(cnt).items()
   ans=0
   for i,j in cnt:
      if i > 1:
         ans+=i*(i-1)//2*j
   print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
tmp=sys.stdin.readline()
def main():
   cnt=[0]*2019
   cnt[0]+=1
   for i in reversed(range(len(tmp))):
      cnt[int(tmp[i:])%2019] += 1
   import collections
   cnt=collections.Counter(cnt).items()
   ans=0
   for i,j in cnt:
      if i > 1:
         ans+=i*(i-1)//2*j
   print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
tmp=input()
l=[int(tmp[i:]) for i in reversed(range(len(tmp)))]
cnt=[0]*2019
cnt[0] = 1
for i in l:
   cnt[i%2019] += 1
import collections
cnt=collections.Counter(cnt).items()
ans=0
for i,j in cnt:
   if i > 1:
      ans+=i*(i-1)//2*j
print(ans)

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
tmp=input()
l=[int(tmp[i:]) for i in reversed(range(len(tmp)))]
cnt=[0]*2019
cnt[0] = 1
for i in l:
   cnt[i%2019] += 1
import collections
ans=0
for i in cnt:
   if i > 1:
      ans+=i*(i-1)//2
print(ans)

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()