Buggy python submission (verdict: Time Limit Exceeded):
a = list(input())
a.reverse()
add = 0
ans = [1] + [0] * 2018
ans_int = 0

for i in range(len(a)):
    add = (add + int(a[i]) * 10 ** i) %2019
    if ans[add] == 1:
        ans_int += 1
        continue
    else:
        ans[add] = 1


print(ans_int)

Fixed submission:
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))

Buggy python submission (verdict: Time Limit Exceeded):
a = list(input())
a.reverse()
add = 0
ans = [1] + [0] * 2018
ans_int = 0

for i in range(len(a)):
    add = (add + int(a[i]) * 10 ** i) %2019
    if ans[add] == 1:
        ans_int += 1
        continue
    else:
        ans[add] = 1


print(ans_int)

Fixed submission:
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))

Buggy python submission (verdict: Time Limit Exceeded):
a = list(input())
a.reverse()
s = [0]
ans = [1] + [0] * 2018
ans_int = 0

for i in range(len(a)):
    add = s[i] + int(a[i]) * 10 ** i
    add = add % 2019
    ans[add] += 1
    s.append(add)
    if ans[add] > 1:
        ans_int += 1


print(ans_int)

Fixed submission:
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))

Buggy python submission (verdict: Time Limit Exceeded):
a = list(input())
a.reverse()
s = [0]
ans = [1] + [0] * 2018
ans_int = 0

for i in range(len(a)):
    add = s[i] + int(a[i]) * 10 ** i
    add = add % 2019
    ans[add] += 1
    s.append(add)
    if ans[add] > 1:
        ans_int += 1


print(ans_int)

Fixed submission:
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))

Buggy python submission (verdict: Time Limit Exceeded):
a = list(input())
a = [int(s) for s in a]
a = a[::-1]
s = [0]
ans = [1] + [0] * 2018
ans_int = 0

for i in range(len(a)):
    add = s[i] + a[i] * 10 ** i
    add = add % 2019
    ans[add] += 1
    s.append(add)
    if ans[add] > 1:
        ans_int += 1


print(ans_int)

Fixed submission:
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))

Buggy python submission (verdict: Time Limit Exceeded):
a = list(input())
a = [int(s) for s in a]
a = a[::-1]
s = [0]
ans = [1] + [0] * 2018

for i in range(len(a)):
    add = s[i] + a[i] * 10 ** i
    add = add % 2019
    ans[add] += 1
    s.append(add)

ans_int = 0

for i in range(2019):
    if ans[i] > 1:
        ans_int += (ans[i] - 1)

print(ans_int)

Fixed submission:
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))

Buggy python submission (verdict: Time Limit Exceeded):
a = list(input())
a = a[::-1]
s = [0]

for i in range(len(a)):
    add = s[i] + int(a[i]) * 10**i
    add = add % 2019
    s.append(add)

ans = 0
for i in range(len(s)-3):
    for j in range(i+1,len(s)):
        if s[i] == s[j]:
            ans += 1

print(ans)


Fixed submission:
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))

Buggy python submission (verdict: Time Limit Exceeded):
a = list(input())
a = a[::-1]
s = [0]

for i in range(len(a)):
    add = s[i] + int(a[i]) * 10**i
    add = add % 2019
    s.append(add)

ans = 0
for i in range(len(s)-3):
    for j in range(i+1,len(s)):
        if s[i] == s[j]:
            ans += 1

print(ans)


Fixed submission:
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))

Buggy python submission (verdict: Time Limit Exceeded):
a = list(input())
a = [int(s) for s in a]
a = a[::-1]
s = [0]

for i in range(len(a)):
    add = s[i] + a[i] * 10**i
    add = add % 2019
    s.append(add)

#print(s)
ans = 0

for i in range(len(s)):
    for j in range(i+1,len(s)):
        if s[i] == s[j]:
            ans += 1

print(ans)

Fixed submission:
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))