Buggy python submission (verdict: Runtime Error):
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
        
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += factorial(w) / (factorial(2)*factorial(w - 2))
    
print(int(cnt))

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

Buggy python submission (verdict: Runtime Error):
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += factorial(w) / (factorial(2)*factorial(w - 2))
    
print(int(cnt))

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

s = input()
mod = 2019
array = [0]*mod

for i in range(len(s)):
    array[int(s[i:len(s)]) % mod] += 1
    
array[0] += 1
    
cnt = 0
for i in range(mod):
    if array[i] > 1:
        cnt += factorial(array[i]) / (factorial(2)*factorial(array[i] - 2))
        
print(int(cnt))

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

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

for i in range(len(s)):
    array[i] = int(s[i:len(s)]) % mod
    
array[len(s)] = 0

cnt = 0

for i in range(0, len(array)-1):
    for j in range(i+1, len(array)):
        if array[i] == array[j]:
            cnt += 1
            
print(cnt)

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

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

for i in range(len(s)):
    array[i] = int(s[i:len(s)]) % mod
    
array[len(s)] = 0

cnt = 0

for i in range(0, len(array)-1):
    for j in range(i+1, len(array)):
        if array[i] == array[j]:
            cnt += 1
            
print(cnt)

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

s = input()
array = [0]*(len(s)+1)
mod = 2019

for i in range(len(s)):
    array[i] = int(s[i:len(s)]) % mod
    
array[len(s)] = 0

array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w > 2:
            cnt += factorial(w) / (factorial(2)*factorial(w - 2))
            w = 1
        elif w == 2:
            cnt += 1
            w = 1
            
if w != 1:
    cnt += factorial(w) / (factorial(2)*factorial(w - 2))
    
print(int(cnt))

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

s = input()
array = [0]*(len(s)+1)
mod = 2019

for i in range(len(s)):
    array[i] = int(s[i:len(s)]) % mod
    
array[len(s)] = 0

array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w != 1:
            cnt += factorial(w) / (factorial(2)*factorial(w - 2))
            w = 1
            
if w != 1:
    cnt += factorial(w) / (factorial(2)*factorial(w - 2))
    
print(int(cnt))

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

s = input()
array = [0]*(len(s)+1)
mod = 2019

for i in range(len(s)):
    array[i] = int(s[i:len(s)]) % mod
    
array[len(s)] = 0

array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w != 1:
            cnt += factorial(w) / (factorial(2)*factorial(w - 2))
            w = 1
            
if w != 1:
    cnt += factorial(w) / (factorial(2)*factorial(w - 2))
    
print(int(cnt))

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

Buggy python submission (verdict: Runtime Error):
s = input()

dp = [[0]*2019 for i in range(len(s))]

mod = 2019

for l in range(0, len(s)-1):
    dp[l][int(s[l])] += 1
    for m in range(0, mod):
        if dp[l][m] != 0:
            num = int(s[l+1])
            dp[l+1][(10*m+num)%mod] += dp[l][m]
            
cnt = 0
for l in range(0, len(s)):
    if dp[l][0] != 0:
        cnt += dp[l][0]
        
print(cnt)

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

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

dp = [[0]*2019 for i in range(len(s))]

mod = 2019

for l in range(0, len(s)-1):
    dp[l][int(s[l])] += 1
    for m in range(0, mod):
        if dp[l][m] != 0:
            num = int(s[l+1])
            dp[l+1][(10*m+num)%mod] += dp[l][m]
            
cnt = 0
for l in range(0, len(s)):
    if dp[l][0] != 0:
        cnt += dp[l][0]
        
print(cnt)

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))

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

dp = [[0]*2019 for i in range(len(s))]

mod = 2019

for l in range(0, len(s)-1):
    dp[l][int(s[l])] += 1
    for m in range(0, mod):
        if dp[l][m] != 0:
            num = int(s[l+1])
            dp[l+1][(10*m+num)%mod] += dp[l][m]
            
cnt = 0
for l in range(0, len(s)):
    if dp[l][0] != 0:
        cnt += dp[l][0]
        
print(cnt)

Fixed submission:
s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))