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

l = [0 for i in range(2019)]
n = len(s)
l[0] = 1
prev = 0
digit = 1
for c in s:
    t = (int(c) * digit + prev) % 2019
    l[t] += 1
    digit = digit * 10
    prev = t

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

Fixed submission:
s = input()
s = s[::-1]

l = [0 for i in range(2019)]
n = len(s)
l[0] = 1
prev = 0
digit = 1
for c in s:
    t = (int(c) * digit + prev) % 2019
    l[t] += 1
    digit = (digit * 10) % 2019
    prev = t

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(map(int,list(input())))

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

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

Fixed submission:
s = input()
s = s[::-1]

l = [0 for i in range(2019)]
n = len(s)
l[0] = 1
prev = 0
digit = 1
for c in s:
    t = (int(c) * digit + prev) % 2019
    l[t] += 1
    digit = (digit * 10) % 2019
    prev = t

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

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

l = [0 for i in range(2019)]
n = len(s)
s_int = int(s)

for i in range(n+1):
    tmp = s_int % (10**i) % 2019 
    l[tmp] += 1

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

Fixed submission:
s = input()
s = s[::-1]

l = [0 for i in range(2019)]
n = len(s)
l[0] = 1
prev = 0
digit = 1
for c in s:
    t = (int(c) * digit + prev) % 2019
    l[t] += 1
    digit = (digit * 10) % 2019
    prev = t

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

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

l = [0 for i in range(2019)]
n = len(s)
s_int = int(s)

for i in range(n+1):
    tmp = s_int % (10**i) % 2019 
    l[tmp] += 1

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

Fixed submission:
s = input()
s = s[::-1]

l = [0 for i in range(2019)]
n = len(s)
l[0] = 1
prev = 0
digit = 1
for c in s:
    t = (int(c) * digit + prev) % 2019
    l[t] += 1
    digit = (digit * 10) % 2019
    prev = t

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

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

l = [0 for i in range(2019)]
n = len(s)
l[0] = 1

for i in range(n):
    tmp = int(s[i:]) % 2019 
    l[tmp] += 1

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

Fixed submission:
s = input()
s = s[::-1]

l = [0 for i in range(2019)]
n = len(s)
l[0] = 1
prev = 0
digit = 1
for c in s:
    t = (int(c) * digit + prev) % 2019
    l[t] += 1
    digit = (digit * 10) % 2019
    prev = t

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

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

l = []
n = len(s)

for i in range(n):
    tmp = int(s[i:]) % 2019
    l.append(tmp)
l.append(0)
res = 0
for i in range(2018):
    count = l.count(i)
    res += count * (count-1) // 2

print(res)

Fixed submission:
s = input()
s = s[::-1]

l = [0 for i in range(2019)]
n = len(s)
l[0] = 1
prev = 0
digit = 1
for c in s:
    t = (int(c) * digit + prev) % 2019
    l[t] += 1
    digit = (digit * 10) % 2019
    prev = t

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)