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
p02756
u955474478
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['s = input()\nq = int(input())\nfor i in range(q):\n a = input()\n if " " in a:\n l = list(a.split())\n if l[1] == "1":\n s = l[2] + s\n else:\n s += l[2]\n else:\n s.reverse()\nprint(s)', 's = input()\nq = int(input())\ns1 = ""\ns2 = ""\nc = 1\nfor i in range(q):\n a = input()\n if " " in a...
['Runtime Error', 'Accepted']
['s599243393', 's549394479']
[9784.0, 10224.0]
[2205.0, 374.0]
[198, 301]
p02756
u958053648
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["import sys\nfrom collections import deque\n\tS=[input()]\n\tS=deque(S)\n\tQ=int(sys.stdin.readline())\n\tflag=0\n\tfor i in range(Q):\n\t\tqu=tuple(input().split())\n\t\tif qu[0]=='1':\n\t\t\tif flag==0:\n\t\t\t\tflag+=1\n\t\t\telse:\n\t\t\t\tflag=0\n\t\telse:\n\t\t\tif qu[1]=='1' and flag==0:\n\t\t\t\tS.appendleft(q...
['Runtime Error', 'Accepted']
['s669764499', 's364868418']
[2940.0, 7028.0]
[17.0, 469.0]
[482, 489]
p02756
u963164554
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["S = input()\nQ = int(input())\nfor _ in range(Q):\n q = list(map(str, input().split()))\n if q[0]=='1':\n list(S).reverse()\n S = ''.join(S)\n else:\n if q[1]=='1':\n S = q[2] + S\n else:\n S = S + q[2]\n\nprint(S)", "S = input()\nQ = int(input())\nfor _ in r...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s023828920', 's966003442', 's709702188']
[6112.0, 7996.0, 9440.0]
[2104.0, 2108.0, 633.0]
[260, 266, 566]
p02756
u963764813
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['s = input()\nq_number = int(input())\nreverse_flag = 1\nfor i in range(q_number):\n temp = input().split()\n if temp[0] == "1": \n reverse_flag = reverse_flag * -1\n else:\n if int(temp[1]) == 1 or -2:\n s = temp[2] + s\n elif int(temp[1]) == -1 or 2:\n s = s + temp[2] \n\nif reverse_flag =...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s475550593', 's716824205', 's650707988']
[2940.0, 41712.0, 4548.0]
[18.0, 2106.0, 1650.0]
[335, 356, 456]
p02756
u966207392
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["from collections import deque\nS = input()\nQ = int(input())\nrev = 0\n\nfor i in range(Q):\n T = input().split()\n if T[0] == '1':\n rev += 1\n else:\n if T[1] == '1':\n if rev % 2 == 0:\n S.insert(0, T[2])\n else:\n S.append(T[2])\n e...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s098921681', 's186516265', 's321567373', 's856344292']
[9572.0, 9580.0, 14280.0, 14512.0]
[27.0, 29.0, 305.0, 302.0]
[493, 496, 508, 509]
p02756
u968404618
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["s = input()\nt = ''\nq = int(input())\nQ = [list(map(str, input().split())) for _ in range(q)]\n\nfor qi in Q:\n if int(qi[0]) == 1:\n s, t = t, s\n else:\n if int(qi[1]) == 1:\n t += qi[2]\n else:\n s += qi[2]\nt[::-1]\nt += s\nprint(t)\n", 'from collections import d...
['Wrong Answer', 'Accepted']
['s922069026', 's083486045']
[40400.0, 37964.0]
[707.0, 474.0]
[273, 404]
p02756
u968649733
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["S = input()\nQ = int(input())\n\ncnt=0\nfor i in range(Q):\n T = input().split()\n if T[0] == '1':\n if i >0:\n \tcnt += 1\n elif T[0] == '2':\n #normal\n if cnt % 2 == 0:\n if T[1] == '1':\n S = T[2] + S \n elif T[1] == '2':\n S = S + T[2] \n #reverse\n elif cnt % 2 ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s095474072', 's814632582', 's044104608']
[3956.0, 10100.0, 10228.0]
[2104.0, 460.0, 447.0]
[453, 587, 595]
p02756
u969133463
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["import math\n\ns = list(input())\nq = int(input())\n\nmae = []\nusi = []\nk = 0\nm = 0\nfor i in range(q):\n a = input().split()\n if(a[0] == '1'):\n k += 1\n if(a[0] == '2'):\n if(k %2 == 0):\n if(a[1] == '1'):\n mae.appendleft(a[2])\n else:\n ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s180025470', 's283481750', 's986184964']
[4084.0, 4992.0, 11812.0]
[20.0, 2104.0, 440.0]
[594, 304, 652]
p02756
u969190727
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['import sys\ninput=sys.stdin.readline\ns=input()\nq=int(input())\nsign=1\nfor i in range(q):\n Q=[str(i) for i in input().split()]\n if Q[0]=="1":\n sign*=-1\n else:\n f,c=Q[1:]\n if f=="1" and sign==1:\n s=c+s\n elif f=="2" and sign==-1:\n s=c+s\n else:\n s=s+c\nprint(s if sign==1 els...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s592536499', 's700891653', 's685291853']
[3968.0, 4684.0, 4568.0]
[2104.0, 1453.0, 1452.0]
[311, 335, 357]
p02756
u969236097
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["import sys\na = sys.stdin.read().split('\\n')[:-1]\ns = list(a[0])\nq = int(a[1])\nf = 1\nfor i in range(2, q + 2):\n if a[i][0] == '1':\n f = 1 - f\n else:\n l = len(s)\n s.insert(a[i][2] == '21'[f] ? 0 : l, a[i][4])\nif f == 1:\n print(''.join(s))\nelse:\n print(''.join(reversed(s))...
['Runtime Error', 'Accepted']
['s117551741', 's625254640']
[2940.0, 18516.0]
[19.0, 1002.0]
[304, 291]
p02756
u970082363
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['import sys\ninput = sys.stdin.readline\n\ns = input()\nq = int(input())\n\ndef addflont(s,c):\n return c+s\ndef addback(s,c):\n return s+c\n\nreverse = 0\n\nfor i in range(q):\n t = list(map(str,input().split()))\n if t[0]=="1":\n reverse += 1\n if t[0]=="2":\n if t[1]=="1":\n ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s537971728', 's541166846', 's635656325']
[3756.0, 3188.0, 4648.0]
[2104.0, 18.0, 1784.0]
[607, 498, 629]
p02756
u970133396
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['from collections import deque\ns=input()\nQ=int(input())\n\nans=deque()\nans.append(s)\nrev=False\n\nfor _ in range(Q):\n query=input().split()\n if query[0]=="1":\n rev = not rev\n else:\n if rev:\n query[1]=str(3-int(query[1]))\n if query[1]=="1":\n ans.appendleft...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s003302015', 's177903910', 's483551696', 's680478657', 's718916482', 's721751895', 's949653508', 's704893020']
[8432.0, 4332.0, 6768.0, 4424.0, 9584.0, 6768.0, 8688.0, 4552.0]
[1260.0, 2104.0, 622.0, 2104.0, 2104.0, 1299.0, 1507.0, 1768.0]
[499, 415, 486, 483, 536, 490, 504, 662]
p02756
u970267139
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["s = input()\nQ = int(input())\nquery = [input().split() for _ in range(Q)]\n\ncnt = 0\nfor q in query:\n if q[0] == '1':\n cnt += 1\n else:\n reverse = cnt % 2\n if q[1] == '1':\n if reverse == 0:\n s = q[2] + s\n else:\n s = s + q[2]\n ...
['Runtime Error', 'Accepted']
['s022850919', 's229515701']
[171324.0, 14184.0]
[563.0, 310.0]
[487, 564]
p02756
u970809473
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['s=list(input())\ntop=bool()\nt=[]\nu=[]\nn=int(input())\nfor i in range(n):\n q=list(map(str,input().split()))\n if q[0]==\'1\':\n top=not top\n else:\n if (q[1]=="1") ^ top:\n t.insert(0,q[2])\n else:\n u.append(q[2])\ns=t+s+u\nif top:\n print(*list(reversed(s)),sep=\'\')\nelse:\n print(s)\n'...
['Wrong Answer', 'Accepted']
['s503360048', 's143437764']
[16792.0, 17640.0]
[2206.0, 458.0]
[294, 315]
p02756
u971719367
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["true_letter = input()\nprint(true_letter)\nQ= int(input())\nletter = ['*']\nreversed = False\nfor i in range(Q):\n query = input().split()\n if len(query)==1:\n reversed = not bool(reversed)\n else:\n if int(query[1])==1: \n if reversed == False:\n letter.insert(0,quer...
['Wrong Answer', 'Accepted']
['s388245720', 's808804756']
[4084.0, 6900.0]
[2104.0, 480.0]
[655, 1360]
p02756
u973055892
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["import sys\nfrom collections import deque\n\ndef main():\n input = sys.stdin.readline\n\n s = input()[:-1]\n q = int(input())\n tmp = [input().split() for _ in range(q)]\n\n flag = 0\n ans = deque([s])\n for t in tmp:\n if len(t) == 1:\n flag = ~flag \n else:\n ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s537967402', 's811228756', 's448497568']
[39540.0, 41740.0, 42996.0]
[147.0, 2106.0, 209.0]
[611, 407, 613]
p02756
u974792613
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['s = input()\nq = int(input())\n\nt = [0] * q\nf = [0] * q\nc = [""] * q\n\nfor i in range(q):\n lis = list(input().split())\n t[i] = int(lis[0])\n if t[i] == 2:\n f[i] = int(lis[1])\n c[i] = lis[2]\n\nidx = 0\nchs = ""\nflip = False\nins = 0\nwhile idx < q:\n if t[idx] == 1:\n flip = ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s154783718', 's720015318', 's270538541']
[10300.0, 10100.0, 9076.0]
[2104.0, 2104.0, 690.0]
[1005, 981, 423]
p02756
u975039852
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['s = input()\nq = int(input)\nrev = False\nfor i in range(q):\n inp = input()\n if int(inp[0]) == 1:\n rev = not rev\n else:\n t, f, c = inp.split()\n if (int(f) == 1 and rev) or (int(f) == 2 and not rev):\n s += c\n else:\n s = c + s\nprint(reversed(s) if rev else s)', "s = input()\nq = int(i...
['Runtime Error', 'Accepted']
['s104467536', 's167198221']
[3188.0, 4480.0]
[17.0, 579.0]
[279, 304]
p02756
u979362546
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["s = input()\nq = int(input())\nfor i in range(q):\n\tt, f, c = map(str, input().split())\n\tif t == '1':\n\t\ts = s[::-1]\n\telif f == '1':\n\t\t\ts = c + s\n\telse:\n\t\t\ts += c\nprint(s)", "s = input()\nq = int(input())\nfor i in range(q):\n\tt, f, c = map(str, input().split())\n\tif t == '1':\n\t\ts = s[::-1]\n\t...
['Runtime Error', 'Runtime Error', 'Accepted']
['s012326761', 's895750550', 's553845593']
[3884.0, 3848.0, 8692.0]
[2104.0, 2104.0, 676.0]
[167, 167, 415]
p02756
u980641911
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
["from collections import deque\n\n\nreverse = False\n\nstring = deque(input().rstrip())\noperate_times = int(input().rstrip())\n\nfor i in range(operate_times):\n row = input().rstrip()\n if row[0]=='1':\n if reverse:\n reverse = False\n else:\n reverse = True\n \n if ro...
['Wrong Answer', 'Accepted']
['s497323251', 's342977394']
[6004.0, 8436.0]
[511.0, 589.0]
[863, 903]
p02756
u983181637
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['s = list(input())\nq = int(input())\n\nfor _ in range(q):\n Q = [x for x in input().split()]\n if Q[0] == \'1\':\n s = s[::-1]\n else:\n if Q[1] == \'1\':\n s.insert(0, Q[2])\n else:\n s.append(Q[2])\n\nfor i in s:\n print(i, end ="")', "from collections import deque\n\ns = deque(input())\nq = ...
['Time Limit Exceeded', 'Accepted']
['s911279444', 's944237289']
[7112.0, 8436.0]
[2104.0, 547.0]
[239, 337]
p02756
u985041094
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['def change_fb(str_list):\n tmp = str_list[0]\n str_list[0] = str_list[-1]\n str_list[-1] = tmp\n\ns = str(input())\nq = int(input())\nw = [input() for i in range(q)]\n\nchange = False\nstr_list = list(s)\nfor data in w:\n if int(data[0]) == 1:\n change = not change\n else:\n if change:\n ...
['Runtime Error', 'Accepted']
['s248670885', 's735275506']
[149116.0, 45976.0]
[1885.0, 727.0]
[573, 574]
p02756
u987170100
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['S = input()\nfor _ in range(int(input())):\n l = input().split()\n print(l)\n if len(l) == 1:\n S = S[::-1]\n else:\n if l[1] == "1":\n S = l[2] + S\n else:\n S = S + l[2]\nprint(S)\n', 'S = input()\nl1 = []\nl2 = []\nrev = False\nfor _ in range(int(input())):\n ...
['Wrong Answer', 'Accepted']
['s247481261', 's877650149']
[4984.0, 5724.0]
[2104.0, 508.0]
[226, 478]
p02756
u995323427
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string...
['S = input()\nNQ = int(input())\n\nreverseFlag = False\n\nfor i in range(NQ):\n query = input().split()\n if (int(query[0]) == 1):\n reverseFlag = not reverseFlag\n else:\n if (reverseFlag):\n if (int(query[1]) == 1):\n S = query[2] + S\n else:\n ...
['Wrong Answer', 'Accepted']
['s960877773', 's468902907']
[3956.0, 4556.0]
[2104.0, 1658.0]
[517, 629]
p02757
u021019433
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['p = int(input().split()[1])\ns = input()\nif 10 % p:\n s = reversed(s)\na = enumerate(s, 1)\nif 10 % p == 0:\n r = sum(i for i, x in a if x % p == 0)\nelse:\n d = [1] + [0] * (p - 1)\n t, y = 0, 1\n for i, x in a:\n t = (t + x * y) % p\n d[t] += 1\n y = y * 10 % p;\n r = sum(i * (i - 1) // 2 for i in d...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s014281962', 's046146205', 's083909553', 's141601907', 's306002984', 's886051623', 's899445391', 's909228915', 's958019944', 's638600229']
[3500.0, 2940.0, 3500.0, 3500.0, 3500.0, 3876.0, 3876.0, 3500.0, 2940.0, 3628.0]
[18.0, 19.0, 18.0, 74.0, 77.0, 169.0, 75.0, 76.0, 17.0, 142.0]
[315, 319, 317, 290, 296, 370, 369, 296, 374, 296]
p02757
u023229441
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n,p=map(int,input().split())\ns=input()\ndef U(x):\n return int(s[x:])\nif p in [2,5]:\n keta=0\n ans=0\n for i in range(n):\n keta+=1\n if int(s[i])%p==0:\n ans+=keta\n print(ans)\n exit()\n\n\nikeru=[0 for i in range(p)]\nfor i in range(n):\n a=U(i) % p\n ikeru[a]+=1...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s164952512', 's287066863', 's313782683', 's480511048', 's481191407']
[3560.0, 2940.0, 3828.0, 3560.0, 14536.0]
[2104.0, 17.0, 2104.0, 2104.0, 530.0]
[390, 380, 380, 381, 540]
p02757
u023540496
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n,p = (int(num) for num in input().split())\ns = input()\ns = s[::-1]\n\ndec = [1] * n\nfor i in range(1,n):\n dec[i] = (dec[i - 1] * 10) % p\ns_mod = [0] * n\nfor i in range(n):\n s_mod[i] = (int(s[i]) * dec[i]) % p\n \nprint(dec)\nprint(s_mod)\n \ncumsum = [0] * (n + 1)\ncnt = [1] + [0] * (p - 1)\nfor i...
['Wrong Answer', 'Accepted']
['s131331282', 's231270570']
[32716.0, 25940.0]
[326.0, 289.0]
[499, 827]
p02757
u023958502
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n, P = map(int, input().split())\nS = input()\nans = 0\n#----------------------------------------------\n# 1.\n\n\n# S = 1234\n\n# 23 = (234 - 4) // 10 ** (4 - 3)\n# = 230 // 10\n# = 23\n#\n# 2.\n\n\n#\n# 3.\n\n# int(S[a: b]) * 10 ** (n - b) == (int(S[a: n]) - int(S[b: n]))\n\n\n\n\n\n#\n\n\n\n#--------------...
['Wrong Answer', 'Accepted']
['s639737708', 's222955602']
[4576.0, 3500.0]
[402.0, 251.0]
[2295, 2297]
p02757
u034128150
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N, P = map(int, input().split())\nS = input()\n\nif P == 2:\n ans = 0\n for i, d in enumerate(map(int, S)):\n if d % 2 == 0:\n ans += i+1\n print(ans)\nelif P == 5:\n ans = 0\n for i, d in enumerate(map(int, S)):\n if d % 5 == 0:\n ans += i+1\n print(ans)\nelse:\n...
['Wrong Answer', 'Accepted']
['s730992608', 's247777173']
[9452.0, 9440.0]
[325.0, 325.0]
[598, 581]
p02757
u037430802
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['\n\n\nN,P = map(int, input().split())\nS = input()\n\nans = 0\nmod_P = [0] * P\nmod_P[0] += 1\n\nif P in [2,5]:\n \n for i in range(N):\n ans += mod_P[0]\n mod_P[int(S[N-1-i]) % P] += 1\n \n print(ans)\n\nelse:\n \n curr = 0\n for i in range(N):\n curr = int(S[N-1-i]) * pow(1...
['Wrong Answer', 'Accepted']
['s543446238', 's525230261']
[96360.0, 4452.0]
[2104.0, 571.0]
[1595, 816]
p02757
u044220565
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
["# coding: utf-8\nimport numpy as np\nN,P = list(map(int, input().split()))\nS = '0'+input()\n\n#N=200000\n#P=9893\n#S= '0'+'1234567890' * 20000\n\nif (P==2)|(P==5):\n sum=0\n for i in range(N, 0, -1):\n if int(S[i]) % P == 0:\n sum+= i\n print(sum)\n\n\nelse:\n dp1 = np.zeros(N + 1)\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s114336098', 's219761048', 's279672612']
[15724.0, 14348.0, 12564.0]
[1255.0, 1317.0, 229.0]
[814, 573, 754]
p02757
u062655521
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
["n, p = map(int, input().split(' '))\ns = input()\np_len = len(str(p))\nans = 0\n\nfor i in range(len(s), len(s) + 1 - p_len):\n for j in range(i + p_len, len(s) + 1):\n n_ss = int(s[i:j])\n if n_ss % p == 0:\n ans += 1\n\nprint(ans)", "n, p = map(int, input().split(' '))\ns = input()\n\nif...
['Wrong Answer', 'Accepted']
['s864837100', 's120193942']
[3500.0, 11208.0]
[17.0, 253.0]
[249, 496]
p02757
u073852194
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
["from collections import Counter\nimport sys\nif sys.platform == 'ios' or 'darwin':\n sys.stdin = open('input_file.txt')\n\nN, P = map(int, input().split())\nS = input()\n\nans = 0\n\nif P == 2 or P == 5:\n for i in range(N):\n if int(S[-1 - i]) % 2 == 0:\n ans += N - i\nelse:\n M = []\n ...
['Runtime Error', 'Accepted']
['s042231545', 's990922706']
[3316.0, 19236.0]
[20.0, 557.0]
[545, 457]
p02757
u075012704
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from collections import Counter\nN, P = map(int, input().split())\nS = input()\n\nif 10 % P == 0:\n ans = 0\n for i, s in enumerate(S, start=1):\n if int(s) % P != 0:\n continue\n ans += i\n print(ans)\n\nelse:\n X = [0]\n for i, s in enumerate(S[::-1]):\n X.append((X[-1...
['Wrong Answer', 'Accepted']
['s843981108', 's475142216']
[12048.0, 12052.0]
[517.0, 526.0]
[445, 440]
p02757
u078181689
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['import sys\n\nn,p = list(map(int,input().split())); s = input()\n\nans = 0\n\nif p == 2 or p == 5:\n for i in range(n):\n if int(s[i])%p == 0:\n ans += i+1\n print(ans)\n sys.exit()\n \nres = [0] * p\narr = [int(s[i:])%p for i in range(n)]\nfor i in arr:\n res[i] += 1\nfor i in res:\n...
['Wrong Answer', 'Accepted']
['s076404999', 's274039481']
[3560.0, 12364.0]
[2104.0, 525.0]
[362, 486]
p02757
u111473084
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from collections import Counter\n\nn, p = map(int, input().split(" "))\ns = list(map(int, input()))\ns = s[::-1]\n\nans = 0\nif 10 % p == 0: # p = 2, 5\n for i, num in enumerate(s, 1):\n if num % p == 0:\n ans += i\n print(ans)\n exit()\n\npower = 1\nt = [0] * len(s)\nt[0] = s[0] % p\nfor i...
['Wrong Answer', 'Accepted']
['s741696498', 's507894002']
[110172.0, 12668.0]
[2104.0, 198.0]
[639, 594]
p02757
u123525541
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
[' n, p = map(int, input().split())\n s = input()\n\n\n def solve1(s, p):\n v = 0\n pow10 = 1\n ans = 0\n cnt = [0] * p\n cnt[0] = 1\n\n for i in range(n - 1, -1, -1):\n v = (pow10 * int(s[i]) + v) % p\n pow10 = (pow10 * 10) % p\n ans += cnt[v]\n cnt[...
['Runtime Error', 'Accepted']
['s820979600', 's400767176']
[2940.0, 3500.0]
[17.0, 124.0]
[595, 544]
p02757
u123872895
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from collections import Counter\n\nn, p = list(map(int, input().split()))\n\ns = input()\n\n\na = 0\nt = list(map(int, list(s)))\nt.reverse()\n\n\nif p == 2:\n for i in range(n):\n if t[i] % 2 == 0:\n a += len(t) - i \nelif p == 5:\n for i in range(n):\n if t[i] % 5 == 0:\n a...
['Wrong Answer', 'Accepted']
['s661196798', 's833611289']
[13520.0, 13612.0]
[167.0, 157.0]
[653, 560]
p02757
u139112865
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['#E\nfrom collections import Counter\nn,p=map(int,input().split())\ns=input()\ncnt=0\n\nif p==2 or p==5:\n for i in range(n):\n if int(s[i])%p==0:\n cnt+=i+1\nelse:\n U=[0]\n for i in range(n):\n x=n-1-i\n U.append((U[i]+int(s[x])*10**(i))%p)\n print(U)\n C=Counter(U)\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s500085725', 's676676181', 's055121250']
[4100.0, 5692.0, 12080.0]
[2104.0, 2104.0, 534.0]
[359, 355, 360]
p02757
u145600939
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n,p = map(int,input().split())\ns = list(map(int,list(input())))\nans = 0\ncnt = [0]*p\ncnt[0] = 1\n\nif p == 2:\n for i in range(n):\n if s[i] in [0,2,4,6,8] :\n ans += i + 1\nelif p == 5:\n for i in range(n):\n if s[i] in [0,5]:\n ans += i + 1\nelse:\n sp = [0]*n\n sp[n-1] = s[n-1]%p\n cnt[sp[n...
['Wrong Answer', 'Accepted']
['s600748638', 's395467209']
[8500.0, 6560.0]
[2104.0, 485.0]
[489, 419]
p02757
u150821332
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['import numpy as np\n\ndef a():\n n, p = list(map(int, input().split()))\n s = input()\n if(p==2 or p==5):\n count=0\n for i in range(1,n+1):\n if(int(s[-i])%p == 0):\n count += n-i+1\n print(count)\n return\n\n num = np.array([int(s[i:]) for i in range(n)]) % p\n print(num)\n c = sum(num...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s303964416', 's811760712', 's753228728']
[20628.0, 19820.0, 14560.0]
[2109.0, 2109.0, 571.0]
[427, 448, 470]
p02757
u181644161
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N,P=map(int,input().split())\nS=str(input())\nans=0\n\nif 10%P==0:\n for i in range(N):\n if int(S[i])%P==0:\n ans+=i+1\nelse:\n rem = [0]*P\n mod = 0\n ten = 1\n rem[mod]=1\n for i in range(N):\n mod=(mod+S[N-i-1]*ten)%P\n ten=ten*10%P\n rem[mod]+=1\n for j...
['Runtime Error', 'Accepted']
['s095780468', 's303457524']
[3500.0, 3500.0]
[129.0, 158.0]
[346, 352]
p02757
u195054737
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n, p = map(int, input().split())\ns = input()\n\nans = 0\nif p in (2, 5):\n for i, j in enumerate(s):\n if int(j) % p == 0:\n ans += i + 1\n\nelse:\n cnt = [0] * p\n cnt[0] = 1\n now = 0\n for i, j in enumerate(reversed(s)):\n now = (int(s) * pow(10, i, p) + now) % p\n a...
['Wrong Answer', 'Accepted']
['s699131168', 's597751223']
[3560.0, 3500.0]
[2104.0, 506.0]
[351, 351]
p02757
u201234972
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
["def main():\n N, P = map( int ,input().split())\n S = [ int(s) for s in list(input())][::-1]\n if P == 2 or P == 5:\n ans = 0\n for i in range(N):\n if S[i]%P == 0:\n ans += N-i\n print(ans)\n return\n\n \n L = [0]*P\n L[0] = 1\n t = 0\n fo...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s240803708', 's336602470', 's641699632', 's908687796']
[6436.0, 6564.0, 6504.0, 6436.0]
[614.0, 96.0, 60.0, 112.0]
[502, 511, 536, 496]
p02757
u203382704
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N, P = map(int, input().split())\nd = list(map(int, input()))\nans =0\nfor k in range(0,N):\n for l in range(k+1,N+1):\n num = int("".join(map(str,d[k:l])))\n \n if num == 0:\n break\n elif num % P == 0:\n ans += 1\n print(num)\n\nprint(ans)\n', 'N, P = ...
['Wrong Answer', 'Accepted']
['s174965776', 's446904723']
[14828.0, 5220.0]
[2104.0, 176.0]
[293, 518]
p02757
u212786022
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['dp = [[0 for i in range(N-j)] for j in range(N)]\ndp\nfor j in range(N):\n dp[j][0]=(int(S[j])%mod)\n for i in range(1,N-j):\n dp[j][i]=((dp[j][i-1]*10+int(S[j+i]))%mod)\nans = 0\nfor i in range(N):\n ans += dp[i].count(0)\n \nprint(ans)', 'N, P = map(int, input().split())\nS = list(map(int,list(in...
['Runtime Error', 'Accepted']
['s846871981', 's532054848']
[3064.0, 13632.0]
[18.0, 210.0]
[246, 592]
p02757
u268554510
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N,P = map(int,input().split())\nS = list(map(int,list(input())))\nS=S[::-1]\nans = 0\nfrom collections import Counter\nif P==2:\n l = [0,2,4,6,8]\n for i,s in enumerate(S):\n if s in l:\n ans+=N-i\nelif P==5:\n l=[0,5]\n for i,s in enumerate(S):\n if s in l:\n ans+=N-i\n\nelse:\n l = [0]*(N+2)\n ...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s154791260', 's215805683', 's298095936', 's580552935', 's679380877', 's282866633']
[7004.0, 6436.0, 3500.0, 6948.0, 3624.0, 6560.0]
[2104.0, 101.0, 288.0, 2104.0, 288.0, 461.0]
[529, 255, 254, 529, 257, 500]
p02757
u312025627
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['def main():\n N, P = (int(i) for i in input().split())\n S = input()\n\n ans = 0\n if P == 5:\n for i in range(1):\n for j in range(1, N-i+1):\n num = int(S[i:i+j])\n if num % P == 0:\n # print("!", end=" ")\n ans += len...
['Runtime Error', 'Accepted']
['s865414864', 's075166184']
[3064.0, 14488.0]
[17.0, 143.0]
[852, 648]
p02757
u318384266
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
["N, P = map(int, input().split())\nS = input()\ncounter=0\ndef power_func(a,b,p):\n\tif b==0:\n\t\treturn 1\n if b%2==0:\n\t\td=power_func(a,b//2,p)\n\t\treturn d*d %p\n\tif b%2==1:\n\t\treturn (a*power_func(a,b-1,p ))%p\nif P==2:\n counter = 0\n for i in range(len(S)):\n if S[i] in ['2','4','6','8','0...
['Runtime Error', 'Accepted']
['s452817789', 's424923975']
[2940.0, 3628.0]
[17.0, 1795.0]
[641, 677]
p02757
u328364772
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n, p = map(int, input().split())\ns = input()\n\nans = 0\n\nif p == 2 or p == 5:\n for i in range(n):\n if int(s[i]) % p == 0:\n ans += i+1\nelse:\n \tmod = [-1 for i in range(p)]\n\tmod[0] = 0\n mp = 0\n m10 = 1\n for i in range(n-1, -1, -1):\n mp = (mp + int(s[i]) * m10) % p\n ...
['Runtime Error', 'Accepted']
['s273000883', 's608949479']
[2940.0, 3500.0]
[17.0, 169.0]
[406, 414]
p02757
u338824669
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from collections import defaultdict\n\nN,P=map(int,input().split())\nS=input()\n\ndef solMin():\n dp=[[0]*P for i in range(N+1)]\n \n for i,s in enumerate(map(int,S), start=1):\n dp[i][s%P]+=1\n for p in range(P):\n dp[i][(p*10+s)]+=dp[i-1][p]\n \n return sum(dp[i][0] for i in range(N+1))\n\ndef solLa...
['Runtime Error', 'Accepted']
['s478451338', 's664359295']
[27104.0, 42928.0]
[534.0, 544.0]
[562, 564]
p02757
u346812984
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['import sys\n\nsys.setrecursionlimit(10 ** 6)\nINF = float("inf")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n N, P = map(int, input().split())\n S = input()\n\n if P == 2 or P == 5:\n ans = 0\n for i in range(N):\n if int(S[i]) % P ...
['Wrong Answer', 'Accepted']
['s403243407', 's293749603']
[3628.0, 3500.0]
[122.0, 130.0]
[727, 726]
p02757
u350248178
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n,p=map(int,input().split())\ns=[int(j) for j in input()][::-1]\n\nif p==2:\n ans=0\n for i,j in enumerate(s):\n if j%2==0:\n ans+=(n-i)\n print(ans)\n exit()\nif p==5:\n ans=0\n for i,j in enumerate(s):\n if j%5==0:\n ans+=(n-i)\n print(ans)\n exit()\n\nc=[...
['Wrong Answer', 'Accepted']
['s768671682', 's621123270']
[16256.0, 14456.0]
[442.0, 276.0]
[468, 443]
p02757
u353797797
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from collections import Counter\nimport sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep="\\n")\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(...
['Wrong Answer', 'Accepted']
['s458852705', 's613906017']
[16828.0, 13620.0]
[173.0, 149.0]
[863, 813]
p02757
u454472984
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n, p = map(int, input().split())\n \ns = list(input())\nans = 0\nif p == 2 or p == 5:\n for i in range(n):\n if int(s[i]) % p == 0:\n ans += i + 1\nelse:\n d = [0] * (n + 1)\n ten = 1\n for i in range(n - 1, -1, -1):\n a = int(s[i]) * ten % p\n sum+=a\n ten *= 10\n ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s000874702', 's596362628', 's112623710']
[6308.0, 15852.0, 12412.0]
[109.0, 239.0, 209.0]
[478, 484, 467]
p02757
u471641802
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['# from collections import Counter\nn, p = map(int, input().split())\ns = [int(i) for i in input()]\np_cnt = 0\n\nif p == 2 or p == 5:\n for i in range(n):\n if s[i] % p == 0:\n p_cnt += i+1\nelse:\n s = s[::-1]\n div_dic = dict(zip(range(p), [0] * p))\n tmp = 0\n\n for i in range(n):\...
['Wrong Answer', 'Accepted']
['s895904237', 's440604430']
[6560.0, 6436.0]
[502.0, 506.0]
[520, 476]
p02757
u497952650
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N,P = map(int,input().split())\nS = input()\n\nif P%2 == 0 or P%5 == 0:\n ans = 0\n S = S[::-1]\n for i,j in enumerate(S):\n if int(j)%P == 0:\n ans += i+1\n print(ans)\nelse:\n tmp = 0\n mod = [0]*P\n ##mod[0] = 1\n S = S[::-1]\n for i,j in enumerate(S):\n tmp = (t...
['Wrong Answer', 'Accepted']
['s306386823', 's875146871']
[3500.0, 3500.0]
[497.0, 492.0]
[396, 396]
p02757
u517152997
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['#\nimport sys\nimport math\n#import numpy as np\nimport itertools\nfrom collections import Counter\n\nn,p = (int(i) for i in input().split())\n\ns = [int(i) for i in list(input())] \n\nanswer = 0\n#print(s)\nq=0\nx=[]\nif p == 2 or p == 5:\n for i in range(n-1,-1,-1):\n if s[i]%p == 0:\n answer +...
['Wrong Answer', 'Accepted']
['s942756534', 's827075367']
[13408.0, 13436.0]
[159.0, 176.0]
[642, 743]
p02757
u532966492
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['def main():\n n, p = map(int, input().split())\n s = list(map(int, list(input())))\n now = 1\n now2 = 0\n\n dp = [0]*p\n cnt = 0\n if p != 5:\n for i in s:\n now2 = (now2*10+i) % p\n dp[((i-now2) % p)*pow(now, p-2, p) % p] += 1\n cnt += dp[((-now2) % p)*pow...
['Wrong Answer', 'Accepted']
['s031123856', 's463688619']
[103568.0, 12740.0]
[2104.0, 631.0]
[500, 220]
p02757
u535803878
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['input = _input().__next__\nn, p = [int(c) for c in input().split()]\ns = input() \n\nif p in (2,5):\n a = tuple(int(c)%p for c in s)\n out = 0\n for i,x in enumerate(a):\n if x==0:\n out += (i + 1)\nelse:\n a = [0]*n\n tmp = 0\n for i in reversed(range(n)):\n tmp = (tmp *...
['Runtime Error', 'Accepted']
['s763759954', 's532746864']
[3064.0, 13328.0]
[17.0, 496.0]
[472, 622]
p02757
u543954314
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n,p = map(int, input().split())\ns = list(map(int, list(ns())))\nif p in (2, 5):\n print(sum(i+1 for i in range(n) if s[i]%p == 0))\n exit(0)\n \nans = g = 0\nd = [0]*p\nd[0] = 1\nt = 1\nfor i in range(n-1,-1,-1):\n g = (g + s[i]*t)%p\n ans += d[g]\n d[g] += 1\n t = (t*10)%p\nprint(ans)', 'n,p = map(i...
['Runtime Error', 'Accepted']
['s514681009', 's397640649']
[3064.0, 6560.0]
[18.0, 174.0]
[288, 288]
p02757
u577170763
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
["class Solution:\n\n def solve(self, N: int, P: int, S: str):\n\n if P == 2 or P == 5:\n answer = 0\n for idx, s in enumerate(S):\n if int(s) % P == 0:\n answer += idx + 1\n\n else:\n answer = 0\n U = [0] * P # int(S[i,N] m...
['Wrong Answer', 'Accepted']
['s749369024', 's154640207']
[3560.0, 3500.0]
[2104.0, 135.0]
[713, 848]
p02757
u595064211
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N, P = map(int, input().split())\nS = input()\nans = 0\n\nd = [0]*(N+1)\n# d[N-1] = 1\n\nif 10%P == 0:\n ans = 0\n for i in range(N):\n if int(S[i]) % P == 0:\n ans += i + 1\n print(ans)\nelse:\n \n ten = 1\n \n for i in range(N-1,-1,-1):\n a = int(S[i]) * ten % P\n ...
['Wrong Answer', 'Accepted']
['s148746687', 's775180610']
[14536.0, 11088.0]
[414.0, 257.0]
[614, 618]
p02757
u595856802
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['def main():\n n, p = map(int, input().split())\n s = input()\n\n TF = 2, 5\n if p in TF:\n answer = 0\n for i, char in enumerate(s):\n if int(char) % p == 0:\n answer += i + 1\n print(answer)\n return\n\n u = [int(s[i:]) for i in range(n)]\n u.ap...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s589494635', 's994123078', 's661455886']
[8820.0, 57192.0, 12928.0]
[2104.0, 2110.0, 505.0]
[841, 972, 970]
p02757
u608088992
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['import sys\nfrom collections import defaultdict\n\ndef solve():\n input = sys.stdin.readline\n N, P = map(int, input().split())\n S = input().strip("\\n")\n modSum = 0\n modSum = int(S[0]) % P\n modDict = defaultdict(int)\n ans = 0\n\n if P == 2 or P == 5:\n for i in range(N):\n ...
['Runtime Error', 'Accepted']
['s062591936', 's428087632']
[9780.0, 10040.0]
[69.0, 327.0]
[753, 674]
p02757
u671455949
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from collections import deque\n\nimport numpy as np\n\nn, p = map(int, input().split())\nd = deque(input())\n\nans = 0\nif p == 2 or p == 5:\n for i in range(n):\n k = int(d.popleft())\n if n % p == 0:\n ans += i + 1\nelse:\n sub = [0 for i in range(n)]\n wk = 0\n for i in range(n):\n k = int(d.pop(...
['Wrong Answer', 'Accepted']
['s919518603', 's408816924']
[23892.0, 21496.0]
[799.0, 770.0]
[581, 568]
p02757
u685983477
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from collections import defaultdict\ndd = defaultdict(int)\nn,p=map(int, input().split())\nS = list(input().rstrip())\ntmp = 0\nr=1\nsu=0\n\nif p==2 or p==5:\n c=n\n for s in S[::-1]:\n if int(s)%p==0:\n su+=c\n c-=1\n print(su)\nelse:\n for s in S[::-1]:\n tmp+=int(s)*r\n ...
['Wrong Answer', 'Accepted']
['s689225180', 's474070434']
[7320.0, 7328.0]
[180.0, 180.0]
[425, 434]
p02757
u686230543
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['import numpy as np\n\nn, p = map(int, input().split())\ns = np.array([int(i) % p for i in input()])\nmod = np.zeros((n, p), dtype=np.int)\nfor i in range(n):\n mod[i, s[i]] = 1\ncount = mod[0, 0]\nfor i in range(1, n):\n idx = s[i]\n for j in range(p):\n mod[i, idx] += mod[i-1, j]\n idx = (idx + 10) % p\npri...
['Runtime Error', 'Accepted']
['s394885137', 's801800335']
[1561444.0, 3500.0]
[2118.0, 153.0]
[324, 371]
p02757
u698176039
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['import sys\ninput = sys.stdin.readline\n\nN,P = map(int,input().split())\nS = list(input())\n\nA = [0]*(N)\nA[-1] = int(S[-1])\nA[-1] %= P\nbase = 10\nfor i in reversed(range(N-1)):\n A[i] = A[i+1] + base*int(S[i])\n A[i] %= P\n base *= 10\n\n\nans = 0\nif P==2 or P==5:\n for i in reversed(range(N)):\n ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s136464149', 's642295800', 's944766695']
[6372.0, 6248.0, 13088.0]
[23.0, 23.0, 262.0]
[602, 603, 628]
p02757
u698919163
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N,P = map(int,input().split())\nS = input()\n\ndef solve(S,N,P):\n if P == 2:\n ans = 0\n for i in range(N):\n if int(S[i])%P == 0:\n ans += i+1\n return ans\n if P == 5:\n ans = 0\n for i in range(N):\n if int(S[i])%P == 0:\n ...
['Wrong Answer', 'Accepted']
['s796703758', 's079583197']
[3500.0, 3560.0]
[438.0, 459.0]
[627, 634]
p02757
u723792785
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n, mod = map(int, input().split())\ns = input()\n\ntotal = 0\nif mod == 2 or mod == 5:\n\tfor i, q in enumerate(s):\n\t\tif int(q)%mod == 0:\n\t\t\ttotal += i+1\nelse:\n\tcounts = [0]*mod\n\tcounts[0] = 1\n\th = 0\n\t\n\td = 1\n\tfor t in reversed(s):\n\t\tm = int(s)*d%mod\n\t\th = (h+m)%mod\n\t\ttotal += counts[h]\n...
['Wrong Answer', 'Accepted']
['s431267680', 's673314741']
[3500.0, 3500.0]
[2104.0, 187.0]
[329, 329]
p02757
u785573018
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n, p = map(int, input().split())\ns = input()\na = []\nc = 0\nif p == 2:\n b = [0]*n\n for i in range(n):\n if int(s[i])%2 == 0:\n b[i] += 1\n for i in range(n):\n if b[i] == 1:\n c += i+1\nelif p == 5:\n b = [0]*n\n for i in range(n):\n if int(s[i])%5 == 0:\n...
['Wrong Answer', 'Accepted']
['s851895977', 's242874109']
[18884.0, 18888.0]
[243.0, 235.0]
[711, 698]
p02757
u788703383
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n,p = map(int,input().split())\ns = input()\nnum = 0\ns1 = [0]*(n+1)\nans = 0\nif p == 2 or p == 5:\n\tfor i in range(len(s)):\n\t\tif int(s[i])%p == 0:\n\t\t\tans += i+1\t\n\tprint(ans)\n\texit()\nans = 0\narr = [0]*p\ns = s[::-1]\nz = 1\nfor i in range(n):\n\ts1[i+1] = s1[i] + int(s[i])*z\n\tz *=10 %p\n\ts1[i+1] %=...
['Wrong Answer', 'Accepted']
['s501777202', 's836718373']
[8560.0, 3500.0]
[2104.0, 167.0]
[396, 363]
p02757
u836311327
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from math import factorial\nimport collections\n\ndef permutations_count(n, r):\n \n return factorial(n) // factorial(n - r)\n\n\ndef combinations_count(n, r):\n \n return factorial(n) // (factorial(n - r) * factorial(r))\n\n\nn,p = map(int, input().split())\nS = input()\nsu = 0\n\nif p > 6 or p == 3:\n\n...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s047233761', 's371305271', 's788778201', 's997707301']
[17808.0, 17632.0, 18868.0, 17728.0]
[505.0, 312.0, 516.0, 503.0]
[786, 776, 680, 790]
p02757
u866746776
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n, p = map(int, input().rstrip().split())\ns = input().rstrip()\n\nif p == 2 or p == 5:\n ans = 0\n s = map(int, s)\n for i, c in enumerate(s):\n if c % p == 0:\n ans += i + 1\n print(ans)\nelse:\n s = s[::-1]\n cnt = [0] * p\n k = 0\n cnt[k] = 1\n for i, c in enumerate(ma...
['Runtime Error', 'Accepted']
['s488838375', 's814447499']
[3500.0, 3500.0]
[289.0, 388.0]
[462, 558]
p02757
u872887731
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['ii = lambda : int(input())\nmi = lambda : map(int,input().split())\nli = lambda : list(map(int,input().split()))\n\nn,p = mi()\ns = input().strip()\nsrev = s[-1]\n\nif p == 2 or p == 5:\n ans = 0\n for i in range(n):\n if int(s[i]) % p == 0:\n ans += i +1\n print(ans)\n exit()\n\nacum = ...
['Wrong Answer', 'Accepted']
['s594737940', 's169253948']
[26344.0, 24544.0]
[250.0, 299.0]
[560, 650]
p02757
u873927631
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
["#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, P: int, S: int):\n if N == 1:\n print(1 if S[0]%P == 0 else 0)\n arr = [[int(S[i])%P for i in range(N)]]\n for i in range(2,N):\n prevArr = arr[-1]\n arr.append([0]*(N-i+1))\n for j in range(N-i+1):\n sum = 0\n ...
['Runtime Error', 'Accepted']
['s756585091', 's940597791']
[6844.0, 4612.0]
[2104.0, 148.0]
[1165, 1474]
p02757
u888092736
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from collections import defaultdict\n\nn, p = map(int, input(). split())\ns = input()\n\ncnt = 0\nif 10 % p == 0:\n for i, c in enumerate(s, 1):\n if int(c) % p == 0:\n cnt += 1\nelse:\n rem_dic = defaultdict(int)\n rem_dic[0] = 1\n for i in range(1, n + 1):\n rem_dic[int(s[n - 1:...
['Wrong Answer', 'Accepted']
['s061702474', 's411497540']
[3876.0, 5156.0]
[113.0, 470.0]
[409, 414]
p02757
u898967808
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['from collections import Counter\n\nn,p = map(int,input().split())\ns = input()\n\nans = 0\nif p == 2 or p == 5:\n for i in range(n):\n if int(s[i]) % p == 0:\n ans += (i+1)\n\nprint(ans) ', 'from collections import Counter\n\nn,p = map(int,input().split())\ns = input()\n\nans = 0\nif p == 2 or p == 5:\n...
['Wrong Answer', 'Accepted']
['s215676369', 's834295488']
[3872.0, 3752.0]
[133.0, 174.0]
[418, 404]
p02757
u899308536
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N,P = list(map(int,input().split()))\nS = input()\n\nU = [0]\na = 0\n\nfor i in range(N):\n a += int(S[-i-1])*(pow(10,i)%P)\n a %= P\n U.append(a)\nprint(U)\n\nc = 0\nfor i in range(P):\n\n m = U.count(i)\n c += m*(m-1)//2\nprint(c)', '\n\nN,P = list(map(int,input().split()))\nS = input()\n\nif P == 2:...
['Wrong Answer', 'Accepted']
['s508696687', 's130926315']
[3812.0, 11900.0]
[2108.0, 267.0]
[230, 927]
p02757
u918601425
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N,P=[int(s) for s in input().split()]\nS=list(input())\nif P!=2 and P!=5:\n ls=[0 for _ in range(N)]\n mod=[0 for _ in range(P)]\n d=10\n ls[0]=int(S[-1])\n mod[ls[0]]+=1\n for i in range(1,N):\n ls[i]=(ls[i-1]+d*int(S[-1-i]))%2019\n d=(d*10)%2019\n mod[ls[i]]+=1\n #print(ls)\n #print(mod) \n ans=m...
['Runtime Error', 'Accepted']
['s080255039', 's761559674']
[12056.0, 12576.0]
[270.0, 269.0]
[469, 465]
p02757
u969190727
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n,p=map(int,input().split())\ns=input()[::-1]\nA=[0]*n\nA[0]=int(s[0])\nt=1\nfor i in range(1,n):\n A[i]=(int(s[i])*t+A[i-1])%p\n t=(t*10)%p\nans=0\nimport collections\nD=collections.defaultdict(int)\nD[0]=1\nif p!=2 and p!=5:\n for i in range(n):\n ans+=D[A[i]]\n D[A[i]]+=1\n print(ans)\nelse:\n s=s[::-1]...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s134189595', 's979271280', 's620641610']
[12040.0, 12056.0, 12044.0]
[270.0, 260.0, 260.0]
[384, 382, 387]
p02757
u971124021
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n,p = list(map(int,input().split()))\nS = input()\n\nif p == 2 or p == 5:\n ans = 0\n for i,s in enumerate(S):\n if int(s)%p == 0:\n ans += i+1\n print(ans)\n exit()\n\nM = [0]*p\npre = 0\nans = 0\ni = 1\nfor s in S[::-1]:\n pre += s*i\n pre %= p\n M[pre] += 1\n i *= 10\n\nM[0] += 1\nans = sum(map(lam...
['Runtime Error', 'Runtime Error', 'Accepted']
['s028145719', 's802759772', 's858043336']
[3500.0, 3500.0, 3500.0]
[106.0, 101.0, 148.0]
[332, 362, 410]
p02757
u994521204
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['n,p=map(int,input().split())\nS=input()\ns=int(s)\nans=0\nif p==5:\n for i in range(n):\n if int(S[i])==5 or int(S[i])==0:\n ans+=i+1\nelif p==2:\n for i in range(n):\n if int(S[i])%2==0:\n ans+=i+1\nelse:\n kouho=[0]*p\n for i in range(n):\n a=int(S[-i:])\n ...
['Runtime Error', 'Accepted']
['s848430166', 's001043253']
[3500.0, 4452.0]
[18.0, 208.0]
[424, 530]
p02757
u996731299
2,000
1,048,576
Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S \- there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten. Here substrings starting with a `0...
['N,P=map(int,input().split())\nS=list(map(int,list(input())))\ncount=0\n\nif P!=2 and P!=5:\n for i in range(0,N):\n chec=S[i]\n j=0\n while i+j<N:\n \u3000\u3000\u3000chec%=P\n if chec==0:\n count+=1\n j+=1\n if i+j<N:\n ...
['Runtime Error', 'Accepted']
['s292252055', 's966841428']
[2940.0, 3500.0]
[17.0, 176.0]
[527, 415]
p02758
u535803878
2,000
1,048,576
There are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable. Takahashi, who is a misc...
['\nimport numpy as np\n\nM = 998244353\n\nn = int(input())\nxs = [0] * n\nds = [0] * n\nfor i in range(n):\n x, d = (int(c) for c in input().split())\n ds[i] = d\n xs[i] = x\nxs = np.array(xs)\nds = np.array(ds)\n\nimport sys\nsys.setrecursionlimit(n)\n\nindex = xs.argsort()\nxs = xs[index]\nds = ds[index]\n\...
['Runtime Error', 'Runtime Error', 'Accepted']
['s616474777', 's672777796', 's895799702']
[190092.0, 2940.0, 198700.0]
[1270.0, 17.0, 1417.0]
[845, 886, 903]
p02758
u593567568
2,000
1,048,576
There are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable. Takahashi, who is a misc...
['import sys\nimport bisect\nsys.setrecursionlimit(10 ** 7)\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n\nclass SegmentTree:\n \n\n def __init__(self, N, operator, unit, a=None):\n self.op = operator\n self.UNIT = unit\n\n s...
['Wrong Answer', 'Accepted']
['s246259488', 's062392987']
[59796.0, 246348.0]
[2111.0, 1424.0]
[2233, 782]
p02758
u686230543
2,000
1,048,576
There are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable. Takahashi, who is a misc...
['import heapq\n\nmod = 998244353\n\nn = int(input())\nrobot = [tuple(map(int, input().split())) for _ in range(n)]\nrobot.sort(reverse=True)\nparent = list(range(n))\n\nroot = []\nfor i in range(n):\n x, d = robot[i]\n while root:\n r = heapq.heappop(root)\n if r[0] < x + d:\n parent[r[1]] = i\n else:\...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s640641144', 's851041776', 's774933345']
[47916.0, 62520.0, 47916.0]
[1603.0, 1572.0, 1549.0]
[539, 575, 545]
p02758
u716530146
2,000
1,048,576
There are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable. Takahashi, who is a misc...
[" import sys, math, itertools, collections, bisect\ninput = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')\ninf = float('inf') ;mod = 998244353\nmans = 998244353 ;ans = 0 ;count = 0 ;pro = 1\nsys.setrecursionlimit(10**6)\n\nn = int(input())\nXD = [tuple(map(int,input().split())) for i in range(n)]\nXD.ap...
['Runtime Error', 'Accepted']
['s721038050', 's592084967']
[2940.0, 202376.0]
[17.0, 1023.0]
[614, 571]
p02760
u000540018
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
["import sys\nimport numpy as np\n\nlines = sys.stdin.readlines()\nbingo_card = np.zeros([3,3])\nfor i, l in enumerate(input()):\n if i <= 2:\n bingo_card[i] = [int(num) for num in l.split()]\n else:\n bingo_card[bingo_card == int(l)] = None\n \ncheck_arr = np.isnan(bingo_card)\nif check_arr[...
['Runtime Error', 'Accepted']
['s100274923', 's369984807']
[12500.0, 12528.0]
[154.0, 156.0]
[675, 674]
p02760
u004482945
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
['60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34', "a = [list(map(int, input().split())) for i in range(3)]\nn = int(input())\n\nfor _ in range(n):\n b = int(input())\n for y in range(3):\n for x in range(3):\n if a[y][x] == b:\n a[y][x] = -1\n\nfor y in range(3):\n f = True\...
['Runtime Error', 'Accepted']
['s199950847', 's595977660']
[9008.0, 9176.0]
[24.0, 30.0]
[59, 664]
p02760
u007018214
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
['import sys\n#n=int(input())\n#l = list(map(int,input().split()))\n#a,b,c = map(int,input().split())\n\nly = []\n\nfor i in range(3):\n ly.append(list(map(int,input().split())))\n\nlt = []\n\nfor i in range(3):\n l = []\n for j in range(3):\n l.append(ly[j][i])\n lt.append(l)\n\nl = ly+lt + [[ly[0][...
['Wrong Answer', 'Accepted']
['s818850944', 's741135004']
[3064.0, 3064.0]
[17.0, 17.0]
[659, 650]
p02760
u008079810
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
["A=[]\nfor i in range(3):\n A.append(list(map(int,input().split())))\nN=int(input())\nfor i in range(N):\n b=int(input())\n for ii in range(3):\n for iii in range(3):\n if A[ii][iii]==b:\n A[ii][iii]=0\nprint(A)\nflag=False\nfor i in range(3):\n if A[i][:]==[0,0,0]:\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s063863335', 's988831317', 's449038182']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0]
[587, 579, 567]
p02760
u013292712
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
['l=[]\nfor i in range(3):\n l.append(list(map(int,input().split())))\nn=int(input())\nl1=[]\nfor i in range(n):\n l1.append(int(input())\nfor i in range(len(l)):\n for j in range(len(l)):\n if(l[i][j] in l1):\n l[i][j]=0\nf=0\nif((l[0][0]==0 and l[0][1]==0 and l[0][2]==0) or (l[1][0]==0 and l[1]...
['Runtime Error', 'Accepted']
['s612960093', 's798053602']
[3064.0, 3188.0]
[17.0, 17.0]
[685, 688]
p02760
u015993380
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
['card = [[int(x) for x in input().split()] for y in range(3)]\nbools = [[0,0,0],[0,0,0],[0,0,0]]\nn = int(input())\nfor _ in range(n):\n x = int(input())\n for i in range(3):\n for j in range(3):\n if x == card[i][j]:\n bools[i][j] = 1\nok = False\nfor i in range(3):\n if (bools[i][0], bools[i][1], b...
['Runtime Error', 'Accepted']
['s032567316', 's132662372']
[3064.0, 3064.0]
[17.0, 17.0]
[549, 546]
p02760
u016323272
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
["#ABC157.B\nA = list(map(int,input().split()))\nN = int(input())\nb = list(map(int,input().split()))\n\nfor i in b:\n if i in A:\n A[A.index(i)]=0\nif A[0]==0 and A[1]==0 and A[2]==0:\n print('Yes')\nelif A[3]==0 and A[4]==0 and A[5]==0:\n print('Yes')\nelif A[6]==0 and A[7]==0 and A[8]==0:\n print(...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s241249680', 's338489127', 's351193316', 's443644399', 's936561835', 's563945604']
[3064.0, 3064.0, 3192.0, 3188.0, 3192.0, 3064.0]
[19.0, 17.0, 20.0, 19.0, 18.0, 17.0]
[610, 684, 618, 610, 610, 705]
p02760
u016901717
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
['a1=input().split()\na2=input().split()\na3=input().split()\nA=[a1,a2,a3]\nb=[int(input()) for i in range(int(input()))]\nif a1[0] and a1[1] and a1[2] in b:\n print("Yes")\nelif a2[0] and a2[1] and a2[2] in b:\n print("Yes")\nelif a3[0] and a3[1] and a3[2] in b:\n print("Yes")\nelif a1[0] and a2[0] and a3[0] ...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s094630825', 's368879257', 's946027064', 's176483040']
[3064.0, 3064.0, 2940.0, 3064.0]
[17.0, 18.0, 17.0, 18.0]
[568, 568, 565, 941]
p02760
u017050982
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
['A = [[0 for i in range(3)]for i2 in range(3)]\nc = [[False for i in range(3)]for i2 in range(3)]\nA[0] = list(map(int,input().rstrip().split(" ")))\nA[1] = list(map(int,input().rstrip().split(" ")))\nA[2] = list(map(int,input().rstrip().split(" ")))\nint_inp = int(input())\ns = 0\nfor i in range(int_inp):\n s = int(...
['Runtime Error', 'Accepted']
['s291262290', 's937720693']
[3064.0, 3064.0]
[17.0, 17.0]
[695, 693]
p02760
u018771977
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
["#! env/bin/local python3\n# -*- coding: utf-8 -*-\n\nimport numpy as np\n\na_1 = list(map(int, input().split()))\na_2 = list(map(int, input().split()))\na_3 = list(map(int, input().split()))\n_ = input()\npickup_number = []\nwhile True:\n try:\n pickup_number.append(int(input()))\n except EOFError:\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s511000596', 's830586532', 's708745010']
[21004.0, 12496.0, 12508.0]
[309.0, 157.0, 154.0]
[646, 646, 592]
p02760
u019113646
2,000
1,048,576
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet. Determine whether we will have a bi...
['x1 = list(map(int, input().split()))\nx2 = list(map(int, input().split()))\nx3 = list(map(int, input().split()))\ncard = [x1, x2, x3]\n\nnumLen = int(input())\nnumList = [int(input()) for _ in range(numLen)]\nans = "No"\nfor x in range(3):\n for y in range(3):\n for numList_i in range(numLen):\n ...
['Wrong Answer', 'Accepted']
['s378055722', 's590808146']
[3064.0, 3064.0]
[18.0, 18.0]
[804, 762]