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

t, a = 0, 1
mod = [0]*2019
mod[0] = 1
s = s[::-1]
n = len(s)
for i in range(n):
    t = (t + int(s[i]) * a) % 2019
    a *= 10
    mod[t] += 1
ans = 0

for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

Fixed submission:
s = input()
#s = '9' * 200000

mod = [1] + [0]*2018
t = 0
a = 1
n = len(s)
s = s[::-1]
for i in range(n):
    t = (t + int(s[i])*a) % 2019
    a = a * 10 % 2019
    mod[t] += 1
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

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

mod = [1] + [0]*2018
t = 0
a = 0
n = len(s)
s = reversed(s)
for i in range(n):
    t += int(s[i]) * (10 ** a)
    a += 1
    mod[t%2019] += 1
    print(t,t%2019)
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

Fixed submission:
s = input()
#s = '9' * 200000

mod = [1] + [0]*2018
t = 0
a = 1
n = len(s)
s = s[::-1]
for i in range(n):
    t = (t + int(s[i])*a) % 2019
    a = a * 10 % 2019
    mod[t] += 1
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

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

mod = [1] + [0]*2018
t = 0
a = 0
n = len(s)
s = s[::-1]
for i in range(n):
    t += int(s[i]) * (10 ** a)
    a += 1
    mod[t%2019] += 1
    #print(t,t%2019)
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

Fixed submission:
s = input()
#s = '9' * 200000

mod = [1] + [0]*2018
t = 0
a = 1
n = len(s)
s = s[::-1]
for i in range(n):
    t = (t + int(s[i])*a) % 2019
    a = a * 10 % 2019
    mod[t] += 1
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

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

mod = [1] + [0]*2018
t = 0
a = 0
n = len(s)
s = s[::-1]
for i in range(n):
    t += int(s[i]) * (10 ** a)
    a += 1
    mod[t%2019] += 1
    #print(t,t%2019)
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

Fixed submission:
s = input()
#s = '9' * 200000

mod = [1] + [0]*2018
t = 0
a = 1
n = len(s)
s = s[::-1]
for i in range(n):
    t = (t + int(s[i])*a) % 2019
    a = a * 10 % 2019
    mod[t] += 1
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

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

n = len(s)
ans = 0
flag = 0
for i in range(n):
    flag = 0
    for j in range(i+1,n):
        if flag != 0:
            flag -= 1
            continue
        if int(s[i:j+1]) % 2019 == 0:
            ans += 1
            flag = 3
print(ans)


Fixed submission:
s = input()
#s = '9' * 200000

mod = [1] + [0]*2018
t = 0
a = 1
n = len(s)
s = s[::-1]
for i in range(n):
    t = (t + int(s[i])*a) % 2019
    a = a * 10 % 2019
    mod[t] += 1
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

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

n = len(s)
ans = 0
flag = 0
for i in range(n):
    flag = 0
    for j in range(i+1,n):
        if flag != 0:
            flag -= 1
            continue
        if int(s[i:j+1]) % 2019 == 0:
            ans += 1
            flag = 3
print(ans)

Fixed submission:
s = input()
#s = '9' * 200000

mod = [1] + [0]*2018
t = 0
a = 1
n = len(s)
s = s[::-1]
for i in range(n):
    t = (t + int(s[i])*a) % 2019
    a = a * 10 % 2019
    mod[t] += 1
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

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

n = len(s)
ans = 0
flag = 0
for i in range(n):
    flag = 0
    for j in range(i+1,n):
        if flag != 0:
            flag -= 1
            continue
        if int(s[i:j+1]) % 2019 == 0:
            ans += 1
            flag = 3
print(ans)

Fixed submission:
s = input()
#s = '9' * 200000

mod = [1] + [0]*2018
t = 0
a = 1
n = len(s)
s = s[::-1]
for i in range(n):
    t = (t + int(s[i])*a) % 2019
    a = a * 10 % 2019
    mod[t] += 1
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)