Buggy python submission (verdict: Runtime Error):
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0

for i in range(len(s)):
    if i == 0:
        mods[0] = int(s[-1])
    else:
        mods[i] = mods[i-1] + (10**i % 2019) * int(s[len(s) - i - 1])
    countRemainder[mods[i]] += 1

countRemainder[0] += 1

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

print(cnt)



Fixed submission:
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

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

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
countRemainder = [0] * 2019
cnt = 0

for i in range(len(s)):
    countRemainder[int(s[i:]) % 2019] += 1

countRemainder[0] += 1

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

print(cnt)

Fixed submission:
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

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

print(cnt)

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

minLength = 4
maxLength = len(s)
cnt = 0

skipFlag = 0
skipFlag2 = 0

for length in range(minLength,maxLength+1):
    for position in range(maxLength - length + 1):
        if skipFlag > 0:
            skipFlag += 1
            if skipFlag == 4:
                skipFlag = 0
            continue
        if skipFlag2 > 0:
            skipFlag2 += 1
            if skipFlag2 == 2:
                skipFlag2 = 0
            continue
        num = int(''.join(s[position:position+length]))
        if num % 3 == 0:
            if num % 673 == 0:
                cnt += 1
                skipFlag = 1
            else:
                skipFlag2 = 1

print(cnt)

Fixed submission:
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

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

print(cnt)

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

minLength = 4
maxLength = len(s)
cnt = 0

for length in range(minLength,maxLength+1):
    for position in range(maxLength - length + 1):
        num = int(''.join(s[position:position+length]))
        if num % 3 == 0:
            if num % 673 == 0:
                cnt += 1
                position += 4

print(cnt)

Fixed submission:
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

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

print(cnt)

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

minLength = 4
maxLength = len(s)
cnt = 0

for position in range(maxLength):
    modCnt = 0
    for i in range(position, maxLength):
        modCnt = (modCnt + int(s[i])) % 3
        if modCnt == 0:
            num = int(''.join(s[position:i+1]))
            if num % 673 == 0:
                cnt += 1

print(cnt)


Fixed submission:
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

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

print(cnt)

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

s_mod3 = []

for i in range(len(s)):
    s_mod3.append(int(s[i]) % 3)

minLength = 4
maxLength = len(s)
cnt = 0

for position in range(maxLength):
    modCnt = 0
    for i in range(position, maxLength):
        modCnt = (modCnt + s_mod3[i]) % 3
        if modCnt == 0:
            num = int(''.join(s[position:i+1]))
            if num % 673 == 0:
                cnt += 1

print(cnt)

Fixed submission:
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

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

print(cnt)

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

minLength = 4
maxLength = len(s)

cnt = 0

for length in range(minLength,maxLength+1):
    for position in range(maxLength - length + 1):
        num = int(''.join(s[position:position+length]))
        if num % 3 == 0:
            if num % 673 == 0:
                cnt += 1

print(cnt)

Fixed submission:
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

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

print(cnt)

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

minLength = 4
maxLength = len(s)

cnt = 0

for length in range(minLength,maxLength+1):
    for position in range(maxLength - length + 1):
        num = int(''.join(s[position:position+length]))
        if num % 2019 == 0:
            cnt += 1

print(cnt)

Fixed submission:
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

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

print(cnt)