Problem p02702 (python)

Fixed submission:
import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i,2019)
  mod.append((now + mod[i]) % 2019)


c = collections.Counter(mod)
hindo = c.values()
for i in hindo:
  if i != 1:
    cnt += i*(i-1)//2


print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i,2019)
  mod.append((now + mod[i]) % 2019)


c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)
for i in range(hindo.index(1)):
  n = hindo[i]
  cnt += n*(n-1)//2

print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i,2019)
  mod.append((now + mod[i]) % 2019)

c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)

for i in range(hindo.index(1)):
  n = hindo[i]
  cnt += n*(n-1)//2

print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i+1,2019)
  mod.append((now + mod[i]) % 2019)

c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)
if hindo.index(1) != 0:
  for i in range(hindo.index(1)):
    n = hindo[i]
    cnt += n*(n-1)//2
else:
  cnt = 0

print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i+1,2019)
  mod.append((now + mod[i]) % 2019)

c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)
for i in range(hindo.index(1)):
  n = hindo[i]
  cnt += n*(n-1)//2

print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
tens = 1
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * tens % 2019
  mod.append((now + mod[i]) % 2019)
  tens *= 10
  tens %= 2019

c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)
for i in range(hindo.index(1)):
  n = hindo[i]
  cnt += n*(n-1)//2

print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
tens = 1
for i in range(len(reverse_S)):
  now = int(reverse_S[i])*tens%2019
  mod.append((now+mod[i])%2019)
  tens *= 10
  tens %= 2019

c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)
for i in range(hindo.index(1)):
  n = hindo[i]
  cnt += n*(n-1)/2

print(int(cnt))

Buggy submission (verdict: Runtime Error):
import collections
S = input()
cnt = 0

length = len(S)
mod = [0]
reverse_S = S[::-1]
tens = 1
for i in range(len(S)):
  now = int(reverse_S[i])*tens%2019
  mod.append((now+mod[i])%2019)
  tens *= 10
  tens %= 2019

c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)
for i in range(hindo.index(1)):
  n = hindo[i]
  cnt += n*(n-1)/2

print(int(cnt))

Buggy submission (verdict: Runtime Error):
import collections
S = input()
cnt = 0

length = len(S)
mod = [0]
reverse_S = S[::-1]
tens = 1
for i in range(len(S)):
  now = int(reverse_S[i])*tens%2019
  mod.append((now+mod[i])%2019)
  tens *= 10
  tens %= 2019;

c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)
for i in range(hindo.index(1)):
  n = hindo[i]
  cnt += n*(n-1)/2

print(int(cnt))