Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = (int(X)*(10**(i))) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Fixed submission:
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*pow(10,i,2019) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*(10**(i))+S
  mod_val=(S % 2019)
  mod_count.append(mod_val)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Fixed submission:
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*pow(10,i,2019) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = input()
count=0
S=[0]
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S.append(int(X)*(10**(int(i+1)-1))+S[i])
  mod_val=(S[i+1] % 2019)
  mod_count.append(mod_val)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Fixed submission:
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*pow(10,i,2019) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = input()
count=0
S=[0]
mod_count=[]
ans=0
for K in range(1,len(N)+1):
  S.append(int(N[-K])*(10**(K-1))+S[K-1])
for X in S:
  mod_val=(X % 2019)
  mod_count.append(mod_val)

c = Counter(mod_count)

for Y in c.values():
  ans+= Y*(Y-1)/2
print(int(ans))


Fixed submission:
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*pow(10,i,2019) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = input()
count=0
S=[0]
mod_count=[]
ans=0
for K in range(1,len(N)+1):
  S.append(int(N[-K])*(10**(K-1))+S[K-1])
for X in S:
  mod_val=(X % 2019)
  mod_count.append(str(mod_val))

c = Counter(mod_count)

for Y in c.values():
  ans+= Y*(Y-1)/2
print(int(ans))

Fixed submission:
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*pow(10,i,2019) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = input()
count=0
S=[0]
mod_count=[]
ans=0
for K in range(1,len(N)+1):
  S.append(int(N[-K:]))
for X in S:
  mod_val=(X % 2019)
  mod_count.append(str(mod_val))

c = Counter(mod_count)

for Y in c.values():
  ans+= Y*(Y-1)/2
print(int(ans))

Fixed submission:
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*pow(10,i,2019) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
count=0
for i in range(len(N)+1):
  for j in range(i+1,len(N)+1):
    if(int(N[i:j])%3!=0):
      continue
    if(int(N[i:j])%673==0):
      count+=1

print(count)


Fixed submission:
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*pow(10,i,2019) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
count=0
for i in range(len(N)+1):
  for j in range(i+1,len(N)+1):
    if(int(N[i:j])%2019==0):
      count+=1

print(count)

Fixed submission:
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*pow(10,i,2019) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))