Buggy python submission (verdict: Runtime Error):
s = input()[::-1]
p = 0
dp = [0] * 2019
dp[0] = 1
for i in s:
    p = (p + (int(s) * (10 ** (i)))) % 2019
    dp[p] += 1
ans = 0
for i in dp:
    ans += i * (i - 1) // 2
print(ans)

Fixed submission:
s = input()[::-1]
p = 0
dp = [0] * 2019
dp[0] = 1
d = 1
for i in s:    
    p = (int(i) * d + (p)) % 2019
    dp[p] += 1
    d *= 10
    d = d % 2019
ans = 0
for i in dp:
    ans += i * (i - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
p = 0
dp = [0] * 2019
dp[0] = 1
for i in range(len(s)):
    p = (p + (int(s[-1 - i]) * (10 ** (i)))) % 2019
    dp[p] += 1
ans = 0
for i in dp:
    ans += i * (i - 1) / 2
print(int(ans))

Fixed submission:
s = input()[::-1]
p = 0
dp = [0] * 2019
dp[0] = 1
d = 1
for i in s:    
    p = (int(i) * d + (p)) % 2019
    dp[p] += 1
    d *= 10
    d = d % 2019
ans = 0
for i in dp:
    ans += i * (i - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = input()
p = 0
dp = [0]
for i in range(len(s)):
    p = (p + (int(s[-1 - i]) * (10 ** (i)))) % 2019
    dp.append(p % 2019)
t = collections.Counter(dp)
ans = 0
for i in t.values():
    ans += i * (i - 1) / 2
print(int(ans))

Fixed submission:
s = input()[::-1]
p = 0
dp = [0] * 2019
dp[0] = 1
d = 1
for i in s:    
    p = (int(i) * d + (p)) % 2019
    dp[p] += 1
    d *= 10
    d = d % 2019
ans = 0
for i in dp:
    ans += i * (i - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = input()
p = 0
dp = [0]
for i in range(len(s)):
    p = (p + (int(s[-1 - i]) * (10 ** (i)))) % 2019
    dp.append(p % 2019)
t = collections.Counter(dp)
ans = 0
for i in t.values():
    ans += i * (i - 1) / 2
print(int(ans))

Fixed submission:
s = input()[::-1]
p = 0
dp = [0] * 2019
dp[0] = 1
d = 1
for i in s:    
    p = (int(i) * d + (p)) % 2019
    dp[p] += 1
    d *= 10
    d = d % 2019
ans = 0
for i in dp:
    ans += i * (i - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = input()
p = 0
dp = [0]
for i in range(len(s)):
    p = p + (int(s[-1 - i]) * (10 ** (i)))
    dp.append(p % 2019)
t = collections.Counter(dp)
ans = 0
for i in t.values():
    ans += i * (i - 1) / 2
print(int(ans))

Fixed submission:
s = input()[::-1]
p = 0
dp = [0] * 2019
dp[0] = 1
d = 1
for i in s:    
    p = (int(i) * d + (p)) % 2019
    dp[p] += 1
    d *= 10
    d = d % 2019
ans = 0
for i in dp:
    ans += i * (i - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
for i in range(len(s) - 4):
    for j in range(i + 5, len(s) + 1):
        if int(s[i:j]) % 2019 == 0:
            ans += 1
print(ans)


Fixed submission:
s = input()[::-1]
p = 0
dp = [0] * 2019
dp[0] = 1
d = 1
for i in s:    
    p = (int(i) * d + (p)) % 2019
    dp[p] += 1
    d *= 10
    d = d % 2019
ans = 0
for i in dp:
    ans += i * (i - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
for i in range(len(s) - 4):
    for j in range(i + 5, len(s) + 1):
        if int(s[i:j]) % 2019 == 0:
            ans += 1
print(ans)

Fixed submission:
s = input()[::-1]
p = 0
dp = [0] * 2019
dp[0] = 1
d = 1
for i in s:    
    p = (int(i) * d + (p)) % 2019
    dp[p] += 1
    d *= 10
    d = d % 2019
ans = 0
for i in dp:
    ans += i * (i - 1) // 2
print(ans)