Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math

S = input()

mm = [0] * (2019)
mm[0] = 1
a = [0] * (len(S) + 1 ) 
T = 0
ten = 1
ll = len(S)
for i in range(ll):
    if i > 0:
        ten = ten * 10
    a[i+1] =  ( a[i] + (int(S[ll-1-i])*ten ) ) % 2019
    mm[ a[i+1] ] += 1
    #print(s)

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)

Fixed submission:
import numpy as np
import sys
import math

S = input()

mm = [0] * (2019)
mm[0] = 1
a = [0] * (len(S) + 1 ) 
T = 0
ten = 1
ll = len(S)
for i in range(ll):
    if i > 0:
        ten = ( ten * 10 ) % 2019
    a[i+1] =  ( a[i] + (int(S[ll-1-i])*ten ) ) % 2019
    mm[ a[i+1] ] += 1
    #print(s)

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math

S = input()
SS = int(S)
mod = 1000000000 + 7

mm = [0] * (2019)
mm[0] = 1
T = 0
ten = 1
for i in range(len(S)):
    if i > 0:
        ten = ten * 10
    s = SS % 10
    SS = SS // 10
    T = T + ( s * (ten) )
    mm[T % 2019 ] += 1

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)

Fixed submission:
import numpy as np
import sys
import math

S = input()

mm = [0] * (2019)
mm[0] = 1
a = [0] * (len(S) + 1 ) 
T = 0
ten = 1
ll = len(S)
for i in range(ll):
    if i > 0:
        ten = ( ten * 10 ) % 2019
    a[i+1] =  ( a[i] + (int(S[ll-1-i])*ten ) ) % 2019
    mm[ a[i+1] ] += 1
    #print(s)

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math

S = input()

mod = 1000000000 + 7

mm = [0] * (2019)
mm[0] = 1
T = 0
ten = 1
for ind , s in enumerate( S[::-1] ):
    if ind > 0:
        ten = ten * 10
    T = T + ( int(s) * (ten) )
    mm[T % 2019 ] += 1

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)

Fixed submission:
import numpy as np
import sys
import math

S = input()

mm = [0] * (2019)
mm[0] = 1
a = [0] * (len(S) + 1 ) 
T = 0
ten = 1
ll = len(S)
for i in range(ll):
    if i > 0:
        ten = ( ten * 10 ) % 2019
    a[i+1] =  ( a[i] + (int(S[ll-1-i])*ten ) ) % 2019
    mm[ a[i+1] ] += 1
    #print(s)

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math

S = input()

mm = [0] * (2019)
mm[0] = 1
T = 0

for ind , s in enumerate( S[::-1] ):
    T = T + ( int(s) * (10 ** (ind) ))
    mm[T % 2019 ] += 1

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)

Fixed submission:
import numpy as np
import sys
import math

S = input()

mm = [0] * (2019)
mm[0] = 1
a = [0] * (len(S) + 1 ) 
T = 0
ten = 1
ll = len(S)
for i in range(ll):
    if i > 0:
        ten = ( ten * 10 ) % 2019
    a[i+1] =  ( a[i] + (int(S[ll-1-i])*ten ) ) % 2019
    mm[ a[i+1] ] += 1
    #print(s)

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math

S = input()

tmp = []

for i in range(1,50008):
    x = 2019 * i
    if str(x).find("0") == -1:
        tmp.append(x)

ans = 0
ll = len(S)
for wide in range(5,9):
    for i in range(ll - wide + 1):
        if i + wide > ll:
            break
        ss = int(S[i:i+wide])
        if ss in tmp:
            ans += 1
        else:
            continue
        index = 0
        while True :
            flag = 0
            for ww in range(5,9):
                if i + wide + 1 + index + index + ww >=  ll :
                    flag  = 1
                    break
                if int(S[i+wide + 1 + index : i + wide + 1 + index + ww]) in tmp:
                    ans += 1
                index += 8
            if flag == 1:
                break

print(ans)

Fixed submission:
import numpy as np
import sys
import math

S = input()

mm = [0] * (2019)
mm[0] = 1
a = [0] * (len(S) + 1 ) 
T = 0
ten = 1
ll = len(S)
for i in range(ll):
    if i > 0:
        ten = ( ten * 10 ) % 2019
    a[i+1] =  ( a[i] + (int(S[ll-1-i])*ten ) ) % 2019
    mm[ a[i+1] ] += 1
    #print(s)

ans = 0

for m in mm:
    ans += int( (m * (m-1) ) / 2 )

print(ans)