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
p02701
u830162518
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N=int(input())\nS=[input() for i in range (N)]\nL=list(S)\nsorted(L)\nprint(len(L)+1)', 'N=int(input())\nL=[input() for i range(N)]\nM=sorted(L)\nprint(len(M))', 'N=int(input())\nL=[input() for i in range(n)]\nM=set(L)\nprint(len(M))', 'N=int(input())\nL=[input() for i in range(N)]\nM=set(L)\nprint(len(M))\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s159697949', 's277641967', 's744992340', 's617088755']
[27088.0, 8912.0, 9172.0, 35588.0]
[284.0, 20.0, 24.0, 263.0]
[81, 67, 67, 68]
p02701
u834983620
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['a = int(input())\naaa = list([input(i)for i in range(a)])\n\nans = len(set(aaa))\n\nprint(ans)', 'a = int(input())\naaa = set([input()for i in range(a)])\n\nbbb = list(set(aaa))\n\nans = len(bbb)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s427867273', 's342424863']
[36184.0, 39436.0]
[609.0, 290.0]
[89, 104]
p02701
u842901156
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['from collections import Counter\nN = int(input())\ns = [input() for i in range(N)]\nprint(len(s))', 'from collections import Counter\nN = int(input())\ns = [input() for i in range(N)]\nc = collections.Counter(s)\nprint(len(c))', 'N = int(input())\ns = [input() for i in range(N)] \nc = collections.Counter(s)\nprint(len(c))', 'N = int(input())\ns = [input() for i in range(N)] \nc = collections.Counter(s)\nprint(c)', 'from collections import Counter\nN = int(input())\ns = [input() for i in range(N)]\nc = Counter(s)\nprint(len(c))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s140925902', 's424120558', 's634455521', 's911665681', 's297965079']
[23616.0, 23536.0, 23212.0, 23252.0, 38900.0]
[231.0, 229.0, 229.0, 227.0, 261.0]
[94, 121, 127, 122, 109]
p02701
u845847173
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['from collections import Counter\n\nn = int(input())\ns = [str(e) for e in input().split()]\nprint(len(Counter(s)))', 'from collections import Counter\n\nn = int(input())\ns = []\nfor _ in range(n):\n s.append(input())\nprint(len(Counter(s)))']
['Wrong Answer', 'Accepted']
['s989375439', 's302349645']
[9472.0, 38900.0]
[23.0, 282.0]
[110, 120]
p02701
u847692421
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nS = []\nfor i in range(1, N+1):\n S_i = input()\n S.append(S_i)\ncnt = 0\nfor i in range(0, N):\n flg = 0\n for j in range(i+1, N):\n if( S[i] == S[j]):\n break\n if(flg ==0):\n cnt += 1\nprint(cnt)', 'N = int(input())\nS = []\nfor i in range(1, N+1):\n S_i = input()\n S.append(S_i)\nA = set(S)\nprint(len(A))']
['Wrong Answer', 'Accepted']
['s147097289', 's725375947']
[23444.0, 35360.0]
[2206.0, 279.0]
[291, 116]
p02701
u848535504
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nS = [int(input()) for i in range(N)]\n\nprint(len(set(S)))', 'N = int(input())\nS = [input() for i in range(N)]\n\nprint(len(set(S)))']
['Runtime Error', 'Accepted']
['s607407262', 's194451921']
[9120.0, 35632.0]
[24.0, 258.0]
[73, 68]
p02701
u848647227
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['a = int(input())\nar = []\nfor i in range(a):\n ar.append(l)\nprint(len(set(ar)))', 'a = int(input())\nar = []\nfor i in range(a):\n l = input()\n ar.append(l)\nprint(len(set(ar)))']
['Runtime Error', 'Accepted']
['s915178433', 's644660123']
[9104.0, 35508.0]
[22.0, 275.0]
[80, 96]
p02701
u850087201
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['import numpy as np\nN = int(input())\nl = []\nfor i in range(N):\n l.append(input())\nk = np.array(l)\nans = 0\nfor i in range(N):\n a = 0\n if k[np.argsort(k)[i]]!=a:\n ans+= 1\n a = k[np.argsort(k)[i]]', 'N = int(input())\nl = []\nfor i in range(N):\n l.append(input())\nk = sorted(l)\nans = 0\nfor i in range(N):\n a = 0\n if l[i]!=a:\n ans+= 1\n a = l[i]\nprint(ans)', 'N = int(input())\nl = []\nfor i in range(N):\n l.append(input())\nk = sorted(l)\nans = 0\nfor i in range(N):\n a = 0\n if k[i]!=a:\n ans+= 1\n a = k[i]\nprint(ans)', 'N = int(input())\nl = []\nfor i in range(N):\n l.append(input())\nk = sorted(l)\nans = 0\na = 0\nfor i in range(N):\n if k[i]!=a:\n ans+= 1\n a = k[i]\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s184168061', 's580478528', 's842827367', 's789387567']
[59964.0, 25460.0, 25296.0, 25596.0]
[2207.0, 349.0, 359.0, 362.0]
[215, 175, 175, 171]
p02701
u850479192
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['\ni = int(input())\nlists = []\nfor j in range(i):\n lists.insert(j, str(input()))\n\nprint(lists)\nprint(len(set(lists)))\n', 'i = int(input())\nlists = []\nfor j in range(i):\n lists.insert(j, str(input()))\n\nprint(lists)\nprint(len(set(lists)))', 'i = int(input())\nlists = []\nfor j in range(i):\n lists.insert(j, str(input()))\n\nprint(lists)\nprint(len(set(lists)))\n', 'N = int(input())\nlists = []\nfor i in range(N):\n lists.append(input())\nset_S = list(set(lists))\nprint(len(set_S))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s136830669', 's857236443', 's927356404', 's870801770']
[37900.0, 38084.0, 38032.0, 35580.0]
[318.0, 321.0, 321.0, 277.0]
[154, 117, 118, 116]
p02701
u855831834
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nans = {}\nfor i in range(N):\n t = input()\n if t not in ans:\n ans[t] = 1\nprint(len(ans.keys())', 'N = int(input())\nans = {}\nfor i in range(N):\n t = input()\n if t not in ans:\n ans[t] = 1\nprint(len(ans.keys()))\n']
['Runtime Error', 'Accepted']
['s731483802', 's532530813']
[8908.0, 35292.0]
[20.0, 280.0]
[114, 116]
p02701
u857673087
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nS =[input() for i in range(N+1)]\n\ns = set(S)\n\nprint(len(s))', 'N = int(input())\nS =[input() for i in range(N)]\n\ns = set(S)\n\nprint(len(s))']
['Runtime Error', 'Accepted']
['s751695314', 's734888076']
[23352.0, 35640.0]
[224.0, 270.0]
[76, 74]
p02701
u862920361
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['mport collections\nS=[]\nN=int(input())\nfor i in range(N):\n S.append(input())\nprint(len(collections.Counter(S)))\n \n\n \n\n', 'import collections\nS=[]\nN=int(input())\nfor i in range(N):\n S.append(input())\nprint(len(collections.Counter(S)))\n ']
['Runtime Error', 'Accepted']
['s802370161', 's007942651']
[9012.0, 38920.0]
[23.0, 280.0]
[126, 119]
p02701
u863433366
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n = int(input())\ns = [input() for _ in range(n)]\nans = [[] for _ in range(n)]\n\nfor i in range(n):\n ans[i] = s[i]\n\nprint(len(ans))', 'n = int(input())\ns = [input() for _ in range(n)]\nans = [[] for _ in range(n)]\n\nfor i in range(n):\n ans[i] = s[i]\n\nANS = set(ans)\nprint(len(ANS))']
['Wrong Answer', 'Accepted']
['s866280338', 's390967789']
[37460.0, 37388.0]
[292.0, 326.0]
[130, 148]
p02701
u863955163
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nS = [input() for i in range(N)]\na = set(S)\nprint(len(a)', 'N = int(input())\nS = [input() for i in range(N)]\na = set(S)\nprint(len(a))']
['Runtime Error', 'Accepted']
['s034901130', 's352115960']
[8896.0, 35584.0]
[22.0, 268.0]
[72, 73]
p02701
u865728927
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n = int(input())\nli = list()\nfor i range(n):\n\tli.append(str(input()))\n\nprint(len(set(li)))\n\n', 'n = int(input())\nli = list()\nfor i in range(n):\n\tli.append(str(input()))\n\nprint(len(set(li)))\n\n']
['Runtime Error', 'Accepted']
['s363517880', 's707802758']
[8948.0, 35572.0]
[23.0, 293.0]
[92, 95]
p02701
u866700524
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['M = int(input())\nP = [input().split() for i in range(M)]\nprint(len(set(P)))', 'M = int(input())\nP = [input() for i in range(M)]\nprint(len(set(P)))']
['Runtime Error', 'Accepted']
['s878950710', 's960333937']
[55068.0, 35572.0]
[326.0, 252.0]
[75, 67]
p02701
u875049118
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N=input()\nS = [str(input()) for i in range(N)]\nprint(len(set(S)))', 'S=[str(input()) for i in range(2*10^5-1)]\nS.pop(0)\nprint(len(set(S)))', 'S=[str(input()) for i in range(2*10^1-1)]\nS.pop(0)\nprint(len(set(S))', "S = [str(input()) for i in range(2*10^5)]\n#(2*10^5): \nS.pop(0)\nif '' in S:\n print(len(set(S))-1)\nelse:\n print(len(set(S)))", 'N=int(input())\nS = [str(input()) for i in range(N)]\nprint(len(set(S)))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s219441774', 's861656540', 's931226814', 's934309671', 's123835620']
[9096.0, 9096.0, 9016.0, 9116.0, 35728.0]
[22.0, 22.0, 23.0, 24.0, 277.0]
[65, 69, 68, 131, 70]
p02701
u878291720
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nS = set()\nfor i in range(N):\n S.add(i)\nprint(len(S))', 'N = int(input())\nS = set()\nfor i in range(N):\n S.add(input())\nprint(len(S))']
['Wrong Answer', 'Accepted']
['s259957736', 's328353937']
[26232.0, 31040.0]
[52.0, 288.0]
[70, 76]
p02701
u883218362
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['# C - gacha\n\nn = int(input())\ns = []\nc = 0\n\nfor i in range(n):\n s.append(input())\n\ns.sort()\n\nfor j in range(n-1):\n if s[j] != s[j+1]:\n c += 1\n\n\nprint(c)\n', '# C - gacha\n\nn = int(input())\ns = []\nc = 1\n\nfor i in range(n):\n s.append(input())\n\ns.sort()\n\nfor j in range(1,n):\n if s[j-1] != s[j]:\n c += 1\n\n\nprint(c)\n']
['Wrong Answer', 'Accepted']
['s400001689', 's376075235']
[23776.0, 23788.0]
[350.0, 337.0]
[166, 166]
p02701
u884601206
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n=int(input())\na=list(map(int,input().split()))\na=set(a)\nprint(len(a))\n', 'n=int(input())\na=[0]*n\nfor i in range(n):\n a[i]=input()\n \na=set(a)\nprint(len(a))\n\n']
['Runtime Error', 'Accepted']
['s656787862', 's239182324']
[9168.0, 35544.0]
[22.0, 276.0]
[71, 84]
p02701
u891202624
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N=int(input())\nS=[]\ncount++\nfor i in range(N):\n A=input()\n if A not in S:\n S.append(A)\n count+=1\nprint(count)', 'N=int(input())\nS=[]\nfor i in range(N):\n A=input()\n S.append(A)\nprint(len(set(S)))']
['Runtime Error', 'Accepted']
['s543813442', 's413062097']
[8932.0, 35552.0]
[27.0, 276.0]
[129, 87]
p02701
u892882715
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\n\nitems = [input() for _ in range(N)]\n\nd = {}\nfor item in items:\n if item not in d:\n d[item] = True\n print(item)\n \n', 'N = int(input())\n\nd = {}\n\nfor _ in range(N):\n s = input()\n if s not in d:\n print(s)\n d[s] = 1\n \n', 'N = int(input())\n\ns = set(input() for _ in range(N))\n \nprint(len(s))\n \n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s684444515', 's770763463', 's619501126']
[38512.0, 35400.0, 30960.0]
[341.0, 700.0, 270.0]
[139, 105, 75]
p02701
u904081717
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = input()\nstr_list = [input() for _ in range(N)]\n\nprint(len(set(str_list)))', 'N = int(input())\nstr_list = [input() for _ in range(N)]\n\nprint(len(set(str_list)))\n']
['Runtime Error', 'Accepted']
['s629129832', 's078787239']
[9048.0, 35724.0]
[21.0, 258.0]
[77, 83]
p02701
u906024886
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['A=map(int,input().split())\nlist = []\nfor n in range(A):\n\tcon = str(input())\n\tif con not in list:\n\t\tlist.append(con)\n\telse: pass\nprint(str(len(list)))\n', 'n = int(input())\ns = set(input() for _ in range(n))\nprint(len(s))']
['Runtime Error', 'Accepted']
['s519962584', 's954067025']
[9096.0, 30984.0]
[23.0, 261.0]
[150, 65]
p02701
u907223098
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n=int(input())\nr=0\nl=[]\nfor i in range(n):\n l.append(input())\nl.sort()\nfor i in range(n-1):\n if l[i]!=l[i+1]:\n r+=1\n \nprint(r)\n', 'n=int(input())\nr=1\nl=[]\nfor i in range(n):\n l.append(input())\nl.sort()\nfor i in range(n-1):\n if l[i]!=l[i+1]:\n r+=1\n \nprint(r)\n']
['Wrong Answer', 'Accepted']
['s839409109', 's088087249']
[23952.0, 23960.0]
[340.0, 349.0]
[133, 133]
p02701
u907566687
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\n\narr = []\n\nfor i in range(N):\n arr.append(input())\n\nprint(len(set(arr))', 'N = int(input())\n\narr = []\n\nfor i in range(N):\n arr.append(input())\n\nprint(len(arr.set()))', 'N = int(input())\n\narr = []\n\nfor i in range(N):\n arr.append(input())\n\nprint(len(set(arr)))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s216908895', 's330270683', 's749969586']
[9028.0, 23268.0, 35524.0]
[23.0, 243.0, 260.0]
[91, 93, 92]
p02701
u912867658
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n = int(input())\nal = []\ncount = 1\nfor i in range(n):\n a = input()\n if a\u3000in al:\n count += 1\n else:\n al.append(a)\nprint(count)', 's = set(open(0))\nprint(len(s)-1)\n']
['Runtime Error', 'Accepted']
['s895798855', 's179855816']
[8960.0, 30948.0]
[20.0, 75.0]
[136, 33]
p02701
u919065552
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nL = []\nif not (1 <= N <= 2*(10**5)):\n exit()\n\n\nfor i in range(N):\n d = input()\n if not (1 <= len(d) <= 10):\n exit()\n if not (d.lower() == d):\n exit()\n L.append(d)\n\nprint(len(set(L)))\nroot@stypr-ubuntu:~/1# ', 'N = int(input())\nL = []\nif not (1 <= N <= 2*(10**5)):\n exit()\n\n\nfor i in range(N):\n d = input()\n # if not (1 <= len(d) <= 10):\n # exit()\n # if not (d.lower() == d):\n # exit()\n L.append(d)\n\nprint(len(set(L)))']
['Runtime Error', 'Accepted']
['s493418883', 's988003712']
[9080.0, 35564.0]
[23.0, 277.0]
[252, 235]
p02701
u926517746
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\n# N = 3\n\nitems = []\n\nfor i in range(0, N) :\n newItem = str(input())\n # newItem = str("apple")\n\n if newItem not in items :\n items.append(newItem)\n\nlen(items)', 'N = int(input())\n# N = 3\n\nitems = set()\n\nfor i in range(0, N) :\n items.add(str(input()))\n # items.add(str("apple"))\n # print(newItem)\n\nprint(len(items)) # don\'t forget print()!']
['Wrong Answer', 'Accepted']
['s203471610', 's060643460']
[10160.0, 31116.0]
[2206.0, 317.0]
[189, 185]
p02701
u928347588
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n = int(input())\nls = []\ncount = 0\nfor x in range(n):\n ls.append(input())\nset(ls)\nprint(len(ls))', 'n = int(input())\nls = []\ncount = 0\nfor x in range(n):\n ls.append(input())\nls = set(ls)\nprint(len(ls))']
['Wrong Answer', 'Accepted']
['s398372123', 's315312977']
[35592.0, 35588.0]
[274.0, 279.0]
[99, 104]
p02701
u931636178
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input)\nans = []\nfor _ in range(N):\n s = input()\n ans.append(s)\nprint(len(list(set(ans)))', 'N = int(input())\nans = []\nfor _ in range(N):\n s = input()\n ans.append(s)\nprint(len(list(set(ans))))']
['Runtime Error', 'Accepted']
['s351044868', 's310524862']
[8968.0, 35656.0]
[20.0, 283.0]
[98, 101]
p02701
u932868243
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n=int(input())\nlists=[input() for x in range(n)]\nlistget=[]\nfor s in lists:\n for y in range(1,n+1):\n listget.append(s[y])\nprint(len(set(listget))\n \n ', 'n=int(input())\nlists=[input() for x in range(n)]\nprint(len(set(lists))', 'n=int(input())\ns=[input() for _ in range(n)]\nprint(len(set(s)))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s959169351', 's963524186', 's720179872']
[9032.0, 8972.0, 35580.0]
[22.0, 22.0, 257.0]
[168, 70, 63]
p02701
u935089856
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\na = []\n\nfor i in range(N):\n a.append(input())\n \nb = set(a)\nprint(len(a))', 'N = int(input())\na = []\n\nfor i in range(N):\n a.append(input())\n \nb = set(a)\nprint(len(b))']
['Wrong Answer', 'Accepted']
['s743897659', 's265166869']
[35708.0, 35588.0]
[281.0, 287.0]
[91, 91]
p02701
u938718404
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n=int(input())\nli=[]\nfor si in n:\n si=input()\n li.append(si)\nprint(len(set(li)))', 'n=int(input())\nli=[]\nfor si in range(n):\n si=input()\n li.append(si)\nprint(len(set(li)))']
['Runtime Error', 'Accepted']
['s580509455', 's800224945']
[9144.0, 35596.0]
[22.0, 275.0]
[86, 93]
p02701
u940592576
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n = int(input())\nobj= []\nfor i in range (n):\n\tobj.append(input())\ndictOfElems = dict()\nfor elem in obj:\n if elem in dictOfElems:\n dictOfElems[elem] += 1\n else:\n dictOfElems[elem] = 1\nprint(len(dict))', 'n = int(input())\nobj= []\nfor i in range (n)\n\tobj.append(input())\ndictOfElems = dict()\n # Iterate over each element in list\n for elem in obj:\n # If element exists in dict then increment its value else add it in dict\n if elem in dictOfElems:\n dictOfElems[elem] += 1\n else:\n dictOfElems[elem] = 1\nprint(len(dict))\n', 'n = int(input())\nobj= []\nfor i in range (n):\n\tobj.append(input())\ndictOfElems = dict()\n # Iterate over each element in list\n for elem in obj:\n # If element exists in dict then increment its value else add it in dict\n if elem in dictOfElems:\n dictOfElems[elem] += 1\n else:\n dictOfElems[elem] = 1\nprint(len(dict))', 'n = int(input())\nobj= []\nfor i in range (n):\n\tobj.append(input())\ndictOfElems = dict()\nfor elem in obj:\n if elem in dictOfElems:\n dictOfElems[elem] += 1\n else:\n dictOfElems[elem] = 1\nprint(len(dictOfElems))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s173469825', 's239641936', 's415549792', 's127306244']
[38204.0, 9004.0, 9020.0, 38328.0]
[292.0, 22.0, 25.0, 296.0]
[207, 360, 360, 214]
p02701
u942356554
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n=int(input())\nList = [input() for i in range(n)]\nset(List)\nprint(len(List))', 'n=int(input())\nList = [input() for i in range(n)]\nd=set(List)\nprint(len(d))']
['Wrong Answer', 'Accepted']
['s364087931', 's476260904']
[35636.0, 35636.0]
[251.0, 262.0]
[76, 75]
p02701
u944886577
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n=int(input())\nlst={}\n for i in range(n):\n lst[str(input())]+=1\nprint(len(lst))', 'n=int(input())\nlst=[]\nfor i in range(n)\n lst.extend(str(input()))\n \n \nlist_uniq=[]\nfor j in lst\n if list_uniq.count(j)==0:\n list_uniq.extend(j)\n else:\n pass\n print(len(list_uniq))', 'n=int(input())\nlst={}\nfor i in range(n):\n lst.extend(input().split())\nlist_uniq={}\nans=0\nfor j in lst:\n if list_uniq.count(j)==0:\n list_uniq.append(j)\n ans+=1\n else:\n pass\nprint(ans)', 'n=int(input())\nlst=[]\nfor i in range(n)\n lst.extend(str(input()))\n\n\nlist_uniq=[]\nfor j in lst\n if list_uniq.count(j)==0:\n list_uniq.extend(j)\n else:\n pass\n print(len(list_uniq))\n\n ', 'n=int(input())\nlst={}\nfor i in range(n):\n lst[input()]=1\nprint(len(lst))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s253304351', 's284035200', 's562105192', 's906811678', 's180896129']
[8860.0, 8936.0, 9148.0, 8988.0, 35284.0]
[24.0, 25.0, 24.0, 25.0, 272.0]
[82, 185, 191, 186, 73]
p02701
u945200821
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['import sys\nfrom collections import Counter\n\n\ndef main():\n scan = sys.stdin.readline\n \n n = int(scan().rstrip())\n s = scan().rstrip().split()\n \n print(len(Counter(s)))\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\nfrom collections import Counter\n\n\ndef main():\n scan = sys.stdin.readline\n \n n = int(scan().rstrip())\n s = [scan().rstrip() for _ in range(n)]\n \n print(len(Counter(s)))\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s324833675', 's430971136']
[9464.0, 38924.0]
[23.0, 102.0]
[211, 223]
p02701
u949442192
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nL = [input()]\n\nfor _ in range(N-1):\n a = input()\n imin = 0\n imax = len(L)-1\n l = 0\n\n while (imin<imax):\n l = (imin+imax)//2\n if (a==L[l]):\n break\n elif (a>L[l]):\n imin = min(l+1,len(L)-1)\n else:\n imax = max(l-1,0)\n \n if(imax==imin) \n \tif (a>L[imin]):\n \tL.insert(imin+1,a)\n \telif (a<L[imin]):\n \tL.insert(imin,a)\n \nprint(len(L))', 'N = int(input())\nL = [input()]\n \nfor _ in range(N-1):\n a = input()\n imin = 0\n imax = len(L)-1\n l = 0\n \n while (imin<imax):\n l = (imin+imax)//2\n if (a==L[l]):\n break\n elif (a>L[l]):\n imin = min(l+1,len(L)-1)\n else:\n imax = max(l-1,0)\n \n if(imax==imin) \n \tif (a>L[imin]):\n \tL.insert(imin+1,a)\n \telif (a<L[imin]):\n \tL.insert(imin,a)\n \nprint(len(L))\nN = int(input())\nL = [input()]\n\nfor _ in range(N-1):\n a = input()\n imin = 0\n imax = len(L)-1\n l = 0\n\n while (imin<imax):\n l = (imin+imax)//2\n if (a==L[l]):\n break\n elif (a>L[l]):\n imin = min(l+1,len(L)-1)\n else:\n imax = max(l-1,0)\n \n if(imax==imin): \n \tif (a>L[imin]):\n \tL.insert(imin+1,a)\n \telif (a<L[imin]):\n \tL.insert(imin,a)\n \nprint(len(L))', 'N = int(input())\nL = set([input() for _ in range(N)])\nprint(len(L))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s107395506', 's656688204', 's007914495']
[8876.0, 9008.0, 35528.0]
[20.0, 23.0, 267.0]
[462, 926, 67]
p02701
u957098479
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nS = list(map(str,input().split()))\n\nT = list(set(S))\nprint(len(T))', 'N = int(input())\nS = [input() for i in range(N)]\nT = list(set(S))\nprint(len(T))']
['Wrong Answer', 'Accepted']
['s663727015', 's381721104']
[8864.0, 35520.0]
[23.0, 267.0]
[83, 79]
p02701
u974231963
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['\ns = int(input()) \ns_list = [input() for _ in range(s)]\nprint(s_list) \n\nans = 0\n\ns_list = set(s_list)\n\nprint(len(s_list))', '\ns = int(input()) \ns_list = [input() for _ in range(s)]\n\n\nans = 0\n\ns_list = set(s_list)\n\nprint(len(s_list))']
['Wrong Answer', 'Accepted']
['s250303404', 's544567364']
[38120.0, 35712.0]
[284.0, 276.0]
[158, 160]
p02701
u974918235
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\ngacha = set()\nfor _ in range(N):\n gacha.append(input())\nprint(len(gacha))', 'N = int(input())\ngacha = set()\nfor _ in range(N):\n gacha.add(input())\nprint(len(gacha))']
['Runtime Error', 'Accepted']
['s622943534', 's104059128']
[9160.0, 31020.0]
[25.0, 286.0]
[91, 88]
p02701
u976282379
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\nS = []\nwhile True:\n Si = input()\n if Si:\n S.append(Si)\n else:\n break\ng = S[: N]\nprint(g)\n', 'c = input().split("\\n")\nN = int(c[0])\nS = c[1:]\nprint(len(set(S[:N])))\n', 'n = int(input())\ns = set(input() for _ in range(n))\nprint(len(s))\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s240465038', 's782717117', 's898838167']
[23404.0, 9100.0, 31008.0]
[245.0, 22.0, 275.0]
[129, 71, 66]
p02701
u984989720
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n = int(input())\na = [input() for i in range(n)]\n\nc = collections.counter(a)\n\nprint(len(c))', 'n = int(input())\na = [input().split() for i in range(n)]\n\nc = collections.counter(a)\n\nprint(len(c))\n', 'import collections\nn = int(input())\na = [input() for i in range(n)]\nlist_a = list(a)\nc = collections.Counter(a)\n\nprint(len(c))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s470846940', 's990635087', 's850172798']
[23084.0, 55052.0, 40484.0]
[227.0, 340.0, 276.0]
[91, 100, 127]
p02701
u988661952
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['import collections\n\nN=int(input())\nlist=[input() for i in range(N)]\n\nc= collections.Counter(list)\n\nm=0\nfor i in c.values():\n m+=i\n\nprint(m)', 'import collections\n\nN=int(input())\nlist=[input() for i in range(N)]\n\nc= collections.Counter(list)\n\nm=0\nfor i in c.values():\n m+=1\n\nprint(m)']
['Wrong Answer', 'Accepted']
['s785742218', 's205054598']
[38708.0, 38920.0]
[282.0, 279.0]
[142, 142]
p02701
u990148524
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n = int(input())\n\nl = list()\nfor num in range (1,n+1):\n l.append(input())\n\nanswer = [x for x in set(l) if l.count(x) > 1]\nprint(len(answer))', 'n = int(input())\n\nl = list()\nfor num in range (1,n+1):\n l.append(input())\n\nprint(len(set(l)))\n']
['Wrong Answer', 'Accepted']
['s323780621', 's811116097']
[35572.0, 35716.0]
[2206.0, 276.0]
[143, 97]
p02701
u992471673
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['n=int(input())\n\ns=input().split()\n\nans=[0 for i in range(n)]\nfor i in range(0,n-1):\n s[i]=int(s[i])\n ans[s[i]-1]+=1\n\nfor i in range(0,n):\n print(ans[i])\n\n\n', 'n=int(input())\n\ns=[0]*n\n\nfor i in range(0,n):\n s[i]=input()\n\n\ns_set=set(s)\nans=len(s_set)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s921036481', 's528545509']
[10464.0, 35620.0]
[27.0, 276.0]
[164, 104]
p02701
u997927785
2,000
1,048,576
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get?
['N = int(input())\n\nkeihin = []\n\n\nfor i in range(N):\n if keihin.count(input()) == 0:\n keihin.append(input())\n\n\nprint(len(keihin))\n', 'N = int(input())\nS = [str(input()) for _ in range(N)]\n\nS.sort()\n\ncount = 1\n\nfor i in range(N-1):\n if S[i] != S[i+1]:\n count += 1\n\nprint(count)']
['Runtime Error', 'Accepted']
['s571718139', 's862868171']
[10160.0, 23820.0]
[2206.0, 350.0]
[198, 152]
p02702
u002625175
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 main():\n s = input()\n n = len(s)\n\n mod = 2019\n\n counts = [0] * mod\n\n prev = int(s[-1])\n counts[prev] += 1\n for i in range(2, n + 1):\n t = prev + int(s[-i]) * 10 ** (i - 1)\n counts[t % mod] += 1\n prev = t\n\n ans = 0\n for count in counts:\n if count > 1:\n ans += count * (count - 1) // 2\n\n print(ans)\n\nmain()\n', 'from collections import defaultdict\n\ndef main():\n s = input()\n n = len(s)\n\n mod = 2019\n\n counts = [0] * mod\n\n prev = int(s[-1])\n for i in range(2, n + 1):\n t = prev + int(s[-i]) * 10 ** (i - 1)\n counts[t % mod] += 1\n prev = t\n\n ans = 0\n for count in counts:\n if count > 1:\n ans += count * (count - 1) // 2\n\n print(ans)\n\nmain()\n', 'from collections import defaultdict\n\ndef main():\n s = input()\n n = len(s)\n\n mod = 2019\n\n counts = [0] * mod\n\n prev = int(s[-1])\n counts[prev] += 1\n for i in range(2, n + 1):\n t = prev + int(s[-i]) * 10 ** (i - 1)\n print(t)\n counts[t % mod] += 1\n prev = t\n\n ans = 0\n for count in counts:\n if count > 1:\n ans += count * (count - 1) // 2\n\n print(ans)\n\nmain()\n', '\ndef main():\n s = tuple(map(int, input()[::-1]))\n\n mod = 2019\n\n counts = [0] * mod\n counts[0] = 1\n t = 0\n x = 1\n for i in range(len(s)):\n t = (t + s[i] * x) % mod\n counts[t] += 1\n x = (x * 10) % mod\n\n ans = 0\n for count in counts:\n if count > 1:\n ans += count * (count - 1) // 2\n\n print(ans)\n\nmain()\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s239248712', 's402543377', 's452153633', 's062854229']
[9572.0, 9536.0, 31668.0, 10960.0]
[2206.0, 2206.0, 2262.0, 81.0]
[373, 353, 386, 327]
p02702
u014958112
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()\ncounts = [0] * 2019\ncounts[0] = 1\nresult = 0\n\nfor i in range(len(s)):\n mod2019 = int(s[-i:]) % 2019\n print("mod2019={}".format(mod2019))\n counts[mod2019] += 1\n\nfor cnt in counts:\n result += cnt*(cnt-1)//2\n \nprint(result)\n ', 's = input()[::-1]\ncounts = [0] * 2019\ncounts[0] = 1\nnum, d = 0, 1\nresult = 0\n\nfor i in s:\n num += int(i) * d\n num %= 2019\n d *= 10\n d %= 2019\n counts[num] += 1\n \nfor cnt in counts:\n result += cnt*(cnt-1)//2\n \nprint(result)\n ']
['Wrong Answer', 'Accepted']
['s053888748', 's084698169']
[9324.0, 9284.0]
[2206.0, 111.0]
[252, 251]
p02702
u015593272
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 sys\n S = sys.stdin.readline()[:-1]\n\n S = input()\n int_S = int(S)\n N = len(S)\n cnt = 0\n pos_l = 0\n pos_r = 0\n\n\n while (True):\n pos_r += + 1\n \n if (pos_r < N):\n tmp = int(S[pos_l: pos_r + 1])\n if (tmp % 2019 == 0):\n cnt += 1\n pos_l = pos_r\n else:\n pos_l += 1\n \n if (pos_l >= N):\n break\n\n\n print(cnt)\n\nif __name__ == '__main__':\n main()", "def main():\n import collections\n\n S = input()\n\n mod_list = [0]\n\n for i in range(len(S)):\n index = len(S) - i - 1\n num = int(S[index])\n\n mod_list.append((mod_list[-1] + num * pow(10, i, 2019)) % 2019)\n\n CTR_mod_list = collections.Counter(mod_list).most_common()\n cnt = 0\n\n for i in range(len(CTR_mod_list)):\n n = CTR_mod_list[i][1]\n\n if (n == 1):\n break\n\n cnt += n * (n - 1) // 2\n\n print(cnt)\n\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Accepted']
['s702740088', 's587733875']
[9052.0, 16760.0]
[23.0, 331.0]
[503, 507]
p02702
u017415492
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.
['P=2019\nS = input()\nN=len(S)\n\nans = 0\ncount = [0] * P\ncount[0] = 1\nu = 0\nfor i, s in enumerate(reversed(S)):\n print(i,s)\n u = (int(s) * pow(10, i, P) + u) % P\n ans += count[u]\n count[u] += 1\n\nprint(ans)', 'P=2019\nS = input()\nN=len(S)\ncount=[0]*P\nans = 0\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\n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s849709398', 's268508449']
[9220.0, 9256.0]
[434.0, 340.0]
[205, 188]
p02702
u021019433
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 = {0: 1}\ns, p = 0, 1\nfor c in reversed(input()):\n s = (s + p * int(c)) % 2019\n d[s] = d.get(s, 0) + 1\n p = p * 10 % 2019\nprint(sum(x * (x - 1) // 2 for x in d))\n', 'from collections import defaultdict\n\nd = defaultdict(int)\nd[0] = 1\ns, p = 0, 1\nfor c in reversed(input()):\n s = (s + p * int(c)) % 2019\n d[s] = d.get(s, 0) + 1\n p = p * 10 % 2019\nprint(sum(x * (x - 1) // 2 for x in d.values()))\n']
['Wrong Answer', 'Accepted']
['s195264966', 's170793442']
[9348.0, 9568.0]
[118.0, 124.0]
[166, 231]
p02702
u022843632
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 functools import reduce\n\nn = int(input()) \nl = [int(x) for x in list(str(n))]\n\nnum=len(l)\ncount=0\nsum=0\nfor i in range(num-3): \n for j in range(3,num):\n if i>=j or j-i<3:\n pass\n else:\n for x in l[i:j+1]:\n sum=sum+x\n if sum%3==0:\n new_n = int(reduce(lambda x, y: x + y, [str(x) for x in l[i:j+1]]))\n if new_n%2019==0:\n count=count+1 \nprint(count)\n ', 'input()\ns=s[::-1]\nn=len(s)\n \ncount=[0]*2019\ncount[0]=1\nnum,d=0,1\n \nfor i in s:\n num+=int(i)*d\n num%=2019\n d*=10\n d%=2019\n count[num]+=1\n \nans=0\nfor i in count:\n ans+=i*(i-1)//2\n \nprint(ans)', 'nput()\ns=s[::-1]\nn=len(s)\n \ncount=[0]*2019\ncount[0]=1\nnum,d=0,1\n \nfor i in s:\n num+=int(i)*d\n num%=2019\n d*=10\n d%=2019\n count[num]+=1\n \nans=0\nfor i in count:\n ans+=i*(i-1)//2\n \nprint(ans)', 's=input()\ns=s[::-1]\nn=len(s)\n \ncount=[0]*2019\ncount[0]=1\nnum,d=0,1\n \nfor i in s:\n num+=int(i)*d\n num%=2019\n d*=10\n d%=2019\n count[num]+=1\n \nans=0\nfor i in count:\n ans+=i*(i-1)//2\n \nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s418170727', 's550170516', 's855854982', 's298296567']
[12656.0, 9208.0, 9064.0, 9332.0]
[2206.0, 20.0, 22.0, 115.0]
[487, 196, 195, 198]
p02702
u028014940
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=list(input())[::-1] \nn=len(s)\namari_lis=[0]*2019 # \namari_lis[0]=1 \n\nnum=0\nkurai=1\nfor keta in s:\n num+=int(keta)*kurai\n num%=2019\n amari_lis[num]+=1\n kurai*=10\n kurai%=2019 \n\nans=0\nfor i in amari_lis:\n ans+=i*(i-1)/2 \n\nprint(ans)', 's=list(input())[::-1] \nn=len(s)\namari_lis=[0]*2019 # \namari_lis[0]=1 \n\nnum=0\nkurai=1\nfor keta in s:\n num+=int(keta)*kurai\n num%=2019\n amari_lis[num]+=1\n kurai*=10\n kurai%=2019 \n\nans=0\nfor i in amari_lis:\n ans+=i*(i-1)/2 \n\nprint(int(ans))']
['Wrong Answer', 'Accepted']
['s562847810', 's720865349']
[11896.0, 11892.0]
[115.0, 121.0]
[634, 638]
p02702
u029000441
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.
["\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor, ceil,pi\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef SI(): return input().rstrip()\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n\ns=SI()\nn=len(s)\nbeki=[0 for i in range(n+1)]\nbeki[0]=1\nfor i in range(n):\n beki[i+1]=(beki[i]*10)%2019\n\n\n#k=int(s)\ndp=[0 for i in range(n)]\ndp[-1]=int(s[-1])\nfor i in range(n):\n j=n-i-1\n dp[j-1]=(dp[j]+int(s[j-1])*beki[i+1])%2019\n#print(dp)\nans=0\nu=Counter(dp)\nfor i in u:\n ans+=(u[i]*(u[i]-1))//2\nprint(ans)\n ", "\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor, ceil,pi\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef SI(): return input().rstrip()\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n\ns=SI()\nn=len(s)\nbeki=[0 for i in range(n+1)]\nbeki[0]=1\nfor i in range(n):\n beki[i+1]=(beki[i]*10)%2019\n\n\n#k=int(s)\ndp=[0 for i in range(n)]\ndp[-1]=int(s[-1])\n#print(dp[3])\nfor i in range(n-1):\n j=n-i-1\n \n dp[j-1]=(dp[j]+int(s[j-1])*beki[i+1])%2019\n\n#print(dp)\nans=0\nu=Counter(dp)\n#print(u)\nfor i in u:\n if i==0:\n ans+=(u[i]*(u[i]+1))//2\n else:\n ans+=(u[i]*(u[i]-1))//2\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s108860973', 's150078301']
[24116.0, 24076.0]
[200.0, 196.0]
[1114, 1234]
p02702
u036104576
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 itertools\n# import numpy as np\nimport time\nimport math\n\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import defaultdict\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn = readline().decode()\nn = list(reversed(n))\n\nx = 1\ncount = [0 for _ in range(2019)]\nMOD = 2019\nacc = 0\n\ncount[0] = 1\nans = 0\n\nfor c in n:\n a = x * int(c)\n acc += a\n acc %= MOD\n ans += count[acc]\n count[acc] += 1\n x = (x * 10) % MOD\n\nprint(ans)\n', 'import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\n\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import defaultdict\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn = readline().decode()\nn = list(reversed(n))\n\nx = 1\ncount = [0 for _ in range(2019)]\nMOD = 2019\nacc = 0\n\ncount[0] = 1\nans = 0\n\nfor c in n:\n a = x * int(c)\n acc += a\n acc %= MOD\n ans += count[acc]\n count[acc] += 1\n x = (x * 10) % MOD\n\nprint(ans)\n', 'import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\n\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import defaultdict\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn = input()\nn = reversed(n)\n\nx = 1\ncount = [0 for _ in range(2019)]\nMOD = 2019\nacc = 0\ncount[0] = 1\nans = 0\n\nfor c in n:\n a = x * int(c)\n acc += a\n acc %= MOD\n ans += count[acc]\n count[acc] += 1\n x = (x * 10) % MOD\n\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s736894207', 's771725822', 's970421546']
[10876.0, 10832.0, 9640.0]
[27.0, 28.0, 141.0]
[513, 513, 494]
p02702
u054825571
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\nN=len(S)\nfor i in range(N-2):\n s=S[i:i+3]\n for j in range(i+3,N):\n s+=S[j]\n print(s)\n if int(s)%2019==0:\n ans+=1\nprint(ans)', 'S=input()\nans,n=0,len(S)\ndp=[0]*(2019)\ns,dp[0],k=0,1,1\nfor i in S[::-1]:\n s=(s+int(i)*k)%2019\n k=(k*10)%2019\n ans+=dp[s]\n dp[s]+=1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s729541559', 's662168952']
[63232.0, 9316.0]
[2306.0, 119.0]
[155, 145]
p02702
u060736237
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 work, temp = [0] * 2019, 0\n work[0] = 1\n a = 1\n for s in S:\n temp += int(s) * a\n work[temp%2019] += 1\n a *= 10\n a %= 2019\n print(sum([w*(w-1)//2 for w in work]))\nmain()', 'def main():\n S = input()\n N = len(S)\n S = int(S)\n work, temp = 0, [0] * 2019, 0\n for i in range(N+1): work[(S % 10**i) % 2019] += 1\n print(sum([w*(w-1)//2 for w in work]))\nmain()', 'def main():\n S = input()\n work, temp = [0] * 2019, 0\n work[0] = 1\n a = 1\n for s in S[::-1]:\n temp += int(s) * a\n work[temp%2019] += 1\n a *= 10\n a %= 2019\n print(sum([w*(w-1)//2 for w in work]))\nmain()']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s491490367', 's532032622', 's918194260']
[9296.0, 9344.0, 9408.0]
[80.0, 205.0, 82.0]
[240, 196, 246]
p02702
u067077296
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)\ncnt = 0\nfor i in range(n-2):\n for j in range(i+3, n+1):\n if int(s[i:j]) % 2019 == 0:\n print(i, j)\n cnt += 1\n\nprint(cnt)', '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', 'Accepted']
['s632153120', 's490796240']
[9372.0, 9388.0]
[2206.0, 113.0]
[174, 280]
p02702
u067694718
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_cu = [0] * n\ncounter = [0] * 2019\n\nfor i in range(1, n+1):\n s_cu[i-1] = int(s[n-i:]) \n counter[int(s[n-i-1:]) % 2019] += 1\n\nans = 0\nfor i in counter:\n ans += (i * (i - 1)) // 2\n\nprint(ans)', 's = input()\nn = len(s)\ns_cu = [0] * (n+1)\ncounter = [0] * 2019\ncounter[0] += 1\n\nfor i in range(n):\n s_cu[i+1] = (int(s[n-i-1]) + s_cu[i]) % 2019\n counter[s_cu[i] % 2019] += 1\n\nans = 0\nfor i in counter:\n ans += (i * (i - 1)) // 2\n\nprint(ans)\n', 's = input()\nn = len(s)\ns_cu = [0] * (n+1)\ncounter = [0] * 2019\ncounter[0] += 1\nfor i in range(n):\n s_cu[i+1] = (int(s[n-i-1]) * pow(10,i,2019) + s_cu[i]) % 2019\n counter[s_cu[i+1]] += 1\n\nans = 0\nfor i in counter:\n ans += (i * (i - 1)) // 2\n\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s118375004', 's655042289', 's607841683']
[27120.0, 16136.0, 16148.0]
[2206.0, 124.0, 355.0]
[222, 250, 261]
p02702
u070201429
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)\n\nl = [0]\nfor i in range(n):\n l.append(int(s[i:n]) % 2019)\n\nfrom collections import Counter\ndic = Counter(l)\n\nans = 0\nfor i in dic.values():\n ans += i * (i - 1) // 2\nprint(ans)\n\nprint(dic)', 's = input()\nn = len(s)\n\nnum = 1\nl = [0]\nfor i in range(n-1, -1, -1):\n l.append((l[-1] + int(s[i]) * num) % 2019)\n num *= 10\n num %= 2019\n\nfrom collections import Counter\ndic = Counter(l)\n\nans = 0\nfor i in dic.values():\n ans += i * (i - 1) // 2\nprint(ans)']
['Wrong Answer', 'Accepted']
['s544520552', 's059141035']
[9460.0, 16608.0]
[2206.0, 133.0]
[216, 266]
p02702
u087356957
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#import numpy as np\n\n\ndef merge_sort(lst, low, high):\n if low >= high:\n return\n mid = int((low+high)/2)\n merge_sort(lst, low, mid)\n merge_sort(lst, mid+1, high)\n for i in range(low, mid+1):\n tmp_array[i] = lst[i]\n j = high\n for i in range(mid+1, high+1):\n tmp_array[i] = lst[j]\n j -= 1\n i = low\n j = high\n for k in range(low, high+1):\n if tmp_array[i] <= tmp_array[j]:\n lst[k] = tmp_array[i]\n i += 1\n else:\n lst[k] = tmp_array[j]\n j -= 1\n\n\nS = stdin.readline().rstrip()\nN = len(S)\nSp = S\n\nres_map = [0 for _ in range(N)]\n\naa_list2 = [1]\nfor i in range(1,N):\n aa_list2.append((aa_list2[i-1]*10)%2019)\n\ntmp_array = [None for _ in range(N)]\nres_map[N-1] = int(S[N-1])\nindex=1\nfor i in range(N-2,-1,-1):\n res_map[i] = (int(S[i])*aa_list2[index] + res_map[i+1])%2019\n index+=1\n\nres_map.sort()\ntemp_num=int(res_map[0])\nindex=1\ntot = 0\n\naa_table = [0 for i in range(2019)]\naa_table2 = [0 for i in range(2019)]\nfor i in range(len(res_map)):\n aa_table2[res_map[i]]+=1\n\naa_table2[0]+=1\n\n\nfor i in range(1,N):\n if res_map[i]<res_map[i-1]:\n aa = 2/0\n\nfor i in range(1,len(res_map)):\n if temp_num==int(res_map[i]):\n index+=1\n continue\n else:\n aa_table[temp_num] = index\n index=1\n temp_num=int(res_map[i])\n\naa_table[0] += 1 \n\nfor i in range(2018):\n if aa_table[i] != aa_table2[i]:\n aa = 2/0\n# if temp_num==0:\n\n# elif index>1:\n\n# index=1\n# temp_num=int(res_map[i])\n\n\ntot = 0\nfor i in range(2019):\n tot+=int((aa_table[i]-1)*aa_table[i]/2)\n\n\n\n\n\n\n# num+=1\n\n \n\nprint(tot)\n\n', 'from sys import stdin\n#import numpy as np\n\n\ndef merge_sort(lst, low, high):\n if low >= high:\n return\n mid = int((low+high)/2)\n merge_sort(lst, low, mid)\n merge_sort(lst, mid+1, high)\n for i in range(low, mid+1):\n tmp_array[i] = lst[i]\n j = high\n for i in range(mid+1, high+1):\n tmp_array[i] = lst[j]\n j -= 1\n i = low\n j = high\n for k in range(low, high+1):\n if tmp_array[i] <= tmp_array[j]:\n lst[k] = tmp_array[i]\n i += 1\n else:\n lst[k] = tmp_array[j]\n j -= 1\n\n\nS = stdin.readline().rstrip()\nN = len(S)\nSp = S\n\nres_map = [0 for _ in range(N)]\n\naa_list2 = [1]\nfor i in range(1,N):\n aa_list2.append((aa_list2[i-1]*10)%2019)\n\ntmp_array = [None for _ in range(N)]\nres_map[N-1] = int(S[N-1])\nindex=1\nfor i in range(N-2,-1,-1):\n res_map[i] = (int(S[i])*aa_list2[index] + res_map[i+1])%2019\n index+=1\n\nres_map.sort()\ntemp_num=int(res_map[0])\nindex=1\ntot = 0\n\naa_table = [0 for i in range(2019)]\naa_table2 = [0 for i in range(2019)]\nfor i in range(len(res_map)):\n aa_table2[res_map[i]]+=1\n\naa_table2[0]+=1\n\n\nfor i in range(1,N):\n if res_map[i]<res_map[i-1]:\n aa = 2/0\n\nfor i in range(1,len(res_map)):\n if temp_num==int(res_map[i]):\n index+=1\n if i==len(res_map)-1:\n aa_table[temp_num]=index\n continue\n else:\n aa_table[temp_num] = index\n index=1\n temp_num=int(res_map[i])\n if i==len(res_map)-1:\n aa_table[temp_num]=1\n\naa_table[0] += 1 \n\n\ntot = 0\nfor i in range(2019):\n tot+=int((aa_table[i]-1)*aa_table[i]/2)\n\n\n\n\n\n\n# num+=1\n\n \n\nprint(tot)\n\n']
['Runtime Error', 'Accepted']
['s263788203', 's913381240']
[26128.0, 25768.0]
[302.0, 329.0]
[1906, 1775]
p02702
u089142196
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)\n\nT=[0]*n\nfor i in range(n):\n T[i]=int(S[i:])', 'S=input()\nN=len(S)\n\nT=[0]\nfor i in range(N):\n p = int(S[-1-i])\n T.append( (T[-1]+ pow(10,i,2019)*p)%2019 )\n \nfrom collections import Counter\nans=0\nU=dict(Counter(T))\nfor num in U:\n ans += U[num]*(U[num]-1)//2\nprint(ans)']
['Wrong Answer', 'Accepted']
['s676709495', 's905902659']
[15276.0, 16692.0]
[2206.0, 338.0]
[66, 231]
p02702
u091051505
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]\np = 0\ndp = [0] * 2019\ndp[0] = 1\nfor i in s:\n p = (p + (int(s) * (10 ** (i)))) % 2019\n dp[p] += 1\nans = 0\nfor i in dp:\n ans += i * (i - 1) // 2\nprint(ans)', 's = input()[::-1]\np = 0\ndp = [0] * 2019\ndp[0] = 1\nd = 1\nfor i in s: \n p = (int(i) * d + (p)) % 2019\n dp[p] += 1\n d *= 10\n d = d % 2019\nans = 0\nfor i in dp:\n ans += i * (i - 1) // 2\nprint(ans)']
['Runtime Error', 'Accepted']
['s083516030', 's064264344']
[9384.0, 9312.0]
[204.0, 106.0]
[180, 209]
p02702
u092646083
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.
['mod_673 = [1] * 672\nfor i in range(1,672):\n mod_673[i] = (mod_673[i -1] * 10) % 672\n\nS = input()\nS = S[::-1]\nA = [0] * (len(S) + 1)\nB = [0] * (len(S) + 1)\nx = 0\nAns = [[0] * 3 for i in range(673)]\nfor i in range(1, len(S) + 1):\n A[i] = (A[i - 1] + int(S[i - 1]) * mod_673[(i - 1) % 672]) % 673\n B[i] = (B[i - 1] + int(S[i - 1])) % 3\n\nfor i in range(len(S) + 1):\n Ans[A[i]][B[i]] += 1\n\nfor i in range(673):\n for j in range(3):\n y = Ans[i][j]\n x += y * (y - 1) // 2\n\nprint(x)', 'mod_673 = [1] * 672\nfor i in range(1,672):\n mod_673[i] = (mod_673[i -1] * 10) % 673\n\nS = input()\nS = S[::-1]\nA = [0] * (len(S) + 1)\nB = [0] * (len(S) + 1)\nx = 0\nAns = [[0] * 3 for i in range(673)]\nfor i in range(1, len(S) + 1):\n A[i] = (A[i - 1] + int(S[i - 1]) * mod_673[(i - 1) % 672]) % 673\n B[i] = (B[i - 1] + int(S[i - 1])) % 3\n\nfor i in range(len(S) + 1):\n Ans[A[i]][B[i]] += 1\n\nfor i in range(673):\n for j in range(3):\n y = Ans[i][j]\n x += y * (y - 1) // 2\n\nprint(x)']
['Wrong Answer', 'Accepted']
['s803938566', 's741651692']
[16012.0, 16016.0]
[221.0, 216.0]
[502, 502]
p02702
u093041722
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,int(S)%2019]\ninit = 0\nfor i in range(len(S)-1):\n S = S[1:]\n a.append(int(S)%2019)\nb = [kv*(kv-1)//2 for kv in Counter(a).values() if kv > 1]\nprint(sum(b))', 'S = input()\nl = [int(n) for n in list(S)]\na = [0,int(S)%2019]\ninit = 0\nfor i in range(len(S)-1):\n S = S[1:]\n a.append(int(S)%2019)\nb = [kv*(kv-1)//2 for kv in Counter(a).values() if kv > 1]\nprint(sum(b))', 'from collections import Counter,deque\nfrom scipy import special\nS = input()\nl = [int(n) for n in S]\na = [0]\nt = 0\nm = 1\nd = deque(l)\nmod = 2019\nwhile d:\n temp = d.pop()\n t = (t + (temp * m)) % mod\n m = (m * 10) % mod\n a.append(t%mod)\nb = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]\nprint(sum(b))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s168462888', 's279086884', 's213567060']
[9468.0, 12188.0, 52648.0]
[2206.0, 2206.0, 295.0]
[179, 209, 335]
p02702
u095192632
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)\nprint(N)\ncnt = 0\n\nfor i in range(N):\n for j in range(i+4, N+1):\n if int(S[i:j]) % 2019 == 0:\n cnt += 1\nprint(cnt)\n\n', 's = list(input())\nmods = [0]*(len(s))\ncountRemainder = [0] * 2019\ncnt = 0\n\n\nm = 1\nmod = 0\nfor i in range(len(s)):\n mod += int(s[len(s) - i - 1]) * m\n\n mod %= 2019\n m *= 10\n m %= 2019\n\n countRemainder[mod] += 1\n\ncountRemainder[0] += 1\n\nfor i in range(2019):\n cnt += int(countRemainder[i] * (countRemainder[i] - 1) / 2)\n\nprint(cnt)\n\n']
['Wrong Answer', 'Accepted']
['s632647693', 's752993784']
[9312.0, 11984.0]
[2205.0, 148.0]
[159, 349]
p02702
u102367647
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(int,list(input())))\n N = len(S)\n t = 0\n A = [0] * 2019\n for i in range(N):\n t = (t + S[-1-i] * 10 ** i) % 2019\n A[t] += 1\n result = sum([a*(a-1)//2 for a in A])\n print(result)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n S = list(input())\n N = len(S)\n t = 0\n A = [0] * 2019\n A[0] += 1\n d = 1\n for s in reversed(S):\n d *= 10\n d %= 2019\n t += (int(s) * d)\n t %= 2019\n A[t] += 1\n result = sum([a*(a-1)//2 for a in A])\n print(result)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s041710814', 's543391365']
[12092.0, 10468.0]
[2205.0, 84.0]
[277, 324]
p02702
u102461423
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\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n\nS = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')\n", 'import numpy as np', "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n\nMOD = 18001\n\ndef solve(S):\n dp = np.zeros(MOD, np.int64)\n temp = np.empty_like(dp)\n pow10 = 1\n answer = 0\n for x in S[::-1]:\n dp[0] += 1\n x = x * pow10 % MOD\n temp[x:] = dp[:-x]\n temp[:x] = dp[-x:]\n dp, temp = temp, dp\n answer += dp[0]\n pow10 *= 10\n pow10 %= MOD\n return answer\n\n\ndef cc_export():\n from numba.pycc import CC\n cc = CC('my_module')\n cc.export('solve', '(i4[:],)')(solve)\n cc.compile()\n\n\ntry:\n from my_module import solve\nexcept:\n cc_export()\n exit()\n\nS = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')\nprint(solve(S))\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\nfrom numba import njit\n\n@njit('i4[:]')\ndef solve(S):\n dp = np.zeros(2019, np.int64)\n pow10 = 1\n answer = 0\n for x in S[::-1]:\n dp[0] += 1\n x = x * pow10 % 2019\n newdp = np.zeros_like(dp)\n newdp[x:] += dp[:-x]\n newdp[:x] += dp[-x:]\n answer += newdp[0]\n pow10 *= 10\n pow10 %= 2019\n dp = newdp\n return answer\n\n\nS = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')\nprint(solve(S))\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n\nMOD = 20001\n\ndef solve(S):\n dp = np.zeros(MOD, np.int64)\n temp = np.empty_like(dp)\n pow10 = 1\n answer = 0\n for x in S[::-1]:\n dp[0] += 1\n x = x * pow10 % MOD\n temp[x:] = dp[:-x]\n temp[:x] = dp[-x:]\n dp, temp = temp, dp\n answer += dp[0]\n pow10 *= 10\n pow10 %= MOD\n return answer\n\n\ndef cc_export():\n from numba.pycc import CC\n cc = CC('my_module')\n cc.export('solve', '(i4[:],)')(solve)\n cc.compile()\n\n\ntry:\n from my_module import solve\nexcept:\n cc_export()\n exit()\n\nS = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')\nprint(solve(S))\n", "import sys\nimport numpy as np\nfrom numba import njit\n\nMOD = 2019\n\n@njit('(i4[::1],)', cache=True)\ndef f(S):\n dp = np.zeros(MOD, np.int64)\n temp = np.empty_like(dp)\n pow10 = 1\n answer = 0\n for x in S[::-1]:\n dp[0] += 1\n x = x * pow10 % MOD\n temp[x:] = dp[:-x]\n temp[:x] = dp[-x:]\n dp, temp = temp, dp\n answer += dp[0]\n pow10 *= 10\n pow10 %= MOD\n return answer\n\n\nS = np.int32(list(input().rstrip()))\nprint(f(S))\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s094401564', 's134194382', 's656329832', 's854707655', 's882712055', 's516247068']
[28940.0, 26960.0, 29160.0, 91564.0, 29200.0, 109268.0]
[121.0, 109.0, 1900.0, 382.0, 2079.0, 730.0]
[199, 18, 775, 600, 775, 484]
p02702
u110199424
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\ndata = []\n\ncount = 0\nfor i in range(len(S)):\n for j in range(i+4, min(i+7,len(S)+1)):\n if(int(S[i:j]) % 2019 == 0):\n count += 1\n data.append([i,j])\n\nfor i in range(len(data)):\n if(data[i][1] == data[i+1][0]):\n count += 1\n\nprint(count)', 'S = str(input())\n\nTmod = []\n\nfor i in range(len(S)):\n T = int(S[i:len(S)])\n Tmod.append(T % 2019)\n\nout = 0\nfor j in range(2019):\n count = 0\n for k in range(len(S)):\n if(Tmod[k] == j):\n count += 1\n out += (count*(count - 1))/2.0\n\n\nprint(int(out))', 'from collections import Counter\n\nS = str(input())\n\nmemo = [0]\nd = 0\nmod = 2019\n\n\nfor s in S[::-1]:\n tmp = int(s) * pow(10, d, mod) % mod\n tmp = memo[-1] + tmp\n memo.appemd(tmp%mod)\n d += 1\n\nc = Counter(memo)\nans = sum(v * (v-1)/2 for v in c.values())\nprint(ans)\n\n', 'from collections import Counter\n\nS = str(input())\n\nmemo = [0]\nd = 0\nmod = 2019\n\n\nfor s in S[::-1]:\n tmp = int(s) * pow(10, d, mod) % mod\n tmp = memo[-1] + tmp\n memo.append(tmp%mod)\n d += 1\n\nc = Counter(memo)\nans = sum(v * (v-1)/2 for v in c.values())\nprint(int(ans))\n\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s073232499', 's513398218', 's558389232', 's323154564']
[16752.0, 9512.0, 9484.0, 16820.0]
[328.0, 2206.0, 23.0, 353.0]
[294, 279, 275, 280]
p02702
u111652094
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=str(input())\nl=len(S)\nans=0\n\nmod=[0]*2019\nmod[0]+=1\nt=0\nfor i in range(l):\n t=int(S[l-i:-1:-1])*pow(10,i,2019)\n mod[t%2019]+=1\n \nfor j in range(len(mod)):\n m=mod[j]\n ans=ans+m*(m-1)//2\nprint(ans)', "S=str(input())\nS.split()\nans=0\nlist_2019=[]\n\n\nfor i in range(1,10**4):\n list_2019.append(i*2019)\n\nfor i in range(len(S)):\n for j in range(i+1,len(S)):\n s=''.join(S[i:j+1])\n if int(s) in list_2019:\n ans=ans+1\n print(i,j)\nprint(ans)", '\nS=str(input())\nans=0\nlist_2019=[]\n\n\nfor i in range(1,10**6):\n list_2019.append(i*2019)\n\nfor i in list_2019:\n ans=ans+S.count(str(i))\n\nprint(ans)', 'S=str(input())\nl=len(S)\nans=0\ndig=1\nmod=[0]*2019\nmod[0]=1\nt=0\nfor i in range(l):\n t=(t+int(S[-i-1])*dig)%2019\n mod[t]+=1\n dig=(dig*10)%2019\n \nfor j in mod:\n ans=ans+(j*(j-1))//2\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s842127449', 's859931615', 's873471155', 's739312188']
[9264.0, 9864.0, 48824.0, 9128.0]
[22.0, 2205.0, 2207.0, 115.0]
[213, 272, 151, 204]
p02702
u114641312
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 math import factorial,sqrt,ceil,gcd\n# from itertools import permutations as permus\n# from collections import deque,Counter\n# import re\nfrom functools import lru_cache \n# from decimal import Decimal, getcontext\n\n# # eps = Decimal(10) ** (-100)\n\n# import numpy as np\n# import networkx as nx\n# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson\n# from scipy.sparse import csr_matrix\n# from scipy.special import comb\n\n\nS = input()\nSlen = len(S)\n\nif len(S)<=3:\n print(0)\n exit()\n\n@lru_cache(maxsize=10000)\ndef check(n):\n if n%2019 == 0:\n return True\n else:\n return False\n\nans = 0\nfor i in range(Slen - 4 + 1):\n num_s = 4\n # for num_s in range(4,Slen+1-i):\n while num_s < Slen+1-i:\n num = int(S[i:i+num_s])\n if check(num):\n ans += 1\n num_s += 4\n else:\n num_s += 1\n print(num,num_s,ans)\n\nprint(ans)\n\n# for row in board:\n\n# print("{:.10f}".format(ans))\n# print("{:0=10d}".format(ans))\n', '# from math import factorial,sqrt,ceil,gcd\n# from itertools import permutations as permus\n# from collections import deque,Counter\n# import re\nfrom functools import lru_cache \n# from decimal import Decimal, getcontext\n\n# # eps = Decimal(10) ** (-100)\n\n# import numpy as np\n# import networkx as nx\n# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson\n# from scipy.sparse import csr_matrix\n# from scipy.special import comb\n\n\nS = input()[::-1]\n\nMOD = 2019\ntmp = [0]*MOD\ntmp[0] += 1\ntens = 1\nnum = 0\nfor s in S:\n num += int(s) * tens\n num = num % MOD\n tmp[num] += 1\n tens *= 10\n tens %= MOD\n\nans = 0\nfor i in tmp:\n ans += i*(i-1)//2\n\nprint(ans)\n\n# for row in board:\n\n# print("{:.10f}".format(ans))\n# print("{:0=10d}".format(ans))\n']
['Wrong Answer', 'Accepted']
['s143663803', 's958729804']
[39800.0, 9716.0]
[2264.0, 120.0]
[1282, 1045]
p02702
u123872895
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.
['inp = input()\n\ns = 0\n\nfor i in range(len(inp)-3):\n\tnum = int(inp[i:])\n\twhile num > 2019:\n\t\tprint(num)\n\t\tif num % 2019 == 0:\n\t\t\ts += 1\n\t\tnum = num // 10\n\nprint(s)', 'inp = input()\n\ns = 0\n\nfor i in range(len(inp)-3):\n\tnum = int(inp[i:-1])\n while num >2019:\n\t\tif num % 2019 == 0:\n\t\t\ts += 1\n\t\tnum = num / 10\n\nprint(s)', 'from collections import defaultdict\n\ns = input()\n\nrests = [0]\nn = 0\na = 0\nm = 1\nc = defaultdict(int)\nc[0] += 1\nfor i in list(s)[::-1]:\n n = n + int(i)*m\n\n c[n % 2019] += 1\n m = m * 10 % 2019\n\nfor v in c.values():\n a += v * (v-1) // 2\nprint(a)\n\n\n\n\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s771146084', 's879728952', 's265232259']
[9540.0, 8824.0, 12200.0]
[2213.0, 21.0, 114.0]
[161, 151, 259]
p02702
u127499732
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 ans = 0\n for i in range(1, 1001, 1):\n x = str(2019 * i)\n ans += s.count(x)\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n from collections import Counter\n s = input()\n\n l = [0]\n t = 1\n for i, x in enumerate(s[::-1]):\n t = t * 10 % 2019\n y = (l[-1] + int(x) * t) % 2019\n l.append(y)\n\n c = Counter(l)\n ans = sum([v * (v - 1) // 2 for v in c.values()])\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s525819442', 's253943724']
[9056.0, 16784.0]
[263.0, 108.0]
[179, 338]
p02702
u151785909
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\nfor i in range(len(s)-3):\n for j in range(4,len(s)-i):\n t=s[i:j+i]\n if int(t)%2019==0:\n ans+=1\nprint(ans)', 'n = list(input())\nn.reverse()', 'from collections import Counter\n\nn = list(input())\nn.reverse()\nx = [0]*(len(n))\na=0\nfor i in range(len(n)):\n a+=int(n[i])*10**i\n x[i]=a%2019', 'from collections import Counter\n\nn = list(input())\nn.reverse()\nx = [0]*(len(n))\na=0\nex=1\nfor i in range(len(n)):\n a+=int(n[i])*ex\n x[i]=a%2019\n ex=ex*10%2019\nc=Counter(x)\nans = c[0]\nfor i in c.keys():\n b=c[i]\n ans += b*(b-1)//2\n\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s025019497', 's865494174', 's956037793', 's449861672']
[9340.0, 10360.0, 13036.0, 18008.0]
[2206.0, 26.0, 2206.0, 126.0]
[153, 29, 146, 255]
p02702
u153302617
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)\narray = [0]*2019\narray[0] += 1\ncount = 0\nfor i in reversed(range(0, N)):\n x = s[i:N]\n y = int(x)\n array[y%2019] += 1\n\nfor i in array:\n count += i*(i-1)/2\nprint(count)\n', 's = str(input())\nN = len(s)\narray = [0]*2019\narray[0] += 1\ncount = 0\nd = 1\nr = 0\nfor i in reversed(range(0, N)):\n r = ( r + int( s[i] ) * d ) % 2019\n d = d * 10 % 2019\n print(s[i],r,d)\n array[r] += 1\nfor i in array:\n count += i*(i-1)/2\nprint(int(count))\n', 's = str(input())\nN = len(s)\narray = [0]*2019\narray[0] += 1\ncount = 0\nd = 1\nr = 0\nfor i in reversed(range(0, N)):\n r = ( r + int( s[i] ) * d ) % 2019\n d = d * 10 % 2019\n array[r] += 1\nfor i in array:\n count += i*(i-1)/2\nprint(int(count))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s399183745', 's896930984', 's884344021']
[9148.0, 9284.0, 9304.0]
[2206.0, 260.0, 108.0]
[207, 269, 249]
p02702
u156815136
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 statistics import median\n#import collections\n\nfrom fractions import gcd\nfrom itertools import combinations \nfrom collections import deque\nfrom collections import defaultdict\nimport bisect\n#\n# d = m - k[i] - k[j]\n\n#\n#\n#\n\n#\n#\n\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n\ndef readInts():\n return list(map(int,input().split()))\ndef main():\n S = input()\n cnt = 0\n start = 0\n LIST = []\n while start+4 < len(S):\n for i in range(start+4,len(S)+1):\n if S[i-1] == 0:\n start += 4\n continue\n if int(S[start:i]) % 2019 == 0:\n cnt += 1\n start += 4\n start += 1\n print(cnt)\nif __name__ == '__main__':\n main()\n", "from statistics import median\n#import collections\n\nfrom fractions import gcd\nfrom itertools import combinations \nfrom collections import deque\nfrom collections import defaultdict\nimport bisect\n#\n# d = m - k[i] - k[j]\n\n#\n#\n#\n\n#\n#\n\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n\ndef readInts():\n return list(map(int,input().split()))\ndef main():\n S = input()\n cnt = 0\n start = 0\n while start+4 < len(S):\n for i in range(start+4,len(S)+1):\n if S[i-1] == 0:\n continue\n if int(S[start:i]) % 2019 == 0:\n cnt += 1\n start += 3\n start += 1\n print(cnt)\nif __name__ == '__main__':\n main()\n", "from statistics import median\n#import collections\n\nfrom fractions import gcd\nfrom itertools import combinations \nfrom collections import deque\nfrom collections import defaultdict\nimport bisect\n#\n# d = m - k[i] - k[j]\n\n#\n#\n#\n\n#\n#\n\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n\ndef readInts():\n return list(map(int,input().split()))\ndef main():\n S = input()\n cnt = 0\n start = 0\n while start+4 < len(S):\n for i in range(start+4,len(S)+1):\n if S[i-1] == 0:\n break\n if int(S[start:i]) % 2019 == 0:\n cnt += 1\n break\n start += 2\n print(cnt)\nif __name__ == '__main__':\n main()\n", "from statistics import median\n#import collections\n\nfrom fractions import gcd\nfrom itertools import combinations \nfrom collections import deque\nfrom collections import defaultdict\nimport bisect\n#\n# d = m - k[i] - k[j]\n\n#\n#\n#\n\n#\n#\n\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n\ndef readInts():\n return list(map(int,input().split()))\ndef main():\n S = input()\n LIST = []\n for i in range(2000):\n LIST.append(2019*i)\n start = 0\n cnt = 0\n while start+4 < len(S):\n for i in range(start+4,len(S)+1):\n #print(S[start:i])\n if int(S[start:i]) in LIST:\n cnt += 1\n start += 1\n print(cnt)\nif __name__ == '__main__':\n main()\n", 'S = input()\nfrom collections import defaultdict\ndic = defaultdict(int)\ndic[0] += 1\n\nS = S[::-1]\nd = 1\nnow = 0\nfor i in range(len(S)):\n \n now += d*int(S[i]) % 2019\n dic[now%2019] += 1\n d *= 10\n d %= 2019\nans = 0\nfor k,v in dic.items():\n ans += v*(v-1)//2\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s074345417', 's533014281', 's535964327', 's704312817', 's710378259']
[11176.0, 11248.0, 11176.0, 11308.0, 9588.0]
[2206.0, 2206.0, 2206.0, 2206.0, 131.0]
[973, 932, 924, 947, 363]
p02702
u161432819
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\n\nS = input()\nl = len(S)\n\ncount = 0\nfor i in range(0, l-3):\n for j in range(3, l):\n if i < (j-3):\n new_s = int(S[i:j+1])\n if new_s % 2019 == 0:\n count += 1\n else:\n continue\n else:\n continue\nprint(count)', 'from collections import Counter\nS=input()[::-1]\nmod=2019\n\nX = [0]\nfor i, s in enumerate(S):\n X.append((X[-1] + int(s)*pow(10, i, mod)) % mod)\n\nC = Counter(X)\nans = 0\nfor v in C.values():\n ans += v * (v - 1) // 2\nprint(ans)']
['Wrong Answer', 'Accepted']
['s686664428', 's995933300']
[9336.0, 16604.0]
[2206.0, 337.0]
[280, 226]
p02702
u163529815
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())\nS.reverse()\namari = []\nA = 0\nc = 0\nfor i in range(len(S)):\n a = (int(A) + int(S[i]) *(10 ** i)) % 2019\n amari.append(a)\n A = a\nprint(c + len(amari) - len(set(amari)))\n', 'import sys\ndef input():\n return sys.stdin.readline()[:-1]\n\n\ndef main():\n S = input()[::-1] \n counts = [0] * 2019\n counts[0] = 1\n num, d = 0, 1\n\n for char in S:\n num = num + int(char) * d\n num = num % 2019\n d = d * 10\n d = d % 2019\n counts[num] += 1 \n\n ans = 0\n for cnt in counts:\n ans += cnt * (cnt - 1) // 2\n print(ans)\n\n \nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s513598255', 's627089639']
[11256.0, 9320.0]
[2206.0, 82.0]
[194, 540]
p02702
u165133750
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)\nprint(s)\ns = s[::-1]\nprint(s)\nx, tot = 1, 0\nm = 2019\nans = 0\ncnt = [int() for _ in range(m)]\nfor i in range(n):\n cnt[tot] += 1\n tot += (int(s[i])) * x\n tot %= m\n ans += cnt[tot]\n x = x * 10 % m\nprint(ans)\n', 's = str(input())\nn = len(s)\ns = s[::-1]\nx, tot = 1, 0\nm = 2019\nans = 0\ncnt = [int() for _ in range(m)]\nfor i in range(n):\n cnt[tot] += 1\n tot += (int(s[i])) * x\n tot %= m\n ans += cnt[tot]\n x = x * 10 % m\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s555077756', 's601185871']
[9204.0, 9248.0]
[133.0, 136.0]
[248, 230]
p02702
u169138653
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\ns=input()\nn=len(s)\ns=s[::-1]\naccum=[0]*n\np=2019\nd=dict()\nfor i in range(n):\n accum[i]=int(s[i])*pow(10,i,p)%p\nfor i in range(n-1):\n accum[i+1]+=accum[i]\n accum[i+1]%=p\naccum[-1]%=p\nans=0\n#print(accum)\nfor i in range(n):\n #print(d)\n if accum[i] not in d:\n if accum[i]==0:\n ans+=1\n d[accum[i]]=1\n else:\n if accum[i]==0:\n ans+=1\n ans+=d[accum[i]]\n d[accum[i]]+=1\nprint(ans)', 'import sys\ninput=sys.stdin.readline\ns=input()\nn=len(s)\ns=s[::-1]\naccum=[0]*n\np=2019\nd=dict()\nfor i in range(n):\n accum[i]=int(s[i])*pow(10,i,p)%p\nfor i in range(n-1):\n accum[i+1]+=accum[i]\n accum[i+1]%=p\naccum[-1]%=p\nans=0\n#print(accum)\nfor i in range(n):\n #print(d)\n if accum[i] not in d:\n if accum[i]==0:\n ans+=1\n d[accum[i]]=1\n else:\n if accum[i]==0:\n ans+=1\n ans+=d[accum[i]]\n d[accum[i]]+=1\nprint(ans)\n', 'import sys\ninput=sys.stdin.readline\ns=input()\nn=len(s)\ns=s[::-1]\naccum=[0]*n\np=2019\nd=dict()\nfor i in range(n):\n accum[i]=int(s[i])*pow(10,i,p)%p\nfor i in range(n-1):\n accum[i+1]+=accum[i]\n accum[i+1]%=p\naccum[-1]%=p\nans=0\n#print(accum)\nfor i in range(n):\n #print(d)\n if accum[i] not in d:\n if accum[i]==0:\n ans+=1\n d[accum[i]]=1\n else:\n if accum[i]==0:\n ans+=1\n ans+=d[accum[i]]\n d[accum[i]]+=1\nprint(ans)', 's=input()\nn=len(s)\ns=s[::-1]\naccum=[0]*n\np=2019\nd=dict()\nfor i in range(n):\n accum[i]=int(s[i])*pow(10,i,p)%p\nfor i in range(n-1):\n accum[i+1]+=accum[i]\n accum[i+1]%=p\naccum[-1]%=p\nans=0\n#print(accum)\nfor i in range(n):\n #print(d)\n if accum[i] not in d:\n if accum[i]==0:\n ans+=1\n d[accum[i]]=1\n else:\n if accum[i]==0:\n ans+=1\n ans+=d[accum[i]]\n d[accum[i]]+=1\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s257857154', 's417896472', 's707835283', 's056174959']
[10712.0, 10672.0, 10624.0, 16488.0]
[26.0, 22.0, 23.0, 447.0]
[481, 482, 481, 445]
p02702
u169350228
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\nimport math\ns = str(input())\nn = len(s)\nwa = [0 for i in range(n+1)]\nfor i in range(1,n+1):\n wa[i] = (wa[i-1]+int(s[i-1]))%9\n\nans = 0\n\nfor i in range(n):\n for j in range(i+3,n):\n if (wa[j]-wa[i])%9 == 3 or (wa[j]-wa[i])%9 == 6:\n if int(s[i:j+1])%2019 == 0:\n ans += 1\n\nprint(ans)\n', 'import numpy as np\ns = list(map(int,input()))\nn = len(s)\nans = 0\nmod = 2019\npast = s[n-1]\nima = 0\nd = dict()\nd[s[n-1]] = 1\nnow = 10\nfor i in range(1,n):\n ima = (past+s[n-i-1]*now)%mod\n if ima == 0:\n ans += 1\n if ima in d:\n d[ima] += 1\n else:\n d[ima] = 1\n past = ima\n now = (now*10)%mod\n\nfor i in d.values():\n ans += i*(i-1)//2\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s204614583', 's238270139']
[28936.0, 28796.0]
[2206.0, 234.0]
[337, 381]
p02702
u170761365
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.
['number = str(input())[::-1]\nremainderDictionary = {}\n \nsum = 0\nx = 1\nfor i in number:\n sum += int(i) * x\n remainder = sum % 2019\n remainderValue = remainderDictionary.get(remainder,0) + 1\n remainderDictionary[remainder] = remainderValue\n x = (x * 10) % 2019\n \nans = 0\nfor i in remainderDictionary:\n value = remainderDictionary[i]\n ans += value * (value - 1) // 2 # N C 2\nprint(ans)', 'S = str(input())\nremainderDictionary = {}\n \nsum = 0\nx = 1\nfor i in S:\n sum += int(i) * x\n remainder = sum % 2019\n remainderValue = remainderDictionary.get(remainder,0) + 1\n remainderDictionary[remainder] = remainderValue\n x *= 10\n x %= 2019\n \nans = 0\nfor i in remainderDictionary:\n value = remainderDictionary[i]\n ans += value * (value - 1) // 2 # N C 2\nprint(ans)', "string = input()\n\npairs = 0\nlimit = len(string)-3\nsecondLimit\nfor i in range(limit):\n substring += string[i]\n for j in range(i+1,secondLimit):\n substring += string[j]\n if j-i > 3 and int(substring) % 673 == 0:\n n += 1\n substring = ''\nprint(n)", 'string = str(input())\n n = 0\n limit = len(string)-4\n secondLimit = len(string)\n size = len(string)-1\n potencys = [0] * 1500 \n potencys.append(1)\n thirdLimit = size\n for i in range(size, 2, -1):\n intValue = int(string[i])\n potencyIndex = 0\n thirdLimit = i - 1\n for j in range(thirdLimit, -1, -1):\n potencyIndex += 1\n if potencyIndex >= len(potencys):\n potencys.append(potencys[-1]*10)\n intValue += int(string[j])* potencys[potencyIndex]\n if i-j > 2 and intValue % 673 == 0:\n n += 1\n print(n)', 'string = str(input())\n\npairs = 0\nlimit = len(string)-4\nsecondLimit = len(string)\nsubstringArray = list()\nsubstringArray.append(string[0])\nfor i in range(1, secondLimit):\n substringArray.append(substringArray[i-1] + string[i])\n\nfor i in range(0,limit):\n for j in range(i+3,secondLimit):\n print(substringArray[j][i:])\n if j >= 3 and int(substringArray[j][i:]) % 673 == 0:\n pairs += 1\nprint(pairs)', 'S = str(input())\nremainderDictionary = {}\n \nsum = 0\nx = 1\nfor i in S:\n sum += int(i) * x\n remainder = sum % 2019\n remainderDictionary[remainder] += remainderDictionary.get(remainder,0) + 1\n x = (x * 10) % 2019\n \nans = 0\nfor i in remainderDictionary:\n value = remainderDictionary[i]\n ans += value * (value - 1) // 2 # N C 2\nprint(ans)', 'S = str(input())\nremainderDictionary = {0: 1}\n \nsum = 0\nx = 1\nfor i in S:\n sum += int(i) * x\n remainder = sum % 2019\n remainderValue = remainderDictionary.get(remainder,0) + 1\n remainderDictionary[remainder] = remainderValue\n x *= 10\n x %= 2019\n \nans = 0\nfor i in remainderDictionary:\n value = remainderDictionary[i]\n ans += value * (value - 1) // 2 # N C 2\nprint(ans)', 'string = str(input())\nn = 0\nlimit = len(string)-4\nsecondLimit = len(string)\nsize = len(string)-1\npotencys = [0] * 1500 \npotencys.append(1)\nthirdLimit = size\nfor i in range(size, 2, -1):\n intValue = int(string[i])\n potencyIndex = 0\n thirdLimit -= 1\n for j in range(thirdLimit, -1, -1):\n potencyIndex += 1\n if potencyIndex >= len(potencys):\n potencys.append(potencys[-1]*10)\n intValue += int(string[j])* potencys[potencyIndex]\n if i-j > 2 and intValue % 673 == 0:\n n += 1\nprint(n)', 'S = str(input())\nSurpus = [0] * 2019\nSurpus[0] = 1\n\nsum = 0\nx = 1\nfor i in S:\n sum += int(i) * x\n Surpus[sum % 2019] += 1\n x *= 10\n x %= 2019\n\nans = 0\nfor i in Surpus:\n ans += i * (i - 1) // 2\nprint(ans)', 'S = str(input())\nremainderDictionary = {}\n \nsum = 0\nx = 1\nfor i in S:\n sum += int(i) * x\n remainder = sum % 2019\n remainderValue = remainderDictionary.get(remainder,0) + 1\n remainderDictionary[remainder] = remainderValue\n x = (x * 10) % 2019\n \nans = 0\nfor i in remainderDictionary:\n value = remainderDictionary[i]\n ans += value * (value - 1) // 2 # N C 2\nprint(ans)', 'string = str(input())\nn = 0\nlimit = len(string)-4\nsecondLimit = len(string)\nsize = len(string)-1\npotencys = [1, 10, 100, 1000]\nthousandList = [0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]\noldIntValue = 0\npotencyIndex = 0\nthirdLimit = size\nif secondLimit > 3:\n for i in range(size, size-4, -1):\n oldIntValue += int(string[i])*potencys[potencyIndex]\n potencyIndex += 1\n\npotencyIndex = 3\nintValue = oldIntValue\nfor j in range(size-4, -1, -1):\n potencyIndex += 1\n if potencyIndex >= len(potencys):\n potencys.append(potencys[-1]*10)\n intValue += int(string[j])* potencys[potencyIndex]\n if intValue % 673 == 0:\n n += 1\n\nsize -= 1\nfor i in range(size, 2, -1):\n intValue = (oldIntValue / 10) + thousandList[int(string[i-3])] # it is the fourth value in the intValue or 10^3\n oldIntValue = intValue\n potencyIndex = 3\n for j in range(i-4, -1, -1):\n potencyIndex += 1\n if potencyIndex >= len(potencys):\n potencys.append(potencys[-1]*10)\n intValue += int(string[j])* potencys[potencyIndex]\n if intValue % 673 == 0:\n n += 1\nprint(n)', "number = str(input())[::-1]\nremainderDictionary = {0: 1}\ndigitDictionary = {'1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9}\n\nsum = 0\nx = 1\nfor i in number:\n x = (x * 10) % 2019\n sum = (sum + digitDictionary[i] * x) % 2019 \n remainderDictionary[sum] = remainderDictionary.get(sum,0) + 1\n\nansDictionary = {} # dictionary with the number of occurences and the corresponding N combinations of 2\nans = 0\nfor i in remainderDictionary:\n remainderOccurences = remainderDictionary[i]\n value = ansDictionary.get(remainderOccurences,-1)\n if value == -1:\n value = remainderOccurences * (remainderOccurences - 1) // 2 # N combinations of 2\n ansDictionary[remainderOccurences] = value\n ans += value\nprint(ans)"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s197014003', 's330385919', 's476778416', 's507738359', 's521099091', 's613253096', 's763327640', 's814666297', 's847409638', 's932033884', 's946466776', 's671523160']
[9360.0, 9208.0, 9240.0, 9000.0, 3504904.0, 9352.0, 9240.0, 521596.0, 9208.0, 9264.0, 525384.0, 9364.0]
[131.0, 133.0, 21.0, 20.0, 2273.0, 21.0, 133.0, 2220.0, 114.0, 128.0, 2219.0, 97.0]
[395, 379, 256, 545, 407, 346, 383, 504, 208, 379, 1074, 723]
p02702
u175034939
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 = list(input())[::-1]\nn = len(S)\nd = defaultdict(int)\nd[0] += 1\nres = 0\nfor i, s in enumerate(S):\n res += int(s)*pow(10, i, 6)\n res %= 6\n d[res] += 1\n\nans = 0\nfor v in d.values():\n ans += v*(v-1)//2\nprint(ans)', 'from collections import defaultdict\nS = list(input())[::-1]\nn = len(S)\nd = defaultdict(int)\nd[0] += 1\nres = 0\nfor i, s in enumerate(S):\n res += int(s)*pow(10, i, 2019)\n res %= 2019\n d[res] += 1\nprint(d)\n\nans = 0\nfor v in d.values():\n print(v)\n ans += v*(v-1)//2\nprint(ans)', 'from collections import defaultdict\nS = list(input())[::-1]\nn = len(S)\nd = defaultdict(int)\nd[0] += 1\nres = 0\nfor i, s in enumerate(S):\n res += int(s)*pow(10, i, 2019)\n res %= 2019\n d[res] += 1\n\nans = 0\nfor v in d.values():\n ans += v*(v-1)//2\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s288532920', 's705163217', 's727346497']
[12192.0, 12108.0, 12144.0]
[256.0, 338.0, 337.0]
[259, 287, 265]
p02702
u179304833
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 deque\nimport time\nstart = time.time()\n\ns = str(input())\n\nn=len(s)\ni :int=0\n\nspan :int=1\nmlist=deque("0")\nslist :str=""\n\n\n #slist = str(sss) + slist\n #m = int(slist)%2019\n #mlist.append(str(m))\n #print(str(mlist))\n #span+=1\n\n#ll=len(mlist)\n#l=len(set(mlist))\n#print(ll-l)\nend = time.time()\nprint(f"{end-start}sec.")', 's = str(input())\nn=len(s)\nleft :int=1\nmlist=[0]\nwhile left<int(n)+1:\n m = int(s[n-left:n])%2019\n mlist.append(m)\n left+=1\n\n#ll=len(mlist)\n#l=len(set(mlist))\nprint(len(mlist))', 'from collections import deque\ns = str(input())\n\nn=len(s)\nspan=1\nmlist=deque("0")\nslist=""\n\nwhile span<n+1:\n slist = s[n-span] + slist\n #print(str(slist))\n m = int(slist)%2019\n mlist.append(m)\n span+=1\n \n\nll=len(mlist)\n\nl=len(set(mlist))\nprint(ll-l)\n', 'from collections import deque\n\n\n\ns = str(input())\n\nn=len(s)\nspan=1\nmlist=deque("0")\nslist=""\n\nwhile span<n+1:\n slist = s[n-span] + slist\n #print(str(slist))\n m = int(slist)%2019\n mlist.append(m)\n span+=1\n \n\nll=len(mlist)\n\nl=len(set(mlist))\n\nprint(ll-l)\n\n', 'from collections import deque\nimport time\nstart = time.time()\n\ns = str(input())\nn=len(s)\nspan :int=1\nmlist=deque("0")\nslist :str=""\n\nwhile span<int(n)+1:\n slist = str(s[n-span]) + slist\n #print(str(slist))\n m = int(slist)%2019\n mlist.append(str(m))\n span+=1\n\nll=len(mlist)\nl=len(set(mlist))\nprint(ll-l)\nend = time.time()\nprint(f"{end-start}sec.")', 's = str(input()[::-1])\nn=len(s)\nmlist,m,d=[],0,1\n \nfor ss in s:\n m += int(ss) * d\n m %= 2019\n d *= 10\n d %= 2019\n mlist.append(m)\n \nl=sorted(mlist)\nl.append(2020)\npre,count,ans=0,0,0\nfor ll in l:\n if pre==ll:\n count+=1\n else:\n ans+=count*(count+1)//2\n pre=ll\n count=0\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s283631010', 's355622018', 's433261458', 's587606151', 's654804746', 's228395952']
[9468.0, 9680.0, 9860.0, 9764.0, 10204.0, 18728.0]
[23.0, 2206.0, 2206.0, 2206.0, 2206.0, 167.0]
[376, 177, 255, 369, 384, 299]
p02702
u185297444
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.
['#ABC164d\ndef main():\n s = input()\n MOD = 2019\n d = [ 0 for i in range(MOD)]\n # print(d)\n ans = 0\n k = 0\n d[0] = 1\n s = s[::-1]\n # print(s)\n p = 1\n for i in s:\n print(p,i,k)\n print(\'pnosiki\')\n print(p * int(i) + k)\n k = (p * int(i) + k) % MOD\n print(\'k:\')\n print(k)\n ans += d[k]\n d[k] += 1\n p = (p * 10) % MOD\n print(ans)\n return\n\nif __name__ == "__main__":\n main()\n', '#ABC164d\ndef main():\n s = input()\n MOD = 2019\n d = [ 0 for i in range(MOD)]\n # print(d)\n ans = 0\n k = 0\n d[0] = 1\n s = s[::-1]\n # print(s)\n p = 1\n for i in s:\n # print(p,i,k)\n # print(\'pnosiki\')\n # print(p * int(i) + k)\n k = (p * int(i) + k) % MOD\n # print(\'k:\')\n # print(k)\n ans += d[k]\n d[k] += 1\n p = (p * 10) % MOD\n print(ans)\n return\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s531023523', 's368080153']
[9392.0, 9344.0]
[457.0, 86.0]
[470, 480]
p02702
u188745744
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\ntmp=sys.stdin.readline()\ndef main():\n cnt=[0]*2019\n cnt[0]+=1\n for i in reversed(range(len(tmp))):\n cnt[int(tmp[i:])%2019] += 1\n import collections\n cnt=collections.Counter(cnt).items()\n ans=0\n for i,j in cnt:\n if i > 1:\n ans+=i*(i-1)//2*j\n print(ans)\n\nif __name__ == "__main__":\n main()', 'import sys\nimport collections\ntmp=sys.stdin.readline()\ndef main():\n cnt=[0]*2019\n cnt[0]+=1\n for i in reversed(range(len(tmp))):\n cnt[int(tmp[i:])%2019] += 1\n cnt=collections.Counter(cnt).items()\n ans=0\n for i,j in cnt:\n if i > 1:\n ans+=i*(i-1)//2*j\n print(ans)\n\nif __name__ == "__main__":\n main()', 'import sys\ntmp=sys.stdin.readline()\ndef main():\n cnt=[0]*2019\n cnt[0]+=1\n for i in reversed(range(len(tmp))):\n cnt[int(tmp[i:])%2019] += 1\n import collections\n cnt=collections.Counter(cnt).items()\n ans=0\n for i,j in cnt:\n if i > 1:\n ans+=i*(i-1)//2*j\n print(ans)\n\nif __name__ == "__main__":\n main()', 'import sys\ntmp=sys.stdin.readline().rstrip()\ndef main():\n ans=0\n cnt=[0]*2019\n cnt[0]+=1\n t=0\n d=1\n for i in reversed(tmp):\n t=(t+int(i)*d)%2019\n cnt[t]+=1\n d=d*10%2019\n for i in cnt:\n ans+=i*(i-1)//2\n print(ans)\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s001384994', 's175455909', 's771685860', 's957156562']
[9272.0, 9568.0, 9288.0, 9312.0]
[24.0, 28.0, 20.0, 81.0]
[335, 332, 335, 286]
p02702
u188827677
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]\n\ncounts = [0]*2019 \ncounts[0] = 1 \n\nnum, d = 0,1\u3000\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 c in counts:\n ans += c*(c-1)//2\n \nprint(ans)', '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 c in counts:\n ans += c*(c-1)//2\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s474430605', 's649060911']
[8964.0, 9368.0]
[24.0, 111.0]
[673, 671]
p02702
u189023301
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\n\ndef main():\n n = input()\n l = len(n)\n mody = 2019\n cnt = 0\n for i in range(l - 3):\n x = int(n[i:i + 4])\n x %= mody\n if x == 0:\n cnt += 1\n for j in range(i + 4, l):\n x = 10 * x + int(n[j])\n x %= mody\n if x == 0:\n cnt += 1\n print(cnt)\nif __name__ == '__main__':\n main()\n", 'from collections import Counter\nS = list(map(int, input()))\nP = 2019\n\ndef solve(S,P):\n S = S[::-1]\n T = [0] * len(S)\n T[0] = S[0] % P\n power = 1\n for i in range(1, len(S)):\n power *= 10\n power %= P\n T[i] = T[i-1] + power * S[i]\n T[i] %= P\n counter = Counter(T)\n return sum(x * (x - 1) // 2 for x in counter.values()) + counter[0]\nprint(solve(S,P))\n']
['Runtime Error', 'Accepted']
['s671061935', 's563316073']
[9200.0, 19596.0]
[66.0, 113.0]
[415, 397]
p02702
u189513668
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\nS = input()\n#print(type(S))\n\ns = []\nfor i in range(int(S) // 2019):\n s.append(str(i*2019))\n\ncount = 0\nfor i in s:\n S_ = S\n while re.search(i, S_):\n #print(i)\n S_ = S_[:re.search(i, S_).start()] + "," + S_[re.search(i, S_).start()+1:]\n count += 1\n \nprint(count)', 'import re\nS = input()\n\ns = []\nfor i in range(1000):\n s.append(str(i*2019))\n\ncount = []\nfor i in s:\n count += len(re.findall(S, i))\n\nprint(count)', 'S = input()\n\nn = len(S)\nm = 2019\n\nS_ = S[::-1]\n\nx = 1\ntotal = 0\nmodlis = [0 for i in range(m)]\n\nans = 0\nfor i in range(n):\n modlis[total] += 1\n print("S_[i]:", S_[i])\n print("int(S_[i])*x:", int(S_[i])*x)\n print("total:", total)\n total += int(S_[i])*x\n print("total:", total)\n total %= m\n print("total:", total)\n ans += modlis[total]\n print("x:", x)\n x = x * 10 % m\n print("x:", x)\n\nprint(ans)\n', 'import re\nS = input()\n#print(type(S))\n\ns = []\nfor i in range(1000):\n s.append(str(i*2019))\n\ncount = 0\nfor i in s:\n S_ = S\n while re.search(i, S_):\n print(i)\n S_ = S_[:re.search(i, S_).start()] + "," + S_[re.search(i, S_).start()+1:]\n count += 1\n \nprint(count)', 'import re\nS = input()\n#print(type(S))\n\ns = []\nfor i in range(10000):\n s.append(str(i*2019))\n\ncount = 0\nfor i in s:\n S_ = S\n while re.search(i, S_):\n print(i)\n S_ = S_[:re.search(i, S_).start()] + "," + S_[re.search(i, S_).start()+1:]\n count += 1\n \nprint(count)', 'import re\nS = input()\n#print(type(S))\n\ns = []\nfor i in range(int(S) // 2019 // 5):\n s.append(str(i*2019))\n\ncount = 0\nfor i in s:\n S_ = S\n while re.search(i, S_):\n #print(i)\n S_ = S_[:re.search(i, S_).start()] + "," + S_[re.search(i, S_).start()+1:]\n count += 1\n \nprint(count)', 'S = input()\n\ncount = 0\nfor j in range(4, len(S)+1):\n for i in range(len(S)-4):\n if S[i:i+4] % 2019 == 0:\n count += 1\n\nprint(count)', 'S = input()\n\nn = len(S)\nm = 2019\n\nS_ = S[::-1]\n\nx = 1\ntotal = 0\nmodlis = [0 for i in range(m)]\n\nans = 0\nfor i in range(n):\n modlis[total] += 1\n print("S_[i]:", S_[i])\n print("int(S_[i])*x:", int(S_[i])*x)\n print("total:", total)\n total += int(S_[i])*x\n print("total:", total)\n total %= m\n print("total:", total)\n ans += modlis[total]\n print("x:", x)\n x = x * 10 % m\n print("x:", x)\n\nprint(ans)\n', 'S = input()\n\nn = len(S)\nm = 2019\n\nS_ = S[::-1]\n\nx = 1\ntotal = 0\nmodlis = [0 for i in range(m)]\n\nans = 0\nfor i in range(n):\n modlis[total] += 1\n #print("S_[i]:", S_[i])\n #print("int(S_[i])*x:", int(S_[i])*x)\n \n total += int(S_[i])*x\n \n total %= m\n \n ans += modlis[total]\n #print("x:", x)\n x = x * 10 % m\n #print("x:", x)\n\nprint(ans)']
['Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s013888492', 's048047404', 's105843195', 's370452855', 's387659699', 's837455743', 's884052426', 's990351730', 's019730642']
[521536.0, 39984.0, 18688.0, 10812.0, 11548.0, 522580.0, 9164.0, 18680.0, 9372.0]
[2220.0, 349.0, 837.0, 2206.0, 2206.0, 2221.0, 21.0, 848.0, 136.0]
[307, 150, 430, 296, 297, 312, 151, 430, 436]
p02702
u192042624
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\nimport sys\nimport math\n\nS = input()\n\ntmp = []\n\nfor i in range(1,50008):\n x = 2019 * i\n if str(x).find("0") == -1:\n tmp.append(x)\n\nans = 0\nll = len(S)\nfor wide in range(5,9):\n for i in range(ll - wide):\n ss = S[i:i+wide]\n if ss in tmp:\n ans += 1\n else:\n continue\n index = 0\n while True :\n flag = 0\n for ww in range(5,9):\n if i + wide + 1 + index + index + ww >= ll :\n flag = 1\n break\n if S[i+wide + 1 + index : i + wide + 1 + index + ww] in tmp:\n ans += 1\n index += 8\n if flag == 1:\n break\n\nprint(ans)', 'import numpy as np\nimport sys\nimport math\n\nS = input()\n\nmm = [0] * (2019)\nmm[0] = 1\na = [0] * (len(S) + 1 ) \nT = 0\nten = 1\nll = len(S)\nfor i in range(ll):\n if i > 0:\n ten = ( ten * 10 ) % 2019\n a[i+1] = ( a[i] + (int(S[ll-1-i])*ten ) ) % 2019\n mm[ a[i+1] ] += 1\n #print(s)\n\nans = 0\n\nfor m in mm:\n ans += int( (m * (m-1) ) / 2 )\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s254679090', 's944382618']
[28220.0, 34172.0]
[2206.0, 244.0]
[744, 362]
p02702
u193264896
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\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\nfrom collections import defaultdict\nINF = float('inf')\n\ndef main():\n S = readline().decode('utf-8')\n L = len(S)\n d = defaultdict(int)\n\n for i in range(L):\n s = int(S[i:])\n a = s%2019\n d[a] += 1\n\n ans = 0\n\n for key, value in d.items():\n ans += value*(value-1)//2\n if key == 0:\n ans += value\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys\nfrom collections import Counter\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n S = input()\n L = len(S)\n amari = [0] * L\n for i in range(L):\n amari[i] = int(S[i:])%2019\n c = Counter(amari)\n ans = 0\n for n in c.values():\n ans += n*(n-1)//2\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\nfrom collections import defaultdict\nINF = float('inf')\n\ndef main():\n S = readline().decode('utf-8')\n L = len(S)\n d = defaultdict(int)\n\n for i in range(L):\n s = int(S[i:])\n a = s%2019\n d[a] += 1\n\n ans = 0\n\n for key, value in d.items():\n ans += value*(value-1)//2\n if key == 0:\n ans += value\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "from namba import njit\n\n@njit\ndef main():\n S = input()\n L = len(S)\n amari = [0] * 2019\n tmp = 0\n for i in range(L):\n tmp += int(S[-i-1])*(10**i)%2019\n tmp %= 2019\n amari[tmp] += 1\n ans = amari[0]\n for i in range(2019):\n ans += amari[i]*(amari[i]-1)//2\n print(ans)\nif __name__ == '__main__':\n main()", "def main():\n S = input()\n L = len(S)\n amari = [0] * 2019\n tmp = 0\n for i in range(L)[::-1]:\n tmp += int(S[i])\n tmp %= 2019\n amari[tmp] += 1\n ans = amari[0]\n for i in range(2019):\n ans += amari[i]*(amari[i]-1)//2\n print(ans)\nif __name__ == '__main__':\n main()", "import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\n\nINF = float('inf')\n\n\ndef main():\n s = map(int, input()[::-1])\n mod = 2019\n counts = [0] * mod\n counts[0] = 1\n t = 0\n x = 1\n for num in s:\n t = (t + num * x) % mod\n counts[t] += 1\n x = (x * 10) % mod\n ans = 0\n for count in counts:\n if count > 1:\n ans += count * (count - 1) // 2\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s021537236', 's035899241', 's395662535', 's503394214', 's636564583', 's384641727']
[9832.0, 11412.0, 9776.0, 9116.0, 9284.0, 9272.0]
[2206.0, 2206.0, 2206.0, 24.0, 65.0, 86.0]
[479, 440, 479, 353, 313, 471]
p02702
u195054737
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 itertools\nimport numpy as np\nimport time\nimport math\nimport re\n\nsys.setrecursionlimit(10**7)\n\nfrom collections import defaultdict\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\ndef main():\n s = input()\n\n tmp_list = []\n tmp = 2019\n while tmp <= 2000000:\n tmp_list.append(str(tmp))\n tmp += 2019\n\n counter = 0\n for i in tmp_list:\n a = [m.span() for m in re.finditer(i, s)]\n a = np.array(a)\n a += 1\n print(len(a))\n counter += len(a)\n print(counter)\n\n\n\nif __name__ == "__main__":\n main()\n pass', 'import sys\nimport itertools\nimport numpy as np\nimport time\nimport math\nimport re\n\nsys.setrecursionlimit(10**7)\n\nfrom collections import defaultdict\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\ndef main():\n s = input()\n\n tmp_list = []\n tmp = 2019\n while tmp <= 200000:\n tmp_list.append(str(tmp))\n tmp += 2019\n\n counter = 0\n for i in tmp_list:\n a = [m.span() for m in re.finditer(i, s)]\n a = np.array(a)\n a += 1\n counter += len(a)\n print(counter)\n\n\n\nif __name__ == "__main__":\n main()\n pass', 'import sys\nimport itertools\nimport numpy as np\nimport time\nimport math\nimport re\n\nsys.setrecursionlimit(10**7)\n\nfrom collections import defaultdict\nfrom collections import Counter\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\ndef main():\n S = input()[::-1]\n MOD = 2019\n \n X = [0]\n for i, s in enumerate(S):\n X.append((X[-1] + int(s) * pow(10, i, MOD)) % MOD)\n \n C = Counter(X)\n ans = 0\n for v in C.values():\n ans += v * (v - 1) // 2\n print(ans)\n\n\n\n\nif __name__ == "__main__":\n main()\n pass']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s048849307', 's344868846', 's897019147']
[30584.0, 30564.0, 34516.0]
[596.0, 173.0, 387.0]
[642, 619, 600]
p02702
u196746947
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#include<string>\nusing namespace std;\nstring s;\nint n;\nn=s.length()\ncin>>s\nint sum=0;\nfor(int i=0;i<n,i++){\nfor(int j=i+1;j<n,j++){\nstring num=str.substr(i,j-i+1);\n int x=stoi(num);\n if(x%2019==0){\n sum+=1;\n }\n \n}\n}\ncout<<sum;', 'import sys\nimport collections as coun\nsys.setrecursionlimit(10000000)\ns=input()\nn=len(s)\ndef mod10(x):\n return (10**(x%224))%2019\ndp=[-1]*n\ntmp=0\nfor i in reversed(range(n)):\n if i==n-1:\n dp[i]=int(s[i])\n else:\n dp[i]=(dp[i+1]+int(s[i])*pow(10,n-1-i,2019))%2019\n\n#print(dp)\np=-1\nfor i in range(len(dp)-1):\n if dp[i]==dp[i+1]:\n dp[i]=p\n p=p-1\n\n#print(dp)\n\nc=coun.Counter(dp)\nsum=0\nfor v in c.values():\n sum+=v*(v-1)//2\n#print(sum)\nfor i in dp:\n if i==0:\n sum+=1\n#print(sum)\nif dp[-1]==0:\n sum=sum-1\nprint(sum)']
['Runtime Error', 'Accepted']
['s779566365', 's802996399']
[8920.0, 16640.0]
[19.0, 397.0]
[250, 564]
p02702
u197457087
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\nS = str(input())\nN = len(S)\n\n\nsmod = [0]\ntemp = 0\nfor i in range(N):\n temp = temp + int(S[(N-1)-i])*pow(10,i)\n print(temp)\n smod.append(temp%2019)\n\n\ncmod = Counter(smod)\nprint(cmod)\n\nans = 0\nfor i in cmod.values():\n ans += i*(i-1)/2\nprint(int(ans))', 'from collections import Counter\nS = str(input())\nN = len(S)\n\n\nsmod = [0]\ntemp = 0\nketa = 1\nfor i in range(N):\n temp = temp + int(S[(N-1)-i])*keta\n #print(temp)\n smod.append(temp%2019)\n keta *= 10\n\n\ncmod = Counter(smod)\nprint(cmod)\n\nans = 0\nfor i in cmod.values():\n ans += i*(i-1)/2\nprint(int(ans))\n \n', 'from collections import Counter\nS = str(input())\nN = len(S)\n\n\nsmod = [0]\ntmod = 0\nketa = 1\nfor i in range(N):\n temp = tmod + int(S[(N-1)-i])*keta\n #print(temp)\n tmod = temp%2019\n smod.append(tmod)\n keta = keta*10%2019\n\n\ncmod = Counter(smod)\n#print(cmod)\n\nans = 0\nfor i in cmod.values():\n ans += i*(i-1)/2\nprint(int(ans))\n \n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s343546951', 's440019693', 's127405981']
[31900.0, 11800.0, 16608.0]
[2273.0, 2206.0, 141.0]
[335, 365, 391]
p02702
u197968862
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\nmod = [1] + [0]*2018\nt = 0\na = 0\nn = len(s)\ns = reversed(s)\nfor i in range(n):\n t += int(s[i]) * (10 ** a)\n a += 1\n mod[t%2019] += 1\n print(t,t%2019)\nans = 0\nfor i in range(2019):\n ans += mod[i]*(mod[i]-1)//2\nprint(ans)', 's = input()\n\nt, a = 0, 1\nmod = [0]*2019\nmod[0] = 1\ns = s[::-1]\nn = len(s)\nfor i in range(n):\n t += int(s[i]) * a\n t %= 2019\n a *= 10 #a *= 2019 <- TLE\n a %= 2019\n mod[t] += 1\nans = 0\n\nfor i in range(2019):\n ans += mod[i]*(mod[i]-1)//2\nprint(ans)']
['Runtime Error', 'Accepted']
['s633982360', 's482510768']
[9192.0, 9268.0]
[24.0, 119.0]
[247, 264]
p02702
u198668088
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())\nmod_list = []\n\nfor i in range(len(S)-3):\n for j in range(i+4, len(S)+1):\n num = int(''.join(S[i:j]))\n mod_list.append(num % 2019)\n\nprint('test')", 'S = list(input())[::-1]\nans = 0\nmods = [0] * 2019\nmods[0] = 1 # If 2019 is exist, count number\ncurrent = 0\nx = 1\nfor s in S:\n current = (current + x * int(s)) % 2019\n ans += mods[current]\n mods[current] += 1\n x = x * 10 % 2019\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s041531732', 's850321943']
[10900.0, 11700.0]
[2206.0, 121.0]
[179, 251]
p02702
u199830845
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)\n\n\n\n\ncounter = [0] * 2019\nindices = []\nk = 10\nfor i in range(N + 1):\n if i == 0:\n sub = 0\n counter[i] = 0\n elif i == 1:\n sub = int(S[N - 1])\n counter[i] = sub % 2019\n else:\n \n sub += int(S[N - i]) * k\n k *= 10\n\n counter[i] = counter[i-1] + sub\n counter[i] %= 2019\n k %= 2019\n\n \n # counter[rest] += 1\n\nans = 0\nfor r in counter:\n ans += r * (r - 1) // 2\nprint(ans)', 'S = list(input())\nN = len(S)\n\n\n\n\ncounter = [0] * 2019\nk = 10\nfor i in range(N + 1):\n if i == 0:\n sub = 0\n elif i == 1:\n sub = int(S[N - 1])\n else:\n sub += int(S[N - i]) * k\n k *= 10\n k %= 2019\n rest = sub % 2019\n counter[rest] += 1\n\nans = 0\nfor r in counter:\n ans += r * (r - 1) // 2\nprint(ans)']
['Runtime Error', 'Accepted']
['s182331158', 's856726333']
[10660.0, 10532.0]
[23.0, 139.0]
[928, 658]
p02702
u202560873
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)\n\ncounter = [0] * 2019\ncounter[0] = 1\nT = 0\nR = 1\nfor i in range(N):\n T = (T + R * int(S[n - i - 1])) % 2019\n R = 10 * R % 2019\n counter[T] += 1\n\nans = 0\nfor i in range(2019):\n m = counter[i]\n ans += m * (m - 1) // 2\n\nprint(ans)', 's = input()\nt = s[::-1]\nn = len(s)\nresid = [0] * 2019\nresid[0] = 1\ncsum = 0\npowoften = 1\nfor i in range(n):\n csum = (csum + int(t[i]) * powoften) % 2019\n powoften = (10 * powoften) % 2019\n resid[csum] += 1\nans = 0\nfor i in range(2019):\n ans += resid[i] * (resid[i] - 1) // 2\nprint(ans)']
['Runtime Error', 'Accepted']
['s293900359', 's189241501']
[9364.0, 9204.0]
[24.0, 116.0]
[265, 297]