Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(10**(len(s)-i))%mod
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)

Fixed submission:
s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(pow(10,(len(s)-i),mod))
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input()[::-1])
mod = 2019
tot = [0]
for i in range(len(s)):
    tot.append((tot[i] + (int(s[i])*(10**i))%mod)%mod)
dp = [0 for _ in range(2020)]
ans = 0
for t in tot:
    ans += dp[t]
    dp[t]+= 1
print(ans)

Fixed submission:
s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(pow(10,(len(s)-i),mod))
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input()[::-1])
mod = 2019
tot = [0]
for i in range(len(s)):
    tot.append((tot[i] + (int(s[i])*(10**i))%mod)%mod)
cnt = {}
looked = []
ans = 0
for i in range(len(s)+1):
    if tot[i] in looked:
        ans += cnt[tot[i]]
        cnt[tot[i]] += 1
    else:
        cnt[tot[i]] = 1
        looked.append(tot[i])
print(ans)


Fixed submission:
s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(pow(10,(len(s)-i),mod))
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input()[::-1])
mod = 2019
tot = [0]
for i in range(len(s)):
    tot.append((tot[i] + (int(s[i])*(10**i))%mod)%mod)
cnt = {}
looked = []
ans = 0
for i in range(len(s)+1):
    if tot[i] in looked:
        ans += cnt[tot[i]]
        cnt[tot[i]] += 1
    else:
        cnt[tot[i]] = 1
        looked.append(tot[i])
print(ans)


Fixed submission:
s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(pow(10,(len(s)-i),mod))
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)

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

Fixed submission:
s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(pow(10,(len(s)-i),mod))
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)

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

Fixed submission:
s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(pow(10,(len(s)-i),mod))
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
a = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        a.append(s[i:j])

l = []
x = 2019
while x<=200000:
    l.append(x)
    x += 2019
ans = 0

for x in l:
    ans += a.count(str(x))
print(ans)

Fixed submission:
s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(pow(10,(len(s)-i),mod))
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)