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

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*(k%2019))%2019
      k*=10
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

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

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

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

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

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

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*(10**(i-1))%2019)%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

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

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*10**(i-1))%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

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

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+(int(s[n-i])*10**(i-1))%2019)%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=int(i*(i-1)/2)
  print(res)

if __name__ == '__main__':
  main()


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

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

input = sys.stdin.readline
def main():

  s=input()
  s=s.strip("\n")
  n=len(s)
  res=0
  t=[0]*(n+1)
  
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+(int(s[n-i])*10**(i-1))%2019)%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=int(i*(i-1)/2)
  print(res)

if __name__ == '__main__':
  main()


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():

  s=input()
  s=s.strip("\n")
  n=len(s)
  res=0
  d={key:0 for key in range(2019)}
  t=[0]*(n+1)
  d[0]=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+(int(s[n-i])*10**(i-1))%2019)%2019
      d[t[n-i]]+=1
  for i in d.values():
      if i<2:
        continue
      res+=int(i*(i-1)/2)
  print(res)

if __name__ == '__main__':
  main()

Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

s=input()
s=s.strip("\n")
n=len(s)
res=0
d={key:0 for key in range(2019)}
t=[0]*(n+1)
d[0]=1
for i in range(1,n+1):
    t[n-i]=(t[n-i+1]+(int(s[n-i])*10**(i-1))%2019)%2019
    d[t[n-i]]+=1
for i in d.values():
    if i<2:
      continue
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

s=input()
s=s.strip("\n")
n=len(s)
res=0
d={}
t=[0]*(n+1)
d[0]=1
for i in range(1,n+1):
    t[n-i]=(t[n-i+1]+(int(s[n-i])*10**(i-1))%2019)%2019
    if t[n-i] not in d:
        d[t[n-i]]=1
    else:
        d[t[n-i]]+=1
for i in d.values():
    if i<2:
      continue
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from collections import deque

s=input()
s=s.strip("\n")
n=len(s)
res=0
d={}
t=[0]*(n+1)
d[0]=1
for i in range(1,n+1):
    t[n-i]=(t[n-i+1]+(int(s[n-i])*10**(i-1))%2019)%2019
    if t[n-i] not in d:
        d[t[n-i]]=1
    else:
        d[t[n-i]]+=1
for i in d.values():
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from collections import deque

s=input()
s=s.strip("\n")
n=len(s)
res=0
d={}
t=[0]*(n+1)
d[0]=1
for i in range(1,n+1):
    t[n-i]=(t[n-i+1]+(int(s[n-i])*10**(i-1))%2019)%2019
    if t[n-i] not in d:
        d[t[n-i]]=1
    else:
        d[t[n-i]]+=1
for i in d.values():
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from collections import deque

s=input()
l=len(s)
i=0
d=0
while i+3<=l-1:
    for j in range(i+3,l):
        if int(s[i:j+1])%2019!=0:
            continue
        else:
            d+=1
            i=i+1
            break
    else:
        i+=1
print(d)




Fixed submission:
from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

if __name__ == '__main__':
  main()