Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict


s = input()
n = len(s)

dd = defaultdict(int)

d = [0 for i in range(2019)]
d[0] = 1
tmp = 0
_10 = 1
# print(s, n)
for i in range(n - 1, -1, -1):
    # print(i, s[i])
    # print(int(s[i]), _10)
    tmp += (int(s[i]) * _10) % 2019
    _10 *= 10
    # print(tmp, tmp % 2019)
    d[tmp % 2019] += 1


# count = 0
# for i in range(len(d)):
#     if d[i] >= 2:
#         count += (d[i])*(d[i]-1)//2
# print(count)

# # print(dd)
print(sum(v*(v-1)//2 for v in d))


Fixed submission:
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict


s = input()
n = len(s)

dd = defaultdict(int)

d = [0] * 2019
d[0] = 1
tmp = 0
_10 = 1
# print(s, n)
for i in range(n - 1, -1, -1):
    # print(i, s[i])
    tmp = tmp + (int(s[i]) * _10) % 2019
    _10 *= 10
    # print(tmp, tmp % 2019)
    d[tmp % 2019] += 1


# count = 0
# for i in range(len(d)):
#     if d[i] >= 2:
#         count += (d[i])*(d[i]-1)//2
# print(count)

# # print(dd)
print(sum(v*(v-1)//2 for v in d))


Fixed submission:
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict


s = input()
n = len(s)

dd = defaultdict(int)

d = [0] * 2019
d[0] = 1
tmp = 0
_10 = 1
# print(s, n)
for i in range(n - 1, -1, -1):
    # print(i, s[i])
    tmp = tmp + int(s[i]) * _10
    _10 *= 10
    # print(tmp, tmp % 2019)
    d[tmp % 2019] += 1


# count = 0
# for i in range(len(d)):
#     if d[i] >= 2:
#         count += (d[i])*(d[i]-1)//2
# print(count)

# # print(dd)
print(sum(v*(v-1)//2 for v in d))


Fixed submission:
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict


s = input()
n = len(s)

dd = defaultdict(int)

d = [0] * 2019
d[0] = 1
tmp = 0
_10 = 1
# print(s, n)
for i in range(n - 1, -1, -1):
    # print(i, s[i])
    tmp = tmp + int(s[i]) * _10
    _10 *= 10
    # print(tmp, tmp % 2019)
    d[tmp % 2019] += 1


# count = 0
# for i in range(len(d)):
#     if d[i] >= 2:
#         count += (d[i])*(d[i]-1)//2
# print(count)

# # print(dd)
print(sum(v*(v-1)//2 for v in d))


Fixed submission:
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict


s = input()
n = len(s)

dd = defaultdict(int)

# d = [0] * 2019
dd[0] = 1
tmp = 0
_10 = 1
# print(s, n)
for i in range(n - 1, -1, -1):
    # print(i, s[i])
    tmp = tmp + int(s[i]) * _10
    _10 *= 10
    # print(tmp, tmp % 2019)
    dd[tmp % 2019] += 1

# print(dd)
print(sum(v*(v-1)//2 for v in dd.values()))


Fixed submission:
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict


s = input()
n = len(s)

dd = defaultdict(int)

# d = [0] * 2019
dd[0] = 1

# print(s, n)
for i in range(n - 1, -1, -1):
    # print(i, s[i])
    tmp = s[i:n]
    # print(tmp, int(tmp) % 2019)
    dd[int(tmp) % 2019] += 1

# print(dd)
print(sum(v*(v-1)//2 for v in dd.values()))


Fixed submission:
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict


s = input()
n = len(s)

dd = defaultdict(int)

d = [0] * 2019
dd[0] = 1

# print(s, n)
for i in range(n - 1, -1, -1):
    # print(i, s[i])
    tmp = s[i:n]
    # print(tmp, int(tmp) % 2019)
    dd[int(tmp) % 2019] += 1

# print(dd)
print(sum(v*(v-1)//2 for v in dd.values()))


Fixed submission:
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)

Buggy python submission (verdict: Runtime Error):
for i in range(100):
    t = i * 2019
    if t > 200000:
        break
    for i in range(len(str(s))):
        for j in range(i+1, len(str(s))+1):
            tmp = s[i:j]
            if int(tmp) == t:
                c += 1


print(c)

Fixed submission:
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)

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

for i in range(len(str(s))):
    for j in range(i+1, len(str(s))+1):
        tmp = s[i:j]
        if int(tmp) % 2019 == 0:
            c += 1

print(c)


Fixed submission:
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)