Buggy python submission (verdict: Runtime Error):
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values:
    cnt += int(d*(d-1)/2)
print(cnt)

Fixed submission:
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values():
    cnt += int(d*(d-1)/2)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*(10**i)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res:
    cnt += int(res[d]*(res[d]-1)/2)
print(cnt)

Fixed submission:
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values():
    cnt += int(d*(d-1)/2)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
res = dict()
res[0] = 1

T = 0
for i in range(n):
    T += int(s[-1-i])*(10**i)%2019
    T = T%2019
    if res.get(T) == None:
        res[T] = 1
    else:
        res[T] += 1
cnt = 0
for d in res:
    if not res[d] == 1:
        cnt += int(res[d]*(res[d]-1)/2)
print(cnt)

Fixed submission:
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values():
    cnt += int(d*(d-1)/2)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
res = dict()
res[0] = 1

for i in range(n):
    T = int(s[-i-1:])%2019
    if res.get(T) == None:
        res[T] = 1
    else:
        res[T] += 1
cnt = 0
for d in res:
    if not res[d] == 1:
        cnt += int(res[d]*(res[d]-1)/2)
print(cnt)

Fixed submission:
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values():
    cnt += int(d*(d-1)/2)
print(cnt)

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

skip_num = []

if n < 4:
    print('0')
else:
    cnt = 0
    for j in range(n-3):
        if j in skip_num:
            continue

        i = 0
        skip_add = 0
        while i < n-3-j:
            step = int(s[n-4-i-j:n-j])
            if step % 2019 == 0:
                skip_num.append(j+i+4)
                cnt += 1+skip_add
                skip_add += 1
                i += 3
            i += 1
    print(cnt)

Fixed submission:
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values():
    cnt += int(d*(d-1)/2)
print(cnt)

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

skip_num = []

if n < 4:
    print('0')
else:
    cnt = 0
    for j in range(n-3):
        if j in skip_num:
            continue

        i = 0
        skip_add = 0
        while i < n-3-j:
            step = int(s[n-4-i-j:n-j])
            if step % 2019 == 0:
                skip_num.append(j+3)
                cnt += 1+skip_add
                skip_add += 1
                i += 3
            i += 1

print(cnt)

Fixed submission:
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values():
    cnt += int(d*(d-1)/2)
print(cnt)

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

if n < 4:
    print('0')
else:
    cnt = 0
    for j in range(n-3):
        i = 0
        while i < n-3-j:
            step = int(s[n-4-i-j:n-j])
            if step % 2019 == 0:
                cnt += 1
                i += 3
            i += 1

print(cnt)

Fixed submission:
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values():
    cnt += int(d*(d-1)/2)
print(cnt)

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

if n < 4:
    print('0')
else:
    cnt = 0
    for i in range(n-3):
        for j in range(i+3, n):
            step = int(s[i:j+1])
            if step%2019 == 0:
                cnt += 1

print(cnt)

Fixed submission:
import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values():
    cnt += int(d*(d-1)/2)
print(cnt)