Buggy python submission (verdict: Runtime Error):
from math import pow
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)



Fixed submission:
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)

Buggy python submission (verdict: Runtime Error):
from math import pow
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i))) % MOD
    dp[temp] += 1

for item in dp:
    if item != 0:
        ans += item*(item-1)//2

print(ans)



Fixed submission:
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)

Buggy python submission (verdict: Runtime Error):
from math import pow
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*pow(10, i)) % MOD
    dp[temp] += 1

for item in dp:
    ans += item*(item-1)//2

print(ans)



Fixed submission:
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import log10
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0
for i in range(len(n)):
    temp = (temp+int(n[-i-1])*10**i) % MOD
    dp[temp] += 1

for item in dp:
    ans += item*(item-1)//2

print(ans)



Fixed submission:
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import log10
n = int(input())

ans = 0

for i in range(4, int(log10(n))+2):
    s = n % (10**i)
    while s >= 2019:
        if s % 2019 == 0:
            ans += 1
        s //= 10

print(ans)

Fixed submission:
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import log10
n = int(input())

ans = 0

for i in range(4, int(log10(n))+2):
    s = n % (10**i)
    while s >= 2019:
        if s % 2019 == 0:
            ans += 1
        s //= 10

print(ans)

Fixed submission:
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
len_S = len(S)
ans = 0

for i in range(0, len_S-4):
    for j in range(i+4, len_S+1):
        if int(S[i:j]) % 2019 == 0:
            ans += 1

print(ans)

Fixed submission:
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)