problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02702
u202634017
2,000
1,048,576
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.
['from collections import Counter\n\ns = list(input())\nls = len(s)\nT = [0] * (ls+1)\nmodL = [0]\ncnt = 0\npad = 1\n\nfor i in reversed(range(0, ls)):\n T[i] = T[i+1] + int(s[i]) * pad\n modL.append(T[i] % 2019)\n pad = pad * 10 % 2019\n\nprint(modL)\n\nans = 0\nfor c in Counter(modL).values():\n ans += c * (c - 1) // 2\n\nprint(ans)\n', 'from collections import Counter\n\ns = list(input())\nls = len(s)\nT = [0] * (ls+1)\nmodL = [0]\ncnt = 0\npad = 1\n\nfor i in reversed(range(0, ls)):\n T[i] = T[i+1] + int(s[i]) * pad\n modL.append(T[i] % 2019)\n pad = pad * 10 % 2019\n\nans = 0\nfor c in Counter(modL).values():\n ans += c * (c - 1) // 2\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s484415120', 's932677450']
[28432.0, 26164.0]
[169.0, 156.0]
[327, 314]
p02702
u203383537
2,000
1,048,576
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.
['s=input()\ns=s[::-1]\n\nt=0\nx=1\nans=0\ncnt=[0]*2019\n\nfor i in s:\n t += int(i)*x\n t %= 2019\n x *= 10\n x %= 2019\n cnt[t]+=1\n\nfor i in cnt:\n ans +=i*(i-1)//2\n\nprint(ans) ', 's=input()\ns=s[::-1]\n\nt=0\n\nx=1\ncnt=[0]*2019\ncnt[0]=1\n\n\nfor i in s:\n t += int(i)*x\n t %= 2019\n x *= 10\n x %= 2019\n cnt[t]+=1\n\nans=0\nfor i in cnt:\n ans +=i*(i-1)//2\n\nprint(ans) ']
['Wrong Answer', 'Accepted']
['s446015540', 's350774600']
[9388.0, 9188.0]
[110.0, 115.0]
[181, 194]
p02702
u204616996
2,000
1,048,576
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.
['S=input()\nN=len(S)\nif N<4:\n print(0)\n exit(0)\nM=2019\nX=S\nans=0\nx=[]\nfor l in range(N-3):\n for r in range(l+3,N):\n if int(X[l:r+1])%M==0:\n ans+=1\n x.append([l,r])\n break\ndef search(a,x,j):\n while j<len(x):\n if a[1]==x[j][0]:\n return 1+search(x[j],x,j+1)\n j+=1\n return 0\nfor i,a in enumerate(x):\n ans+=search(a,x,i+1)\nprint(ans)\n\n\n', 'from collections import defaultdict\nd = defaultdict(int)\nS=input()\nS=S[::-1]\ni=0\nx=0\nMOD=2019\nfor s in S:\n x+=(int(s)*pow(10,i,MOD))%MOD\n x%=MOD\n d[x]+=1\n i+=1\nans=0\nfor k in d.values():\n ans=ans+k*(k-1)//2\nprint(ans+d[0])\n']
['Wrong Answer', 'Accepted']
['s118191275', 's076036810']
[9780.0, 9788.0]
[2206.0, 351.0]
[364, 228]
p02702
u207097826
2,000
1,048,576
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.
['S = input()\nmod2019 = [0]*(len(S)+1)\n\nfor i in range(len(S)-1):\n mod2019[i] = int(S[i:len(S)-1])%2019\n\nanswer = 0\ncount = [0 for _ in range(2020)]\n\n\nfor i in range(len(S)):\n answer += count[mod2019[i]]\n count[mod2019[i]] += 1\nprint(answer)', 'S = input()\nmod2019 = [0]*(len(S)+1)\n\nfor i in range(len(S)):\n mod2019[i] = int(S[i:])%2019\n\nanswer = 0\ncount = [0 for _ in range(2020)]\n\n\nfor i in range(len(S)):\n answer += count[mod2019[i]]\n count[mod2019[i]] += 1\nprint(answer)', 'S = input()\nmod2019 = [0]*len(S)\n\nfor i in range(len(S)):\n mod2019[i] = int(S[i:])%2019\n\nmod2019.extend(0)\n\nanswer = 0\ncount = [0 for _ in range(2020)]\n\n\nfor i in range(len(S)):\n answer += count[mod2019[i]]\n count[mod2019[i]] += 1\nprint(answer)', 'S = input()\nmod2019 = [0]*len(S)\n\nfor i in range(len(S)):\n mod2019[i] = int(S[i:])%2019\n\nmod2019.extend([0])\n\nanswer = 0\ncount = [0 for _ in range(2020)]\n\n\nfor i in range(len(S)):\n answer += count[mod2019[i]]\n count[mod2019[i]] += 1\nprint(answer)', 'S = input()\nmod2019 = [0]*(len(S)+1)\n\nfor i in range(len(S)):\n mod2019[i] = int(S[i:-1])%2019\n\nanswer = 0\ncount = [0 for _ in range(2020)]\n\n\nfor i in range(len(S)):\n answer += count[mod2019[i]]\n count[mod2019[i]] += 1\nprint(answer)', 'S = input()\nmod2019 = [0]*(len(S)+1)\n\nfor i in range(len(S)):\n mod2019[i] = int(S[i:len(S)-1])%2019\n\nanswer = 0\ncount = [0 for _ in range(2020)]\n\n\nfor i in range(len(S)):\n answer += count[mod2019[i]]\n count[mod2019[i]] += 1\nprint(answer)', 'S = input()\nmod2019 = [0]*len(S)\n\nmod2019[-1] = int(S[-1])\nketa_mod = 1\nfor i in range(len(S)-2,-1,-1):\n keta_mod = (keta_mod*10)%2019\n mod2019[i] = (mod2019[i+1] + int(S[i])*keta_mod)%2019\n\nmod2019.extend([0])\n\nanswer = 0\ncount = [0 for _ in range(2020)]\n\nfor i in range(len(S)+1):\n answer += count[mod2019[i]]\n count[mod2019[i]] += 1\nprint(answer)\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s101412618', 's143159531', 's272531909', 's422603238', 's514581848', 's920915497', 's470753989']
[11032.0, 10972.0, 11008.0, 10980.0, 10956.0, 11020.0, 16384.0]
[2206.0, 2206.0, 2206.0, 2206.0, 2206.0, 2206.0, 165.0]
[248, 238, 253, 255, 240, 246, 362]
p02702
u211160392
2,000
1,048,576
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.
['# 2019 = 3*673\nMOD = 2019\nS = input()\nN = len(S)\nX = [0]*2100\nX[0] += 1\ntmp = 0\nhoge = pow(10,N,2019)\n\nfor i in range(N):\n tmp = (tmp*10+int(S[i]))%MOD\n hoge = (hoge*202)%MOD \n X[(tmp*hoge)%MOD] += 1\n\nans = 0\n\nfor i in X:\n if i >= 2:\n ans += (i*i-1)\n\nprint(ans)', '# 2019 = 3*673\nMOD = 2019\nS = input()\nN = len(S)\nX = [0]*2100\nX[0] += 1\ntmp = 0\nhoge = pow(10,N,2019)\n\nfor i in range(N):\n tmp = (tmp*10+int(S[i]))%MOD\n hoge = (hoge*202)%MOD \n X[(tmp*hoge)%MOD] += 1\n\nans = 0\n\nfor i in X:\n ans += ((i*(i-1))//2)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s430590873', 's486350919']
[9372.0, 9324.0]
[122.0, 127.0]
[280, 268]
p02702
u213497190
2,000
1,048,576
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.
['from collections import Counter\n\ns = input()[::-1]\nn = len(s)\ncounts = [0] * 2019\ncounts[0] = 1\ncurrent = 0\nd = 0\n\nfor i in range(n):\n current += int(s[i]) * 10**d\n d += 1\n current %= 2019\n counts[current] += 1\n\nans = 0\nfor i, count in enumerate(counts):\n if count > 1:\n print(i)\n ans += count * (count-1) //2\nprint(ans)\n\n\n# res = [int(s[a:])%2019 for a in range(n)]\n# res.append(0)\n\n# ans = 0\n# # count = Counter(res)\n\n# # ans += (count[i] * (count[i] - 1)) // 2\n# print(ans)\n\n', 'from collections import Counter\n\ns = input()\nn = len(s)\n\nres = [int(s[a:])%2019 for a in range(n)]\nres.append(0)\n\nans = 0\n# count = Counter(res)\n\n# ans += (count[i] * (count[i] - 1)) // 2\nprint(ans)\n\n', 'from collections import Counter\n\ns = input()\nn = len(s)\n\nres = [int(s[a:])%2019 for a in range(n)] + [0]\n\nans = 0\n# count = Counter(res)\n\n# ans += (count[i] * (count[i] - 1)) // 2\nprint(ans)\n\n', 's = input()[::-1]\nn = len(s)\ncounts = [0] * 2019\ncounts[0] = 1\ncurrent = 0\nd = 1\n\nfor c in s:\n current += int(c) * d\n d *= 10\n current %= 2019\n d %= 2019\n counts[current] += 1\n\nans = 0\nfor count in counts:\n if count > 1:\n # print(i)\n ans += count * (count-1) //2\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s471764557', 's655993301', 's847325161', 's915805891']
[9696.0, 9732.0, 9844.0, 9324.0]
[2206.0, 2206.0, 2206.0, 110.0]
[536, 227, 219, 306]
p02702
u218838821
2,000
1,048,576
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.
['S = list(map(str,input()))\n\ncounter = 0\n\nfor i in range(len(S)):\n for j in range(1,len(S)-i):\n s = int("".join(S[i:i+j]))\n if s % 2019 == 0:\n counter += 1\n\nprint(counter)', 'S = list(map(int,input()))[::-1] \n\ncounter = 0\namari = [0]*2019\namari[0] = 1\n\ns,d = 0,1\n\nfor i in S:\n s += i *d\n amari[s%2019] += 1\n d *= 10\n d %= 2019\n\n\nfor i in range(2019):\n counter += amari[i] * (amari[i]-1) / 2\n\n\nprint(int(counter))']
['Wrong Answer', 'Accepted']
['s529944661', 's090343588']
[10524.0, 12024.0]
[2206.0, 104.0]
[198, 259]
p02702
u221061152
2,000
1,048,576
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.
['import collections\n\nS=input()\nS_int = int(S)\nmods_count = collections.Counter([int(S[i:])%2019 for i in range(len(S))])\ncount = 0\nfor mod in mods_count:\n c = mods_count[mod]\n if c > 1:\n count += c*(c-1)//2\nprint(count)', 'S=input()\ndp = [0]*2019\ndp[0]+=1\n\np=0\nq=1\nfor i in reversed(range(len(S)-1)):\n p = (p+int(S[i])*q)%2019\n q = q*10%2019\n dp[p]+=1\n\nc=0\nfor j in dp:\n c += j*(j-1)//2\nprint(c)', 'S=input()\n\np,q=0,1\ndp = {0:1}\nmod = 2019\n\nfor i in range(len(S)-1,-1,-1):\n p = (p+int(S[i])*q)%mod\n if p not in dp:dp[p]=0\n dp[p]+=1\n q= (q*10)%mod\n\ncnt = 0\nfor i in dp:\n cnt += dp[i]*(dp[i]-1)//2\nprint(cnt)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s423051701', 's804999684', 's880218154']
[9852.0, 9196.0, 9336.0]
[2206.0, 103.0, 133.0]
[223, 176, 212]
p02702
u227020436
2,000
1,048,576
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.
['#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n# D - Multiple of 2019\n\ns = input()\n\ncount = 0\ncounter = Counter([0])\n\nsuffix = 0\npow = 1\nfor i in range(len(s) - 1, -1, -1):\n suffix = (int(s[i]) * pow + suffix) % 2019\n pow = pow * 10 % 2019\n count += counter[suffix]\n counter[suffix] += 1\n\nprint(count)\n', '# D - Multiple of 2019\n\nfrom collections import Counter\n\ns = input()\n\ncount = 0\ncounter = Counter([0])\n\nsuffix = 0\npow = 1\nfor i in range(len(s) - 1, -1, -1):\n suffix = (int(s[i]) * pow + suffix) % 2019\n pow = pow * 10 % 2019\n count += counter[suffix]\n counter[suffix] += 1\n\nprint(count)\n']
['Runtime Error', 'Accepted']
['s657845054', 's354040062']
[9284.0, 9676.0]
[21.0, 169.0]
[315, 300]
p02702
u237299453
2,000
1,048,576
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.
['s = [int(a) for a in input()[::-1]]\n\nm = 2019\nn = len(S)\n\nf = 0\n\np = 1\n\nX = [0] * 2019\n\nX[0] = 1\n\nq = 0\n\nfor a in S:\n f = (f + a * p) % m\n q += X[f]\n \n X[s] += 1\n \n p = p * 10 % m\n \n\nprint(q)', 'n =input()\n\n\ndef judge(x):\n \n if x % 2019 == 0:\n return(1)\n else:\n return(0)\n\na = 0\nfor i in range(1,len(n)):\n for j in range(i, len(n)):\n s = n[i:j]\n d = int("s")\n a = a + judge(d)\n \nprint(a)\n ', 'S = [int(a) for a in input()[::-1]]\nm = 2019\nN = len(S)\ns = 0\np = 1\nX = [0] * 2019\nX[0] = 1\nans = 0\nfor a in S:\n s = (s + a * p) % m\n ans += X[s]\n X[s] += 1\n p = p * 10 % m\n \nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s042740142', 's841309715', 's478482712']
[10840.0, 9256.0, 10832.0]
[48.0, 20.0, 123.0]
[209, 219, 197]
p02702
u237327356
2,000
1,048,576
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.
['s = list(input())\nn = len(s)\nmod = 2019\n\nd=[0]*(n+1)\nk=1\nfor i in range(n):\n d[i+1]=d[i]+k*int(s[n-i-1])\n d[i+1]%=mod\n k*=10\n k%=mod\n\ncount = [0]*mod\nfor i in range(n+1):\n count[d[i]] += 1\n\nans = 0\nfor i in range(mod):\n c = count[i]\n ans += c*(c-1) / 2\n\nprint(ans)\n', 's = list(input())\nn = len(s)\nmod = 2019\n\nd=[0]*(n+1)\nk=1\nfor i in range(n):\n d[i+1]=d[i]+k*int(s[n-i-1])\n d[i+1]%=mod\n k*=10\n k%=mod\n\ncount = [0]*mod\nfor i in range(n+1):\n count[d[i]] += 1\n\nans = 0\nfor i in range(mod):\n c = count[i]\n ans += c*(c-1) // 2\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s563578576', 's804562328']
[17712.0, 17800.0]
[177.0, 176.0]
[286, 287]
p02702
u243312682
2,000
1,048,576
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.
["def main():\n s = input()\n s_len = len(s)\n s_rev = reversed(s)\n mod = 2019\n d = [0] * mod\n d[0] = 1\n rev_num = 0\n \n for i in range(l_len):\n rev_num += int(s_rev(i)) * (10**i%mod)\n rev_num %= mod\n d[rev_num] += 1\n \n \n print(sum(i*(i-1)//2 for i in d))\n\nif __name__ == '__main__':\n main()", 'def main():\n def modpow(x, n, mod):\n res = 1\n while n:\n if n % 2:\n res *= x % mod\n x *= x % mod\n n >>= 1\n return res\n\n s = input()\n s = s[::-1]\n s_len = len(s)\n mod = 2019\n d = [0] * mod\n d[0] = 1\n rev_num = 0\n \n for i in range(s_len):\n rev_num += int(s[i]) * int(modpow(10, i, mod))\n rev_num %= mod\n d[rev_num] += 1\n \n \n print(sum(i*(i-1)//2 for i in d))\n ', "def main():\n def modpow(x, n, mod):\n res = 1\n while n:\n if n % 2:\n res *= x % mod\n x *= x % mod\n n >>= 1\n return res\n\n s = input()\n s = s[::-1]\n s_len = len(s)\n mod = 2019\n d = [0] * mod\n d[0] = 1\n rev_num = 0\n \n for i in range(s_len):\n rev_num += int(s[i]) * int(modpow(10, i, mod))\n rev_num %= mod\n d[rev_num] += 1\n \n \n print(sum(i*(i-1)//2 for i in d))\n \nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s661372458', 's788806363', 's506641422']
[9164.0, 9128.0, 9336.0]
[21.0, 27.0, 859.0]
[501, 642, 680]
p02702
u249218427
2,000
1,048,576
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.
['# -*- coding: utf-8 -*-\nS = input()\nprint(len(S))\ndict_amari = {}\ncount = 0\n\nhenkan = {i: [(10*j+i)%2019 for j in range(2019)] for i in range(1,10)}\n\ndef amari_new(dict_amari, s, henkan):\n dict_amari_new = {henkan[k] : v for k,v in dict_amari.items()}\n if s in dict_amari_new.keys():\n dict_amari_new[s] += 1\n else:\n dict_amari_new[s] = 1\n return dict_amari_new\n\nfor s in S:\n dict_amari = amari_new(dict_amari, int(s), henkan[int(s)])\n if 0 in dict_amari.keys():\n count += dict_amari[0]\n\nprint(count)', '# -*- coding: utf-8 -*-\nS = input()\ncount = 0\nlist_amari = [0 for i in range(2019)]\namari_prev = 0\nX = 1\n\nfor i in range(len(S)):\n amari = (int(S[-i-1])*X+amari_prev)%2019\n list_amari[amari] += 1\n amari_prev = amari\n X = (10*X)%2019\n\nfor v in list_amari:\n count += v*(v-1)//2\n\nprint(count)', '# -*- coding: utf-8 -*-\nS = input()\nlist_amari = [0 for i in range(2019)]\namari_prev = 0\nX = 1\n\nfor i in range(len(S)):\n amari = (int(S[-i-1])*X+amari_prev)%2019\n list_amari[amari] += 1\n amari_prev = amari\n X = (10*X)%2019\n\ncount = list_amari[0]\nfor v in list_amari:\n count += v*(v-1)//2\n\nprint(count)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s117835949', 's751774107', 's220249421']
[9992.0, 9192.0, 9120.0]
[2206.0, 122.0, 123.0]
[514, 294, 306]
p02702
u250664216
2,000
1,048,576
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.
['s = input()\ncount = 0\nleft = -1\nright = 4\nfor i in range(len(s)-4):\n for j in range(i+4,len(s)):\n if int(s[i:j]) % 2019 == 0:\n left = i\n right = j\n break\n\nif left >= 0:\n while right <= len(s):\n if int(s[left:right]) % 2019 == 0:\n # print(s[left:right])\n count += 1\n left = right - 1\n right = left + 4\n else:\n right += 1\nprint(count)', 'mods = [0]*2019\nmods[0] = 1\ns = input()\nt = 0\nu = 1\nfor i in range(1,len(s)+1):\n t = (t + int(s[-i])*u)%2019\n u = u*10%2019\n mods[t] += 1\n\n\ncnt = 0\nfor x in mods:\n if x >= 2:\n cnt += x*(x-1)/2\nprint(int(cnt))']
['Wrong Answer', 'Accepted']
['s939870334', 's196272898']
[9312.0, 8908.0]
[2206.0, 110.0]
[447, 227]
p02702
u250828304
2,000
1,048,576
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.
['S = input()\n\np = 2019\nN = len(S)\nt = [0]*(N+1)\nfor i in range(N-1,-1,-1):\n k = (int(S[i]) * pow(10,N-i-1,p))%p\n t[i] = (t[i+1]+k)%p\nt= t[:N]\ncnt = [0]*p\nfor i in range(N):\n cnt[t[i]]+=1 \nans = 0\nfor i in range(p):\n m = cnt[i]\n ans += (m*(m-1))\nprint(ans)', 'S = input()\n\np = 7\nN = len(S)\nt = [0]*(N+1)\nfor i in range(N-1,-1,-1):\n k = (int(S[i]) * pow(10,N-i-1,p))%p\n t[i] = (t[i+1]+k)%p\nt= t[:N]\ncnt = [0]*p\nfor i in range(N):\n cnt[t[i]]+=1 \nans = 0\nfor i in range(p):\n m = cnt[i]\n if i == 0:\n ans = 1 + (m*(m-1))//2\n else:\n ans += (m*(m-1))//2\nprint(ans)', 'S = input()\n\np = 2019\nN = len(S)\nt = [0]*(N+1)\nfor i in range(N-1,-1,-1):\n k = (int(S[i]) * pow(10,N-i-1,p))%p\n t[i] = (t[i+1]+k)%p\nt= t[:N]\ncnt = [0]*p\nfor i in range(N):\n cnt[t[i]]+=1 \nans = cnt[0]\nfor i in range(1,p):\n m = cnt[i]\n ans += (m*(m-1))//2\nprint(ans+1)', 'S = input()\n\np = 2019\nN = len(S)\nt = [0]*(N+1)\nfor i in range(N-1,-1,-1):\n k = (int(S[i]) * pow(10,N-i-1,p))%p\n t[i] = (t[i+1]+k)%p\nt= t[:N]\ncnt = [0]*p\nfor i in range(N):\n cnt[t[i]]+=1 \nans = cnt[0]\nfor i in rxange(1,p):\n m = cnt[i]\n ans += (m*(m-1))//2\nprint(ans)', 'S = input()\n\np = 2019\nN = len(S)\nt = [0]*(N+1)\nfor i in range(N-1,-1,-1):\n k = (int(S[i]) * pow(10,N-i-1,p))%p\n t[i] = (t[i+1]+k)%p\nt= t[:N]\ncnt = [0]*p\nfor i in range(N):\n cnt[t[i]]+=1\nans = 0\nfor i in range(p):\n m = cnt[i]\n if i == 0 and m > 0:\n ans += (m*(m+1))//2\n else:\n ans += (m*(m-1))//2\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s214479087', 's383797916', 's782314210', 's928940373', 's905942410']
[17872.0, 12224.0, 17772.0, 18052.0, 17892.0]
[382.0, 289.0, 384.0, 379.0, 384.0]
[259, 309, 271, 270, 319]
p02702
u253389610
2,000
1,048,576
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.
['import numpy as np\n\n\ndef count_multi(s, d):\n m = a = np.array([c for c in s]).astype(np.int)\n keta = 1\n count = np.count_nonzero(m == 0)\n while len(m) > 1:\n m = (m[:-1]*10 + a[keta:]) % d\n keta += 1\n count += np.count_nonzero(m == 0)\n return count\n \nprint(count_multi(input().strip()*2000, 2019))\n', 'import numpy as np\n\n\ndef count_multi(s, d):\n a = np.array([c for c in s]).astype(np.int)\n m = a % d\n keta = 1\n count = np.count_nonzero(m == 0)\n while len(m) > 1:\n m = (10*m[:-1] + a[keta:]) % d\n keta += 1\n count += np.count_nonzero(m == 0)\n return count\n \nprint(count_multi(input().strip(), 2019))\n', 'import numpy as np\n\n\ndef count_multi(s, d):\n a = np.array([int(c) for c in s], dtype=np.uint16)\n \n m = a\n # s not include 0\n count = 0\n while len(m) > 1:\n a = a[1:]\n m = (m[:-1]*10 + a) % d\n count += np.count_nonzero(m == 0)\n return count\n\nprint(count_multi(input().strip(), 2019)\n ', 'def main():\n mod = 2019\n count = [0] * 2019\n count[0] = 1\n s = input().strip()\n digit = 1\n current = 0\n for c in s[::-1]:\n current = (current + int(c) * digit) % mod\n count[current] += 1\n digit = digit * 10 % mod\n return sum([n * (n - 1) // 2 for n in count if n > 1])\n\n\nprint(main())\n']
['Wrong Answer', 'Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s078090754', 's294496935', 's317043580', 's901242774']
[1114456.0, 33624.0, 8956.0, 9364.0]
[2232.0, 2207.0, 23.0, 78.0]
[318, 321, 319, 330]
p02702
u266014018
2,000
1,048,576
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.
["# import sys \n# import os\n# import numpy as np\n# path = os.path.join(os.getcwd(),'input.txt')\n# input = open(path).readline\n\nS = input()\ncand = np.zeros(2019,dtype=int)\nans = 0\nrem = 0\nfor i,s in enumerate(S[::-1]):\n rem += int(s)*(10**i)\n rem %= 2019\n cand[rem] +=1\nans = cand[0]\ncand = cand[cand>1]\nfor c in cand:\n ans += c*(c-1)/2\nprint(int(ans))", "# import sys \n# import os\n# path = os.path.join(os.getcwd(),'input.txt')\n# input = open(path).readline\n\nimport numpy as np\nS = input()\ncand = np.zeros(2019,dtype=int)\nrem = 0\norder = 1\nmod = 2019\nfor s in S[::-1]:\n rem += (int(s)*order)%mod\n rem %= mod\n cand[rem] +=1\n order *= 10\n order %=mod\nans = cand[0]\ncand = cand[cand>1]\nfor c in cand:\n ans += c*(c-1)/2\nprint(int(ans))"]
['Runtime Error', 'Accepted']
['s445194823', 's513356595']
[9192.0, 27324.0]
[21.0, 284.0]
[361, 394]
p02702
u267718666
2,000
1,048,576
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.
['S = input()\nP = [0 for _ in range(len(S)+1)]\nmod = 2019\nd = 1\nfor i in range(len(S), 0, -1):\n P[i-1] = int(S[i-1])*d + P[i]\n P[i-1] = P[i-1] % mod\n d *= 10\n\nfor p in P:\n A[p] += 1\n\nans = 0\nfor a in A:\n ans += a*(a-1)//2\nprint(ans)', 'from collections import Counter\nS = input()\nP = [0] * (len(S)+1)\nmod = 2019\nd = 1\nfor i in range(len(S), 0, -1):\n P[i-1] = int(S[i-1])*d + P[i]\n P[i-1] = P[i-1] % mod\n d *= 10\n d = d % mod\n\nP = Counter(P)\nans = 0\nfor p in P.values():\n ans += p*(p-1)//2\nprint(ans)']
['Runtime Error', 'Accepted']
['s279374302', 's896318555']
[12528.0, 16544.0]
[2206.0, 164.0]
[245, 278]
p02702
u268210555
2,000
1,048,576
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.
['import numpy as np\ns = input()\ny = 2019\ndp = np.zeros(y, dtype="int64")\ntmp = np.zeros(y, dtype="int64")\nk = 1\nr = 0\nfor c in s[::-1]:\n i = int(c)*k%y\n tmp[i:] = dp[:y-i]\n tmp[:i] = dp[-i:]\n tmp[i] += 1\n dp, tmp = tmp, dp\n r += dp[0]\n k *= 10\n k %= y\nprint(r) 1', 'from collections import *\ns = input()\np = 2019\nc = Counter()\nc[0] += 1\nv = r = 0\nk = 1\nfor i in s[::-1]:\n v += int(i)*k\n v %= p\n r += c[v]\n c[v] += 1\n k *= 10\n k %= p\nprint(r)']
['Runtime Error', 'Accepted']
['s908305475', 's678176123']
[8956.0, 9932.0]
[20.0, 175.0]
[285, 193]
p02702
u268318377
2,000
1,048,576
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.
['from collections import Counter\n\nS = [int(s) for s in input()]\ny = 2019\nT = [S[-1]] * len(S)\n\nfor i in range(len(S)-2, -1, -1):\n T[i] = (T[i+1] + S[i] * 10) % y\n\ncnt = 0\nfor c in Counter(T).values():\n cnt += c * (c - 1) // 2\n \nprint(cnt)', 'from queue import deque\n\n\nS = deque(input())\nmod = 2019\nT = [0] * mod\nT[0] = 1\na, b = 0, 1\n\nfor _ in range(len(S)):\n s = int(S.pop())\n a = a + s * b\n a = a % mod\n T[a] += 1\n b = b * 10\n b = b % mod\n \nprint(sum((i * (i - 1) // 2 for i in T)))']
['Wrong Answer', 'Accepted']
['s419301522', 's574065642']
[18148.0, 11152.0]
[109.0, 135.0]
[240, 262]
p02702
u272336707
2,000
1,048,576
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.
['s = str(input())\nL = len(s)\ndict = {}\nfor i in range(L):\n amari = s[i:] % 2019\n if not(amari in dict.keys()):\n dict[amari] = 1\n else:\n dict[amari] += 1\nans = 0\nfor key in dict.keys():\n ans += (dict[amari]*(dict[amari]-1))/2\nprint(ans)', 's = str(input())\nL = len(s)\ndict = {}\nfor i in range(L):\n amari = (int(s[i:])*(10**i)) % 2019\n if not(amari in dict.keys()):\n dict[amari] = 1\n else:\n dict[amari] += 1\ndict[0] += 1\nans = 0\nfor key in dict.keys():\n ans += (dict[key]*(dict[key]-1))/2\nprint(int(ans))', 's = str(input())\nL = len(s)\ndict = {}\nfor i in range(L):\n amari = (int(s[i:])*(10**i)) % 2019\n if not(amari in dict.keys()):\n dict[amari] = 1\n else:\n dict[amari] += 1\nif not(0 in dict.keys()):\n dict[0] = 1\nelse:\n dict[0] += 1\nans = 0\nfor key in dict.keys():\n ans += (dict[key]*(dict[key]-1))/2\nprint(int(ans))', 's = str(input())\nL = len(s)\ndict = {}\nfor i in range(L):\n amari = (int(s[i:])*(10**i)) % 2019\n if not(amari in dict.keys()):\n dict[amari] = 1\n else:\n dict[amari] += 1\nans = 0\nfor key in dict.keys():\n ans += (dict[key]*(dict[key]-1))/2\nprint(int(ans))', 's = str(input())\nL = len(s)\ndict = {}\nfor i in range(L):\n amari = int(s[i:]) % 2019\n if not(amari in dict.keys()):\n dict[amari] = 1\n else:\n dict[amari] += 1\nans = 0\nfor key in dict.keys():\n ans += (dict[key]*(dict[key]-1))/2\nprint(int(ans))', 's = str(input())\nL = len(s)\ndict = {}\nfor i in range(L-1):\n amari = int(s[i:]) % 2019\n if not(amari in dict.keys()):\n dict[amari] = 1\n else:\n dict[amari] += 1\nans = 0\nfor key in dict.keys():\n ans += (dict[key]*(dict[key]-1))/2\nprint(int(ans))', 's = str(input())\nL = len(s)\ndict = [0] * 2019\ndict[0] += 1\nnum = 0\nfor i in range(L-1, (-1), (-1)):\n num += (int(s[i]) * pow(10,(L-i-1), 2019))%2019\n amari = num % 2019\n dict[amari] += 1\nans = 0\nfor j in range(2019):\n ans += (dict[j]*(dict[j]-1))/2\nprint(int(ans))']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s035910473', 's528597778', 's617250648', 's661029809', 's725015932', 's970068220', 's652186413']
[9280.0, 9424.0, 9424.0, 9568.0, 9540.0, 9428.0, 9276.0]
[23.0, 2206.0, 2206.0, 2206.0, 2206.0, 2206.0, 336.0]
[244, 273, 325, 260, 250, 252, 276]
p02702
u281796054
2,000
1,048,576
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.
['s_inv = str(input())[::-1]\ndp = [1]+[0]*2018\nans = 0\nnum = 0\nk = 1 \nfor i in range(len(s_inv)):\n num+=int(s_inv[i])*k % 2019\n dp[num] += 1\n k = k*10 % 2019\nfor i in dp:\n ans += i*(i-1)/2', 'S=int(input())\nm=S//2019\nans=0\nbaisu=[]\nfor i in range(m):\n baisu.append(2019*(i+1))\nfor num in basiu:\n if num in str(S):\n ans += 1\nprint(ans)', 's_inv = str(input())[::-1]\ndp = [1]+[0]*2018\nMOD = 0\nk = 1\nans = 0\n\nfor i in range(len(s_inv)):\n MOD += s_inv[i]*k%2019\n dp[MOD] += 1\n k*10\n\nfor i in dp:\n ans += i(i-1)/2\n\nprint(ans)', 's_inv = str(input())[::-1]\ndp = [1]+[0]*2018\nMOD = 0\nans = 0\nnum = 0\nk = 1\n\nfor i in range(len(s_inv)):\n num+=int(s_inv[i])*k\n MOD = num % 2019\n dp[MOD] += 1\n k = k*10\n k %= 2019\nfor i in dp:\n ans += i*(i-1)/2\n\nprint(int(ans))\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s104062495', 's474919999', 's554934268', 's507219198']
[9396.0, 617096.0, 9260.0, 9288.0]
[22.0, 2226.0, 23.0, 117.0]
[190, 147, 186, 233]
p02702
u289162337
2,000
1,048,576
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.
['s = input()\na = int(s)\nmods = [a%2019]\nfor i in range(len(s)):\n a = int((a-int(s[-(i+1)]))/10)\n mods.append(a%2019)\nmod_N ={}\nfor i in mods:\n if not i in mod_N:\n mod_N[i] = 1\n else:\n mod_N[i] += 1\nans = 0\nfor i in mod_N:\n ans += int(mod_N[i]*(mod_N[i]-1)/2)\nprint(ans)', 's = input()\na = int(s)\nmod_N = [0]*2019\nmod_N[a%2019] += 1\nfor i in range(len(s)):\n a = a-int(s[i])*10**(len(s)-i-1)\n mod_N[a%2019] += 1\nans = 0\nfor i in mod_N:\n ans += mod_N[i]*(mod_N[i]-1)//2\nprint(ans)\n', 's = input()\na = int(s)%2019\nmod_N = [0]*2019\nmod_N[a] += 1\nr = 10**(len(s)-1)\nfor i in s:\n a = (a-int(i)*10**d)%2019\n d = d//10\n mod_N[a] += 1\nans = 0\nfor i in mod_N:\n ans += i*(i-1)//2\nprint(ans)', 's = input()\na = int(s)%2019\nmods = [0]*2019\nmods[a] += 1\nd = 10**(len(s)-1)\nfor i in s:\n a = (a-int(i)*d)%2019\n d = d//10%2019\n mods[a] += 1\nans = 0\nfor i in mods:\n ans += i*(i-1)//2\nprint(ans)', 's = input()\na = int(s)%2019\nmod_N = [0]*2019\nmod_N[a] += 1\nr = 10**(len(s)-1)\nfor i in range(len(s)):\n a = (a-int(s[i])*10**r)%2019\n r = r//10\n mod_N[a] += 1\nans = 0\nfor i in mod_N:\n ans += i*(i-1)//2\nprint(ans)', 's = input()\na = int(s)\nmod_N = [0]*2019\nmod_N[a%2019] += 1\nfor i in range(len(s)):\n a = a-int(s[i])*10**(len(s)-i-1)\n mod_N[a%2019] = 1\nans = 0\nfor i in mod_N:\n ans += mod_N[i]*(mod_N[i]-1)//2\nprint(ans)\n', 's = input()\na = int(s)%2019\nmod_N = [0]*2019\nmod_N[a] += 1\nr = 10**(len(s)-1)\nfor i in range(len(s)):\n a = (a-int(s[i])*10**d)%2019\n d = d//10\n mod_N[a] += 1\nans = 0\nfor i in mod_N:\n ans += i*(i-1)//2\nprint(ans)', 's = input()\na = int(s)\nmods = [a%2019]\nfor i in range(len(s)):\n a = int((a-int(s[-(i+1)]))10)\n mods.append(a%2019)\nmod_N ={}\nfor i in mods:\n if not i in mod_N:\n mod_N[i] = 0\n else:\n mod_N[i] += 1\nans = 0\nfor i in mod_N:\n ans += int(i*(i-1)/2)\nprint(ans)', 's = input()\na = int(s)%2019\nmod_N = [0]*2019\nmod_N[a] += 1\nr = 10**(len(s)-1)\nfor i in s:\n a = (a-int(i)*10**r)%2019\n r = r//10\n mod_N[a] += 1\nans = 0\nfor i in mod_N:\n ans += i*(i-1)//2\nprint(ans)', 'S = input()\nans = 0\nfor i in range(6, int(S)//2019 + 1):\n d = str(2019*i)\n ans += S.count(d)\nprint(ans)\n', 's = input()\na = int(s)\nmods = [a%2019]\nfor i in range(len(s)):\n a = int((a-int(s[-(i+1)]))/10)\n mods.append(a%2019)\nmod_N ={}\nfor i in mods:\n if not i in mod_N:\n mod_N[i] = 0\n else:\n mod_N[i] += 1\nans = 0\nfor i in mod_N:\n ans += int(mod_N[i]*(mod_N[i]-1)/2)\nprint(ans)', 'S = input()\nans = 0\nfor i in range(int(S)//2019 + 1):\n d = str(2019*i)\n ans += S.count(d)\nprint(ans)', 'S = input()\nans = 0\nfor i in range(6, int(S)//2019 + 1):\n d = str(2019*i)\n if "0" in d:\n continue\n ans += S.count(d)\nprint(ans)\n', 's = input()\na = int(s)%2019\nmods = [0]*2019\nmods[a] += 1\nd = 10**(len(s)-1)\nfor i in s:\n a = (a-int(i)*d)%2019\n d = d//10%2019\n mods[a] += 1\nans = 0\nfor i in mods:\n ans += i*(i-1)//2\nprint(ans)', 's = input()\na = 0\nmods = [0]*2019\nmods[a] += 1\nr = 1\nfor i in s[::-1]:\n a = (a+int(i)*r)%2019\n r = r*10%2019\n mods[a] += 1\nans = 0\nfor i in mods:\n ans += i*(i-1)//2\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s039084854', 's069585952', 's079432441', 's162692479', 's183063486', 's220030418', 's262904883', 's373012543', 's495253903', 's497325731', 's623762633', 's733519563', 's734692058', 's940146620', 's952004213']
[9212.0, 9652.0, 9376.0, 9300.0, 19232.0, 9580.0, 9368.0, 9032.0, 19400.0, 9600.0, 9284.0, 9492.0, 9496.0, 9428.0, 9352.0]
[205.0, 2206.0, 222.0, 293.0, 2206.0, 2206.0, 217.0, 21.0, 2206.0, 2205.0, 204.0, 2205.0, 2206.0, 295.0, 101.0]
[279, 208, 200, 197, 215, 207, 215, 264, 200, 106, 279, 102, 134, 197, 179]
p02702
u293436958
2,000
1,048,576
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.
['import collections\n\nS = list(input())\na=[int(x) for x in S] \na.reverse()\nprint(a)\n\nn=len(a)\nT=[0]*n\n\nT[0]=a[0]\n\nfor i in range(1,n):\n T[i]=T[i-1]+(a[i]*10**i)\n \n\n\nprint(T)\nL=list()\nfor i in range(n):\n L.append(T[i]%2019)\n \n\nprint(L)\nc = collections.Counter(L)\n\n\nprint(int(len([i[0] for i in c.items() if i[1] >= 2])) + int(len([i for i in L if i==0])))', 'S = list(input())\na=[int(x) for x in S] \na.reverse()\n#print(a)\nl=[0]*2019\nl[0]=1\nT=0\nd=1\n\nfor i in a:\n T+=(int(i)*d)\n T%=2019\n l[T]+=1\n d*=10\n d%=2019\nresult=0\nfor n in l:\n result+=n*(n-1)/2\nprint(int(result))']
['Wrong Answer', 'Accepted']
['s295040214', 's059730962']
[89108.0, 12348.0]
[2209.0, 128.0]
[457, 255]
p02702
u296557772
2,000
1,048,576
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.
['from collections import defaultdict\n\ndef count_substring(s):\n found_remainder = defaultdict(int)\n current_mod = 0\n found_remainder[0] = 1\n\n output = 0\n for i in range(len(s)-1,-1,-1):\n digit = s[i]\n current_mod = (int(digit)*10**(len(s)-1-i) % 2019 + current_mod) % 2019\n print(i, current_mod)\n output += found_remainder[current_mod]\n found_remainder[current_mod] += 1\n\n return output\n\ns = input()\nprint(count_substring(s))\n', 'from collections import defaultdict\n\ndef get_modulos():\n modulos = []\n for i in range(224):\n modulos.append(10**i%2019)\n return modulos\n\ndef count_substring(s):\n found_remainder = defaultdict(int)\n current_mod = 0\n found_remainder[0] = 1\n\n output = 0\n\n modulos = get_modulos()\n for i in range(len(s)-1,-1,-1):\n digit = s[i]\n current_mod = (int(digit)*modulos[(len(s)-1-i)%224] % 2019 + current_mod) % 2019\n \n output += found_remainder[current_mod]\n found_remainder[current_mod] += 1\n print(dict(found_remainder))\n\n return output\n\ns = input()\nprint(count_substring(s))', 'from collections import defaultdict\n\ndef main():\n s = input()\n \n current_mod = 0\n output = 0\n found_remainder = defaultdict(int)\n for i, digit in enumerate(s):\n current_mod = (current_mod*10 + int(digit)) % 2019\n output += found_remainder[current_mod]\n found_remainder[current_mod] += 1\n return output', 'from collections import defaultdict\n\ndef get_modulos():\n modulos = []\n for i in range(224):\n modulos.append(10**i%2019)\n return modulos\n\ndef count_substring(s):\n found_remainder = defaultdict(int)\n current_mod = 0\n found_remainder[0] = 1\n\n output = 0\n\n modulos = get_modulos()\n for i in range(len(s)-1,-1,-1):\n digit = s[i]\n current_mod = (int(digit)*modulos[(len(s)-1-i)%224] % 2019 + current_mod) % 2019\n \n output += found_remainder[current_mod]\n found_remainder[current_mod] += 1\n #print(dict(found_remainder))\n\n return output\n\ns = input()\nprint(count_substring(s))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s247196076', 's362971122', 's850828895', 's200731286']
[9920.0, 9608.0, 9356.0, 9576.0]
[2206.0, 127.0, 22.0, 124.0]
[478, 666, 317, 667]
p02702
u297667660
2,000
1,048,576
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.
['S = input()\nN = len(S)\nc\nount = 0\nfor i in range(N):\n for j in range(i,N):\n if int(S[i:j+1]) % 2019 == 0:\n count = count + 1\n else:\n continue\nprint(count)', 'S = input()[::-1]\nN = len(S)\nl = [0]*2019\nl[0] = 1\nn = 0\nd = 1\n\nfor i in range(N):\n n += int(S[i]) * d\n r = n % 2019\n l[r] += 1\n d = 10*d % 2019\n \nout = 0 \nfor m in l:\n out += (m*(m-1))//2 \nprint(out)']
['Runtime Error', 'Accepted']
['s020550262', 's908215703']
[9236.0, 9336.0]
[24.0, 118.0]
[193, 221]
p02702
u306950978
2,000
1,048,576
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.
['s = list(input())\np = [0 for i in range(2019)]\nn = len(s)\nans = 0\nkar = 0\nfor i in range(n):\n kar = kar + int(s[n-1-i])*10**i\n p[kar%2019] += 1\n\nfor i in p:\n ans += i*(i-1)//2\nprint(ans)', 's = list(input())\np = [0 for i in range(2019)]\nn = len(s)\nans = 0\nkar = 0\ndig = 1\nfor i in range(n):\n kar = (kar + int(s[n-1-i])*dig)%2019\n dig = (dig*10)%2019\n p[kar] += 1\n\nfor i in range(2019):\n ans += p[i]*(p[i]-1)//2\n if i == 0:\n ans += p[i]\nprint(ans)']
['Wrong Answer', 'Accepted']
['s584129684', 's656617387']
[10644.0, 10416.0]
[2206.0, 121.0]
[195, 278]
p02702
u307516601
2,000
1,048,576
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.
['import sys\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline\nS = input()\n\nres = 0\nstart = 0\nmin_length = 4\nend = start+min_length\nmax_end = len(S)\n\nwhile True:\n tmp_s = S[start:end]\n \n if int(tmp_s) % 2019 == 0:\n print(tmp_s)\n res += 1\n \n if end+1 <= max_end:\n end += 1\n elif end-(start+1) >= min_length:\n start += 1\n end = start + min_length\n else:\n break\n \nprint(res)', 's = input()[::-1] \n\nsum_of_digits = 0 \ncnts = [0] * 2019 ごとに余りが同じ値の数を格納する変数。2019で割る場合、余りは0~2018までの2019通りあるので、リストの長さは2019\ncnts[0] = 1 \nd = 1 \n\n\nfor c in s:\n sum_of_digits += int(c) * d\n sum_of_digits %= 2019\n d *= 10\n\n cnts[sum_of_digits] += 1\n\n\nans = 0\nfor cnt in cnts:\n ans += cnt * (cnt - 1) // 2\n\nprint(ans)', 's = input()[::-1] \n\nsum_of_digits = 0 \ncnts = [0] * 2019 ごとに余りが同じ値の数を格納する変数。2019で割る場合、余りは0~2018までの2019通りあるので、リストの長さは2019\ncnts[0] = 1 \nd = 1 \n\n\nfor c in s:\n sum_of_digits += int(c) * d\n sum_of_digits %= 2019\n d *= 10\n\n cnts[sum_of_digits] += 1\n\n\nans = 0\nfor cnt in cnts:\n ans += cnt * (cnt - 1) / 2\n\nprint(ans)', 's = input()[::-1]\n\nsum_of_digits = 0\n\ncnts = [0] * 2019\n\ncnts[0] = 1\n\nd = 1\n\nfor c in s:\n sum_of_digits += int(c) * d\n sum_of_digits %= 2019\n d *= 10\n d %= 2019\n cnts[sum_of_digits] += 1\n\nans = 0\n \nfor cnt in cnts:\n ans += cnt * (cnt - 1) // 2\n\nprint(ans)\n']
['Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s342900507', 's566507672', 's998130143', 's919962313']
[12164.0, 9312.0, 9436.0, 9364.0]
[2348.0, 2206.0, 2206.0, 114.0]
[406, 1067, 1066, 277]
p02702
u307622233
2,000
1,048,576
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.
['s_len = len(s)\nref = [0] * s_len\n\nfor i in range(1, s_len + 1):\n ref[-i] = int(s[-i]) * pow(10, i, MOD) % MOD\n\nfor i in range(1, s_len):\n ref[-i - 1] += ref[-i]\n ref[-i - 1] %= MOD\n\nref_cnt = Counter(ref)\nans = sum(ref_cnt.values()) - len(ref_cnt)\n\n\nfor i in ref_cnt.values():\n ans += (i - 1) * (i - 2) // 2\n\nif 0 in ref:\n ans += ref_cnt[0]\n\nprint(ans)', 'from collections import Counter\ns = input()\nMOD = 2019\n\ns_len = len(s)\nref = [0] * s_len\n\nfor i in range(1, s_len + 1):\n ref[-i] = int(s[-i]) * pow(10, i, MOD) % MOD\n\nfor i in range(1, s_len):\n ref[-i - 1] += ref[-i]\n ref[-i - 1] %= MOD\n\nref_cnt = Counter(ref)\nans = sum(ref_cnt.values()) - len(ref_cnt)\n\n\nfor i in ref_cnt.values():\n ans += (i - 1) * (i - 2) // 2\n\nif 0 in ref:\n ans += ref_cnt[0]\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s160967276', 's184776786']
[9056.0, 16748.0]
[24.0, 411.0]
[367, 423]
p02702
u312695001
2,000
1,048,576
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.
['def main():\n S = list(input())\n N = len(S)\n ans = 0\n m = 2019\n div_list = [0]*m\n div_list[0] += 1\n num = 0\n print(N)\n for i in range(N):\n num += 10**i*int(S[N-i-1])\n div_list[num%m] += 1\n\n for item in div_list:\n ans += int(item*(item-1)/2)\n\n print(ans)\n\nif __name__ == "__main__":\n main()\n\n', 'from sys import stdin\ninput = stdin.readline\n\ndef main():\n S = list(input())\n S.pop()\n m = 2019\n div_list = [0]*m\n num = 0\n for i, l in enumerate(reversed(S)):\n num += pow(10, i, m)*int(l)\n div_list[num%m] += 1\n\n div_list[0] += 1\n ans = 0\n for item in div_list:\n ans += int(item*(item-1)/2)\n\n print(ans)\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s984948059', 's042978994']
[10496.0, 10564.0]
[2208.0, 301.0]
[347, 394]
p02702
u325956328
2,000
1,048,576
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.
['import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\ndef main():\n A = input()[::-1]\n A = "0" + A\n # lis_num = [int(s) for s in A]\n\n # print(lis_num)\n\n # S = [0] * len(lis_num)\n S = [0] * len(A)\n cnt = [0] * 2019\n cnt[0] = 1\n\n for i in range(len(A) - 1):\n S[i + 1] = S[i] + int(A[i + 1]) * pow(10, i)\n cnt[S[i + 1] % 2019] += 1\n\n # print(S)\n\n\n \n # cnt[i % 2019] += 1\n\n ans = 0\n\n for i in range(2019):\n ans += cnt[i] * (cnt[i] - 1) // 2\n\n print(ans)\n \nif __name__ == \'__main__\':\n main()\n', 'def main():\n A = input()[::-1]\n A = "0" + A\n # lis_num = [int(s) for s in A]\n\n # print(lis_num)\n\n # S = [0] * len(lis_num)\n S = [0] * len(A)\n cnt = [0] * 2019\n cnt[0] = 1\n\n for i in range(len(A) - 1):\n S[i + 1] = (S[i] + int(A[i + 1]) * pow(10, i, 2019)) % 2019\n cnt[S[i + 1] % 2019] += 1\n\n # print(S)\n\n \n # cnt[i % 2019] += 1\n\n ans = 0\n\n for i in cnt:\n ans += i * (i - 1) // 2\n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s685816414', 's809740343']
[10556.0, 16328.0]
[21.0, 329.0]
[590, 514]
p02702
u331997680
2,000
1,048,576
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.
['def main():\n n, d, mods = 0, 1, [1]+[0]*2019\n for i in reversed(input()):\n n = (n+int(i)*d)%2019\n d = d*10\n mods[n] += 1\n print(n,d)\n print(sum([i*(i-1)//2 for i in mods]))\nmain()\n', "S = list(input())\nP = 0\nfor i in range(len(S)-4):\n for j in range(i+5,len(S)+1):\n M = ''.join(S[i:j])\n N = int(M)\n print(N)\n if N%2019 == 0:\n P += 1\nprint(P)", 'def main():\n n, d, mods = 0, 1, [1]+[0]*2019\n for i in reversed(input()):\n n = (n+int(i)*d)%2019\n d = d*10%2019\n mods[n] += 1\n print(sum([i*(i-1)//2 for i in mods]))\nmain()']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s620558216', 's769250267', 's750120060']
[33424.0, 27480.0, 9308.0]
[2263.0, 2300.0, 82.0]
[195, 199, 184]
p02702
u346812984
2,000
1,048,576
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.
['import sys\nimport numpy as np\n\nsys.setrecursionlimit(10 ** 6)\nINF = float("inf")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n S = list(input())\n N = len(S)\n\n val = [0] * (2019)\n tenfactor = 1\n cur = 0\n for i in range(N):\n cur = (cur + int(S[N - i - 1]) * tenfactor) % 2019\n tenfactor = (tenfactor * 10) % 2019\n val[cur] += 1\n\n ans = 0\n for p in range(2019):\n ans += val[p] * (val[p] - 1) // 2\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\nimport numpy as np\n\nsys.setrecursionlimit(10 ** 6)\nINF = float("inf")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n S = list(input())\n N = len(S)\n\n val = [0] * (2019)\n tenfactor = 1\n cur = 0\n val[cur] += 1\n for i in range(N):\n cur = (cur + int(S[N - i - 1]) * tenfactor) % 2019\n tenfactor = (tenfactor * 10) % 2019\n val[cur] += 1\n\n ans = 0\n for p in range(2019):\n ans += val[p] * (val[p] - 1) // 2\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s858342623', 's703249750']
[28632.0, 28520.0]
[181.0, 184.0]
[543, 561]
p02702
u347600233
2,000
1,048,576
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.
['s = input()\ncnt = 0\nfor l in range(len(s)):\n r = l + 4\n while r < len(s) and int(s[l:r]) % 2019 != 0:\n r += 1\n if int(s[l:r]) % 2019 == 0:\n cnt += 1\n print(l, r, s[l:r])\nprint(cnt) ', 's = input()\ncnt = 0\nfor l in range(len(s)):\n r = l + 1\n while r < len(s) and int(s[l:r]) % 2019 != 0:\n r += 1\n if int(s[l:r]) % 2019 == 0:\n cnt += 1\n print(i, j, s[i:j])\nprint(cnt) ', 'M = 2019\ns = input()\ntot, ten, ans = 0, 1, 0\ncnt = [0] * M\nfor si in s[::-1]:\n cnt[tot] += 1\n tot += int(si) * ten\n tot %= M\n ans += cnt[tot]\n ten *= 10\n ten %= M\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s175272851', 's386872792', 's513722124']
[9408.0, 9272.0, 9212.0]
[2206.0, 25.0, 135.0]
[217, 217, 191]
p02702
u350248178
2,000
1,048,576
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.
['s=input()\nm=len(s)\nif n<2019:\n print(0)\n exit()\nfrom collections import Counter\nc=Counter()\ntmp=""\nc[0]+=1\nfor i in s[::-1]:\n tmp=i+tmp\n c[int(tmp)%2019]+=1\n\nll=c.most_common()\nans=0\nfor i,j in ll:\n if j>=2:\n ans+=j*(j-1)//2\n else:\n break\nprint(ans)\n', 's=[int(j) for j in input()][::-1]\nc=[0]*2019\ntmp=0\nc[0]+=1\nt=1\nimport numpy as np\nfor i in s:\n tmp+=t*i\n c[tmp%2019]+=1\n t=t*10%2019\nc=np.array(c)\nans=c*(c-1)//2\nprint(ans.sum())']
['Runtime Error', 'Accepted']
['s496256527', 's081533039']
[9276.0, 27896.0]
[23.0, 195.0]
[282, 187]
p02702
u364862909
2,000
1,048,576
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.
['S=input()\nmem_mod = [0 for i in range(0,2019,1)]\nN = len(S)\ncounter = 0\nS_num_tmp = list(S)\nS_num = list(map(int, S_num_tmp))', 'S=input()\nmem_mod = [0 for i in range(0,2019,1)]\nN = len(S)\ncounter = 0\nS_num_tmp = list(S)\nS_num = list(map(int, S_num_tmp))\ntmp=10\nfor i in range(1,N,1):\n S_num[N-i-1] = S_num[N-i] + (tmp)*S_num[N-i-1]\n tmp=tmp*10', 'import collections\np = 2019\ns=input()\nn=len(s)\narr=[int(s[i]) for i in range(len(s))] \nif p==2 or p==5: \n ans=0\n for i in range(n):\n if arr[i]%p==0:\n ans+=i+1\n print(ans)\nelse: \n dic=collections.defaultdict(int)\n tmp=0\n for i in range(n-1,-1,-1): \n tmp+=arr[i]*pow(10,n-1-i,p)\n tmp%=p\n dic[tmp]+=1\n ans=0\n rem=0 \n for i in range(n-1,-1,-1):\n ans+=dic[rem]\n rem+=arr[i]*pow(10,n-1-i,p) \n rem%=p\n dic[rem]-=1 \n print(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s308597425', 's561860217', 's378057338']
[12524.0, 1965576.0, 11216.0]
[42.0, 2254.0, 669.0]
[125, 221, 922]
p02702
u365838886
2,000
1,048,576
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.
['S = str(input())\nN = len(S)\nb = [0] * 2019\ncount = 0\nb[0] = 1\nt = 0\nk = 1\n\nif len(S) < 4:\n print(0)\nelse:\n t = int(S[-1])\n b[t] += 1\n for i in range(1,N):\n k = k * 10 % 2019\n t = (k * int(S[-i-1]) + t) % 2019 \n b[t] += 1\n\nfor i in b:\n count += i*(i-1)//2', 'S = str(input())\nN = len(S)\nb = [0] * 2019\ncount = 0\nb[0] = 1\nt = 0\nk = 1\n\nif len(S) < 4:\n print(0)\nelse:\n t = int(S[-1])\n b[t] += 1\n for i in range(1,N):\n k = k * 10 % 2019\n t = (k * int(S[-i-1]) + t) % 2019 \n b[t] += 1\n\n for i in b:\n count += i*(i-1)//2\n\n print(count)']
['Wrong Answer', 'Accepted']
['s993235923', 's895905371']
[9268.0, 9168.0]
[125.0, 122.0]
[290, 316]
p02702
u366963613
2,000
1,048,576
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.
["# -*- coding: utf-8 -*-\ns = input()\n# K = [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,\n# 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]\nK = ['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',\n '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']\ncount = 0\nfor i, k in enumerate(K):\n num = s.count(k)\n # print(i, num)\n count += num\n\nprint(count)\n", '# -*- coding: utf-8 -*-\ns = input()\nmods = [0]*2019\nmods[0] += 1\n\n# value = int(s[i:])\n# mods[value % 2019] += 1\nbase = 1\nvalue = 0\nfor c in map(int, reversed(s)):\n value += (c*base) % 2019\n base = (base * 10) % 2019\n # value = int(s[i:])\n mods[value % 2019] += 1\nprint(sum([mod*(mod-1)//2 for mod in mods]))\n']
['Wrong Answer', 'Accepted']
['s523879016', 's908499331']
[9400.0, 9124.0]
[46.0, 101.0]
[1844, 354]
p02702
u367965715
2,000
1,048,576
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.
["import numpy as np\n\ns = input()\n\na = np.zeros(len(s)+1, dtype='i8')\nres = 0\nfor i in range(len(s)):\n for k in range(i+4, len(s)+1):\n if int(s[i:k]) % 2019 == 0:\n print(i, k)\n res += a[i] + 1\n a[k] += 1\n break\n\nprint(res)\n", 's = input()[::-1]\n\nres = 0\ncnt = {0: 1}\nnow = 0\np = 1\nfor i in range(len(s)):\n now = (now + int(s[i]) * p) % 2019\n res += cnt.get(now, 0)\n p = (p * 10) % 2019\n cnt[now] = cnt.get(now, 0) + 1\n\nprint(res)\n']
['Wrong Answer', 'Accepted']
['s445479761', 's692918198']
[27172.0, 9468.0]
[2206.0, 153.0]
[275, 215]
p02702
u374531474
2,000
1,048,576
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.
["S = input()\n\nL = len(S)\nd = 1\nM = 0\nans = 0\nwhile d <= 10 ** 100:\n if '0' in str(d):\n d *= 2019\n continue\n ds = str(d)\n l = len(ds)\n for i in range(L - l):\n if S[i:i + l] == ds:\n ans += 1\n d *= 2019\nprint(ans)\n", 'S = list(map(int, list(input()[::-1])))\n\nN = len(S)\nP = 2019\nC = [0] * P\nB = 1\nt = 0\nans = 0\nfor i in range(N):\n C[t] += 1\n t = (t + S[i] * B) % P\n ans += C[t]\n B = B * 10 % P\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s001192253', 's355842684']
[9156.0, 12320.0]
[97.0, 126.0]
[257, 199]
p02702
u374671031
2,000
1,048,576
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.
['S = input()\n\nN = len(S)\n\nans = 0\nfor i in range(5,N+1):\n for j in range(0,N-i+1):\n Si = S[j:j+i]\n if int(Si) % 2019 == 0:\n ans += 1\n print(Si)\n\nprint(ans)', 'S = input()\ncounts =[0] * 2019\ncounts[0] = 1\nnum, d = 0,1\n\nfor s in S[::-1]:\n num += int(s) *d\n d *= 10\n num %= 2019\n d %= 2019\n counts[num] += 1\n\nans = 0\nfor count in counts:\n ans += count * (count - 1) //2\nprint(ans)']
['Wrong Answer', 'Accepted']
['s281346602', 's162780490']
[9436.0, 9272.0]
[2214.0, 109.0]
[171, 224]
p02702
u375253797
2,000
1,048,576
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.
["N = int(input())\nNN =str(N)\n\nq = N // 2019\n\nprint(q)\n\ndic = {}\n\nfor num in range(1,q+1):\n keta = len(str(2019*num))\n if str(keta) in dic:\n dic[str(keta)].append(str(2019*num).split())\n else:\n dic[str(keta)] = list(str(2019*num).split())\n\nresult = 0\n\nfor num, s in enumerate(NN):\n if s in ('2', '4', '6', '8'):\n for key in dic:\n keta = int(key)\n if NN[num: num+keta+1] in dic[key]:\n result += 1\n\n\nprint(result)\n", 'A = input()\n\nS = 0\nlis = [0] * 2019\nlis[0] += 1\nl = len(A)+1\nd = 1\n\nfor n in reversed(A):\n S += int(n)*d\n S %= 2019\n lis[S] += 1\n d *= 10\n d %= 2019\n\nresult = 0\n\nfor n in lis:\n result += (n*(n-1)//2)\n\n\nprint(result)\n']
['Wrong Answer', 'Accepted']
['s393678901', 's686080285']
[306300.0, 9200.0]
[2216.0, 112.0]
[480, 234]
p02702
u375616706
2,000
1,048,576
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.
['from collections import defaultdict\nS = input()\nN = len(S)\n\nD=defaultdict(int)\nprev=0\nans=0\nfor i,s in enumerate(reversed(S)):\n cur=prev+pow(10,i,2019)*int(s)%2019\n ans+=D[cur]\n D[cur]+=1\n prev=cur\nprint(ans)\n', 'from collections import defaultdict\nS = input()\nN = len(S)\n\nD=defaultdict()\nprev=0\nans=0\nfor i,s in enumerate(reversed(S)):\n cur=prev+pow(10,i,2019)*int(s)%2019\n ans+=D[cur]\n D[cur]+=1\n prev=cur\nprint(ans)\n', 'from collections import defaultdict\nS = input()\nN = len(S)\n\nD=defaultdict(int)\nD[0]=1\nans=0\nprev=0\n\nfor i,s in enumerate(reversed(S)):\n cur=(prev+pow(10,i,2019)*int(s))%2019\n ans+=D[cur]\n D[cur]+=1\n prev=cur\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s226800013', 's599149483', 's402334955']
[30360.0, 9640.0, 9584.0]
[397.0, 25.0, 370.0]
[221, 218, 231]
p02702
u379716238
2,000
1,048,576
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.
['S = input()\nans = 0\nj = 4\ns = 0\nwhile j < len(S)+1:\n for i in range(s, j-3):\n if int(S[i:j]) % 2019 == 0:\n ans += 1\n j += 4\n s += 4\n j += 1\nprint(ans)', 'S = input()\nmod_bucket = [0] * 2019\nmod_bucket[0] = 1\n \n_S = S[::-1]\nmod = 0\np = 1\nfor i in range(len(S)):\n mod = (p * int(_S[i]) + mod) % 2019\n mod_bucket[mod] += 1\n p = p*10%2019\n\nans = sum([mod*(mod-1)/2 for mod in mod_bucket])\nprint(int(ans))']
['Wrong Answer', 'Accepted']
['s819591142', 's288962474']
[9380.0, 9332.0]
[2206.0, 105.0]
[196, 255]
p02702
u382407432
2,000
1,048,576
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.
['N = input()\ncount=0\nfor i in range(len(N)+1):\n for j in range(i+1,len(N)+1):\n if(int(N[i:j])%3==0):\n continue\n if(int(N[i:j])%673==0):\n count+=1\n\nprint(count)', 'from collections import Counter\nN = input()\nS=0\nmod_count=[0]\nans=0\ni=0\nfor X in N[::-1]:\n S = int(X)*pow(10,i,2019) % 2019\n S=mod_count[i]+S\n mod_count.append(S%2019)\n i+=1\n\nc = Counter(mod_count)\nans = sum(Y * (Y-1)/2 for Y in c.values())\nprint(int(ans))']
['Wrong Answer', 'Accepted']
['s819025020', 's734999776']
[9172.0, 16920.0]
[2206.0, 353.0]
[175, 260]
p02702
u384124931
2,000
1,048,576
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.
['s = input()\nl = len(s)\nans = 0\nfor i in range(l):\n for j in range(i+1, l+1):\n a =int(s[i:j]) % 10**9+7 \n if a % 2019 % 10**9+7 == 0:\n ans +=1\nprint(ans)', 's=input()[::-1]\nans=0\nu=0\nd=1\nl=[0]*2019\nl[0]=1\nfor i in map(int,s):\n u=u+(i*d)%2019\n l[u]+=1\n d=d*10%2019\nfor i in l:\n ans+=i*(i-1)//2\nprint(ans)\n', 's=input()[::-1]\nans=0\nu=0\nd=1\nl=[0]*2019\nl[0]=1\nfor i in map(int,s):\n u=(u+i*d%2019)\n l[u]+=1\n d=d*10%2019\nfor i in l:\n ans+=i*(i-1)//2\nprint(ans)\n', 's=input()[::-1]\nans=0\nu=0\nd=1\nl=[0]*2019\nl[0]=1\nfor i in map(int,s):\n u=(u+(i*d)%2019)%2019\n l[u]+=1\n d=d*10%2019\nfor i in l:\n ans+=i*(i-1)//2\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s230876708', 's597194326', 's781443421', 's945950694']
[9256.0, 9312.0, 9256.0, 9368.0]
[2205.0, 23.0, 20.0, 102.0]
[164, 151, 151, 158]
p02702
u385649291
2,000
1,048,576
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.
['def main():\n S = list(map(str,input().rstrip()))\n l = len(S)\n result=0 \n \n for i in range(l):\n for j in range(1,l-i+1):\n print(S[i,i+j+1])\n n = int("".join(map(str, St)))\n print(S)\n if n %2019==0:\n result+=1\n print(result)\n \nif __name__ == "__main__":\n main() \n ', '# coding: utf-8\n# Your code here!\ndef main():\n from functools import reduce\n import collections\n \n S = list(map(int,input().rstrip()))\n N=len(S)\n mod_list = [0]\n for i in range(1,N+1):\n new1 =pow(10,i-1,2019)\n new = (new1*S[-i]+mod_list[-1])%2019\n print(new)\n mod_list.append(new)\n \n count = collections.Counter(mod_list)\n ans =0\n for j in range(2019):\n n = count[j]\n ans+= n*(n-1)/2\n print(int(ans))\nif __name__ == "__main__":\n main()', '# coding: utf-8\n# Your code here!\ndef main():\n from functools import reduce\n import collections\n \n S = list(map(int,input().rstrip()))\n N=len(S)\n mod_list = [0]\n for i in range(1,N+1):\n new1 =pow(10,i-1,2019)\n new = (new1*S[-i]+mod_list[-1])%2019\n #print(new)\n mod_list.append(new)\n \n count = collections.Counter(mod_list)\n ans =0\n for j in range(2019):\n n = count[j]\n ans+= n*(n-1)/2\n print(int(ans))\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s610929075', 's856965288', 's972074871']
[10616.0, 18524.0, 18244.0]
[34.0, 376.0, 322.0]
[358, 521, 522]
p02702
u391589398
2,000
1,048,576
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.
['S = input()\ncount = 0\nfor i in range(i, len(S) - 4):\n for j in range(i+4, len(S)):\n if int(S[i:j]) // 2019 == 0:\n count += 1\nprint(count)', 'S = input()\nmod = 2019\n\ncs_mods = {0:1}\ncumsum = 0\ncount = 0\nfor i, s in enumerate(S[::-1]):\n cumsum = (cumsum + int(s) * pow(10, i, mod)) % mod\n cs_mods.setdefault(cumsum, 0)\n # count += cs_mods[cumsum]\n cs_mods[cumsum] += 1\n\n# count = 0\nfor k, v in cs_mods.items():\n count += v*(v-1)//2\n\nprint(count)']
['Runtime Error', 'Accepted']
['s153586688', 's106661429']
[9340.0, 9388.0]
[25.0, 354.0]
[158, 317]
p02702
u391725895
2,000
1,048,576
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.
['S = input()\nanswer = 0\nfor i in range(int(int(S))//2019 + 1):\n f = 2019 * i\n if f in S:\n answer += 1\n\nprint(answer)', 'S = input()\nanswer = 0\nfor i in range(-int(-int(S))//2019):\n f = 2019 * i\n if f in S:\n answer += 1\n \nprint(answer)', 'S = input()\nanswer = 0\nfor i in range(int(S)//2019 + 1):\n f = 2019 * i\n if f in S:\n answer += 1\n\nprint(answer)', 'S = input()\ncount = [0] * 2019\nN = len(S)\nmod = 0\nfor i in range(N):\n mod += 10*int(S[-i])\n if mod >= 2019:\n mod %= 2019\n \n count[mod] += 1\n\nanswer = count.pop(0)\n\nfor k in range(2018):\n if count[k] > 1:\n answer = answer + count[k]*(count[k] - 1)/2\n\nprint(int(answer))', 'S = input()\ncount = [0]*2019\nmod = 0\n\nfor i in range(len(S))\n\tmod = int(S[-i]) % 2019\n\tcount[mod] += 1\n\nanswer = 0\n\nfor k in range(2019)\n\tanswer = answer + count[k]\n\nprint(answer)', 'S = input()\nanswer = 0\nfor i in range(int(S)//2019 + 1):\n f = 2019 * i\n if str(f) in S:\n answer += 1\n\nprint(answer)', 'S = list(map(int, list(input())))\n\npops = 0\ndigi = 1\ncnt = [0] * 2019\ncnt[0] = 1\n\nwhile S:\n s = S.pop()\n\n pops = (pops + s * digi) % 2019\n digi = (10 * digi) % 2019\n\n cnt[pops] += 1\n\nans = 0\n\nfor i in range(2019):\n ans += cnt[i] * (cnt[i] - 1) // 2\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s036891374', 's529289698', 's651723289', 's680175557', 's739472229', 's810652330', 's562782873']
[9632.0, 9496.0, 9508.0, 9304.0, 8916.0, 9556.0, 12172.0]
[210.0, 203.0, 204.0, 87.0, 20.0, 2205.0, 118.0]
[128, 134, 123, 301, 179, 128, 275]
p02702
u392319141
2,000
1,048,576
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.
['#include <bits/stdc++.h>\nusing namespace std;\n\ntemplate <class A, class B>\nstring to_string(pair<A, B> p);\n\ntemplate <class A, class B, class C>\nstring to_string(tuple<A, B, C> p);\n\ntemplate <class A, class B, class C, class D>\nstring to_string(tuple<A, B, C, D> p);\n\nstring to_string(const string& s) {\n return \'"\' + s + \'"\';\n}\n\nstring to_string(const char* s) {\n return to_string((string) s);\n}\n\nstring to_string(bool b) {\n return (b ? "true" : "false");\n}\n\nstring to_string(vector<bool> v) {\n bool first = true;\n string res = "{";\n for (int i = 0; i < static_cast<int>(v.size()); i++) {\n if (!first) {\n res += ", ";\n }\n first = false;\n res += to_string(v[i]);\n }\n res += "}";\n return res;\n}\n\ntemplate <size_t N>\nstring to_string(bitset<N> v) {\n string res = "";\n for (size_t i = 0; i < N; i++) {\n res += static_cast<char>(\'0\' + v[i]);\n }\n return res;\n}\n\ntemplate <class A>\nstring to_string(A v) {\n bool first = true;\n string res = "{";\n for (const auto &x : v) {\n if (!first) {\n res += ", ";\n }\n first = false;\n res += to_string(x);\n }\n res += "}";\n return res;\n}\n\ntemplate <class A, class B>\nstring to_string(pair<A, B> p) {\n return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";\n}\n\ntemplate <class A, class B, class C>\nstring to_string(tuple<A, B, C> p) {\n return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";\n}\n\ntemplate <class A, class B, class C, class D>\nstring to_string(tuple<A, B, C, D> p) {\n return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";\n}\n\nvoid debug_out() { cerr << endl; }\n\ntemplate <class Head, class... Tail>\nvoid debug_out(Head H, Tail... T) {\n cerr << " " << to_string(H);\n debug_out(T...);\n}\n\n#ifdef LOCAL\n\n#else\n\n#endif\n\nusing Int = unsigned int;\nusing llong = long long;\nusing Llong = unsigned long long;\nusing ldouble = long double;\nusing intV = vector<int>;\nusing intVV = vector<vector<int>>;\nusing llongV = vector<long long>;\nusing llongVV = vector<vector<long long>>;\n\ntemplate<class T = int>\nusing asc_pque = priority_queue<T, vector<T>, greater<T>>;\ntemplate<class T = int>\nusing desc_pque = priority_queue<T, vector<T>, less<T>>;\n\nconst llong MOD = 1000000007;\nconst int IINF = 1000000000;\nconst llong LINF = 100000000000000000LL;\n\ntemplate<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }\ntemplate<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }\n\n\n\n\n\n\n\nint dp[2019] = {0};\nint oldDp[2019] = {0};\n\nvoid calc(int n) {\n FOR(i, 2019) {\n oldDp[i] = dp[i];\n }\n FOR(i, 2019) {\n dp[(i + n) % 2019] = oldDp[i];\n }\n}\n\nint main(void) {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n string S;\n cin >> S;\n\n int ans = 0;\n int pow = 1;\n dp[0] = 1;\n\n for(auto s = S.rbegin(); s != S.rend(); s++) {\n int n = (*s - \'0\') * pow % 2019;\n calc(n);\n ans += dp[0];\n dp[0] += 1;\n pow = pow * 10 % 2019;\n }\n\n cout << ans << endl;\n\n return 0;\n}', 'import numpy as np\n\nS = input()\nMOD = 2019\ndp = np.zeros(MOD, dtype=np.int64)\ndp[0] = 1\n\ndef hoge(dp, s):\n T = dp.copy()\n dp[s:] = T[:-s]\n dp[:s] = T[-s:]\n\ndef huga(dp, s):\n for i in range(MOD):\n dp[i] = dp[(i - s) % MOD]\n\nans = 0\nfor i, s in enumerate(S[::-1]):\n huga(dp, (int(s) * pow(10, i, MOD)) % MOD)\n ans += dp[0]\n dp[0] += 1\nprint(ans)\n', 'import numpy as np\n\nS = input()\nMOD = 2019\ndp = np.zeros(MOD, dtype=np.int64)\ndp[0] = 1\n\ndef hoge(dp, s):\n T = dp.copy()\n dp[s:] = T[:-s]\n dp[:s] = T[-s:]\n\nans = 0\nfor i, s in enumerate(S[::-1]):\n hoge(dp, (int(s) * pow(10, i, MOD)) % MOD)\n ans += dp[0]\n dp[0] += 1\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s711079128', 's742977531', 's832850305']
[8948.0, 27212.0, 26924.0]
[20.0, 2206.0, 953.0]
[3638, 372, 295]
p02702
u402629484
2,000
1,048,576
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.
['\n\nfrom collections import defaultdict\n\ndef gen_10exp_mod(n, mod):\n a = 1\n yield a\n for _ in range(1, n):\n a = (a*10) % mod\n yield a\n\ndef main():\n MOD = 2019\n S = input()[::-1]\n \n A = [int(s)*n % MOD for s, n in zip(S, gen_10exp_mod(len(S), MOD))]\n \n ACC = [0]\n for a in A:\n ACC.append((ACC[-1] + a) % MOD)\n \n print(ACC)\n d = defaultdict(int)\n for acc in ACC:\n d[acc] += 1\n ans = sum(v*(v-1)//2 for v in d.values())\n print(ans)\n\n\nmain()\n', '\n\nfrom collections import defaultdict\n\ndef gen_10exp_mod(n, mod):\n a = 1\n yield a\n for _ in range(1, n):\n a = (a*10) % mod\n yield a\n\ndef main():\n MOD = 2019\n S = input()[::-1]\n \n A = [int(s)*n % MOD for s, n in zip(S, gen_10exp_mod(len(S), MOD))]\n \n ACC = [0]\n for a in A:\n ACC.append((ACC[-1] + a) % MOD)\n \n d = defaultdict(int)\n for acc in ACC:\n d[acc] += 1\n ans = sum(v*(v-1)//2 for v in d.values())\n print(ans)\n\n\nmain()\n']
['Wrong Answer', 'Accepted']
['s677162927', 's046213774']
[26364.0, 24100.0]
[146.0, 128.0]
[1153, 1138]
p02702
u408262366
2,000
1,048,576
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.
['S = input()\ncnt = 0\n\nlength = len(S)\nfor i in range(0,len(S)-4):\n for j in range(i+4,i+4+length//100):\n if int(S[i:j+1]) % 2019 == 0 and j<length:\n cnt += 1\n\nprint(cnt)', 'S = input()\ncnt = 0\n\nfor i in range(0,len(S)-2):\n for j in range(i+1,len(S)):\n if int(S[i:j+1]) % 2019 == 0:\n cnt += 1\n print(i, j)\n \nprint(cnt)', 'S = input()\ncnt = 0\n\nlength = len(S)\nfor i in range(0,len(S)-4):\n for j in range(i+4,length//2):\n if int(S[i:j+1]) % 2019 == 0 and j<length:\n cnt += 1\n\nprint(cnt)', 'import collections\nS = input()\ncnt = 0\n\nmod = [0]\nreverse_S = S[::-1]\nfor i in range(len(reverse_S)):\n now = int(reverse_S[i]) * pow(10,i,2019)\n mod.append((now + mod[i]) % 2019)\n\n\nc = collections.Counter(mod)\nhindo = sorted(c.values(),reverse=True)\nfor i in hindo:\n if i != 1:\n cnt += i*(i-1)//2\n\n\nprint(cnt)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s208950663', 's456723786', 's828711262', 's473213831']
[9404.0, 9392.0, 9260.0, 16636.0]
[2206.0, 2206.0, 2205.0, 325.0]
[177, 163, 171, 315]
p02702
u408375121
2,000
1,048,576
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.
['s = input()\ndic = {}\nfor i in range(2019):\n dic[i] = 0\ndic[0] = 1\nfor j in range(1, len(s)+1):\n m = int(s[:j]) % 2019\n dic[m] += 1\nans = 0\nfor v in dic.values():\n ans += v*(v-1) // 2\nprint(ans)\n', 's = input()\ndic = {}\nfor i in range(2019):\n dic[i] = 0\ndic[0] = 1\nm = 0\nfor j in range(len(s)):\n m = 10*m + s[j]\n m %= 2019\n dic[m] += 1\nans = 0\nfor v in dic.values():\n ans += v*(v-1) // 2\nprint(ans)\n', 's = input()\ndic = {}\nfor i in range(2019):\n dic[i] = 0\ndic[0] = 1\nfor j in range(1, len(s)+1):\n m = s[:j] % 2019\n dic[m] += 1\nans = 0\nfor v in dic.values():\n ans += v*(v-1) // 2\nprint(ans)', 's = input()\ndic = {}\nfor i in range(2019):\n dic[i] = 0\ndic[0] = 1\nm = 0\nfor j in range(len(s)):\n m = 10*m + int(s[j])\n m %= 2019\n dic[m] += 1\nans = 0\nfor v in dic.values():\n ans += v*(v-1) // 2\nprint(ans)\n', 's = input()\ndic = {}\nfor i in range(2019):\n dic[i] = 0\ndic[0] = 1\nm = 0\ndecimal = 1\nfor j in range(1, len(s)+1):\n m += int(s[-j]) * decimal\n m %= 2019\n dic[m] += 1\n decimal *= 10\n decimal %= 2019\n\nans = 0\nfor v in dic.values():\n ans += v*(v-1) // 2\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s067819517', 's649432623', 's781089369', 's986998345', 's327178140']
[9404.0, 9216.0, 9232.0, 9284.0, 9344.0]
[2206.0, 21.0, 22.0, 103.0, 132.0]
[198, 205, 192, 210, 267]
p02702
u409542115
2,000
1,048,576
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.
['S=input()\ni=2019\nx = 0\nwhile i <= int(S):\n for j in range(1,len(S)-len(str(i))+2,1):\n if int(S[j-1:j-1+len(str(i))]) == i:\n x += 1\n i += 2019\nprint(x)\n', 'S = input()[::-1]\n\nS_mod = [0] * (len(S)+1)\nS_mod[0] = int(S[0])\n\nd = 10\n\nfor i in range(len(S)-1):\n S_mod[i + 1] = (S_mod[i] + int(S[i+1])*d)%2019\n d = d * 10 % 2019\n\nmod_count = [0] * 2019\nfor i in range(len(S_mod)):\n mod_count[S_mod[i]] += 1\n \ncount = 0\nfor i in range(2019):\n count += mod_count[i] * (mod_count[i] - 1) / 2\n\nprint(int(count))']
['Time Limit Exceeded', 'Accepted']
['s909636995', 's262974287']
[9396.0, 16048.0]
[2206.0, 139.0]
[175, 360]
p02702
u413165887
2,000
1,048,576
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.
['use std::io::stdin;\nfn main() {\n let mut st = String::new();\n stdin().read_line(&mut st).unwrap();\n let s:Vec<char> = st.trim().chars().collect();\n let mut ten = 1;\n let mut c:usize = 0;\n let mut r:[i64;2020] = [0;2020];\n let m = s.len() as usize;\n for i in 1..m+1 {\n let mut x = s[m-i] as usize;\n x -= 48;\n c = (c+(x*ten)%2019)%2019;\n r[c] += 1;\n ten = (ten*10)%2019;\n };\n let mut result:i64 = 0;\n for i in 0..2019 {\n if &1 < &r[i] {\n result += (r[i]-1)*r[i]/2\n };\n };\n result += r[0];\n println!("{}", result);\n}', 's = input()\nx = list(map(int, list(s)))\nx = x[::-1]\ndic = [0 for _ in range(2020)]\nten = 1\ny = 0\nfor i in range(len(s)):\n y = (y+ten*x[i])%2019\n dic[y] += 1\n ten = (ten*10)%2019\nresult = 0\nfor i in range(2019):\n result += max([dic[i]*(dic[i]-1)//2, 0])\nresult += dic[0]\nprint(result)\n']
['Runtime Error', 'Accepted']
['s340583712', 's591798925']
[8940.0, 12256.0]
[20.0, 108.0]
[615, 296]
p02702
u432251613
2,000
1,048,576
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.
['def main():\n S = input()\n n = len(S)\n p = 2019 \n \n \n \n \n \n \n \n # ...\n \n \n \n \n \n \n \n \n \n\n \n S = [S[i] for i in range(n-1,-1,-1)]\n \n modp_counter = [0 for _ in range(p)]\n modp_tmp = int(S[0])%p\n modp_counter[modp_tmp] = 1\n pair_count = 0\n for i in range(1,n):\n modp = (int(S[i])*pow(10,i)%p+modp_tmp)%p\n modp_tmp = modp\n pair_count += modp_counter[modp]\n modp_counter[modp] += 1\n print(pair_count)\n\n\nmain()\n', 'def main():\n S = input()\n n = len(S)\n p = 2019 \n \n \n \n \n \n \n \n # ...\n \n \n \n \n \n \n \n \n \n\n \n S = [S[i] for i in range(n-1,-1,-1)]\n \n modp_counter = [0] * p\n modp = 0\n modp_counter[0] = 1 \n pair_count = 0\n d = 1\n for s in S:\n modp = (int(s)*d%p+modp)%p\n pair_count += modp_counter[modp]\n modp_counter[modp] += 1\n d *= 10\n d %= p \n print(pair_count)\n\n\nmain()\n']
['Wrong Answer', 'Accepted']
['s286556904', 's815168847']
[10700.0, 10788.0]
[2206.0, 105.0]
[1259, 1433]
p02702
u433836112
2,000
1,048,576
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.
['import collections\n\ns = input().strip()\nt = []\nfor i in range(len(s)):\n t.append(int(s[i:]) % 2019)\n \nt.append(0)\ncount = dict(collections.Counter(t))\nprint(count)\ntot = 0\nfor c in count.values():\n tot += c*(c-1)/2\nprint(int(tot))', 'import numpy as np\n\ns = input().strip()\nt = 0\ncounts = np.array([0] * 2019)\ncounts[0] += 1\nm = 1\n\nfor a in reversed(s):\n t = (t + m * int(a)) % 2019\n counts[t] += 1\n m = m * 10 % 2019\n \nprint(int(np.sum(counts * (counts - 1) /2)))']
['Wrong Answer', 'Accepted']
['s356760217', 's504194302']
[9580.0, 27328.0]
[2206.0, 248.0]
[240, 243]
p02702
u445983356
2,000
1,048,576
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.
['a = [1] + [0] * 2018\ns, p = 0, 1\n\nfor i in reversed(input()) :\n s = (s + p * int(i)) % 2019\n p = p * 10 % 2019\n a[s] += 1\n print(i, s, p, a[s])\n\nprint(sum(x * (x - 1) // 2 for x in a))', 'S = input()\nP =2019\nans = 0\n\ncount = [0] * P\ncount[0] = 1\nu = 0\nfor i, s in enumerate(reversed(S)):\n u = (int(s) * pow(10, i, P) + u) % P\n ans += count[u]\n count[u] += 1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s355290955', 's718955612']
[9284.0, 9188.0]
[295.0, 342.0]
[196, 189]
p02702
u449822557
2,000
1,048,576
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.
['s = input()\ns = list(reversed(s))\nn = len(s)\ndp1 = [0]*n\ndp2 = [0]*n\ncounting = [0]*2019\ncounitng[0] += 1\ndp1[0] = 1\ndp2[0] = int(s[0])\ncounting[dp2[0]] += 1\nif n >= 2:\n for i in range(1,n):\n dp1[i] = (10*dp1[i-1]) % 2019\n dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019\n counting[dp2[i]] += 1\n#print(counting)\nsm = 0\nfor j in range(2019):\n sm += int(counting[j]*(counting[j]-1)/2)\nprint(sm)', 's = input()\ns = list(reversed(s))\nn = len(s)\ndp1 = [0]*n\ndp2 = [0]*n\ncounting = [0]*2019\ndp1[0] = 1\ndp2[0] = int(s[0])\ncounting[dp2[0]] += 1\nif n >= 2:\n for i in range(1,n):\n dp1[i] = (10*dp1[i-1]) % 2019\n dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019\n counting[dp2[i]] += 1\nsm = 0\nfor j in range(2019):\n sm += counting[j]*(counting[j]-1)\nprint(sm)', 's = input()\ns = list(reversed(s))\nn = len(s)\ndp1 = [0]*n\ndp2 = [0]*n\ncounting = [0]*2019\ndp1[0] = 1\ndp2[0] = int(s[0])\ncounting[dp2[0]] += 1\nif n >= 2:\n for i in range(1,n):\n dp1[i] = (10*dp1[i-1]) % 2019\n dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019\n counting[dp2[i]] += 1\nsm = 0\nfor j in range(2019):\n sm += int(counting[j]*(counting[j]-1)/2)\nprint(sm)', 's = input()\ns.reverse()\nn = len(s)\ndp1 = [0]*n\ndp2 = [0]*n\ncounting = [0]*2019\ndp1[0] = 1\ndp2[0] = s[0]\ncounting[dp2[0]] += 1\nif n >= 2:\n for i in range(1,n):\n dp1[i] = (10*dp1[i-1]) % 2019\n dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019\n counting[dp2[i]] += 1\nsm = 0\nfor j in range(2019):\n sm += counting[j]*(counting[j]-1)\nprint(sm)', 's = input()\ns = list(reversed(s))\nn = len(s)\ndp1 = [0]*n\ndp2 = [0]*n\ncounting = [0]*2019\ndp1[0] = 1\ndp2[0] = int(s[0])\ncounting[dp2[0]] += 1\nif n >= 2:\n for i in range(1,n):\n dp1[i] = (10*dp1[i-1]) % 2019\n dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019\n counting[dp2[i]] += 1\nsm = 0\nfor j in range(2019):\n sm += counting[j]*(counting[j]-1)/2\nprint(sm)', 's = input()\ns = list(reversed(s))\nn = len(s)\ndp1 = [0]*n\ndp2 = [0]*n\ncounting = [0]*2019\ncounting[0] += 1\ndp1[0] = 1\ndp2[0] = int(s[0])\ncounting[dp2[0]] += 1\nif n >= 2:\n for i in range(1,n):\n dp1[i] = (10*dp1[i-1]) % 2019\n dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019\n counting[dp2[i]] += 1\n#print(counting)\nsm = 0\nfor j in range(2019):\n sm += int(counting[j]*(counting[j]-1)/2)\nprint(sm)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s180600459', 's233031165', 's303993704', 's718364051', 's741589788', 's339675184']
[13396.0, 24992.0, 24744.0, 9180.0, 24720.0, 24744.0]
[30.0, 160.0, 154.0, 24.0, 157.0, 165.0]
[414, 373, 380, 358, 375, 414]
p02702
u449863068
2,000
1,048,576
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.
['S = input()\n\nr = 1\narr = [0]\nfor c in S[::-1]:\n arr.append((arr[-1] + int(c) * r) % 2019)\n r *= 10\n r %= 2019\nfrom collections import Counter\nctr = Counter(arr)\nans = 0\nfor v in ctr.values():\n ans += v*v(v-1)//2\nprint(ans)', 'S = input()\n\nr = 1\n arr = [0]\n for c in S[::-1]:\n arr.append((arr[-1] + int(c) * r) % 2019)\n r *= 10\n r %= 2019\nfrom collections import Counter\nctr = Counter(arr)\nans = 0\nfor v in ctr.values():\n ans += v*v(v-1)//2\nprint(ans)', 'S = input()\nr = 1\narr = [0]\n\nfor c in S[::-1]:\n arr.append((arr[-1] + int(c) * r) % 2019)\n r *= 10\n r %= 2019\nfrom collections import Counter\nctr = Counter(arr)\nans = 0\nfor v in ctr.values():\n ans += v*(v-1)//2\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s172411316', 's682066380', 's368656944']
[16736.0, 9012.0, 16648.0]
[124.0, 21.0, 124.0]
[226, 231, 225]
p02702
u459150945
2,000
1,048,576
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.
['import sys\nsys.setrecursionlimit(10000000)\nS = input()\nans = 0\n\n# for j in range(i+4, len(S)+1):\n# if int(S[i:j]) % 2019 == 0:\n# ans += 1\n# # break\n# print(ans)\ni = 0\nwhile i < len(S)-3:\n for j in range(i+4, len(S)+1):\n if int(S[i:j]) % 2019 == 0:\n ans += 1\n i += j-5\n break\n i += 1\nprint(ans)\n', 's = input()[::-1]\nlength = len(s)\na = [0] * length\nd = [0] * length\nans = [0] * 2019\nx = 10\n\na[0] = int(s[0])\nd[0] = a[0]\nans[d[0]] += 1\n\nfor i in range(1, length):\n a[i] = int(s[i]) * x % 2019\n d[i] = (d[i-1] + a[i]) % 2019\n ans[d[i]] += 1\n x = x * 10 % 2019\n\nans_c = [i for i in ans if i != 0]\n\nprint(int(sum([ans_c[i] * (ans_c[i]-1) for i in range(len(ans_c))]) / 2) + ans[0])\n']
['Wrong Answer', 'Accepted']
['s476430468', 's597105746']
[9156.0, 23380.0]
[2133.0, 161.0]
[403, 392]
p02702
u460375306
2,000
1,048,576
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.
["# if the remainders (mod 2019) are equal, the difference will be divisible\n# x = Q*2019+5 y = R*2019+5 then x-y=(Q-R)*2019\n# unless Q-R<=0\n# where the substring itself is (Q-R)*2019/10**(something)\n\n# so multiplying by 10 doesn't affect whether a number is divisible by it\nfrom collections import Counter\ns = input()\npartial = 0\nhisto = Counter((partial+int(s[i])*10**(len(s)-1-i))%2019 for i in range(len(s)-1, -1, -1))\n\n# partial = (partial+int(s[i])*10**(len(s)-1-i))%2019\n# remainders.append(partial)\n\nnon_single_count = int(sum(count*(count-1)/2 for value, count in histo.items() if value!=0))\nsingle_count = int(sum(count for value, count in histo.items() if value==0))\nprint(non_single_count+single_count)", '# if the remainders (mod 2019) are equal, the difference will be divisible\n# x = Q*2019+5 y = R*2019+5 then x-y=(Q-R)*2019\n# unless Q-R<=0\n# where the substring itself is (Q-R)*2019/10**(something)\nfrom collections import Counter\ns = input()[::-1]\npartial = 0\nremainders = list()\nnum = (int(character) for character in s)\nfor i, int_char in enumerate(num):\n partial = (partial+(int_char*pow(10,i,2019))%2019)%2019\n remainders.append(partial)\nhisto = Counter(remainders)\nnon_single_count = int(sum(count*(count-1)/2 for value, count in histo.items() if value!=0))\nsingle_count = int(sum(count+count*(count-1)/2 for value, count in histo.items() if value==0))\nprint(non_single_count+single_count)']
['Wrong Answer', 'Accepted']
['s192637675', 's460049655']
[9640.0, 16980.0]
[2206.0, 350.0]
[817, 696]
p02702
u469254913
2,000
1,048,576
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.
['import numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n\nfrom numba import njit\n\n\n@njit\ndef loof(a):\n N = len(a)\n M = np.zeros(2019,dtype=np.int16)\n M[0] += 1\n T = 0\n memo = pow_mod(10,N,2019)\n for i in range(N-1,-1,-1):\n T = a[i] * memo[N-i-1] + T\n m = T % 2019\n M[m] += 1\n # print(m)\n return M\n\n\n@njit\ndef pow_mod(a,n,mod):\n memo = np.array([1])\n if n >= 1:\n for i in range(n-1):\n memo = np.append(memo,memo[-1]*a%mod)\n return memo\n\n\ndef main():\n S = input().rstrip()\n S = list(map(int,list(S)))\n a = np.array(S)\n\n M = loof(a)\n # print(M)\n\n res = 0\n ans = np.array([res])\n\n flag = True\n cnt = 0\n\n for m in M:\n res += m * (m-1) // 2\n ans = np.append(ans,res)\n if (res == 3) & (flag):\n # print(m,cnt)\n flag = False\n cnt += 1\n\n # print(M[1164:1167])\n # print(ans)\n print(res)\n\n\n# print(S)\n\n# np.set_printoptions(threshold=2030)\nmain()\n', 'import numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n\nfrom numba import njit\n\n\n@njit\ndef loof(a,N,memo):\n M = np.zeros(2019,dtype=np.int16)\n M[0] += 1\n T = 0\n for i in range(N-1,-1,-1):\n T = a[i] * memo[N-i-1] + T\n m = T % 2019\n M[m] += 1\n return M\n\n\n@njit\ndef pow_mod(a,n,mod):\n memo = np.array([1])\n if n >= 1:\n for i in range(n-1):\n memo = np.append(memo,memo[-1]*a%mod)\n return memo\n\n\ndef main():\n S = input().rstrip()\n S = list(map(int,list(S)))\n a = np.array(S)\n\n N = len(a)\n\n memo = pow_mod(10,N,2019)\n M = loof(a,N,memo)\n\n res = 0\n\n for m in M:\n res += m * (m-1) // 2\n\n print(res)\n\n\nmain()\n', 'import numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n\nfrom numba import njit, i8\n\n\n\n@njit\ndef loof(a,N):\n M = np.zeros(2019,dtype=np.int16)\n M[0] += 1\n T = 0\n r = 1\n T += a[-1] * r\n T %= 2019\n M[T] += 1\n for i in range(N-2,-1,-1):\n r *= 10\n r %= 2019\n T += a[i] * r\n T %= 2019\n M[T] += 1\n return M\n\n\n\n# def pow_mod(a,n,mod):\n\n# if n >= 1:\n\n\n# return memo\n# else:\n# return memo[0]\n\n\ndef main():\n S = input().rstrip()\n S = list(map(int,list(S)))\n a = np.array(S)\n\n N = len(a)\n\n \n M = loof(a,N)\n\n res = 0\n\n for m in M:\n res += m * (m-1) // 2\n\n print(res)\n\n\nmain()\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s871314098', 's990899344', 's044809464']
[122920.0, 120988.0, 112988.0]
[2209.0, 2209.0, 635.0]
[1094, 793, 943]
p02702
u470369730
2,000
1,048,576
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.
["import re\n\ns = input()\nary = []\nfor i in range(10000):\n if not '0' in str(2019*i):\n ary.append(2019*i)\n\nresult = 0\nfor val in ary:\n result += len(re.findall(str(val), s))\n\nprint(result)\n", "import re\n\ns = input()\nary = []\nfor i in range(10000):\n if not '0' in str(2019*i):\n ary.append(2019*i)\n\nprint(re.findall('('+'|'.join(map(str, ary))+')+', s))\n", 'S = input()[::-1]\n\nmodCount = [1]+[0]*2018\nmod = 0\ndig = 1\nresult = 0\n\nfor i in range(len(S)):\n mod = (int(S[i:i+1])*dig+mod)%2019\n dig = (dig*10)%2019\n result += modCount[mod]\n modCount[mod] += 1\n\nprint(result)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s071342470', 's552604782', 's365493298']
[11400.0, 17788.0, 9200.0]
[2206.0, 2206.0, 136.0]
[191, 163, 215]
p02702
u470560351
2,000
1,048,576
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.
['N = int(input())\nS = [ input() for _ in range(N) ]\nprint(len(set(S)))', 'S = str(input())\nN = len(S)\nl = 0\nr = 0\n\n\nfollow = 0\namari = [0] * N\nfor i in range(N):\n Kazu = int(S[N-i-1]) * pow(10, i)\n Amari_ = (int(Kazu) + follow) % 2019\n amari[i] = Amari_\n follow = Amari_\n\nfrom collections import Counter\nc_ = Counter(amari)\nc = c_.most_common()\n\nans = 0\nfor i in c:\n if i[1] != 0:\n ans += i[1] * (i[1]-1) // 2\n else:\n break\n\nans == c_[0]\nprint(ans)', 'S = str(input())\nN = len(S)\n\nans = 0\namari = [0] * 2019\namari[0] = 1\nfollow = 0\nPOW = 1\n\nfor i in reversed(S):\n follow += int(i) * POW\n follow %= 2019\n amari[follow] += 1\n POW *= 10\n POW %= 2019\n \nprint(sum( i * (i-1) // 2 for i in amari ))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s575777374', 's923131484', 's312530488']
[9444.0, 11460.0, 9360.0]
[210.0, 2206.0, 114.0]
[69, 386, 246]
p02702
u479719434
2,000
1,048,576
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.
['def main(S=None):\n if not S:\n S = input()\n count = 0\n candidates = [str(i) for i in range(2019, 200000, 2019)]\n s_len = len(S)\n for candidate in candidates:\n candidate_len = len(candidate)\n for i in range(s_len):\n if i+candidate_len > s_len:\n break\n if S[i:i+candidate_len] == candidate:\n print(S[i:i+candidate_len], candidate)\n count += 1\n print(count)\n\n\nif __name__ == "__main__":\n # main("1817181712114")\n # main("14282668646")\n main()\n', '\n\ndef main(S=None):\n if not S:\n S = input()\n r = {x: 0 for x in range(0, 2019)}\n r[0] = 1\n tmp = 0\n base = 1\n for i, s in enumerate(S[::-1]):\n s = int(s) * base\n base *= 10\n tmp += s\n tmp %= 2019\n if s != 0:\n r[tmp] += 1\n count = 0\n for k, v in r.items():\n count += v*(v-1)//2\n return count\n\n\nif __name__ == "__main__":\n \n \n \n \n \n main()\n', 'def main(S=None):\n if not S:\n S = input()\n r = [0]*2019\n r[0] = 1\n tmp = 0\n base = 1\n for s in S[::-1]:\n s = int(s) * base\n base *= 10\n # base %= 2019\n tmp += s\n # tmp %= 2019\n r[tmp] += 1\n count = 0\n for v in r:\n count += v*(v-1)//2\n print(count)\n return count\n\n\nif __name__ == "__main__":\n \n \n \n main()\n', 'def main(S=None):\n if not S:\n S = input()\n r = {k: 0 for k in range(0, 2019)}\n r[0] = 1\n tmp = 0\n base = 1\n for i, s in enumerate(S[::-1]):\n s = int(s) * base\n base *= 10\n tmp += s\n tmp %= 2019\n r[tmp] += 1\n count = 0\n for k, v in r.items():\n if v > 1:\n print(k, v)\n count += v*(v-1)//2\n print(count)\n return count\n\n\nif __name__ == "__main__":\n \n \n main()\n', 'def main(S=None):\n if not S:\n S = input()\n r = [0]*2019\n r[0] = 1\n tmp = 0\n base = 1\n for s in S[::-1]:\n s = int(s) * base\n base *= 10\n base %= 2019\n tmp += s\n tmp %= 2019\n r[tmp] += 1\n count = 0\n for v in r:\n count += v*(v-1)//2\n print(count)\n return count\n\n\nif __name__ == "__main__":\n \n \n \n main()\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s003635945', 's079543414', 's148345182', 's302584398', 's661016749']
[9292.0, 9632.0, 9340.0, 9600.0, 9400.0]
[2206.0, 2205.0, 23.0, 2206.0, 83.0]
[554, 588, 497, 530, 493]
p02702
u480200603
2,000
1,048,576
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.
['s = input()\nl = len(s)\nmod = [1] + [0 for _ in range(2017)]\nml = [0 for _ in range(l + 1)]\nans = 0\n\ntmp = 0\nfor idx, degit in s[::-1]:\n m = (int(degit) * (10 ** idx) + tmp) % 2019\n tmp = m\n ans += mod[m]\n mod[m] += 1\n\nprint(ans)\n', 's = input()\nl = len(s)\nmod = [1] + [0 for _ in range(2019)]\nml = [0 for _ in range(l + 1)]\nans = 0\n\ntmp = 0\nfor idx, degit in enumerate(s[::-1]):\n m = int(degit) * pow(10, idx, 2019)\n m = (m + tmp) % 2019\n tmp = m\n ans += mod[m]\n mod[m] += 1\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s750755003', 's346592215']
[10812.0, 10788.0]
[28.0, 362.0]
[241, 269]
p02702
u480264129
2,000
1,048,576
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.
["s=input()\nc=0\nt=[0]*(len(s)+1)\nfor i in [str(i*2019) for i in range(1,10000) if '0' not in str(2019*i)]:\n idx=-1\n while s[idx+1:].count(i)>0:\n idx=s[idx+1:].find(i)\n t[idx+len(i)]+=1+t[idx]\n c+=1\n c+=t[idx]\nprint(c)", 's=input()\nn=len(s)\nmod=2019\nd=0\np=1\nml=[0]*mod\nfor i in range(1,n+1):\n k=int(s[-i])\n d+=p*k\n d%=mod\n ml[d]+=1\n p*=10\n p%=mod\nans=0\nfor i in ml:\n ans+=i*(i-1)//2\nprint(ans+ml[0])']
['Time Limit Exceeded', 'Accepted']
['s292693069', 's012230536']
[11016.0, 9256.0]
[2206.0, 130.0]
[229, 184]
p02702
u480847874
2,000
1,048,576
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.
["from sys import stdin\n\ninput = stdin.readline\n\n\ndef main():\n s = list(input())\n s.reverse()\n MOD = 2019\n tot = 0\n ans = 0\n d = [0 for _ in range(MOD)]\n for i in range(len(s)):\n d[tot] += 1\n x = (10 ** i) % MOD\n p = int(s[i]) * x\n p %= MOD\n tot = (tot + p) % MOD\n ans += d[tot]\n return ans\n\n\nif __name__ == '__main__':\n print(main())\n", "def main():\n s = list(input())\n s.reverse()\n MOD = 2019\n tot = 0\n ans = 0\n d = [0 for _ in range(MOD)]\n for i in range(len(s)):\n d[tot] += 1\n x = pow(10, i, MOD)\n p = int(s[i]) * x\n p %= MOD\n tot = (tot + p) % MOD\n ans += d[tot]\n return ans\n\n\nif __name__ == '__main__':\n print(main())\n"]
['Runtime Error', 'Accepted']
['s945709353', 's706562184']
[10520.0, 10448.0]
[22.0, 311.0]
[402, 354]
p02702
u482743994
2,000
1,048,576
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.
['s=input()\nn=len(s)\nMOD=2019\nfrom collections import defaultdict\nd=defaultdict(int)\nfor i in range(n-1,-1,-1):\n d[int(s[i:n])%2019]+=1\nans=0\nfor i,v in enumerate(d):\n if i==0:\n ans+=v\nelse:\n ans+=v*(v-1)//2\nprint(ans)\n', 's=input()\nn=len(s)\nl=[0]*2019\nl[0]=1\nk=0\nmod=2019\nr=1\nfor i in range(n-1,-1,-1):\n k+=s[i]*r\n r*=10\n r%=mod\n l[k]+=1\nans=0\nfor i in l:\n ans+=i*(i-1)//2\nprint(ans)', 's=input()\nn=len(s)\nl=[0]*2019\nl[0]=1\nk=0\nmod=2019\nr=1\nfor i in range(n-1,-1,-1):\n k+=int(s[i])*r\n r*=10\n r%=mod\n l[k]+=1\nans=0\nfor i in l:\n ans+=i*(i-1)//2\nprint(ans)\n', 's=input()\nn=len(s)\nl=[0]*2019\nl[0]=1\nk=0\nmod=2019\nr=1\nfor i in range(n-1,-1,-1):\n k+=int(s[i])*r\n k%=mod\n r*=10\n r%=mod\n l[k]+=1\nans=0\nfor i in l:\n ans+=i*(i-1)//2\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s060555505', 's130034277', 's411255157', 's158445417']
[9604.0, 9300.0, 9276.0, 9172.0]
[2206.0, 20.0, 23.0, 122.0]
[223, 166, 172, 181]
p02702
u490489966
2,000
1,048,576
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.
['#D\ns = input()\ncount = 0\n# print(len(s))\nfor left in range(len(s) - 3):\n for right in range(left + 3, len(s)):\n print(left + 1, right + 1)\n if int(float(s[left:right + 1])) % 2019 == 0:\n print(s[left:right])\n count += 1\nprint(count)', 's = input()\nans = 0\na = [0] * 2019\na[0] = 1\nk = 0\nmod = 1\nfor i in range(len(s) - 1, -1, -1):\n k = (k + int(s[i]) * mod) % 2019\n mod = (mod * 10) % 2019\n a[k] += 1\nfor i in a:\n ans += i * (i - 1) * 0.5\nprint(int(ans))']
['Runtime Error', 'Accepted']
['s682096976', 's923991186']
[9168.0, 9284.0]
[21.0, 108.0]
[271, 229]
p02702
u508426820
2,000
1,048,576
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.
['S = input()\nN = len(S)\nans = 0\nT = []\nfor i in range(N):\n\n T.append(int(S[i : N]) % 2019)\nT.sort()\nt = set(T)\ncounted = []\nfor i in t:\n a = T.count(i)\n if a > 1:\n counted.append(a)\nfor i in counted:\n ans += i * (i - 1) // 2\nprint(ans)\n', 'S = input()\nN = len(S)\namari = [0 fot i in range(2019)]\nfor i in range(N):\n\tamari[int(S[i : N]) % 2019] += 1\nans = amari[0]\nfor i in amari:\n if i > 1:\n\t ans += i * (i - 1) // 2\nprint(ans)\n', 'S = input()\nN = len(S)\namari = [0 fot i in range(2019)]\nfor i in range(N):\n amari[int(S[i : N]) % 2019] += 1\nans = amari[0]\nfor i in amari:\n if i > 1:\n ans += i * (i - 1) // 2\nprint(ans)\n', 'S = input()[::-1]\nN = len(S)\namari = [0 for i in range(2019)]\nbefore = int(S[0])\namari[before] += 1\nS = S[1::]\nketa = 1\nfor i in S:\n i = int(i)\n keta = (keta * 10) % 2019\n x = (keta * i + before) % 2019\n amari[x] += 1\n before = x\nans = amari[0]\nfor i in amari:\n ans += i * (i - 1) // 2\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s395545287', 's727743873', 's936261548', 's906396775']
[9440.0, 8884.0, 8772.0, 9296.0]
[2206.0, 21.0, 24.0, 113.0]
[254, 197, 199, 315]
p02702
u509739538
2,000
1,048,576
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.
['import math\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef fact(n):\n\tans = 1\n\tm=n\n\tfor _i in range(n-1):\n\t\tans*=m\n\t\tm-=1\n\treturn ans\ndef comb(n,r):\n\tl = min(r,n-r)\n\tm=n\n\tu=1\n\tfor _i in range(l):\n\t\tu*=m\n\t\tm-=1\n\treturn u//fact(l)\n\n\nS = readChar()\n\nres = [0]*len(S)\nres[-1]=int(S[-1])\n\nd = defaultdict(int)\n\nfor i in range(2,len(S)+1):\n\tre = int(S[i*-1])*pow(10,i-1,2019)\n\td[(res[i*-1+1]+re)%2019]+=1\n\nans = d[0]\nfor key in d:\n\tif d[key]>1:\n\t\tans+=comb(d[key],2)\n\nprint(ans)', 'p=d=2019\nz=[0]*p\nfor i,j in enumerate(input()[::-1]):\n\td=d+int(j)*pow(10,i,p)\n\tz[d%p]+=1\nr=z[0]\nfor i in a:\n\tr+=i*(i-1)//2\nprint(r)', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = input()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019', 'import math\nimport queue\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ndef sumDigits3(s):\n\tx = list(s)\n\ty = [int(i) for i in x]\n\treturn sum(y)%3==0\n\ndef mod(a,b,n):\n\treturn (a-b)/pow(10*n)%2019\n\ns = input()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\nfor i in range(len(s)):\n\tprint(s[i])\n\tai[len(s)-i-1] = (int(s[-1*i-1])*pow(10,i))%3\nfor i in range(len(ai)):\n\tsi[i] = sum(ai[0:i])\n\nres = 0\nfor i in range(2019):\n\tc = si.count(i)\n\tres += c*(c-1)/2\n\nprint(res)', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = input().reverse()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019\n\nfor i in range(len(s)):\n\t(int(s[i])*pow(10,i))%p', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = input()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019\n\nfor i in range(len(s)):\n\tai[i] = (int(s[i])*pow(10,i))%p', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = reversed(input())\n\nai = 0\nsi = [0]*len(s)\n\np = 2019\n\nfor i, j in enumerate(s):\n\tai = (int(j)*pow(10,i,p))%p\n\tsi[i] = (si[i-1]+ai)%p\ncountarr = [0]*2019\nfor i in si:\n\tcountarr[i]+=1\n\nres = countarr[0]\nfor i in range(p):\n\tc = countarr[i]\n\tres += c*(c-1)//2\n\nprint(res)', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = input()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019\n\nfor i in range(len(s)):\n\tai[i] = (int(s[-1*i-1])*pow(10,i))%p', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = input()[::-1]\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019\n\nfor i in range(len(s)):\n\t(int(s[i])*pow(10,i))%p', 'import math\nimport queue\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ndef sumDigits3(s):\n\tx = list(s)\n\ty = [int(i) for i in x]\n\treturn sum(y)%3==0\n\ndef mod(a,b,n):\n\treturn (a-b)/pow(10*n)%2019\n\ns = input()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\nfor i in range(len(s)):\n\tai[len(s)-i-1] = (int(s[-1*i-1])*pow(10,i))%3\nfor i in range(len(ai)):\n\tsi[i] = sum(ai[0:i])\n\nres = 0\nfor i in range(2019):\n\tc = si.count(i)\n\tres += c*(c-1)//2\n\nprint(res)', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = input().reverse()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019\nee = 0\nfor i in range(len(s)):\n\tee = (int(s[i])*pow(10,i))%p', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = input()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019\n\nfor i in range(len(s)):\n\tai[i] = (int(s[-1*i-1])', 'p=2019\ns,a,d,z=reversed(input()),0,0,[0]*p\nfor i in range(len(s)):\n\td=(d+(int(s[i])*pow(10,i,p)))%p\n\tz[d]+=1\nr=z[0]\nfor i in range(p):\n\tr+=z[i]*(z[i]-1)//2\nprint(r)', 'p=2019\nz=[0]*p\ns,a,d,r=reversed(input()),0,0,z[0]\nfor i,j in enumerate(s):\n\td=(d+(int(j)*pow(10,i,p)))%p\n\tz[d]+=1\nfor i in range(p):\n\tr+=z[i]*(z[i]-1)//2\nprint(r)', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = input()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019\n\nfor i in range(len(s)):\n\tai[i] = (int(s[-1*i-1]))', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = reverse(input())\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019\n\nfor i in range(len(s)):\n\tai[i] = (int(s[i])*pow(10,i))%p\n\tsi[i] = sum(ai[:i+1])%p\ncountarr = [0]*2019\nfor i in si:\n\tcountarr[i]+=1\n\nres = countarr[0]\nfor i in range(p):\n\tc = countarr[i]\n\tres += c*(c-1)//2\n\nprint(res)', 'import math\n\ndef readInt():\n\treturn int(input())\n\ndef readInts():\n\treturn list(map(int, input().split()))\n\ndef readChars():\n\treturn input().split()\n\ns = input()\n\nai = [0]*len(s)\nsi = [0]*len(s)\n\np = 2019\n\nfor i in range(len(s)):\n\tai[i] = (int(s[-1*i-1])*pow(10,i))%p\n\tsi[i] = sum(ai[:i+1])%p\ncountarr = [0]*2019', 'import math\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef fact(n):\n\tans = 1\n\tm=n\n\tfor _i in range(n-1):\n\t\tans*=m\n\t\tm-=1\n\treturn ans\ndef comb(n,r):\n\tl = min(r,n-r)\n\tm=n\n\tu=1\n\tfor _i in range(l):\n\t\tu*=m\n\t\tm-=1\n\treturn u//fact(l)\n\n\nS = readChar()\n\nres = [0]*len(S)\nres[-1]=int(S[-1])\n\nd = defaultdict(int)\n\nfor i in range(2,len(S)+1):\n\tre = int(S[i*-1])*pow(10,i-1,2019)\n\tres[i*-1] = (res[i*-1+1]+re)%2019\n\t\n\n\nfor i in res:\n\td[i]+=1\n\nans = d[0]\nfor key in d:\n\tif d[key]>1:\n\t\tans+=comb(d[key],2)\n\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s002902945', 's015264631', 's111999247', 's197757671', 's229819799', 's405689488', 's414509382', 's463491596', 's487142295', 's561393862', 's586461133', 's684857535', 's704950027', 's817229876', 's819608557', 's912526851', 's977009931', 's972502282']
[11236.0, 9228.0, 11968.0, 13008.0, 9216.0, 13008.0, 9324.0, 12988.0, 12520.0, 13088.0, 9248.0, 9052.0, 9204.0, 9268.0, 12204.0, 9092.0, 13252.0, 16684.0]
[379.0, 331.0, 25.0, 2206.0, 21.0, 2206.0, 27.0, 2206.0, 2206.0, 2206.0, 21.0, 19.0, 21.0, 322.0, 77.0, 20.0, 2206.0, 382.0]
[1034, 131, 203, 540, 263, 261, 419, 266, 259, 528, 274, 253, 164, 162, 254, 430, 311, 1067]
p02702
u511379665
2,000
1,048,576
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.
['s=input()\n\nans=0\ndd=[]\n\nfir=int(s[0])*1000+int(s[1])*100+int(s[2])*10+int(s[3])\ndd.append(fir%673)\nfor i in range(4,len(s)):\n tmp=(dd[i-4]*10+int(s[i]))%673\n dd.append(tmp)\n\nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\nbit=Bit(len(dd))\nfor i in range(1,len(dd)+1):\n bit.add(i,dd[i-1])\n#print(dd)\nfor i in range(1,len(dd)):\n for j in range(i+1,len(dd)+1):\n if (bit.sum(j)-bit.sum(i))%673==0 and (bit.sum(j)-bit.sum(i))%3==0 :\n ans+=1\n\n\nprint(ans)\n\n', 's=input()[::-1]\n\ncount=[0]*2019\ncount[0]+=1\nsd=0\nd=1\nfor c in s:\n sd+=int(c)*d\n sd%=2019\n d*=10\n d%=2019\n count[sd]+=1\n\nans=0\nfor cnt in count:\n ans+=cnt*(cnt-1)//2\n\nprint(ans)\n\n']
['Runtime Error', 'Accepted']
['s412471954', 's201643327']
[21596.0, 9220.0]
[2206.0, 110.0]
[766, 191]
p02702
u512212329
2,000
1,048,576
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.
["def main():\n s = input()\n # si = tuple(int(c) for c in s) # integers of one digit\n # ms = {2019 * x for x in range(10 ** 200000 - 1 // 2019)}\n ans = 0\n lg = len(si)\n # to slice till the last letter, +1 is needed.\n for i in range(lg + 1):\n for j in range(i + 4, lg + 1):\n j2 = j\n # 2019 = 673 * 3\n # if sum(si[i:j2]) % 3 != 0:\n # continue\n if int(s[i:j2]) % 2019 == 0:\n ans += 1\n\n return ans\n\n\nif __name__ == '__main__':\n print(main())\n", "def main():\n s = input()\n if int(s) % 2019 == 0:\n return 0\n\n return 1\n\n\nif __name__ == '__main__':\n print(main())\n", "def main():\n s = input()\n rem = [0] * 2019 # the count of the each remainder: 0 ~ 2018\n rem[0] = 1 \n\n temp = 0\n for i, c in enumerate(s[::-1]):\n temp += pow(10, i, 2019) * int(c)\n rem[temp % 2019] += 1\n\n return sum(c * (c - 1) // 2 for c in rem)\n\n\nif __name__ == '__main__':\n print(main())\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s344510696', 's819523692', 's734875634']
[9188.0, 9100.0, 9364.0]
[23.0, 203.0, 301.0]
[544, 133, 351]
p02702
u514118270
2,000
1,048,576
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.
['S = input()\ncnt = [0]*2019\ncnt[0] = 1\nn = 0\nt = 1\nfor i in reversed(S):\n n += i*t\n n %= 2019\n cnt[n] += 1\n t *= 10\n t %= 2019\nprint(sum(i*(i-1)//2 for i in cnt))', 'S = input()\nmod = 2019\ncnt = [0]*mod\ncnt[0] = 1\nn = 0\nt = 1\nfor i in map(int,n[::-1]):\n n += i*t\n cnt[n%mod] += 1\n t *= 10\nprint(sum(i*(i-1)//2 for i in cnt))\n', 'S = input()\ncnt = [0]*2019\ncnt[0] = 1\nn = 0\nt = 1\nfor i in reversed(S):\n n += int(i)*t\n n %= 2019\n cnt[n] += 1\n t *= 10\n t %= 2019\nprint(sum(i*(i-1)//2 for i in cnt))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s158698224', 's910050930', 's134488398']
[9288.0, 9224.0, 9320.0]
[23.0, 21.0, 115.0]
[176, 168, 181]
p02702
u518064858
2,000
1,048,576
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.
['s=input()\nn=len(s)\ns_int=[0]*n\nx=pow(10,n-1)\nfor i in range(n):\n s_int[i]=int(s[i])\n x=x//10\n', 's=input()\nn=len(s)\ns_int=[0]*n\nx=pow(10,n-1)', 's=input()\nn=len(s)\ns_int=[0]*n\nx=pow(10,n-1)\nfor i in range(n):\n s_int[i]=(int(s[i])*x)%2019\n', 's=input()\nn=len(s)\ns_int=[0]*n\nx=pow(10,n-1)\nfor i in range(n):\n s_int[i]=int(s[i])', 's=input()\nn=len(s)\ns_int=[0]*n\nx=pow(10,n-1)\nfor i in range(n):\n s_int[i]=int(s[i]*x)%2019\n', 's=input()\nn=len(s)\ns_int=[0]*n\nx=(pow(10,n-1))%2019\nfor i in range(n):\n s_int[i]=(int(s[i])*x)%2019\n x=(x*202)%2019\nt=[0]*(n+1)\nt[0]=int(s)%2019\nfor i in range(1,n):\n t[i]=t[i-1]-s_int[i-1]\n t[i]%=2019\nt.sort()\nt_set=sorted(list(set(t)))\ntcnt=[0]*len(t_set)\nnum=0\nfor i in range(n+1):\n if t_set[num]==t[i]:\n tcnt[num]+=1\n else:\n num+=1\n tcnt[num]+=1\nsum=0\nfor i in range(len(tcnt)):\n sum+=(tcnt[i]*(tcnt[i]-1))//2\nprint(sum)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s236209190', 's258256660', 's265601578', 's410286441', 's805580365', 's382798884']
[10820.0, 10628.0, 11176.0, 10740.0, 18992.0, 24360.0]
[2206.0, 35.0, 2206.0, 75.0, 2206.0, 434.0]
[99, 44, 96, 86, 94, 467]
p02702
u521866787
2,000
1,048,576
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.
['s=input()\ns= s[::-1]\n\nS=[0,]\ncnt=[0]*2019\ncnt[0]=1\nd=1\nnum=0\nfor i in range(len(s)):\n num += int(s[i])*d\n num %= 2019\n d *= 10\n d%= 2019\n # S.append((int(S[i]) + int(s[i]) * 10**i) % 2019)\n cnt[num]+=1\n\nans=0\nfor i in cnt:\n ans += i*(i-1) //2', 's=input()\ns= s[::-1]\n\nS=[0,]\ncnt=[0]*2019\ncnt[0]=1\nd=1\nnum=0\nfor i in range(len(s)):\n num += int(s[i])*d\n num %= 2019\n d *= 10\n d%= 2019\n # S.append((int(S[i]) + int(s[i]) * 10**i) % 2019)\n cnt[num]+=1\n\nans=0\nfor i in cnt:\n ans += i*(i-1) //2\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s216637643', 's438063220']
[9328.0, 9212.0]
[116.0, 122.0]
[263, 275]
p02702
u532966492
2,000
1,048,576
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.
['def main():\n import heapq\n inf = 10**16\n n, m, s = map(int, input().split())\n uvab = [list(map(int, input().split())) for _ in [0]*m]\n cd = [list(map(int, input().split())) for _ in [0]*n]\n g = [[] for _ in [0]*n]\n [g[a-1].append([b-1, c, d]) for a, b, c, d in uvab]\n [g[b-1].append([a-1, c, d]) for a, b, c, d in uvab]\n vertex = [[inf]*2501 for _ in [0]*n]\n h = [(0, 0, min(s, 2500))] \n heapq.heapify(h)\n while h:\n t, p, money = heapq.heappop(h)\n if vertex[p][money] != inf:\n continue\n vertex[p][money] = t\n newmoney = min(money+cd[p][0], 2500)\n if vertex[p][newmoney] == inf:\n heapq.heappush(h, (t+cd[p][1], p, newmoney))\n for a, b, c in g[p]: \n if money < b:\n continue\n if vertex[a][money-b] != inf:\n continue\n heapq.heappush(h, (t+c, a, money-b))\n for i in vertex[1:]:\n print(min(i))\n\n\nmain()\n', 'def main():\n s = input()\n d = [0]*2019\n d[0] += 1\n now = 0\n for j, i in enumerate(s[::-1]):\n now = (int(i)*pow(10, j, 2019)+now) % 2019\n d[now] += 1\n print(sum([i*(i-1)//2 for i in d]))\n\n\nmain()']
['Runtime Error', 'Accepted']
['s515309726', 's050542375']
[9268.0, 9232.0]
[206.0, 293.0]
[1030, 226]
p02702
u539367121
2,000
1,048,576
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.
['s=input()[::-1]\nn=len(s)\np=2019\nS=[0 for i in range(n+1)]\nans=[0]*p\n\nx10=1\nfor j, i in enumerate(s):\n S[j+1]=(S[j]+(x10*int(i)))%p\n x10=10**j\n x10%=p\n ans[S[j+1]]+=1\n\ncnt=ans[0]\nfor a in ans:\n cnt+=(a*(a-1))//2\n \nprint(cnt)\n', 's=input()[::-1]\nn=len(s)\np=2019\nS=[0 for i in range(n+1)]\nans=[0]*p\n\nx10=1\nfor j, i in enumerate(s):\n S[j+1]=(S[j]+(x10*int(i)))%p\n x10*=10\n x10%=p\n ans[S[j+1]]+=1\n\ncnt=ans[0]\nfor a in ans:\n cnt+=(a*(a-1))//2\n \nprint(cnt)\n']
['Wrong Answer', 'Accepted']
['s519234798', 's225925937']
[11464.0, 16568.0]
[2206.0, 162.0]
[230, 228]
p02702
u539969758
2,000
1,048,576
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.
['S = input()\nlength = len(S)\n\na = [0]*length\nfor i in range(length):\n pickup = int(S[length - i - 1])\n a[i] = pickup*pow(10, i, 2019)\n\n\nb = [0]*length\nb[0] = a[0]\nfor i in range(1, length):\n b[i] = (b[i-1] + a[i]) % 2019\n\ncnt, ans = [0] * 2019, 0\nfor x in b:\n ans += cnt[x]\n cnt[x] += 1\nprint(ans)\n', 'S = list(reversed(input()))\nprint(S)\nlength = len(S)\n\na = [0]*length\nfor i in range(length):\n pickup = int(S[i])\n a[i] = pickup*pow(10, i, 2019)\n\nb = [0]*(length+1)\nfor i in range(1, length+1):\n b[i] = (b[i-1] + a[i-1]) % 2019\ncnt, ans = [0] * 2019, 0\nfor x in b:\n ans += cnt[x]\n cnt[x] += 1\n\nprint(ans)', 'S = list(reversed(input()))\n\nlength = len(S)\n\na = [0]*length\nfor i in range(length):\n pickup = int(S[i])\n a[i] = pickup*pow(10, i, 2019)\n\nb = [0]*(length+1)\nfor i in range(1, length+1):\n b[i] = (b[i-1] + a[i-1]) % 2019\ncnt, ans = [0] * 2019, 0\nfor x in b:\n ans += cnt[x]\n cnt[x] += 1\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s119006904', 's390497894', 's146590893']
[23872.0, 25292.0, 25324.0]
[399.0, 407.0, 395.0]
[308, 318, 310]
p02702
u547608423
2,000
1,048,576
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.
['N,M=map(int,input().split())\n\nli=list(range(N+1))\ncount=0\n\n#print(li)\nfor i in range(M,N+2):\n small=(i*(i-1))//2\n large=small+li[-i]*i\n count+=large-small+1\n\nprint(count%(pow(10,9)+7))', 'S=input()\n\nN=len(S)\ncount=0\ntot=[0]*2019\nS=S[::-1]\nbase=0\n#print(S)\nfor i,s in enumerate(S):\n base+=int(s)*pow(10,i,2019)\n base%=2019\n #tot[base]+=1\n #print(base)\n if base==0:\n count+=1\n count+=tot[base]\n #print(tot[base],i,base)\n tot[base]+=1\n#print(tot) \n\nprint(count)']
['Runtime Error', 'Accepted']
['s511954125', 's382539098']
[9144.0, 9260.0]
[205.0, 343.0]
[193, 304]
p02702
u549383771
2,000
1,048,576
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.
['s = input()\nfrom collections import Counter\nx = 1\nmod = 2019\ntotal = 0\nans = 0\ncnt = Counter()\nfor i in range(len(s)-1,0,-1):\n cnt[total] += 1\n total = int(s[i::])%mod\n ans += cnt[total]\nprint(ans)', 's = input()\nfrom collections import Counter\nx = 1\nmod = 2019\ntotal = 0\nans = 0\ncnt = Counter()\nfor i in range(len(s)-1,-1,-1):\n cnt[total] += 1\n total = total + int(s[i])*x\n total %= mod\n ans += cnt[total]\n x = x*10%2019\nprint(ans)']
['Wrong Answer', 'Accepted']
['s740167277', 's607837783']
[9776.0, 9528.0]
[2205.0, 181.0]
[206, 246]
p02702
u557494880
2,000
1,048,576
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.
['S = input()\nA = [0 for i in range(2019)]\nx = 0\nfor i in range(len(S)):\n p = i + 1\n a = (int(S[-p]))*10**i % 2019\n x = (x+a) % 2019\n A[x] += 1\nans = A[i]\nfor i in range(2019):\n ans += A[i]*(A[i]-1)//2\nprint(ans)', 'S = input()\nA = [0 for i in range(2019)]\nx = 0\nfor i in range(len(S)):\n p = i + 1\n a = (int(S[-p]))10**i % 2019\n x = (x+a) % 2019\n A[x] += 1\nans += A[i]\nfor i in range(2019):\n ans += A[i]*(A[i]-1)//2\nprint(ans)', 'S = input()\nA = [0 for i in range(2019)]\nx = 0\nq = 1\nfor i in range(len(S)):\n p = i + 1\n a = (int(S[-p]))\n b = a*q%2019\n x = (x+b) % 2019\n A[x] += 1\n q = q*10%2019\nans = A[0]\nfor i in range(2019):\n ans += A[i]*(A[i]-1)//2\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s156859593', 's211266450', 's830166026']
[9392.0, 8864.0, 9284.0]
[2206.0, 23.0, 142.0]
[225, 225, 253]
p02702
u558764629
2,000
1,048,576
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.
["S = list(input())\n\na = ''\ncount = 0\ni = 0\nwhile(i < len(S)):\n for j in range(i,len(S)):\n a += S[j]\n if(int(a) % 2019 == 0):\n count += 1\n a = ''\n for j in range(i,len(S) - i):\n a += S[j]\n if(int(a) % 2019 == 0):\n count += 1\n i += 1\n a = ''\nprint(count)", 'S = input()\nP =2019\nans = 0\n \ncount = [0] * P\ncount[0] = 1\nu = 0\nfor i, s in enumerate(reversed(S)):\n u = (int(s) * pow(10, i, P) + u) % P\n ans += count[u]\n count[u] += 1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s612557888', 's902348059']
[10564.0, 9276.0]
[2206.0, 341.0]
[316, 190]
p02702
u561083515
2,000
1,048,576
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.
['\nS = input()\nN = len(S)\n\ncnt = [0] * 2019\n\nans = 0\nfor i in range(N - 1, -1, -1):\n ans += cnt[int(S[i:N]) % 2019]\n cnt[int(S[i:N]) % 2019] += 1\n\nprint(ans)', '\nS = input()\nN = len(S)\n\ncnt = [0] * 2019\n\ncnt[0] = 1\n\nans = 0\ne = 1; cur = 0\nfor s in reversed(S):\n cur = (cur + int(s) * e) % 2019\n\n ans += cnt[cur]\n\n e = (e * 10) % 2019\n cnt[cur] += 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s548961695', 's113141588']
[9196.0, 9336.0]
[2206.0, 115.0]
[171, 221]
p02702
u562577097
2,000
1,048,576
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.
['#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = "x" in file.mode or "r" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b"\\n") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode("ascii"))\n self.read = lambda: self.buffer.read().decode("ascii")\n self.readline = lambda: self.buffer.readline().decode("ascii")\n\n\ndef print(*args, **kwargs):\n """Prints the values to a stream, or to sys.stdout by default."""\n sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop("end", "\\n"))\n if kwargs.pop("flush", False):\n file.flush()\n\n\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n\nfrom math import sqrt, floor, factorial, gcd, log\nfrom collections import deque, Counter, defaultdict\nfrom itertools import permutations\nfrom bisect import bisect\n\ninput = lambda: sys.stdin.readline().rstrip("\\r\\n")\nread = lambda: list(map(int, input().strip().split(" ")))\n\n\n\n\n\ndef solve():\n n = int(input()); arr = read()\n mex = 0; curr = 1\n ans = []\n last = 0\n for i in arr:\n \n \n # exit()\n # else:\n \n if curr < i:\n print(-1);exit()\n if i == mex:\n ans.append(curr)\n else:\n ans.append(mex)\n mex = curr\n curr += 1\n \n\n print(*ans)\n\n\n\n\n\n\n \n\nif __name__ == "__main__":\n\tsolve()', 'import sys\nfrom math import sqrt, gcd, ceil, log\nfrom bisect import bisect\nfrom collections import defaultdict\ninp = sys.stdin.readline\nread = lambda: list(map(int, inp().strip().split()))\n\n\n\n\n\ndef solve():\n\ts = inp().strip();\n\tdic = defaultdict(int); dic[0] = 1\n\t# sett.add(0)\n\tans = 0; cum = 0\n\tfor i in range(len(s)-1, -1, -1):\n\t\tcum += (int(s[i])*pow(10, (len(s)-i-1), 2019)) % 2019\n\t\tcum %= 2019\n\t\tdic[cum] += 1\n\t# print(dic)\n\tfor i in dic:\n\t\tans += ((dic[i])*(dic[i]-1))//2\n\tprint(ans)\n\n\n\n\n\n\nif __name__ == "__main__":\n\tsolve()']
['Runtime Error', 'Accepted']
['s474780215', 's057677097']
[9852.0, 9584.0]
[211.0, 328.0]
[3203, 563]
p02702
u563838154
2,000
1,048,576
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.
['s = (input()[::-1]) \nn = len(s)\ncounts = [0]*2019\ncounts[0]=1\nb = 1\nnum = 0\nfor i in range(n):\n num += int(s[i])*b\n num %=2019\n b *=10\n b %2019\n counts[num]+=1\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n# print(counts)\nans = 0\nfor j in counts:\n ans +=j*(j-1)/2\n\n\nprint(ans)\n', 'import math\ns = (input()[::-1]) \nn = len(s)\ncounts = [0]*2019\ncounts[0]=1\nb = 1\nnum = 0\nfor i in range(n):\n num += int(s[i])*b\n num %=2019\n b *=10\n b %2019\n counts[num]+=1\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n# print(counts)\nans = 0\nfor j in counts:\n if j>=2:\n ans +=combinations_count(j, 2)', 'import math\ns = int(input()[::-1]) \nn = len(s)\ncounts = [0]*2019\ncounts[0]=1\nb = 1\nnum = 0\nfor i in range(n):\n num += s[i]*b\n num %=2019\n b *=10\n b %2019\n counts[num]+=1\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n# print(counts)\nans = 0\nfor j in counts:\n ans +=combinations_count(j, 2)\n\n\nprint(ans)\n\n', 's = (input()[::-1]) \nn = len(s)\ncounts = [0]*2019\ncounts[0]=1\nb = 1\nnum = 0\nfor i in s:\n num += int(i)*b\n num %=2019\n b *=10\n b %=2019\n counts[num]+=1\n\n# print(counts)\nans = 0\nfor j in counts:\n ans +=j*(j-1)/2\n\n\nprint(int(ans))']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s228067951', 's454900745', 's607129587', 's150182839']
[9328.0, 9316.0, 9464.0, 9212.0]
[2206.0, 2206.0, 206.0, 111.0]
[395, 425, 425, 284]
p02702
u564589929
2,000
1,048,576
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.
["import sys\nsys.setrecursionlimit(10 ** 6)\ninput = sys.stdin.readline ####\nint1 = lambda x: int(x) - 1\ndef II(): return int(input())\n \ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\n \ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\n \nINF = float('inf')\n \ndef solve():\n S = list(map(int, list(input())))\n \n S = S[::-1]\n # print(S)\n n = len(S)\n mod = 2019\n \n #\n A = [0] * (n)\n a = 1\n for i in range(n):\n A[i] = S[i] * a\n a = a * 10 % mod\n # print(A)\n \n \n R = [0] * (n+1)\n for j in range(n):\n R[j+1] = (R[j] + A[j]) % mod\n # print(R)\n \n \n cnt = {}\n ans = 0\n for l in range(0, n+1):\n r = R[l]\n ans = ans + cnt.get(r, 0)\n cnt[r] = cnt.setdefault(r, 0) + 1\n print(ans)\n \nif __name__ == '__main__':\n solve()", "import sys\nsys.setrecursionlimit(10 ** 6)\ninput = sys.stdin.readline ####\nint1 = lambda x: int(x) - 1\ndef II(): return int(input())\n\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\n\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\n\nINF = float('inf')\n\ndef solve():\n S = list(map(int, list(input())))\n\n S = S[::-1]\n # print(S)\n n = len(S)\n mod = 2019\n\n #\n A = [0] * (n)\n a = 1\n for i in range(n):\n A[i] = S[i] * a\n a = a * 10 % mod\n # print(A)\n\n \n R = [0] * (n+1)\n for j in range(n):\n R[j+1] = (R[j] + A[j]) % mod\n # print(R)\n\n \n cnt = {}\n ans = 0\n for l in range(0, n+1):\n r = R[l]\n ans = ans + cnt.get(r, 0)\n cnt[r] = cnt.setdefault(r, 0) + 1\n print(ans)\n\nif __name__ == '__main__':\n solve()\n", "import sys\nsys.setrecursionlimit(10 ** 9)\n# input = sys.stdin.readline ####\ndef int1(x): return int(x) - 1\ndef II(): return int(input())\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef MS(): return input().split()\ndef LS(): return list(input())\ndef LLS(rows_number): return [LS() for _ in range(rows_number)]\ndef printlist(lst, k=' '): print(k.join(list(map(str, lst))))\nINF = float('inf')\n# from math import ceil, floor, log2\n# from collections import deque\n# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations\n# from heapq import heapify, heappop, heappush\n# import numpy as np # cumsum\n\n\ndef solve():\n S = list(map(int, LS()))\n S = S[::-1]\n ln = len(S)\n mod = 2019\n\n times = 1\n for i in range(ln):\n S[i] = S[i] * times\n times = times * 10 % mod\n\n R = [0] * (ln+1)\n memo = {0: 1}\n ans = 0\n for i in range(1, ln+1):\n tmp = (R[i-1] + S[i-1]) % mod\n R[i] = tmp\n cnt = memo.get(tmp, 0)\n ans = ans + cnt\n memo[tmp] = cnt + 1\n print(ans)\n\nif __name__ == '__main__':\n solve()\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s225611338', 's992553190', 's344547993']
[12120.0, 12116.0, 23668.0]
[40.0, 40.0, 145.0]
[992, 984, 1384]
p02702
u565448206
2,000
1,048,576
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.
["if __name__ == '__main__':\n n=input()\n count=0\n for i in range(0,len(n)-1):\n for j in range(i+1, len(n)):\n if int(n[i:j+1])%2019==0:\n print(int(n[i:j+1]))\n count+=1\n print(count)", 'num = [0 for i in range(2019)]\nnum[0] = 1\ncount = 0\ns = input()\nnow = 0\np = 1\nfor i in range(len(s) - 1, -1, -1):\n now = (now + int(s[i]) * p) % 2019\n count += num[now]\n num[now] += 1\n p = p * 10 % 2019\nprint(count)']
['Wrong Answer', 'Accepted']
['s749234597', 's981211689']
[9828.0, 9092.0]
[2217.0, 124.0]
[238, 227]
p02702
u572142121
2,000
1,048,576
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.
['s=input()\nn=0\nans=0\nA=[0]*2019\nA[0]=1\nfor i,j in enumerate(reversed(s)):\n n=(n+int(j)*pow(10,i,2019))%2019\n print(i,n)\n A[n]+=1\nfor i in A:\n ans+=i*(i-1)//2\nprint(ans)', 's=input()\nn=0\nans=0\nA=[0]*2019\nA[0]=1\nfor i in range(len(s)):\n n=(n+int(s[-1-i])*pow(10,i,2019))%2019\n #print(i,n)\n A[n]+=1\nfor i in A:\n ans+=i*(i-1)//2\nprint(ans)']
['Wrong Answer', 'Accepted']
['s540899650', 's087369615']
[9180.0, 9296.0]
[427.0, 325.0]
[171, 167]
p02702
u572343785
2,000
1,048,576
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.
["S = str(input())\n\ndef main(S):\n count = 0\n a = len(S)\n \n for i in range(a):\n for j in range(i,a):\n if int(S[i:])%2019 == int(S[j:])%2019:\n count += 1\n print(count)\nif __name__ == '__main__':\n main(S)\n", 's = input()[::-1] \n\ncounts = [0] * 2019\ncounts[0] = 1\n\nnum, d = 0, 1\n\nfor char in s:\n num += int(char) * d\n num %= 2019\n d *= 10\n d%= 2019\n counts[num] += 1\n\nans = 0\nfor cnt in counts:\n ans += cnt * (cnt - 1) // 2\n\nprint(ans) \n']
['Wrong Answer', 'Accepted']
['s301849901', 's240420002']
[9536.0, 9384.0]
[2206.0, 109.0]
[251, 301]
p02702
u579508806
2,000
1,048,576
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.
['string=input()\nlength=len(string)\nmod=[1]*2019\nwhile length > 0:\n mod[int(string[length-1:])%2019]+=1\n length-=1\nprint(int(sum([(i*(i-1))/2 for i in mod])))\n', 'string=input()\nlength=len(string)\nmod=[0]*2019\nwhile length > 0:\n mod[int(string[length-1:])%2019]+=1\n length-=1\nprint(int(sum([(i*(i-1))/2 for i in mod])))\n', 'string=input()\nlength=len(string)\nmod=[0]*2019\nwhile length > 0:\n mod[int(string[length-1:])%2019]+=1\n length-=1\nprint(int(sum([(i*(i-1))/2 for i in mod])))', 'string=input() \nlength=len(string) の長さ\nmod=[1]+[0]*2018 \nwhile length > 0: \n s = int(string[length-1:]) \n mod[s%2019]+=1\n length-=1\nanswer=0\nfor i in mod:\n answer+=int(i*(i-1)/2)\nprint(answer)\n', 'string=input()\ncount=0\ntimes=1\nlength=4\nwhile len(string) >= 4:\n target=int(string[:length])\n if len(string) <= length and target <= 200000 and target % 2019 == 0:\n count+=1\n length+=1\n if times % 3 == 0:\n length=4\n string=string[1:]\n times+=1\nprint(count)\n', 'string=input()\nlength=len(string)\nmod=[0]*2019\nwhile length > 0:\n mod[int(string[length-1:])%2019]+=1\n length-=1\nprint(int(sum([(i*(i-1))/2 for i in mod])))', 'string=input()\nlength=len(string)\nmod=[1]+[0]*2018\ns=0\nfor i in range(length):\n s=(s+int(string[-1-i])*pow(10,i,2019))%2019\n mod[s]+=1\nprint(sum([i*(i-1)//2 for i in mod]))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s104780189', 's506920804', 's680170063', 's758301823', 's831479625', 's982715603', 's610720925']
[9256.0, 9228.0, 9408.0, 9188.0, 9368.0, 9352.0, 9312.0]
[2206.0, 2206.0, 2205.0, 2206.0, 881.0, 2206.0, 325.0]
[159, 159, 158, 303, 271, 158, 175]
p02702
u580273604
2,000
1,048,576
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.
["S=input()\ns=int(S)\nc=0\nfor i in range(1,s//2019+1):\n C=str(2019*i)\n if '0' in C:\n continue\n if C in S:\n c+=1\nprint(c)\n\n\nexit()\n\n\n\n\nc=0;s=[]\nfor i in range(0,len(S)+1):\n for j in range(i,len(S)):\n s.append(S[i:j+1])\ndel s[0]\nss = [int(i) for i in s] \n#print(ss)\nsss = list(map(lambda x: x %2019, ss))\n\n#print(sss)\nprint(sss.count(0))\n", 'S=input()\ns=int(S)\nmod=2019\nc=[0]*(len(S)+1)\nd=[0]*2019\n\n\nc[0]=0\nd[0]=1\nfor i in range(len(S)):\n c[i+1]=(c[i]+int(S[-i-1])*pow(10,i,mod))%mod\n d[c[i+1]]+=1\n \nm=0\nfor i in range(2019):\n m+=d[i]*(d[i]-1)//2\n\nprint(m)']
['Time Limit Exceeded', 'Accepted']
['s790347160', 's989263040']
[9788.0, 16236.0]
[2206.0, 521.0]
[349, 218]
p02702
u580697892
2,000
1,048,576
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.
['# coding: utf-8\nS = input()\nans = 0\nfor i in range(len(S)):\n for j in range(i+4, len(S)):\n tmp = int(S[i:j])\n if tmp % 2019 == 0:\n ans += 1\nprint(ans)', '# coding: utf-8\nS = input()\nans = 0\nP = 2019\nN = len(S)\nS = S[::-1]\ncnt = [0 for _ in range(P)]\ncnt[0] = 1\nv = 0\nbai = 1\nfor i in range(N):\n v += int(S[i]) * bai\n v %= P\n bai *= 10\n bai %= P\n cnt[v] += 1\nfor i in range(P):\n ans += ((cnt[i] - 1) * cnt[i]) // 2\nprint(ans)']
['Wrong Answer', 'Accepted']
['s582886220', 's677147939']
[9340.0, 9348.0]
[2205.0, 128.0]
[178, 288]
p02702
u585704797
2,000
1,048,576
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.
['\nS=input()\ns=[0 for i in range(len(S))]\n\nfor i in range(len(S)):\n s[i]=int(S[i])\nCHECK=[0 for i in range(2021)]\nans=0\ntemp=0\nfor i in range(1,len(s)+1):\n #print(s[-i])\n temp=(temp+s[-i]*pow(10,i-1,2019)+2019*2)%2019\n #print(i,temp)\n #print(temp)\n CHECK[temp]+=1\nfor i in CHECK:\n ans+=i*(i+1)//2\n \nprint(ans)', '\nS=input()\ns=[0 for i in range(len(S)+1)]\n\nfor i in range(len(S)):\n s[i]=int(S[i])\nCHECK=[0 for i in range(2021)]\nans=0\ntemp=0\nfor i in range(1,len(s)+1):\n #print(s[-i])\n temp=(temp+s[-i]*pow(10,i-1,2019)+2019*2)%2019\n #print(i,temp)\n #print(temp)\n CHECK[temp]+=1\nfor i in range(2020):\n if i==0:\n ans+=CHECK[i]\n else:\n ans+=max(0,CHECK[i]-1)\n \nprint(ans)', '\nS=input()\ns=[0 for i in range(len(S))]\n\nfor i in range(len(S)):\n s[i]=int(S[i])\nCHECK=[0 for i in range(2021)]\nans=0\ntemp=0\nfor i in range(1,len(s)+1):\n #print(s[-i])\n temp=(temp+s[-i]*pow(10,i-1,2019)+2019*2)%2019\n #print(i,temp)\n #print(temp)\n CHECK[temp]+=1\nfor i in CHECK:\n ans+=i*(i-1)//2\n\nans+=CHECK[0]\n \nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s778309392', 's835723336', 's034979673']
[10728.0, 10900.0, 10956.0]
[347.0, 349.0, 330.0]
[328, 392, 343]
p02702
u586639900
2,000
1,048,576
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.
['S = int(input())\n\nleng = len(str(S))\ncount = 0\n\nfor j in range(leng-3):\n for i in range(leng, 1, -1):\n partial = S // (10 ** j)\n partial = partial % (10 ** i)\n if partial == 0:\n continue\n if partial % 2019 == 0:\n count += 1\n\nprint(count)\n', 'S = input()\nS = S[::-1]\nleng = len(S)\nS = int(S)\n\ncount = [0] * 2019\ncount[0] = 1\n\nfor i in range(leng):\n remainder = (S // (10**i)) % 2019\n\nres = 0\nfor cnt in count:\n res += cnt * (cnt - 1) // 2\n \nres', 'S = input()\nleng = len(S)\nS = int(S)\n\ncount = [0] * 2019\ncount[0] = 1\n\nfor i in range(leng):\n remainder = (S // (10**i)) % 2019\n count[remainder] += 1\n\nres = 0\nfor cnt in count:\n res += cnt * (cnt - 1) // 2\n\nprint(res)', 'S = input()\nS = S[::-1]\nleng = len(S)\nS = int(S)\n\ncount = [0] * 2019\ncount[0] = 1\n\nfor i in range(leng):\n remainder = i % 2019\n\nres = 0\nfor cnt in count:\n res += cnt * (cnt - 1) // 2\n\nprint(res)', 'S = input()\nS = S[::-1]\nleng = len(S)\nS = int(S)\n\ncount = [0] * 2019\ncount[0] = 1\n\nfor i in range(leng):\n remainder = (S // (10**i)) % 2019\n print(S//(10**i), remainder)\n count[remainder] += 1\n\nres = 0\nfor cnt in count:\n res += cnt * (cnt - 1) // 2\n\nprint(res)', 'S = input()\nleng = len(S)\nS = S[::-1]\n\ncount = [0] * 2019\ncount[0] = 1\n\nnum = 0\nd = 1\n\nfor char in S:\n num += int(char) * d\n num %= 2019\n count[num] += 1\n d *= 10\n d %= 2019\n\n\nres = 0\nfor cnt in count:\n res += cnt * (cnt - 1) // 2\n\nprint(res)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s184791944', 's326097377', 's340363838', 's460149576', 's658323208', 's074144656']
[9520.0, 9156.0, 9176.0, 9304.0, 9744.0, 9288.0]
[2205.0, 2206.0, 2206.0, 221.0, 2210.0, 111.0]
[291, 210, 227, 200, 272, 261]
p02702
u588794534
2,000
1,048,576
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.
['baisu=set([])\n\ni=1\nwhile 1:\n temp=2019*i\n if "0" not in str(temp):\n baisu.add(str(temp))\n \n if temp>2000000000:\n break\n i+=1\n\nn=input()\ncnt=0\nfor i in baisu:\n if i in n:\n cnt+=1\n\nprint(cnt)\n\n', 's=input()\n\n\n\n\n\n\n\n\n\n\ncnt=[0]*2019\n\ncnt[0]=1\n\n\nfac=1\n\nfor i in range(len(s)):\n \n ss = int(s[len(s)-i-1])*fac\n ss%=2019\n fac=fac*10\n fac%=2019\n cnt[ss]+=1\n\nresult=0\nfor c in cnt:\n result+=cnt*(cnt-1)//2\n\nprint(result)\n\n\n\n', 'baisu=set([])\n\ni=1\nwhile 1:\n temp=2019*i\n if "0" not in str(temp):\n baisu.add(str(temp))\n \n if temp>20000000000:\n break\n i+=1\n\nn=input()\ncnt=0\nfor i in baisu:\n if i in n:\n cnt+=1\n\nprint(cnt)\n\n', 'baisu=set([])\n\ni=1\nwhile 1:\n temp=2019*i\n if "0" not in str(temp):\n baisu.add(str(temp))\n \n if temp>20000000:\n break\n i+=1\n\nn=input()\ncnt=0\nfor i in baisu:\n if i in n:\n cnt+=1\n\nprint(cnt)\n\n', 's=input()\n\n\n\n\n\n\n\n\n\n\ncnt=[0]*2019\n\ncnt[0]=1\n\n\nfac=1\nss=0\nfor i in range(len(s)):\n \n ss += int(s[len(s)-i-1])*fac\n ss%=2019\n fac=fac*10\n fac%=2019\n cnt[ss]+=1\n \n\nresult=0\nfor c in cnt:\n result+=c*(c-1)//2\n\nprint(result)\n\n\n\n']
['Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s052074042', 's157034181', 's569352850', 's694297906', 's613301491']
[53268.0, 9156.0, 193100.0, 9972.0, 9160.0]
[2207.0, 130.0, 2212.0, 1334.0, 144.0]
[230, 1358, 231, 228, 1364]
p02702
u595905528
2,000
1,048,576
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.
['def digitSum(n):\n \n s = str(n)\n \n array = list(map(int, s))\n \n return sum(array)\nS = input()\nScount = 0\nfor i in range(len(S)):\n for j in range(1,len(S)):\n if (i+j)<len(S):\n part_S = S[i:i+j]\n num = int(part_S)\n if num % 673 == 0:\n num = int(num/673)\n sum3 = digitSum(num)\n while sum3 != digitSum(sum3):\n sum3 = digitSum(sum3)\n if sum3 == 3 or sum3 == 6 or sum3 ==9:\n Scount += 1\nprint(Scount)', 'S = input()\nfrom collections import defaultdict\nd = defaultdict(int)\nbefore = 0\nfor i in range(1,len(S)+1):\n now = (int(S[-i])*pow(10,i,2019)+before) % 2019\n d[now] += 1\n before = now\nd[0] += 1\nans = 0\nfor i in d.values():\n ans += i*(i-1)//2\nprint(ans)']
['Runtime Error', 'Accepted']
['s079564818', 's008988529']
[9276.0, 9556.0]
[24.0, 338.0]
[648, 264]
p02702
u596681540
2,000
1,048,576
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.
['from collections import defaultdict\n\n\ns = input()\nn = len(s)\n\ndd = defaultdict(int)\n\nd = [0] * 2019\ndd[0] = 1\ntmp = 0\n_10 = 1\n# print(s, n)\nfor i in range(n - 1, -1, -1):\n # print(i, s[i])\n tmp = tmp + int(s[i]) * _10\n _10 *= 10\n # print(tmp, tmp % 2019)\n d[tmp % 2019] += 1\n\n\ncount = 0\nfor i in range(len(d)):\n if d[i] >= 2:\n count += (d[i])*(d[i]-1)//2\nprint(count)\n\n# print(dd)\n\n', 'import math\ns = input()\nn = len(s)\ncount = 0\na = [0 for i in range(2019)]\na[0] = 1\nk = 0\nb = [0 for i in range(n)]\nb[0] = 1\nfor i in range(1, n):\n b[i] = b[i-1]*10 % 2019\n\nprint(b)\nfor i in reversed(range(0, n)):\n print((b[n-i-1])*int(s[i]) % 2019)\n k += (b[n-i-1])*int(s[i]) % 2019\n print(k, k % 2019)\n a[k % 2019] += 1\n\nfor i in range(len(a)):\n if a[i] >= 2:\n count += (a[i])*(a[i]-1)//2\nprint(count)\n', 'import math\ns = input()\nn = len(s)\ncount = 0\na = [0 for i in range(2019)]\na[0] = 1\nk = 0\nb = [0 for i in range(n)]\nb[0] = 1\nfor i in range(1, n):\n b[i] = b[i-1]*10 % 2019\n\nprint(b)\nfor i in reversed(range(0, n)):\n print((b[n-i-1])*int(s[i]) % 2019)\n k += (b[n-i-1])*int(s[i]) % 2019\n print(k, k % 2019)\n a[k % 2019] += 1\n\nfor i in range(len(a)):\n if a[i] >= 2:\n count += (a[i])*(a[i]-1)//2\nprint(count)\n', 'for i in range(100):\n t = i * 2019\n if t > 200000:\n break\n for i in range(len(str(s))):\n for j in range(i+1, len(str(s))+1):\n tmp = s[i:j]\n if int(tmp) == t:\n c += 1\n\n\nprint(c)', 's = input()\nc = 0\n\n\n# for j in range(i+1, len(str(s))+1):\n# tmp = s[i:j]\n# if int(tmp) % 2019 == 0:\n# c += 1\n\nfor i in range(1, 100):\n t = i * 2019\n if t > 200000:\n break\n for i in range(len(str(s))):\n for j in range(i+1, len(str(s))+1):\n tmp = s[i:j]\n if int(tmp) == t:\n print(t)\n c += 1\n\n\nprint(c)\n', 'from collections import defaultdict\n\n\ns = input()\nn = len(s)\n\ndd = defaultdict(int)\n\nd = [0 for i in range(2019)]\nd[0] = 1\ntmp = 0\n_10 = 1\n# print(s, n)\nfor i in range(n - 1, -1, -1):\n # print(i, s[i])\n # print(int(s[i]), _10)\n tmp += (int(s[i]) * _10) % 2019\n _10 *= 10\n _10 %= 2019\n # print(tmp, tmp % 2019)\n d[tmp % 2019] += 1\n\n\n# print((b[n-i-1]), int(s[i]))\n# tmp += _10 * int(s[i]) % 2019\n# _10 *= 10 % 2019\n# print(tmp, tmp % 2019)\n# a[tmp % 2019] += 1\n\n\n# count = 0\n\n\n# count += (d[i])*(d[i]-1)//2\n# print(count)\n\n# # print(dd)\nprint(sum(v*(v-1)//2 for v in d))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s105625193', 's362906918', 's814966521', 's818452019', 's967154165', 's311577204']
[9520.0, 18608.0, 18696.0, 9044.0, 9412.0, 9516.0]
[2206.0, 425.0, 421.0, 20.0, 2205.0, 123.0]
[452, 428, 428, 236, 437, 696]