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()

i=1
l=0





for k in range(99):
    j=2019*i
    s=str(j)
    count = sum([S[k:k+len(s)]==s for k in range(0, len(S)-len(s)+1)])
    l=l+count
    i+=1

print(l)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
s = input()
count = 0
L = len(s)
for i in range(L):
    if i+3 < L:
        num = int(s[i])*1000+int(s[i+1])*100+int(s[i+2])*10+int(s[i+3])
        if num % 2019 == 0:
            count += 1
    if i+4 < L:
        num = num*10 + int(s[i+4])
        if num % 2019 == 0:
            count += 1
    if i+5 < L:
        num = num * 10 + int(s[i+5])
        if num % 2019 == 0:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def abc(S):
    # 答えの準備
    ans = 0
    
    # 二重ループ
    print(len(S))
    for i in range (len(S), 4, -1):
        for j in range(0, i):
            print(j, i)
            num = int(S[j:i])
            if num % 2019 == 0:
                ans += 1
    
    # 答え
    return(ans)


# バッチスタート
if __name__ == "__main__":
    # 標準入力処理
    # 1行目の入力を文字列として扱う
    S = input()
    
    # 関数呼び出し
    f = abc(S)
    
    # 答えの出力
    print(f)

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)
ans = 0
if n <= 3:
    print(0)
elif n == 4:
    if int(s[0]*1000+s[1]*100+s[2]*10+s[3]) % 2019 == 0:
        print(1)
        exit()
    else:
        print(0)
        exit()
elif n > 4:
    for i in range(n-3):
        kar = int(s[i])*100 + int(s[i+1])*10 + int(s[i+2])
        for j in range(i+3,n):
            kar = (kar*10 + int(s[j])) %2019
            if kar == 0:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = read().decode().rstrip()

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

cnt = 0
for p in prod:
    cnt += sum(S.startswith(p, i) for i in range(len(S)))

print(cnt)

Submission status: Wrong Answer

Solution code:
14282668646

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
x = 2019
while len(str(x)) < 10:
    ans += s.count(str(x))
    x += 2019
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = str(input())

cnt = 0
for i in range(1, 100):

    baisu = str(i*2019)

    ns=S
    while ns.find(baisu)>-1:
        cnt+=1
        ns = ns[ns.find(baisu)+1:]
        
print(cnt)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()

YEAR = 2019
str_num_list = []
i = 1
ans = 0

while YEAR*i <= 200000:
    str_num_list.append(str(YEAR*i))
    i += 1

for item in str_num_list:
    start = 0
    while True:
        idx = s[start:].find(item)
        if idx == -1:
            break
        else:
            start += idx+1
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from collections import Counter

S = list(input())
S = list(map(int, S))
s = [0] * len(S)
mod = 2019
s[-1] = S[-1]
d = 1
for i in range(len(s) - 2, -1, -1):
    d = (d * 10) % mod
    s[i] = (S[i] * d) % mod

acc = list(accumulate(s[::-1]))[::-1] + [0]
acc = [i % mod for i in acc]
answer = sum(i - 1 for i in Counter(acc).values()) - S.count(0)
print(answer)

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)-4
count=0
for i in range(n+1):
	num=int(s[i:i+4+1])
	# print(num)
	if(num%2019==0):
		count+=1
print(count)

Submission status: Wrong Answer

Solution code:
a1=  '2019'
a2=  '4038'
a3=  '6057'
a4=  '8076'
a5=  '10095'
a6=  '12114'
a7=  '14133'
a8=  '16152'
a9=  '18171'
cnt=0

S=input()
cnt+=S.count(a1)
cnt+=S.count(a2)
cnt+=S.count(a3)
cnt+=S.count(a4)
cnt+=S.count(a5)
cnt+=S.count(a6)
cnt+=S.count(a7)
cnt+=S.count(a8)
cnt+=S.count(a9)

print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = input()
K = ['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',
     '119121', '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']

count = 0
for k in K:
    for i in range(len(s)):
        if (s[i:i + len(k)] == k):
            count += 1
print(count)

Submission status: Wrong Answer

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

cnt = 0
i = 0
while(i < ln-3):
#for i in range(ln-3):
    for j in range(i+3, ln):
        if int(S[i:j+1]) % 2019 == 0:
            cnt += 1
            i = j-1
            break
    i += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
S = input()
# S = '201879812018798120187981'

baisu = [str(2019 * m) for m in range(1, 10000)]

# print(baisu)

cnt = 0
for b in baisu:
    # 開始位置
    s = 0
    while True:
        # 見つけた位置
        pos = S.find(b, s)
        if pos > -1:
            # 次の開始位置を1文字後にする
            s = pos + 1
            cnt += 1
        else:
            break

print(cnt)

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)):
    s_tmp=s[i:j]
    if int(s_tmp)%2019==0:
      count+=1
print(count)

Submission status: Wrong Answer

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

s = input()
length = len(s)

counter = 0

for i in range(length):
    for j in range(length - i):
        target = s[i:i+j+1]
        # print(i, j, target, int(target) % 2019)
        if int(target) % 2019 == 0:
            print(i, j, target)
            counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
def modpow(d, b, p, mod=2019):
    ret = 1
    while p > 0:
        if p % 2 == 1:
            ret = ret * b % mod
        b = b * b % mod
        p //= 2
    return (d * ret) % mod


S = input()
C = [0]
for i in range(len(S)):
    C.append((C[-1] + modpow(int(S[-(i + 1)]), 10, i)) % 2019)
Cd, C0 = {}, 0
for c in C:
    if c == 0:
        C0 += 1
    else:
        Cd[c] = Cd.get(c, 0) + 1
print(C0 + sum([v * (v - 1) // 2 for v in Cd.values()]) - 1)

Submission status: Wrong Answer

Solution code:
S = input()

n = [str(2019*i) for i in range(1, 100)]
#print(n)

ans = 0
for w in n:
  if w in S:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
S = input()

res = 0
start = 0
min_length = 4
end = start+min_length
max_end = len(S)

while True:
  tmp_s = S[start:end]
  
  if int(tmp_s) % 2019 == 0:
    print(tmp_s)
    res += 1
  
  if end+1 <= max_end:
    end += 1
  elif end-(start+1) >= min_length:
    start += 1
    end = start + min_length
  else:
    break
    
print(res)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

S = read()[:-1]

# 2019の倍数である
# 2019 は 10000倍ごとにサイクルが存在する
# →最小の区間はすぐわかる, 連続するときにやっかい
# 連続するときは何回連続したか数えておけば良いのでは？
# 一回最小の区間で置換しよう あと0000とかもやっかいだけどどうしよう→1→9のみなので大丈夫
# 10000のなかで重複するのはない？

x = 2019
multi_x = set()
for i in range(1, 10000):
    tmp = str(x * i)
    if tmp.count('0'):
        continue
    multi_x.add(str(x * i))
# print(multi_x)
# print(len(multi_x))

# 2019の倍数になる最小の区間を
# 5桁から8桁見ておけばいいのは重要なヒント
# 8桁切り出しておいてスライド？#中で8桁まで見る

candi = []
for i in range(len(S)):
    for j in range(i + 5, i + 8):
        if j > len(S):
            continue
        if S[i:j] in multi_x:
            candi.append((i, j))

print(len(candi))

Submission status: Wrong Answer

Solution code:
import sys

s = str(sys.stdin.buffer.readline().rstrip())
c = [2019*i for i in range(1, 100)]
ans = 0

for i in range(99):
    tmp = str(c[i])
    if tmp in s:
        for j in range(len(s) - len(tmp)):
            if tmp == s[j:j+len(tmp)] :
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
box = []
n = 1
while True:
    if n*2019 > 200000:
        break
    else:
        box.append(n*2019)
    n += 1

ans = set()
for mod in box:
    s = S
    if len(str(mod)) > len(s):
        break
    if "0" in str(mod):
        continue
    mae = 0
    ato = len(str(mod))
    while True:
        if ato > len(S):
            break
        if s[mae:ato] == str(mod):
            ans.add((mae, ato))
            mae += 1
            ato += 1
        else:
            mae += 1
            ato += 1
print(len(ans))

Submission status: Wrong Answer

Solution code:
s=input()
b=0
m=len(s)
c=0
for i in range(m-3):
    a=s[i]+s[i+1]+s[i+2]
    for j in range(i+3,m):
        if c==1 and int(s[j])%3!=0:
            c=0
            continue
        a=str(a)
        a=int(a+s[j])
        c=0
        
        if a%3!=0:
            continue

        c=1
        if a%2019==0:
            b+=1
print(b)

Submission status: Wrong Answer

Solution code:

def main():
    S=input()
    N=len(S)
    A=[]
    cnt=0
    A=['12114', '14133', '16152', '18171', '24228', '26247', '28266', 
    '34323', '36342', '38361', '42399', '44418', '46437', '48456', '52494',
    '54513', '56532', '58551', '62589', '66627', '68646', '72684', '76722', 
    '78741', '82779', '84798', '86817', '88836', '92874', '94893', '96912', 
    '98931', '119121', '123159', '125178', '127197', '129216', '131235', '133254', 
    '135273', '137292', '139311', '143349', '145368', '147387', '151425', '153444', 
    '155463', '157482', '163539', '165558', '167577', '169596', '171615', '173634', 
    '175653', '177672', '179691', '183729', '185748', '187767', '189786', '193824', 
    '195843', '197862', '199881']
    for st in A:
        lenst=len(st)
        for i in range(N-lenst+1):
            if S[i:i+lenst]==st:
                cnt+=1
    print(cnt)
main()


'''
for n in range(1,100):
    if '0' not in str(2019*n): 
        A.append(str(2019*n))
'''

Submission status: Wrong Answer

Solution code:
s = input()

result = 0

for start in range(0, len(s) - 4):
    for end in range(start + 4, len(s) + 1):
        num = int(s[start:end])
        if num % 2019 == 0:
            print(start, end)
            result += 1

print(result)

Submission status: Wrong Answer

Solution code:
def main(S=None):
    if not S:
        S = input()
    count = 0
    candidates = [str(i) for i in range(2019, 200000, 2019)]
    s_len = len(S)
    for candidate in candidates:
        candidate_len = len(candidate)
        for i in range(s_len):
            if i+candidate_len > s_len:
                break
            if S[i:i+candidate_len] == candidate:
                count += 1
    print(count)


if __name__ == "__main__":
    # main("1817181712114")
    # main("14282668646")
    main()

Submission status: Wrong Answer

Solution code:
def multiplelist():
    lim = 200000
    i = 2019
    cand = 2019
    ls = []
    while(lim - cand >= 0):
        if '0' not in str(cand):
            ls.append(str(cand))
        cand += i
    return ls
    
def count(text, part):
    return sum(text.startswith(part, i) for i in range(len(text)))

def main():
    s = input()
    candidates = multiplelist()
    total = 0
    for cand in candidates:
        total += count(s, cand)
    print(total)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=input()
ans = 0
dp = [[0 for i in range(len(s)+3)]for j in range(len(s)+3)]
def rec(i,j,num):#j:numの左から何個けずった？ i:sの左から何番目までいった？
    global ans
    if dp[i][j] == 1:
        return
    dp[i][j] = 1
    if int(num) % 2019 == 0:
        ans += 1
    else:
        if j < len(s):
            rec(i,j+1,num+s[j])
        if len(num) >= 5:
            rec(i+1,j,num[1::])

rec(0,1,s[0])
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    s = input().rstrip()

    li = []
    for i in range(6, 100):
        n = str(2019 * i)
        if not ("0" in n):
            li.append(n)

    lens = len(s)
    c = 0
    for l in li:
        for pos in range(lens):
            if s[pos:].startswith(l):
                c += 1

    print(c)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = input()

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

print(ans)

Submission status: Wrong Answer

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    S = input().rstrip()

    numS = int(S)
    N = len(S)

    l = [[] for i in range(7)]

    for i in range(1,101):
        temp = 2019 * i
        if temp > numS:
            break
        temp = str(temp)
        d = len(temp)
        l[d].append(temp)

    res = 0

    for d in range(1,7):
        now = set(l[d])
        for i in range(N-d+1):
            temp = S[i:i+d]
            if temp in now:
                res += 1

    print(res)



main()

Submission status: Wrong Answer

Solution code:
s = input()
s = '1'*(2*(10**5))
if len(s) < 4:
  print('0')
else:
  cnt = 0
  for i in range(len(s)-3):
    if int(s[i:i+2]) %2 != 0:
      continue
    if i+3 > len(s):
      break
    for j in range(i+3, len(s)):
      if int(s[i:j+1]) % 2019 == 0:
        cnt += 1
  print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
length = len(s)
count_dict = {}

for i in range(length-3):
    num = int(s[i:])%2019
    if num not in count_dict:
        count_dict[num] = 1
    else:
        count_dict[num] += 1

count = 0
for k,v in count_dict.items():
    count += v*(v-1)/2
    if k == 0:
        count += v

print(int(count))

Submission status: Wrong Answer

Solution code:
s = input()

baisu = [12114, 14133, 16152, 18171, 24228, 26247, 28266, 34323, 36342, 38361, 42399, 44418, 46437, 48456, 52494, 54513,
         56532, 58551, 62589, 66627, 68646, 72684, 76722, 78741, 82779, 84798, 86817, 88836, 92874, 94893, 96912, 98931,
         119121, 123159, 125178, 127197, 129216, 131235, 133254, 135273, 137292, 139311, 143349, 145368, 147387, 151425,
         153444, 155463, 157482, 163539, 165558, 167577, 169596, 171615, 173634, 175653, 177672, 179691, 183729, 185748,
         187767, 189786, 193824, 195843, 197862, 199881]
cnt = 0
for su in baisu:
    for index in range(100000):
        if index + len(str(su)) - 1 >= len(s):
            break
        # print(s[index:index + len(str(su))])
        if int(s[index:index + len(str(su))]) == su:
            cnt += 1
            # print(s[index:index + len(str(su))])
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
import fractions
import collections
import itertools
from collections import deque
d=collections.deque()
S=list(input())
N=len(S)
cnt=0

amari=[0]*(N+1)
num=0
for i in range(N):
    d.append(int(S[i]))
print(d)
for i in range(N):
    n=d.pop()
    num=(num+pow(10,i)*n)%2019
    amari[i+1]=num
#print(amari)
#c=collections.Counter(amari)
#values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
amari.sort()
#for i in range(len(key)):
#    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
#xprint(l)
buf=0
#print(amari)
for i in range(N-1):
    if amari[i]==amari[i+1]:
        buf=buf+1
    else:
        cnt=cnt+((buf+1)*buf)//2
        buf=0
    #print(buf)
cnt=cnt+(buf*(buf+1))//2
print(cnt)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from collections import defaultdict
from operator import mul
from functools import reduce


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def solve(S: str):
    if len(S) < 4:
        print(0)
        exit()
    prev = int(S[-1])
    digit = 10
    count = defaultdict(int)
    for i in range(1,len(S)+1):
        k = prev % 2019
        # print(prev)
        count[k]+=1
        if i == len(S):
            break
        prev = (prev + digit*int(S[-i-1]))%2019
        digit=digit*10%2019
    sum = 0
    for k in count:
        if k == 0:
            sum += count[k]
            continue
        if count[k] < 2:
            continue
        sum += combinations_count(count[k],2)
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens) # type: int
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()
count = 0
a = []
for i in range(1, 891):
    tmp = str(i*2019)
    idx = s.find(tmp)
    while idx != -1:
        count += 1
        idx = s.rfind(tmp, idx+1)
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = str(input())
N = len(S)
l = 0
r = 0


follow = 0
amari = [0] * N
for i in range(N):
  Kazu = int(S[N-i-1]) * pow(10, i)
  Amari_ = (int(Kazu) + follow) % 2019
  amari[i] = Amari_
  follow = Amari_

from collections import Counter
c_ = Counter(amari)
c = c_.most_common()

ans = 0
for i in c:
  if i[1] != 0:
    ans += i[1] * (i[1]-1) // 2
  else:
    break

ans == c_[0]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    S = input().rstrip("\r\n")
    a = []
    num = 2019
    d = 1
    while num <= 200000:
        num = 2019 * d
        if num > 200000:break
        a.append(str(num))
        d += 1
    ans = set()
    for x in a:
        for i in range(0, len(S)-len(x)+1):
            if x == S[i:i+len(x)]:ans.add((i, i+len(x)))
    print(len(ans))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def main():
    s = input().rstrip()

    s_nums = list(range(len(s)+1))

    ans = 0

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=int(input())
n=len(str(s))
t=0
for j in range(n):
    j+=1
    for i in range(j):
        i+=1
        k=s
        k//=10**(n-j)
        k%=10**(j-i+1)
        print(k)
        if k==0:
            k=1
        if k%2019==0:
            t+=1
print(t)

Submission status: Wrong Answer

Solution code:
S=input()
res=0
l=len(S)
for i in range(l):
    for j in range(i+4,l+1):
        if int(S[i])%2!=0:
            continue
        t=int(S[i:j])
        if t%2019==0:
            res+=1
print(res)

Submission status: Wrong Answer

Solution code:
s=input()
slice_num=4
cnt=0
if int(s)<2019:
    print(0)
while slice_num != len(s):
    for i in range(0,len(s)-slice_num+1):
        print(int(s[i:i+slice_num]))
        if(int(s[i:i+slice_num])%2019==0):
            cnt+=1
    slice_num+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    K = set([str(i*2019) for i in range(1, 101)])
    cnt = 0
    for i in range(len(S)-4):
        if i + 3 <= len(S) - 1:
            if S[i:i+4] in K:
                cnt += 1
        if i + 4 <= len(S) - 1:
            if S[i:i+5] in K:
                cnt += 1
        if i + 5 <= len(S) - 1:
            if S[i:i+6] in K:
                cnt += 1
    print(cnt)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from operator import mul
from functools import reduce


memo = {}


def cmb(n, r):
    if n < r:
        return 0
    if (n, r) in memo:
        return memo[(n, r)]
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    memo[(n, r)] = over // under
    return over // under


s = input()[::-1]
acc = [int(s[0])]
cntr = defaultdict(int)
for i, c in enumerate(s[1:], 1):
    next_mod = (acc[-1] + pow(10, i, 2019) * int(c)) % 2019
    cntr[next_mod] += 1
    acc.append(next_mod)

ans = 0
for k, v in cntr.items():
    if k == 0:
        ans += v + cmb(v, 2)
    elif v > 1:
        ans += cmb(v, 2)
print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())

ans = 0
l=""
for i in s[::-1]:
    l = i + l
    if int(l) % 2019 == 0:
        ans += 1
        l = i

print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
ans = 0
st = 0
for i in range(0,len(N)-3):
    for j in range(i+4,i+9):
        if int(N[i:j]) % 2019 == 0:
            ans += 1
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n = 200000 // 2019
nums = [str(2019*num) for num in range(1, n+1)]

num = input()
count = 0

for _ in range(len(num)-4+1):
    s = num[_:_+4]
    if s in nums:
        count += 1

for _ in range(len(num)-5+1):
    s = num[_:_+5]
    if s in nums:
        count += 1

for _ in range(len(num)-6+1):
    s = num[_:_+6]
    if s in nums:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
s = str(input())
cnt = 0

print(s[0:13])

for i in range(len(s)-3):
    for j in range(len(s)-i+1):
        if j < 3:
            continue
        if (int(s[i:i+j]) % 2019 == 0):
            cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
S = input()
tmp = 2019
count = 0
for j in range(len(S)):
  for i in range(1,len(S)-j):
    if i+5+j > len(S)+1:
      break
    if int(S[i:i+5+j])%2019 == 0:
      count += 1
print(count)

Submission status: Wrong Answer

Solution code:
S =input()
a = len(S)
t = 0
count = 0
for i in range(3,a):
    t = int(S[i-3])*1000 + int(S[i-2])*100 + int(S[i-1])*10 + int(S[i])
    if t % 2019 == 0:
        count+=1
for i in range(4,a):
    t = int(S[i-4])*10000 + int(S[i-3])*1000 + int(S[i-2])*100 + int(S[i-1])*10 + int(S[i])
    if t % 2019 == 0:
        count+=1
for i in range(5,a):
    t = int(S[i-5])*100000 + int(S[i-4])*10000 + int(S[i-3])*1000 + int(S[i-2])*100 + int(S[i-1])*10 + int(S[i])
    if t % 2019 == 0:
        count+=1
for i in range(6,a):
    t = int(S[i-6])*1000000 + int(S[i-5])*100000 + int(S[i-4])*10000 + int(S[i-3])*1000 + int(S[i-2])*100 + int(S[i-1])*10 + int(S[i])
    if t % 2019 == 0:
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
S = input()
n = 0
cnt = 0
for i in range(1,1001):
    n += 2019
    cnt += S.count(str(n))
print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
	s = int(input())
	l = []
	length = 0
	ans = 0
	for i in range(sum(range(1,len(str(s))-2))):
		for l in range(i,len(str(s))-3):
			print(i,l)
			print(str(s)[i:(l+4)])
			if len(str(s)[i:(l+4)]) >= 4 and int(str(s)[i:(l+4)]) % 2019 == 0:
				ans += 1

	print(ans)

	

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
S=input()
length=len(S)
S=int(S)
print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ret)

Submission status: Wrong Answer

Solution code:
S = input()
# S = '2019000'

baisu = [str(2019 * m) for m in range(1, 10)]

cnt = 0
for b in baisu:
    # 開始位置
    s = 0
    while True:
        # 見つけた位置
        pos = S.find(b, s)
        if pos > -1:
            # 次の開始位置を1文字後にする
            s = pos + 1
            cnt += 1

            # 見つけたら後ろに0があるかを確認する
            i = 0
            while True:
                if pos + len(b) + i < len(S) and S[pos + len(b) + i] == '0':
                    i += 1
                    cnt += 1
                else:
                    break

        else:
            break

print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    S = input()
    len_S = len(S)
    #print(S/2019)
    counter = 0
    for i in range(100):
        multiple = str(2019*i)
        len_m = len(multiple)
        for j in range(len_S - len_m + 1):
            if S[j:j+len_m] == multiple:
                counter += 1
    print(counter)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import re
look_up = [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]
s = input()
ans = 0

for ele in look_up:
    ans += (len(re.findall('(?={})'.format(ele), s)))

print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
lenN = len(N)
cnt = 0
for i in range(0,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()

baisu = list()
for i in range(1, 10**3):
    if '0' not in str(2019*i):
        baisu.append(str(2019*i))
        
count = 0
for bai in baisu:
    for i in range(len(S)):
        k = len(bai)
        try:
            if bai ==  S[i:i+k]:
                count += 1
        except:
            pass
print(count)

Submission status: Wrong Answer

Solution code:
s = list(input())

ans = 0
l=""
for i in s[::-1]:
    l = i + l
    if int(l) % 2019 == 0:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

n = len(S)
r = 0
l = 4
ans = 0
for i in range(l,n):
    while r <= n-4:
        s = int(S[r:l])
        if s % 2019 and l < n:
            l += 1
        else:
            ans += 1
            l += 4
            r += 4
            
            
print(ans)

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)
        
def count(text, part):
    return sum(text.startswith(part, i) for i in range(len(text)))

ans=0
for i in lis:
    ans+=count(s,str(i))
print(ans)

Submission status: Wrong Answer

Solution code:
baisu = [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]

S = input()
ans = 0
N = len(S)
for i in range(N-3):
    check = set([int(S[i:i+4]),int(S[i:i+5]),int(S[i:i+6])])
    for j in check:
        if j % 2019 == 0:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

ans = 0
for i in range(1, 100):
    num = str(2019*i)
    for j in range(len(s)-len(num)+1):
        if num == s[j:j+len(num)]:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:

import sys


def answer(S):
    counter = 0
    length = len(S)
    j = 0
    while j+3 < length:
        for i in range(j+3,length):
            # print(S[j:i+1])
            number = int(S[j:i+1])
            if(number % 2019 == 0):
                counter+=1
                j = i
                break
        else:
            j+=1

    return counter

def main():
    S = input()
    # answer()
    print(answer(S))

if __name__ == '__main__':
   main()