Buggy python submission (verdict: Time Limit Exceeded):
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

Fixed submission:
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d, 2019)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
S = list(map(int, input()))[::-1]
mod_list = []
mod_list.append(0)
x = 0
d = 0
for s in S:
    x += s * pow(10, d)
    d += 1
    mod_list.append(x%2019)
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

Fixed submission:
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d, 2019)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

import collections
S = input()
mod_list = []
mod_list.append(0)
for i in range(len(S)):
    x = int(S[i:])
    mod_list.append(x%2019)
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

Fixed submission:
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d, 2019)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = [0 for _ in range(len(s))]
for i in range(len(s)-5, -1, -1):
    for j in range(i+4, len(s)):
        x = int(s[i:j+1])
        if x %2019 != 0:
            continue
        ans[i] += 1
        if j+1 < len(s):
            ans[i] += ans[j+1]
        break

print(sum(ans))

Fixed submission:
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d, 2019)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

s = input()
ans = [0 for i in range(len(s))]
for i in range(len(s)-5, -1, -1):
    for j in range(i+4, len(s)):
        x = int(s[i:j+1])
        if x %2019 == 0:
            ans[i] += 1
            if j+1 < len(s):
              ans[i] += ans[j+1]
            break

print(sum(ans))

Fixed submission:
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d, 2019)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

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

Fixed submission:
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d, 2019)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

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

Fixed submission:
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d, 2019)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

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

Fixed submission:
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d, 2019)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)