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

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi *= 10

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

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

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = int(S.pop())

    pops = (pops + s * digi) % 2019
    digi *= 10

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

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

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = int(S.pop())

    pops = (pops + s * digi) % 2019
    digi *= 10

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count = [0] * 2019
N = len(S)
mod = 0

for i in range(N):
    mod = int(S[-i:]) % 2019
    count[mod] += 1

answer = count.pop(0)

for k in range(2018):
    if count[k] > 1:
        answer = answer + count[k]*(count[k] - 1)/2

print(int(answer))

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
count = [0]*2019
mod = 0

for i in range(len(S))
	mod = int(S[-i]) % 2019
	count[mod] += 1

answer = 0

for k in range(2019)
	answer = answer + count[k]

print(answer)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
answer = 0
for i in range(int(S)//2019 + 1):
    f = 2019 * i
    if str(f) in S:
        answer += 1

print(answer)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
answer = 0
for i in range(int(S)//2019 + 1):
    f = 2019 * i
    if f in S:
        answer += 1

print(answer)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
answer = 0
for i in range(int(int(S))//2019 + 1):
    f = 2019 * i
    if f in S:
        answer += 1

print(answer)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
answer = 0
for i in range(-int(-int(S))//2019):
    f = 2019 * i
    if f in S:
        answer += 1
        
print(answer)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

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

N = len(S)

answer = 0

for start in range(N-4):
    for end in range(start+4,N+1):
        if int(S[start:end]) % 2019 == 0:
            answer += 1

print(answer)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

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

N = len(S)

answer = 0

for start in range(N-3):
    for end in range(start+4,N+1):
        if int(S[start:end]) % 2019 == 0:
            answer += 1

print(answer)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)

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

N = len(S)

answer = 0

for start in range(N-3):
    for end in range(start+3,N+1):
        if int(S[start:end]) % 2019 == 0:
            answer += 1

print(answer)

Fixed submission:
S = list(map(int, list(input())))

pops = 0
digi = 1
cnt = [0] * 2019
cnt[0] = 1

while S:
    s = S.pop()

    pops = (pops + s * digi) % 2019
    digi = (10 * digi) % 2019

    cnt[pops] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)