Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += (int(i)*a)%2019
  dp[total%2019] += 1
  a *= 10
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Fixed submission:
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += (int(i)*a)%2019
  dp[total%2019] += 1
  a *= 10
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Fixed submission:
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
dp = [0]*2019
dp[0] = 1
total = int(s)
k=1

for n in list(map(int, list(s))):
  dp[total%2019]+=1
  total -= n*(10**(len(s)-k))
  k+=1
  

count=0
for i in range(2019):
  m=dp[i]
  count += m*(m-1)/2
 
print(int(count))

Fixed submission:
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
dp = [0]*(len(s)+1)

for n in range(len(s)):
  dp[n+1] = (dp[n]+int(s[-n-1])*(10**n))%2019

count=0
for i in range(2019):
  m=dp.count(i)
  count += m*(m-1)/2
 
print(int(count))

Fixed submission:
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)

result = 0
  
for i in range(1,2019):
  c = len([x for x in range(n) if int(s[x:])%2019 == i])
  result += c*(c-1)/2

d = len([x for x in range(n) if int(s[x:])%2019 == 0])
result += d*(d+1)/2

print(int(result))

Fixed submission:
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)

modlist=[]

for i in range(n):
  modlist.append(int(s[i:])%2019)

modlist.append(0)
 
result = 0
  
for i in range(2019):
  c = modlist.count(i)
  result += c*(c-1)/2

print(int(result))

Fixed submission:
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)

modlist=[]

for i in range(n):
  modlist.append(int(s[i:])%2019)

modlist.append(0)
 
result = 0
  
for i in range(2019):
  c = modlist.count(i)
  if c<=1:
    result += 0
  else:
    result += c*(c-1)/2

print(int(result))

Fixed submission:
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Buggy python submission (verdict: Runtime Error):
s = str(input())
l = len(list(s))

if l<=3:
    print(0)
else:
    n = 0
    for i in range(4,l+1):
        for j in range(0,l-i+1):
            if int(s[j:j+i])%2019 == 0:
                n += 1
            else:
                n += 0

print(n)

Fixed submission:
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
l = len(list(s))

if l<=3:
    print(0)
else:
    n=0
    for i in range(0,l-3):
        for j in range(i+3,l):
            if int(s[i:j+1])%2019==0:
                n += 1
            else:
                n += 0
    print(n)

Fixed submission:
s = input()[::-1]

dp = [0]*2019
dp[0]=1
total = 0
a = 1

for i in list(s):
  total += int(i)*a
  total %= 2019
  dp[total] += 1
  a *= 10
  a %= 2019
count=0
  
for i in range(2019):
    count += dp[i]*(dp[i]-1)//2
 
print(count)