Problem:


Score : 400 points

Problem Statement

Given is a string S consisting of digits from 1 through 9.

Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:

Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Constraints

1 ≤ |S| ≤ 200000

S is a string consisting of digits from 1 through 9.

Input

Input is given from Standard Input in the following format:

S

Output

Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition.

Sample Input 1

1817181712114

Sample Output 1

3

Three pairs - (1,5), (5,9), and (9,13) - satisfy the condition.

Sample Input 2

14282668646

Sample Output 2

2

Sample Input 3

2119

Sample Output 3

0

No pairs satisfy the condition.



Sample input:
1817181712114


Sample output:
3

Submission status: Wrong Answer

Solution code:
S=input()

from collections import defaultdict
d=defaultdict(int)

n=len(S)
b=0
for i in range(n):
    a=int(S[n-i-1])
    b+=a*pow(10,i,2019)
    b%=2019
    d[b]+=1

ans=0

for k,v in d.items():
    if k==0:
        ans+=v
    else:
        ans+=v*(v-1)//2

print(ans)

Submission status: Wrong Answer

Solution code:
from math import log10
n = int(input())

ans = 0
max_e = int(log10(n)) + 1

for s in range(max_e-4):
    for e in range(s+4, max_e):
        if ((n%(10**e)) // (10**s)) % 2019 == 0:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
def solution():
    s = input()
    ans = 0
    for i in range(len(s)):
        for j in range(3):
            e = i+j+3
            if e >= len(s):
                break
            try:
                ch = int(s[i:e+1])
            except IndexError:
                break
            if ch < 2019 or ch > 200000:
                continue
            if ch % 2019 == 0:
                ans += 1
    print(ans)

solution()

Submission status: Wrong Answer

Solution code:
import re

# rを付けることを推奨。
# バックスラッシュをそのままで分かりやすいため。
S = input()
pattern = r'(?=(2019|4038|6057|8076|10095|12114|14133|16152|18171|20190|22209|24228|26247|28266|30285|32304|34323|36342|38361|40380|42399|44418|46437|48456|50475|52494|54513|56532|58551|60570|62589|64608|66627|68646|70665|72684|74703|76722|78741|80760|82779|84798|86817|88836|90855|92874|94893|96912|98931|100950|102969|104988|107007|109026|111045|113064|115083|117102|119121|121140|123159|125178|127197|129216|131235|133254|135273|137292|139311|141330|143349|145368|147387|149406|151425|153444|155463|157482|159501|161520|163539|165558|167577|169596|171615|173634|175653|177672|179691|181710|183729|185748|187767|189786|191805|193824|195843|197862|199881))'
macth = re.findall(pattern, S)
print(len(macth))

Submission status: Wrong Answer

Solution code:
s=input()
count=0
for i in range(0,len(s)-3):
  for j in range(i+4,len(s)+1):
    s_tmp=s[i:j]
    if int(s_tmp)>=200001:
      break
    if int(s_tmp)%2019==0:
      count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = input()
    N = len(S)
    ans = 0
    right = N
    left = N - 5
    while left >= 0 and right >= 0:
        s = S[left:right]
        if int(s) % 2019 == 0:
            ans += 1
            left -= 1
        else:
            if right - left < 5:
                left -= 1
            else:
                right -= 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
string=input()
count=0
times=0
start=0
length=4
while len(string) > 4:
  if times != 0 and times % 3 == 0:
    length=4
    string=string[1:]
  if len(string) >= length:
    target=string[:length]
    target=int(target)
    if target % 2019 == 0:
      count+=1
  times+=1
  length+=1
print(count)

Submission status: Wrong Answer

Solution code:
s=input()
lis=[]
for i in range(1,101):
    if '0' in str(2019*i):
        pass
    else:
        lis.append(2019*i)
        
ngram=[]
for i in range(5,7):
    l=[]
    for j in range(len(s)-i+1):
        l.append(s[j:j+i])
    ngram.append(l)

ans=0
for i in lis:
    ans+=ngram[len(str(i))-5].count(str(i))
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
n = 0
for j in range(3, len(S)):
    for i in range(j-3):
        if(int(S[i:j+1])%2019 == 0):
            print(i,j)
            n = n+1
print(n)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
inf = float("inf")


def is_multiple_2019(num):
    if num % 2019 == 0:
        return True
    return False


s = list(input())
len_s = len(s)

i = 0
count = 0
for j in range(len_s):
    if i < j:
        num = int(''.join(s[i:j+1]))
        if is_multiple_2019(num):
            count += 1
            i = j

print(count)

Submission status: Wrong Answer

Solution code:
s=list(input())
x=0
if len(s)<=3:
    x=0
    print(x)
else :
    for j in range(len(s)):
        count=0
        for i in range(len(s)-j-4):
            a="".join(s[j:j+count+1+4])
            if int(a) % 2019 ==0:
                x+=1
                count+=1
            else:
                count+=1
print(x)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
count = [0]*n

end = n-1
for i in range(n-4,-1,-1):
    max_length = end-i+1
    for j in range(4, max_length+1):
        f = S[i:i+j]
        #print(f,i,j)
        if int(f)%2019 == 0:
            end = i
            if (i+j) >= n:
                count[i] = 1
            else:
                count[i] = 1+count[i+j]
            
print(sum(count))

Submission status: Wrong Answer

Solution code:
s = input()
mods = []
crt = int(s[-1])
if len(s) <= 4:
    print(0)
    exit()
# for i in range(len(s)):
#     crt = crt*10+int(s[i])
#     crt %= 2019
#     mods.append(crt)
# print(mods)
for i in range(len(s)-2,-1,-1):
    crt = crt+int(s[i])*pow(10, (len(s)-i-1), 2019)
    crt %= 2019
    mods.append(crt)
ans = 0
ans += mods.count(0)
modst = set(mods)
ans += len(mods) - len(modst)
print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
ARY = ['2019','4038','6057','8076','10095','12114','14133','16152','18171','20190','22209','24228','26247','28266','30285','32304','34323','36342','38361','40380','42399','44418','46437','48456','50475','52494','54513','56532','58551','60570','62589','64608','66627','68646','70665','72684','74703','76722','78741','80760','82779','84798','86817','88836','90855','92874','94893','96912','98931','100950','102969','104988','107007','109026','111045','113064','115083','117102','119121','121140','123159','125178','127197','129216','131235','133254','135273','137292','139311','141330','143349','145368','147387','149406','151425','153444','155463','157482','159501','161520','163539','165558','167577','169596','171615','173634','175653','177672','179691','181710','183729','185748','187767','189786','191805','193824','195843','197862','199881','201900']
counta=0
for i in ARY:
    flag = True
    tmp = 0
    start = 0
    while tmp>=0:
        tmp = s[start:].find(i)
        if tmp >= 0:
            start += tmp + 1
            counta+=1
        else:
            tmp = -1
print(counta)

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    s_set = set()
    s_len = len(s)
    for i in range(s_len-3):
        for j in range(i+4, s_len+1):
            if int(s[i:j])%6 == 0: 
            	if int(s[i:j])%673 == 0:
              		s_set.add((i, j))

    return len(s_set)

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
hash = {}
result = 0
while result < 100000000:
    result += 2019
    hash[str(result)] = True

cnt = 0
s = str(input())
j = len(s)
while True:
    i = 4
    j_copy = j
    while True:
        if s[j_copy - i:j_copy] in hash:
            print(s[j_copy - i:j_copy])
            cnt+=1
            j_copy-=i
            i = 4
        else:
            i+=1
        if i > 8 or j_copy - i < 0:
            break
    j -= 1
    if j < 4:
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
t = int(s)%2019
l = []
for i in range(t):
    l.append(str(2019*(i+1)))
ans = 0
for j in range(len(l)):
    ans += s.count(l[j])
print(ans)

Submission status: Wrong Answer

Solution code:
def solve(s):
    N = len(s)
    ans = 0
    if N < 4:
        return 0

    for i in range(4,10):
        for j in range(N-i+1):
            ans += 1 if int(s[j:j+i])%2019==0 else 0
    
    return ans

S = str(input())    
print(solve(S))

Submission status: Wrong Answer

Solution code:
s = input()
n = 2019

c = 0
for i in range(1, 1000):
    st = str(n*i)
    if st in s:
        c += len([s[i:i+len(st)] for i in range(len(s)-len(st)+1) if s[i:i+len(st)]==st])
      
print(c)

Submission status: Wrong Answer

Solution code:
s = str(input())                                           
count = 0
 
if len(s) <= 3:
    print(0)
 
for i in range(len(s)-3):
    for j in range(4, len(s)-int(i)+1):
        if int(s[i:i+j]) % 2019 == 0:
            count = count +1
 
print(count)

Submission status: Wrong Answer

Solution code:
S = str(input())
counts = 0
if len(S) < 4:
    print(0)
else:
    for i in range(len(S)-3):
        for j in range(i+3,len(S)):
            s = int(S[i:j+1])
            if s % 2019 == 0:
                counts += 1
print(counts)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    a = input()
    count = 0
    compare = 0
    if len(a)<4:
        count = 0
    else:
        for i in range(len(a)-3):
            for j in range(i+4,len(a)+1):
                compare=int(a[i:j])
                if compare%2019==0:
                    count+=1
                compare = 0;
        print(count)

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    ret = 0
    for s in range(len(S)-4):
        if int(S[s:s+5]) % 2019 == 0:
            ret += 1
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
z = 200000 // 2019
x = [str(2019 * (i + 1)) for i in range(z)]
# print(s)
s = input()
c = set()
for y in x:
  start = 0
  while len(s[start:]) >= len(y):
    a = s[start:].find(y)
    if a == -1:
      break
    if a >= 0:
      c.add((start + a + 1, start + a + len(y)))
      start += a + 1
print(len(c))

Submission status: Wrong Answer

Solution code:
from itertools import combinations 
s=input()
c=0
for x, y in combinations(range(4,len(s) + 1), r = 2):
  #print(x,y)
  if int(s[x:y+1])%2019==0:
    c+=1
    
  
print(c)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

strA = str(input())

i = len(strA)
j = 3
x = 0
for start in range(i-3):
  j += 1  

  for end in range(j,i+1):
    z = int(strA[start:end]) 
    if z % 2019 == 0 and z > 0:
        x = x + 1

print (x)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
target_list = []
itr = 2019
i = 1
for i in range(1, 200000):
    tmp = i * itr
    if tmp > 200000:
        break
    else:
        target_list.append(tmp)
    
def print_ans(S):
    """Test Case
    >>> print_ans('1817181712114')
    3
    >>> print_ans('14282668646')
    2
    >>> print_ans('2119')
    0
    """
    ans = 0
    if len(S) <= 3:
        print(0)
    else:
        for i in range(len(S)):
            for j in range(i + 3, len(S)):
                tmp = S[i:j+1]
                if len(tmp) >= 7:
                    break
                if int(tmp) in target_list:
                    ans = ans + 1
        print(ans)
            
            

if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)

Submission status: Wrong Answer

Solution code:
import re
S = input()
num = 2019
i = 1
ans = 0
while num*i < 200000:
    ans += len(re.findall(f'(?=({str(num*i)}))', str(S)))
    i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
str_len = len(S)
X = 0

# if len(S) >= 4:
#     for i in range(4,str_len + 1):
#         for j in range(str_len - i + 1):
#             if int(S[j:j+i]) % 2019 == 0:
#                 X += 1

if len(S) >= 4:
    for i in range(str_len - 3):
        for j in range(4, str_len - i + 1):
            print(S[i:i+j])
            if int(S[i:i+j]) % 2019 == 0:
                X += 1

print(X)

Submission status: Wrong Answer

Solution code:
import sys

def a():
    input = sys.stdin.readline
    s = input()
    n = len(s)
    se = {i * 2019 for i in range(100)}
    count = 0
    for i in range(n - 3):
        for j in range(i + 4, n + 1):
            a = int(s[i:j])
            if a in se:
                count += 1
    print(count)


a()

Submission status: Wrong Answer

Solution code:
s=str(input())
a,b=0,0
for i in range(1,100):
    a=2019*i
    if str(a) in s:
        b+= sum([s[k:k+len(str(a))]==str(a) for k in range(0, len(s)-len(str(a))+1)])
print(b)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    s = input()
    l = [str(2019 * i) for i in range(2, 1000)]
    cnt = 0
    for n in l:
        ss = s
        while n in ss:
            idx = ss.index(n)
            cnt += 1
            ss = ss[idx + 1:]
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def solve(s):
    N = len(s)
    ans = 0
    if N < 4:
        return 0

    for i in range(4,10):
        for j in range(N-i+1):
            print(int(s[j:j+i]))
            ans += 1 if int(s[j:j+i])%2019==0 else 0
    
    return ans

S = str(input())    
print(solve(S))

Submission status: Wrong Answer

Solution code:
import re
S = input()

num = [str(i*2019) for i in range(1, 100)]

cnt = 0
for i in range(len(num)):
    if(num[i] in S):
        cnt += S.count(num[i])
        m = [j.span() for j in re.finditer(num[i], S)]
        for j in range(len(m)):
            if(len(num[i])+m[j][1]) <= len(S):
                tmp = S[m[j][1]-1:(len(num[i])+m[j][1]-1)]
                if(tmp == num[i]):
                    cnt += 1
             
print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    l = [str(i*2019) for i in range(1, 101) if "0" not in str(i*2019)]
    S = input()
    ans = 0
    for val in l:
        length = len(val)
        for i in range(len(S)-length+1):
            if val == S[i:i+length]:
                ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
getnum=input()
num=str(getnum)
counter=0
for y in range(len(num)):
  for x in range(y):
    if int(num[x:y])%2019==0:
      counter=counter+1
print(counter)

Submission status: Wrong Answer

Solution code:
from collections import Counter

S = input()
num = len(S)

data = [0]*100

for i in range(100):
    data[i] = 2019 * (1 + i)

ans = 0


for i in range(100):
    tar = str(data[i])
    if (tar in S):
        tarNum = len(str(tar))
        for j in range(num - tarNum + 1):
            cut = S[j: j + tarNum]
 #           print(cut)
            if (cut == tar):
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    s = input()
    check = 2019
    ret = 0

    for i in range(len(s) + 1):
        for j in range(i + 4, len(s) + 1):
            # if sum(map(int, s[i:j])) % 3 == 0 and int(s[i:j]) % check == 0:
            ret += 1

    return ret


if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
# python 3.8.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
from math import gcd
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def lcm(a,b):return (a*b) // gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

S = input()

MAX = 200000

iv = 2019
multiple = {}
multiple[len(str(iv))] = set()
multiple[len(str(iv))].add(str(iv))
cnt = 2
while True:
    tmp = iv * cnt
    if tmp <= MAX:
        if len(str(tmp)) not in multiple:
            multiple[len(str(tmp))] = set()
        multiple[len(str(tmp))].add(str(tmp))
        cnt += 1
    else:
        break
ans = 0

for k, v in multiple.items():
    for i in range(len(S)):
        if i+k < len(S)+1:
            if S[i:i+k] in v:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:

S = str(input())

n = len(S)

cnt = 0
for i in range(n+1):
    for j in range(i+1, n+1):
        s = S[i:j]

        if int(s) % 2019 == 0:
            print(i, j)
            cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
# D - Multiple of 2019
s = str(input())
ans = 0

for i in range(len(s)):
    if int(s[i:i+5])%2019==0:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
S=str(input())
x=0
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        a=S[i:j]
        a=int(a)
        if a%29==0:
            x=x+1
print(x)

Submission status: Wrong Answer

Solution code:
l = [str(2019 * i) for i in range(1, 200001)]
s = input()
ans = 0
for i in l:
  if i in s: ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

s=input()
l=len(s)
cnt=collections.defaultdict(int)
tmp=0
for i in range(l):
  tmp+=int(s[l-1-i])*pow(10,i,2019)
  tmp%=2019
  cnt[tmp]+=1
ans=0
for key in cnt.keys():
  if key==0:
    ans+=cnt[key]
  else:
    ans+=(cnt[key]*(cnt[key]-1))//2
print(ans)

Submission status: Wrong Answer

Solution code:
def func():
    return

# n = int(input())
s = input()
# a, b = map(int, input().split())
# a = list(map(int, input().split()))
# a = input().split()

cnt = 0
ls = len(s)
for i in range(ls-3):
    for j in range(i+4, ls+1):
        tmp = int(s[i:j])
        print(tmp)
        if tmp%2019 == 0:
            cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
s_len = len(s)
num = ''
ans = 0
j = 0
for i in range(s_len):
  while j < s_len:
    num += s[j]
    if int(num) % 2019 == 0:
      ans += 1
    j += 1
  j = i + 3
  if j > s_len:
    break
  num = ''
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
sys.setrecursionlimit(500000)

S = list(input())[::-1]
N = len(S)
D = [1]
for i in range(N):
    D.append(D[-1]*10%2019)
M = [(int(S[i])*D[i])%2019 for i in range(N)]
SS = [M[0]]
for i in range(1,N):
    SS.append((SS[-1]+M[i])%2019)
count = [0]*2019
for i in range(N):
    count[SS[i]] += 1

ans = 0
for c in range(len(count)):
    if c==0:
        ans += (count[c] * (count[c] + 1)) // 2
    ans += (count[c] * (count[c] - 1)) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
def f(s):
    pl = [str(2019*i) for i in range(1,51000)]
    res = 0
    for p in pl:
        res += s.count(p)
        # start = 0
        # pos = s.find(p, start)
        # while pos>=0:
        #     res += 1
        #     start = pos + 1
        #     pos = s.find(p, start)
    return res

if __name__ == "__main__":
    print(f(input()))

Submission status: Wrong Answer

Solution code:
def main():
    s = int(input())
    y=0
    t=len(str(s))-3
    f=len(str(s))
    for i in range(t):
        for j in range(i+3,f):
            p=int(str(s)[i:j+1])
            if p%2019==0:
                y+=1

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
S = input()
res = []
for i in range(4,len(S)):
  for j in range(len(S)-i):
    if int(S[j:j+i+1]) % 2019 == 0:
      res.append((j+1,j+i+1))
print(len(S))

Submission status: Wrong Answer

Solution code:
S = input()
count = 0
for i in range(len(S)):
    try:
        for n in range(4,len(S)+1):
            j = i + n
            number = int(S[i:j])
            print(i,j)
            if j == len(S)+1:
                break
            if number % 2019 == 0:
                count += 1
            else:
                continue
    except IndexError:
        break
print(count)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    s = input()
    l = [str(2019 * i) for i in range(2, 101)]
    cnt = 0
    for n in l:
        ss = s
        while n in ss:
            idx = ss.index(n)
            cnt += 1
            ss = ss[idx + 1:]
    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
S=list(input())
S.reverse()
N=len(S)
R=[0]*N
R10=[0]*N
m=2019
K=0

R10[0]=1
R[0]=int(S[0])%m
for i in range(1,N):
    R10[i]=(R10[i-1]*10)%m
    R[i]=(R[i-1]+int(S[i])*R10[i])%m
print(R)
d={}
for i in range(2019):
    d[i]=0

for i in range(N):
    d[R[i]]+=1
ans=0
for i in range(2019):
    if i == 0:
        ans += d[i]
        ans +=d[i]*(d[i]-1)//2
    else:
        ans +=d[i]*(d[i]-1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
a=[]
for i in range(1,100):
    a.append(str(2019*i))
cnt=0
S=input()
for j in a:
    cnt+=S.count(j)

print(cnt)

Submission status: Wrong Answer

Solution code:
S = str(input())
ans = 0
x = -1
flag = True

for i in range(len(S) - 4):
    if x != -1:
        break
    for j in range(i + 3, len(S)):
        if int(S[i:j + 1]) % 2019 == 0:
            x = j
            ans += 1
            break

if x == -1:
    print(max(ans, 0))

else:
    while flag:
        for i in range(x+1, len(S)):
            if i == len(S)-1:
                flag = False
            if int(S[x:i+1]) % 2019 == 0:
                ans += 1
                x = i
                break

    print(ans)

Submission status: Wrong Answer

Solution code:
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys
    import heapq
    # from math import *
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return map(int, data().split())
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)

    s=input()
    s1=s[len(s)-3:len(s)]
    ans=0
    for i in range(len(s)-4,-1,-1):
        s1=s[i]+s1
        k=int(s1)
        d=str(k//2019)
        ind=len(d)
        if k%2019==0:
            ans+=1
            for j in range(len(d)-1,-1,-1):
                if d[j]=='0':
                    ans+=1
                    ind-=1
        cnt = 0
        for j in range(ind):
            if d[j]=='0':
                cnt+=1
            else:
                ans+=max(0,cnt-2)
                cnt=0
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = input()
lenN = len(N)
h = lenN
cnt = 0
if lenN >= 6:
  h = lenN // 2
  
for i in range(0,h-3):
  for j in range(i + 3,h+1):
    p = int(N[i:j])
    if p % 2019 == 0:
      cnt += 1
if lenN >= 6:
  for i in range(h-3,lenN-3):
    for j in range(i + 3,lenN+1):
      p = int(N[i:j])
      if p % 2019 == 0:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)

ans = 0
cnt = [0] * 2019
for i in range(N):
    cnt[int(S[i:]) % 2019] += 1
for i in range(2019):
    ans += cnt[i] * (cnt[i] + 1) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())

count = 0

if len(S) < 4:
    print(count)

for i in range(len(S) - 3):
    for j in range(i + 3, len(S) + 1):
        if int(''.join(S[i:j])) % 2019 == 0:

          count += 1

print(count)

Submission status: Wrong Answer

Solution code:
N=input()

count=0
res=0

while int(len(N))>=0:
    res=N[-5:]
    if int(res)%2019==0:
        count+=1
        
    N=N[:-4]

        
    if int(len(N))<=4:
        break    
    
    



print(count)

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
cnt=0

l=[str(2019*i) for i in range(1,200000//2019+2) if 2019*i<=200000 and not '0' in str(2019*i)]

for i in range(n-4):
  s1=s[i:i+5]
  s2=s[i:i+6]
  if s1 in l:
    cnt+=1
  if i<len(s)-5 and s2 in l:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
S = input()
A_list = []
for i in range(0,120):
    A_list.append(str(i*2019))

# # print(A_list)
ans = 0
for i in range(0,len(S)-4):
    tem = S[i:i+4]
    if int(tem) % 2019 == 0:
        ans += 1

for i in range(0,len(S)-5):
    tem = S[i:i+5]
    if int(tem) % 2019 == 0:
        ans += 1

for i in range(0,len(S)):
    tem = S[i:i+6]
    # print(tem)
    if int(tem) % 2019 == 0:
        ans += 1


count = 0
for i in range(0,110):
    tem = S.count(A_list[i])
    count += tem
print(max(ans,count))

Submission status: Wrong Answer

Solution code:
s=input()

def is2019(s):
    num=int(s)
    return num % 2019 == 0

i=0
ans=0
while i<len(s):
    found=False
    for j in range(1,10):
        if i+j > len(s):
            continue
        if is2019(s[i:i+j]):
            found=True
            ans+=1
            break
    i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import re

s = input()
base = 2019

cnt = 0
for i in range(1, 100):
    idx = 0
    while True:
        idx = s.find(str(base*i), idx)
        if idx == -1:
            break
        cnt += 1
        idx += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
# python 3.8.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
from math import gcd
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def lcm(a,b):return (a*b) // gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

S = input()

MAX = 200000

iv = 2019
multiple = {}
multiple[len(str(iv))] = set()
multiple[len(str(iv))].add(str(iv))
cnt = 2
while True:
    tmp = iv * cnt
    if tmp <= MAX:
        if len(str(tmp)) not in multiple:
            multiple[len(str(tmp))] = set()
        multiple[len(str(tmp))].add(str(tmp))
        cnt += 1
    else:
        break
ans = 0

for k, v in multiple.items():
    for i in range(len(S)):
        if S[i:i+k] in v:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

E = [0]
for i in range(len(S)):
    E.append((E[i] + int(S[i])) % 3)

print(E)

ans = 0
j = len(S)-1
while j >= 3:
    i = j - 3
    while i >= 0:
        if E[i] - E[j+1] == 0:
            ans += (int(S[i:j+1]) % 2019 == 0)
        i -= 1
    j -= 1
print(ans)

Submission status: Wrong Answer

Solution code:

s=input()
S=int(s)
CHECK=[0 for i in range(2020)]
ans=0
for i in range(len(s)-1):
    temp=(S%pow(10,i+1))%2019
    if temp==0:
        ans+=1
    elif CHECK[temp]==0:
        CHECK[temp]=1
    elif CHECK[temp]==1:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
# D - Multiple of 2019
s = str(input())
ans = 0

for i in range(len(s)):
    for j in range(i+4, len(s)):
        if int(s[i:j+1])%2019==0:
            ans += 1
            print(i, j)

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    s_set = set()
    s_len = len(s)
    for i in range(s_len-3):
        for j in range(i+4, s_len+1):
            if int(s[i:j])%6 == 0 and int(s[i:j])%673:
                s_set.add((i, j))

    return len(s_set)

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
N = input()
lenN = len(N)
h = lenN
cnt = 0
if lenN >= 6:
  h = lenN // 2
  
for i in range(0,h-3):
  for j in range(i + 3,h+1):
    p = int(N[i:j])
    if p % 2019 == 0:
      print("{} : {}".format(i,j))
      cnt += 1
if lenN >= 6:
  for i in range(h-3,lenN-3):
    for j in range(i + 3,lenN+1):
      p = int(N[i:j])
      if p % 2019 == 0:
        print("{} : {}".format(i,j))
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
S = input()
li = []
for i in range(1, 100):
  li.append(str(2019*(i)))
cnt = 0
for e in li:
  cnt += sum([S[k:k+len(e)]==e for k in range(0, len(S)-len(e)+1)])
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
s_len = len(s)
num = ''
ans = 0
j = 0
for i in range(s_len):
  while j < s_len:
    num += s[j]
    if int(num) % 2019 == 0:
      ans += 1
    j += 1
  j = i + 3
  num = ''
print(ans)