Buggy python submission (verdict: Runtime Error):
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += i*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
mod = 2019
cnt = [0]*mod
cnt[0] = 1
n = 0
t = 1
for i in map(int,S[::-1]):
    n += i*t
    cnt[n%mod] += 1
    t *= 10
print(sum(i*(i-1)//2 for i in cnt))

Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Runtime Error):
S = input()
mod = 2019
cnt = [0]*mod
cnt[0] = 1
n = 0
t = 1
for i in map(int,n[::-1]):
    n += i*t
    cnt[n%mod] += 1
    t *= 10
print(sum(i*(i-1)//2 for i in cnt))


Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
mod = 2019
cnt = [0]*mod
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    cnt[n%mod] += 1
    t *= 10
print(sum(i*(i-1)//2 for i in cnt))


Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
S = (input())
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    x = int(i)
    n += x*t
    cnt[n%2019] += 1
    t *= 10
print(sum(i*(i-1)//2 for i in cnt))


Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
S = (input())
cnt = deque([0]*2019)
cnt.appendleft(1)
n = 0
t = 1
for i in reversed(S):
    x = int(i)
    n += x*t
    cnt[n%2019] += 1
    t *= 10
cnt2 = [i*(i-1)//2 for i in cnt]
print(sum(cnt2))

Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
S = (input())
A = deque([0])
cnt = deque([0]*2019)
cnt.appendleft(1)
n = 0
t = 1
for i in reversed(S):
    x = int(i)
    n += x*t
    A.append(n%2019)
    cnt[n%2019] += 1
    t *= 10
cnt2 = [i*(i-1)//2 for i in cnt]
print(sum(cnt2))


Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from collections import Counter
S = (input())
A = deque([0])
n = 0
t = 1
for i in reversed(S):
    x = int(i)
    n += x*t
    A.append(n%2019)
    t *= 10
C = Counter(A)
cnt= 0
for v in C.values():
    cnt += v*(v-1)//2
print(cnt)

Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from collections import Counter
S = list((input()))
A = deque([0])
B = deque([])
for i in range(len(S)):
    n = int(''.join(S[len(S)-2-i:]))
    A.append(n)
for j in A:
    B.append(j%2019)
C = Counter(B)
cnt= 0
for v in C.values():
    cnt += v*(v-1)//2
print(cnt)

Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from collections import Counter
S = list((input()))
A = deque([0])
B = deque([])
for i in range(len(S)):
    n = int(''.join(S[len(S)-2-i:]))
    A.append(n)
for j in A:
    B.append(j%2019)
C = Counter(B)
cnt= 0
for v in C.values():
    cnt += v*(v-1)//2
print(cnt)

Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
ans = 0
for i in range(4,len(s)+1):
    for j in range(0,len(s)+1-i):
      d = s[j:j+i]
      l = ''.join(d)
      if int(l) % 2019 == 0:
        ans += 1
print(ans)

Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
ans = 0
s = list(input())
for i in range(len(s)-2):
    for j in range(i+4,len(s)+1):
      d = s[i:j]
      l = ''.join(d)
      if int(l) % 2019 == 0:
            ans += 1
print(ans)

Fixed submission:
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))