Buggy python submission (verdict: Runtime Error):
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
ans = 0
num = 0
k = 1 
for i in range(len(s_inv)):
  num+=int(s_inv[i])*k % 2019
  dp[num] += 1
  k = k*10 % 2019
for i in dp:
  ans += i*(i-1)/2

Fixed submission:
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
k = 1
ans = 0
num = 0

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10

for i in dp:
  ans += i*(i-1)/2

print(int(ans))


Fixed submission:
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Runtime Error):
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
k = 1
ans = 0

for i in range(len(s_inv)):
  MOD += s_inv[i]*k%2019
  dp[MOD] += 1
  k*10

for i in dp:
  ans += i(i-1)/2

print(ans)

Fixed submission:
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))

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


Fixed submission:
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s=str(input())
ans = 0
for i in range(len(s)-3):
  for j in range(i+3,len(s)+1):
    if int(s[i:j]) % 2019 == 0:
      ans += 1
print(ans)

Fixed submission:
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
S=int(input())
m=S//2019
ans=0
baisu=[]
for i in range(m):
  baisu.append(2019*(i+1))
for num in baisu:
  if str(num) in str(S):
    ans += 1
print(ans)


Fixed submission:
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Runtime Error):
S=int(input())
m=S//2019
ans=0
baisu=[]
for i in range(m):
  baisu.append(2019*(i+1))
for num in baisu:
  if num in str(S):
    ans += 1
print(ans)


Fixed submission:
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Runtime Error):
S=int(input())
m=S//2019
ans=0
baisu=[]
for i in range(m):
  baisu.append(2019*(i+1))
for num in basiu:
  if num in str(S):
    ans += 1
print(ans)

Fixed submission:
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))