Buggy python submission (verdict: Runtime Error):
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    s = list(map(int,ipt()))[::-1]
    d = defaultdict(int)
    ans = 0
    ni = 0
    mod = 2019
    d[0] = 1
    n10 = 1
    for i in s:
        ni = (ni+i*n10)%mod
        d[ni] += 1
        n10 = (n10*10)%mod
    for i in d.values():
        ans += i*(i-1)//2
    print(ans)

    return

if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    s = list(map(int,ipt()))[::-1]
    d = defaultdict(int)
    ans = 0
    ni = 0
    mod = 2019
    d[0] = 1
    n10 = 1
    for i in s:
        ni = (ni+i*n10)%mod
        d[ni] += 1
        n10 = (n10*10)%mod
    for i in d.values():
        ans += i*(i-1)//2
    print(ans)

    return

if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
wa = [0 for i in range(n)]
wa[0] = s[n-1]
for i in range(1,n):
    ii = i
    now = 10
    aaa = 1
    while ii > 0:
        if ii%2 == 1:
            aaa = (aaa*now)%mod
        now = (now**2)%mod
        ii //= 2
    wa[i] = (wa[i-1]+s[n-i-1]*aaa)%mod
    if wa[i] == 0:
        ans += 1

for i in range(n):
    for j in range(i+1,n):
        if wa[i] == wa[j]:
            ans += 1

print(ans)


Fixed submission:
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019

for i in range(n-3):
    nn = (s[i]*1000+s[i+1]*100+s[i+2]*10+s[i+3])%mod
    if nn == 0:
        ans += 1
    for j in range(i+4,n):
        nn = (nn*10+s[j])%mod
        if nn == 0:
            ans += 1
print(ans)


Fixed submission:
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
n = len(s)
ans = 0
mod = 2019

for i in range(n-3):
    nn = int(int(s[i])*1000+int(s[i+1])*100+int(s[i+2])*10+int(s[i+3]))%mod
    if nn == 0:
        ans += 1
    for j in range(i+4,n):
        nn = (nn*10+int(s[j]))%mod
        if nn == 0:
            ans += 1

print(ans)


Fixed submission:
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
s = str(input())
n = len(s)
ans = 0

for i in range(n):
    for j in range(i+3,n):
        if int(s[i:j+1])%2019 == 0:
            ans += 1

print(ans)


Fixed submission:
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)