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 = str(input())

bai2019 = []

ans = 0

for i in range(1,100):
    bai2019.append(2019*i)

if len(S) <= 3:
    print(0)
else:
    for i in range(len(S)-3):
        t = int(S[i:i+4])
        if t%2019 == 0:
            ans += 1
    
    if len(S) >= 5:
        for i in range(len(S)-4):
            t = int(S[i:i+5])
            if t%2019 == 0:
                ans += 1
    if len(S) >= 6:
        for i in range(len(S)-5):
            t = int(S[i:i+6])
            if t%2019 == 0:
                ans += 1

    print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0

for i in range(957):
    ans += s.count(str(2019*i))

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
lmax = len(S)
count = 0
now = lmax-2
end = lmax
if(len(S) < 4):
    print(0)
    exit()
while(now >= 0):
    #print(now, end, S[now:end])
    s = int(S[now:end])
    if(s%2019 == 0):
        count += 1
        end = now+1
    now -= 1
print(count)

Submission status: Wrong Answer

Solution code:
S=str(input())
n=0
for i in range(len(S)-3):
  m=int(S[i:len(S)])
  while len(str(m))>=4:
    if m%2019==0:
      n+=1
    a=m//10
    m-=a*10
print(n)

Submission status: Wrong Answer

Solution code:
S = input()

count = 0
for times in range(1, 101):
    num = 2019 * times
    if num > int(S): break
    num_length = len(str(num))
    for i in range(len(S) - num_length + 1):
        j = i + num_length - 1
        sub_S = int(S[i:j + 1])
        if num == sub_S:
            count += 1


print(count)

Submission status: Wrong Answer

Solution code:
s = input()

ans = 0
for i in range(len(s)-3):
    for j in range(len(s)-3):
        j += i+4
        if (j > len(s)):
            continue
        t = int(s[i:j])
        print(t)
        if ((t % 2019) == 0):
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
S = list(input())

for i in range(len(S)):
    S[i] = int(S[i])

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

from collections import  Counter

c = Counter(A)

ans = c[0]

for i in range(1,2019):
    if c[i] >= 2:
        ans += (c[i]*(c[i]-1)) //2

print(ans % mod)

Submission status: Wrong Answer

Solution code:
def count(text, part):
    return sum(text.startswith(part, i) for i in range(len(text)))

s = input()
ans = 0
for i in range(1,100):
  if str(2019*i) in s:
    ans += count(s,str(2019*i))
print(ans)

Submission status: Wrong Answer

Solution code:
def CountOccurrences(string, substring):
    count = 0
    start = 0
    while start < len(string):
        pos = string.find(substring, start)
        if pos != -1:
            start = pos + 1
            count += 1
        else:
            break
    return count
l2019=[i*2019 for i in range(1,4020)]
s=input()
cnt=0
for i in l2019:
    cnt+=CountOccurrences(s,str(i))
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
temp = []
count = 0
for i in range(len(s)):
    if int(s[i:i+5]) % 2019 == 0:
        count += 1
    #temp.append(s[i:i+5])
print(count)

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    N = len(S)
    ans = 0
    left = N-1
    right = left + 1
    T = S[left:right]
    while 0 <= left:
        v = int(T)
        v_len = len(T)
        while 0 < left and v % 2019 != 0:
            left -= 1
            val = int(S[left])
            v = v + val*10**(v_len)
            v_len += 1
        if v % 2019 == 0:
            ans += 1
        right = left + 1
        left = right - 1
        T = S[left:right]
        if left == 0 and right == 1:
            break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
S = sys.stdin.readline().rstrip()
N = len(S)
ans = 0
 
if int(S) < 2019:
    print(0)
    exit()

for i in range(N - 3):
    for k in range(4, N + 1):
        j = i + k
        if int(S[i:j]) % 2019 == 0:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

print(count)

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

print(ans)

Submission status: Wrong Answer

Solution code:
print(1)

Submission status: Wrong Answer

Solution code:
s=input()
num=0
l=len(s)
for i in range(l-4):
    for j in range(i+4,l):
        x=int(s[i:j+1])%2019
        num+=1-int(x==0)
print(num)

Submission status: Wrong Answer

Solution code:
def CountOccurrences(string, substring):
    count = 0
    start = 0
    while start < len(string):
        pos = string.find(substring, start)
        if pos != -1:
            start = pos + 1
            count += 1
        else:
            break
    return count
l2019=[i*2019 for i in range(1,2020)]
s=input()
cnt=0
for i in l2019:
    cnt+=CountOccurrences(s,str(i))
print(cnt)

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, 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, 203919, 205938, 207957, 209976, 211995, 214014, 216033, 218052, 220071, 222090, 224109, 226128, 228147, 230166, 232185, 234204, 236223, 238242, 240261, 242280, 244299, 246318, 248337, 250356, 252375, 254394, 256413, 258432, 260451, 262470, 264489, 266508, 268527, 270546, 272565, 274584, 276603, 278622, 280641, 282660, 284679, 286698, 288717, 290736, 292755, 294774, 296793, 298812, 300831, 302850, 304869, 306888, 308907, 310926, 312945, 314964, 316983, 319002, 321021, 323040, 325059, 327078, 329097, 331116, 333135, 335154, 337173, 339192, 341211, 343230, 345249, 347268, 349287, 351306, 353325, 355344, 357363, 359382, 361401, 363420, 365439, 367458, 369477, 371496, 373515, 375534, 377553, 379572, 381591, 383610, 385629, 387648, 389667, 391686, 393705, 395724, 397743, 399762, 401781, 403800, 405819, 407838, 409857, 411876, 413895, 415914, 417933, 419952, 421971, 423990, 426009, 428028, 430047, 432066, 434085, 436104, 438123, 440142, 442161, 444180, 446199, 448218, 450237, 452256, 454275, 456294, 458313, 460332, 462351, 464370, 466389, 468408, 470427, 472446, 474465, 476484, 478503, 480522, 482541, 484560, 486579, 488598, 490617, 492636, 494655, 496674, 498693, 500712, 502731, 504750, 506769, 508788, 510807, 512826, 514845, 516864, 518883, 520902, 522921, 524940, 526959, 528978, 530997, 533016, 535035, 537054, 539073, 541092, 543111, 545130, 547149, 549168, 551187, 553206, 555225, 557244, 559263, 561282, 563301, 565320, 567339, 569358, 571377, 573396, 575415, 577434, 579453, 581472, 583491, 585510, 587529, 589548, 591567, 593586, 595605, 597624, 599643, 601662, 603681, 605700, 607719, 609738, 611757, 613776, 615795, 617814, 619833, 621852, 623871, 625890, 627909, 629928, 631947, 633966, 635985, 638004, 640023, 642042, 644061, 646080, 648099, 650118, 652137, 654156, 656175, 658194, 660213, 662232, 664251, 666270, 668289, 670308, 672327, 674346, 676365, 678384, 680403, 682422, 684441, 686460, 688479, 690498, 692517, 694536, 696555, 698574, 700593, 702612, 704631, 706650, 708669, 710688, 712707, 714726, 716745, 718764, 720783, 722802, 724821, 726840, 728859, 730878, 732897, 734916, 736935, 738954, 740973, 742992, 745011, 747030, 749049, 751068, 753087, 755106, 757125, 759144, 761163, 763182, 765201, 767220, 769239, 771258, 773277, 775296, 777315, 779334, 781353, 783372, 785391, 787410, 789429, 791448, 793467, 795486, 797505, 799524, 801543, 803562, 805581, 807600, 809619, 811638, 813657, 815676, 817695, 819714, 821733, 823752, 825771, 827790, 829809, 831828, 833847, 835866, 837885, 839904, 841923, 843942, 845961, 847980, 849999, 852018, 854037, 856056, 858075, 860094, 862113, 864132, 866151, 868170, 870189, 872208, 874227, 876246, 878265, 880284, 882303, 884322, 886341, 888360, 890379, 892398, 894417, 896436, 898455, 900474, 902493, 904512, 906531, 908550, 910569, 912588, 914607, 916626, 918645, 920664, 922683, 924702, 926721, 928740, 930759, 932778, 934797, 936816, 938835, 940854, 942873, 944892, 946911, 948930, 950949, 952968, 954987, 957006, 959025, 961044, 963063, 965082, 967101, 969120, 971139, 973158, 975177, 977196, 979215, 981234, 983253, 985272, 987291, 989310, 991329, 993348, 995367, 997386, 999405, 1001424, 1003443, 1005462, 1007481, 1009500, 1011519, 1013538, 1015557, 1017576, 1019595, 1021614, 1023633, 1025652, 1027671, 1029690, 1031709, 1033728, 1035747, 1037766, 1039785, 1041804, 1043823, 1045842, 1047861, 1049880, 1051899, 1053918, 1055937, 1057956, 1059975, 1061994, 1064013, 1066032, 1068051, 1070070, 1072089, 1074108, 1076127, 1078146, 1080165, 1082184, 1084203, 1086222, 1088241, 1090260, 1092279, 1094298, 1096317, 1098336, 1100355, 1102374, 1104393, 1106412, 1108431, 1110450, 1112469, 1114488, 1116507, 1118526, 1120545, 1122564, 1124583, 1126602, 1128621, 1130640, 1132659, 1134678, 1136697, 1138716, 1140735, 1142754, 1144773, 1146792, 1148811, 1150830, 1152849, 1154868,
           1156887, 1158906, 1160925, 1162944, 1164963, 1166982, 1169001, 1171020, 1173039, 1175058, 1177077, 1179096, 1181115, 1183134, 1185153, 1187172, 1189191, 1191210, 1193229, 1195248, 1197267, 1199286, 1201305, 1203324, 1205343, 1207362, 1209381, 1211400, 1213419, 1215438, 1217457, 1219476, 1221495, 1223514, 1225533, 1227552, 1229571, 1231590, 1233609, 1235628, 1237647, 1239666, 1241685, 1243704, 1245723, 1247742, 1249761, 1251780, 1253799, 1255818, 1257837, 1259856, 1261875, 1263894, 1265913, 1267932, 1269951, 1271970, 1273989, 1276008, 1278027, 1280046, 1282065, 1284084, 1286103, 1288122, 1290141, 1292160, 1294179, 1296198, 1298217, 1300236, 1302255, 1304274, 1306293, 1308312, 1310331, 1312350, 1314369, 1316388, 1318407, 1320426, 1322445, 1324464, 1326483, 1328502, 1330521, 1332540, 1334559, 1336578, 1338597, 1340616, 1342635, 1344654, 1346673, 1348692, 1350711, 1352730, 1354749, 1356768, 1358787, 1360806, 1362825, 1364844, 1366863, 1368882, 1370901, 1372920, 1374939, 1376958, 1378977, 1380996, 1383015, 1385034, 1387053, 1389072, 1391091, 1393110, 1395129, 1397148, 1399167, 1401186, 1403205, 1405224, 1407243, 1409262, 1411281, 1413300, 1415319, 1417338, 1419357, 1421376, 1423395, 1425414, 1427433, 1429452, 1431471, 1433490, 1435509, 1437528, 1439547, 1441566, 1443585, 1445604, 1447623, 1449642, 1451661, 1453680, 1455699, 1457718, 1459737, 1461756, 1463775, 1465794, 1467813, 1469832, 1471851, 1473870, 1475889, 1477908, 1479927, 1481946, 1483965, 1485984, 1488003, 1490022, 1492041, 1494060, 1496079, 1498098, 1500117, 1502136, 1504155, 1506174, 1508193, 1510212, 1512231, 1514250, 1516269, 1518288, 1520307, 1522326, 1524345, 1526364, 1528383, 1530402, 1532421, 1534440, 1536459, 1538478, 1540497, 1542516, 1544535, 1546554, 1548573, 1550592, 1552611, 1554630, 1556649, 1558668, 1560687, 1562706, 1564725, 1566744, 1568763, 1570782, 1572801, 1574820, 1576839, 1578858, 1580877, 1582896, 1584915, 1586934, 1588953, 1590972, 1592991, 1595010, 1597029, 1599048, 1601067, 1603086, 1605105, 1607124, 1609143, 1611162, 1613181, 1615200, 1617219, 1619238, 1621257, 1623276, 1625295, 1627314, 1629333, 1631352, 1633371, 1635390, 1637409, 1639428, 1641447, 1643466, 1645485, 1647504, 1649523, 1651542, 1653561, 1655580, 1657599, 1659618, 1661637, 1663656, 1665675, 1667694, 1669713, 1671732, 1673751, 1675770, 1677789, 1679808, 1681827, 1683846, 1685865, 1687884, 1689903, 1691922, 1693941, 1695960, 1697979, 1699998, 1702017, 1704036, 1706055, 1708074, 1710093, 1712112, 1714131, 1716150, 1718169, 1720188, 1722207, 1724226, 1726245, 1728264, 1730283, 1732302, 1734321, 1736340, 1738359, 1740378, 1742397, 1744416, 1746435, 1748454, 1750473, 1752492, 1754511, 1756530, 1758549, 1760568, 1762587, 1764606, 1766625, 1768644, 1770663, 1772682, 1774701, 1776720, 1778739, 1780758, 1782777, 1784796, 1786815, 1788834, 1790853, 1792872, 1794891, 1796910, 1798929, 1800948, 1802967, 1804986, 1807005, 1809024, 1811043, 1813062, 1815081, 1817100, 1819119, 1821138, 1823157, 1825176, 1827195, 1829214, 1831233, 1833252, 1835271, 1837290, 1839309, 1841328, 1843347, 1845366, 1847385, 1849404, 1851423, 1853442, 1855461, 1857480, 1859499, 1861518, 1863537, 1865556, 1867575, 1869594, 1871613, 1873632, 1875651, 1877670, 1879689, 1881708, 1883727, 1885746, 1887765, 1889784, 1891803, 1893822, 1895841, 1897860, 1899879, 1901898, 1903917, 1905936, 1907955, 1909974, 1911993, 1914012, 1916031, 1918050, 1920069, 1922088, 1924107, 1926126, 1928145, 1930164, 1932183, 1934202, 1936221, 1938240, 1940259, 1942278, 1944297, 1946316, 1948335, 1950354, 1952373, 1954392, 1956411, 1958430, 1960449, 1962468, 1964487, 1966506, 1968525, 1970544, 1972563, 1974582, 1976601, 1978620, 1980639, 1982658, 1984677, 1986696, 1988715, 1990734, 1992753, 1994772, 1996791, 1998810, 2000829, 2002848, 2004867, 2006886, 2008905, 2010924, 2012943, 2014962, 2016981, 2019000]


s = input()
ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
import collections

S = list(map(int, list(input())))[::-1]
S = [(S[i] * pow(10, i, 2019)) % 2019 for i in range(len(S))]
for i in range(1, len(S)):
    S[i] = (S[i] + S[i-1]) % 2019 

C = collections.Counter(S)
ans = 0
for x in C.keys():
    if x == 0:
        ans += C[0]
    else:
        ans += C[x] - 1
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

tar = 0
num = 0
for i in range(1,101) :
  tar = 2019 * i
  if tar > int(S) :
    break
  tar_cnt = len(str(tar))
  for j in range(len(S)-tar_cnt+1) :
    #print('{}:{}'.format(j,tar_cnt))

    if S[j:j+tar_cnt] == str(tar):
  	  num += 1
  	  #print('{}:{} {}'.format(j,j+tar_cnt,S[j:j+tar_cnt]))
  	  #print(j)
  	  #print(len(str(tar))+1)

print(num)

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:
    miss = 0
    i = 4
    j_copy = j
    while True:
        if s[j_copy - i:j_copy] in hash:
            cnt+=1
            j_copy-=i
            i = 4
        else:
            i+=1
        if i > 8 or j_copy - i < 0:
            break
    j -= 1
    if j_copy < 4:
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
s = str(input())
if int(s) < 2019:
    print(0)
else:    
#4桁事
    count = 0
    for i in range(len(s)-3):
        num = s[i] + s[i+1] + s[i+2] + s[i+3]
        if int(num) % 2019 == 0:
            count += 1
    
    for i in range(len(s) - 4):
        num = s[i] + s[i+1] + s[i+2] + s[i+3] + s[i + 4]
        if int(num) % 2019 == 0:
            count += 1

    for i in range(len(s) -5):

        num = s[i] + s[i+1] + s[i+2] + s[i+3] + s[i + 4] + s[i + 5]
        if int(num) % 2019 == 0:
            count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)
total = 0

for i in range(l - 1):
    for j in range(i+1, l+1):
        if int(s[i:j]) % 2019 == 0:
            total += 1
            print(s[i:j])

print(total)

Submission status: Wrong Answer

Solution code:
a = input()
b = len(a)

total = 0
for i in range(b-3):
    for j in range(b-i-3):
        s = int(a[i:(j+i+4)])
        print(s)
        if s % 2019 == 0:
            total += 1

print(total)

Submission status: Wrong Answer

Solution code:
S = input()

count = 0
for times in range(1, 101):
    num = 2019 * times
    num_length = len(str(num))
    for i in range(len(S) - num_length + 1):
        j = i + num_length - 1
        sub_S = int(S[i:j + 1])
        if num == sub_S:
            count += 1


print(count)

Submission status: Wrong Answer

Solution code:
s = input()
counter = 0
for i in range(3, len(s)+1):
    for j in range(len(s)-i+1):
        if s[j+i-1] == '1' or s[j+i-1] == '9':
            continue
        num = int(s[j:j + i])
        if num % 2019 == 0:
            counter += 1
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(int(input())//2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = list(input())

for i in range(len(S)):
    S[i] = int(S[i])

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

from collections import  Counter

c = Counter(A)

ans = c[0]

for i in range(1,2019):
    if c[i] >= 2:
        ans += (c[i]*(c[i]-1)) //2

print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    str = input("")
    count = 0;
    for i in range(len(str) - 1):
        for j in range(i + 4, len(str) -1):
            if eval(str[i:j]) % 2019 == 0:
                count += 1
    print(count)

    return
solve()

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(len(num)) < 2019:
        return
    if int(num) % 2019 == 0:
        ans += 1
    else:
        if j < len(s):
            rec(i,j+1,num+s[j])
        if len(num) >= 2:
            rec(i+1,j,num[1::])

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

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    answer = 0
    length = len(s)
    index = [[] for _ in range(10)]
    for i in range(length):
        index[int(s[i])].append(i)
    for i in range(1, 110):
        now = str(i * 2019)
        now_length = len(str(now))
        for j in index[int(now[0])]:
            if now == s[j:j + now_length]:
                answer += 1
    print(answer)


if __name__ == '__main__':
    main()

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)

    maxd = 1
    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)
        maxd = max(maxd,d)

    res = 0

    for d in range(1,maxd+1):
        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:
def main():
    s = input()

    len_s = len(s)

    if len_s <=3:
        print(0)
        exit()
    
    count = 0
    skip_num = 0

    for i in range(0,len_s-3):
        if skip_num > 0:
            skip_num -= 1
            continue
        for j in range(i+3,len_s):
            if int(s[i:j+1]) % 2019 == 0:
                count += 1
                skip_num = j - i - 1
                break

    print(count)

if __name__ == '__main__':
    main()

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, 211995, 226128, 228147, 232185, 236223, 238242, 244299, 246318, 248337, 252375, 254394, 256413, 258432, 264489, 268527, 272565, 274584, 278622, 284679, 286698, 288717, 292755, 294774, 296793, 298812, 312945, 314964, 316983, 331116, 333135, 335154, 337173, 339192, 341211, 345249, 347268, 349287, 353325, 355344, 357363, 359382, 365439, 367458, 369477, 371496, 373515, 375534, 377553, 379572, 381591, 385629, 387648, 389667, 391686, 395724, 397743, 399762, 411876, 413895, 415914, 417933, 419952, 421971, 438123, 442161, 446199, 448218, 452256, 454275, 456294, 458313, 462351, 466389, 472446, 474465, 476484, 482541, 486579, 488598, 492636, 494655, 496674, 498693, 512826, 514845, 516864, 518883, 522921, 526959, 528978, 543111, 547149, 549168, 551187, 555225, 557244, 559263, 561282, 567339, 569358, 571377, 573396, 575415, 577434, 579453, 581472, 583491, 587529, 589548, 591567, 593586, 597624, 599643, 611757, 613776, 615795, 617814, 619833, 621852, 623871, 629928, 631947, 633966, 635985, 652137, 654156, 656175, 658194, 662232, 664251, 668289, 672327, 674346, 676365, 678384, 682422, 684441, 688479, 692517, 694536, 696555, 698574, 714726, 716745, 718764, 724821, 728859, 732897, 734916, 736935, 738954, 742992, 757125, 759144, 761163, 763182, 769239, 771258, 773277, 775296, 777315, 779334, 781353, 783372, 785391, 789429, 791448, 793467, 795486, 799524, 811638, 813657, 815676, 817695, 819714, 821733, 823752, 825771, 831828, 833847, 835866, 837885, 841923, 843942, 845961, 849999, 862113, 864132, 866151, 874227, 876246, 878265, 884322, 886341, 892398, 894417, 896436, 898455, 912588, 916626, 918645, 922683, 926721, 932778, 934797, 936816, 938835, 942873, 944892, 946911, 952968, 954987, 971139, 973158, 975177, 977196, 979215, 981234, 983253, 985272, 987291, 991329, 993348, 995367, 997386, 1112469, 1114488, 1118526, 1122564, 1124583, 1128621, 1132659, 1134678, 1136697, 1138716, 1142754, 1144773, 1146792, 1148811, 1152849, 1154868, 1156887, 1162944, 1164963, 1166982, 1181115, 1183134, 1185153, 1187172, 1189191, 1193229, 1195248, 1197267, 1199286, 1213419, 1215438, 1217457, 1219476, 1221495, 1223514, 1225533, 1227552, 1229571, 1235628, 1237647, 1239666, 1241685, 1245723, 1247742, 1249761, 1253799, 1255818, 1257837, 1259856, 1261875, 1263894, 1265913, 1267932, 1269951, 1273989, 1288122, 1294179, 1296198, 1298217, 1314369, 1316388, 1322445, 1324464, 1326483, 1334559, 1336578, 1338597, 1342635, 1344654, 1346673, 1348692, 1354749, 1356768, 1358787, 1362825, 1364844, 1366863, 1368882, 1374939, 1376958, 1378977, 1395129, 1397148, 1399167, 1411281, 1415319, 1417338, 1419357, 1421376, 1423395, 1425414, 1427433, 1429452, 1431471, 1437528, 1439547, 1441566, 1443585, 1447623, 1449642, 1451661, 1455699, 1457718, 1459737, 1461756, 1463775, 1465794, 1467813, 1469832, 1471851, 1475889, 1479927, 1481946, 1483965, 1485984, 1512231, 1516269, 1518288, 1522326, 1524345, 1526364, 1528383, 1532421, 1536459, 1538478, 1542516, 1544535, 1546554, 1548573, 1552611, 1556649, 1558668, 1564725, 1566744, 1568763, 1576839, 1578858, 1582896, 1584915, 1586934, 1588953, 1592991, 1611162, 1613181, 1617219, 1619238, 1621257, 1623276, 1625295, 1627314, 1629333, 1631352, 1633371, 1639428, 1641447, 1643466, 1645485, 1649523, 1651542, 1653561, 1657599, 1659618, 1661637, 1663656, 1665675, 1667694, 1669713, 1671732, 1673751, 1677789, 1681827, 1683846, 1685865, 1687884, 1691922, 1693941, 1697979, 1699998, 1712112, 1714131, 1718169, 1724226, 1726245, 1728264, 1734321, 1738359, 1742397, 1744416, 1746435, 1748454, 1752492, 1754511, 1758549, 1762587, 1766625, 1768644, 1772682, 1778739, 1782777, 1784796, 1786815, 1788834, 1792872, 1794891, 1798929, 1819119, 1821138, 1823157, 1825176, 1827195, 1829214, 1831233, 1833252, 1835271, 1841328, 1843347, 1845366, 1847385, 1851423, 1853442, 1855461, 1859499, 1861518, 1863537, 1865556, 1867575, 1869594, 1871613, 1873632, 1875651, 1879689, 1883727, 1885746, 1887765, 1889784, 1893822, 1895841, 1899879, 1911993, 1926126, 1928145, 1932183, 1936221, 1942278, 1944297, 1946316, 1948335, 1952373, 1954392, 1956411, 1962468, 1964487, 1968525, 1972563, 1974582, 1982658, 1984677, 1986696, 1988715, 1992753, 1994772, 1996791]
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 numpy as np
import math
s = str(input())
n = len(s)
wa = [0 for i in range(n+1)]
for i in range(1,n+1):
    wa[i] = (wa[i-1]+int(s[i-1]))%9

ans = 0

for i in range(n):
    for j in range(i+3,n):
        if (wa[j]-wa[i])%9 == 3 or (wa[j]-wa[i])%9 == 6:
            if int(s[i:j+1])%2019 == 0:
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ll = []
for i in range(1, 200001//2019+2):
    ll.append(str(2019*i))

cnt = 0

for l in ll:
    cnt += s.count(l)

print(cnt)

Submission status: Wrong Answer

Solution code:
def multiplelist(lim):
    if lim > 200000:
        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(int(s))
    total = 0
    for cand in candidates:
        total += count(s, cand)
    print(total)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()

result = 0

if (len(s) < 4):
    print(0)
    quit()

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:
S=str(input())
S.split()
ans=0
list_2019=[]


for i in range(1,10**4):
    list_2019.append(i*2019)

for i in range(len(S)):
    for j in range(i+1,len(S)):
        s=''.join(S[i:j+1])
        if int(s) in list_2019:
            ans=ans+1
            print(i,j)
print(ans)

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):
    if str(c[i]) in s:
        ans += s.count(str(c[i]))

print(ans)

Submission status: Wrong Answer

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


def lg(x):
    ans=0
    while (x>1):
        ans+=1
        x=x//10
    return ans+1


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

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
for i in range(7,a):
    t = int(S[i-7])*10000000 + 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:
import sys
input = sys.stdin.readline

strA = str(input())

i = len(strA)
j = 4
x = 0
for start in range(i-3):
    
  for end in range(j,i+1):
      if int(strA[start:end]) % 2019 == 0:
        x = x + 1

  j += 1
print (x)

Submission status: Wrong Answer

Solution code:
S = input()
if(len(S) < 5):
    print(0)
    exit()
cnt = 0
for i in range(len(S)-4):
    if(int(S[i:i+5]) % 2019 == 0):
        cnt += 1
    if(len(S)-i >= 6 and S[i] == '1'):
        if(int(S[i:i+6]) % 2019 == 0):
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
s=str(input())
count=0
for i in range(len(s)):
    for j in range(len(s)):
        if len(s[i:j])>0:
            if int(s[i:j])%2019==0:
                count+=1
print(0 if count==0 else count+1)

Submission status: Wrong Answer

Solution code:
s = input().strip()
MOD = 2019
n = list(filter(lambda x: x != '', str(int(s) // MOD).split('0')))
if len(n) == 1:
    if int(s) % MOD == 0:
        print(1)
    else:
        print(0)
else:
    print(len(n))

Submission status: Wrong Answer

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

for i in range(n-3):
    if int(s[i:i+4]) % 2019 == 0:
        ans += 1
        
for i in range(n-4):
    if int(s[i:i+5]) % 2019 == 0:
        ans += 1
        
for i in range(n-5):
    if int(s[i:i+6]) % 2019 == 0:
        ans += 1
        
for i in range(n-6):
    if int(s[i:i+7]) % 2019 == 0:
        ans += 1
        
for i in range(n-7):
    if int(s[i:i+8]) % 2019 == 0:
        ans += 1
        
print(ans)

Submission status: Wrong Answer

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


def lg(x):
    ans=0
    while (x>1):
        ans+=1
        x=x//10
    return ans+1


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