Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
mod = [0]*2019
t = s[len(s)-1]
n = 1
for i in range(len(s)-1,-1,-1):
#     mod.append(int(s[i:])%2019)
    mod[int(t)%2019] += 1
    t = int(t) + (10**(len(s)-i))*int(s[i-1])
#     t = int(t) + n*10*int(s[i-1])
#     n = n*10%2019
for i in range(0,2019):
    ans += mod[i]*(mod[i]-1)/2
ans += mod[0]
print(int(ans))

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

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
mod = []
t = s[len(s)-1]
n = 1
for i in range(len(s)-1,-1,-1):
#     mod.append(int(s[i:])%2019)
    mod.append(int(t)%2019)
#     t = int(t) + (10**(len(s)-i-1))*int(s[i])
    t = int(t) + n*10*int(s[i-1])
    n = n*10%2019
for i in range(0,2019):
    ans += mod.count(i)*(mod.count(i)-1)/2
ans += mod.count(0)
print(int(ans))

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

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
mod = []
t = s[len(s)-1]
for i in range(len(s)-1,-1,-1):
#     mod.append(int(s[i:])%2019)
    mod.append(int(t)%2019)
#     t = int(t) + (10**(len(s)-i-1))*int(s[i])
    t = int(t) + 10**(len(s)-i)*int(s[i-1])
for i in range(1,2019):
    ans += mod.count(i)*(mod.count(i)-1)/2
ans += mod.count(0)
print(int(ans))

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

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

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

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

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

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

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

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

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

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

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