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
p03425
u478462004
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['h,w,d = map(int,input().split(" "))\nboard = [input().split(" ") for i in range(h)]\n\nq = int(input())\nfor i in range(q):\n l,r = map(int,input().split(" "))\n n = int((r-l)/d)\n count = 0\n x = []\n y = []\n for k in range(h):\n if str(l) in board[k]:\n x.append(board[k].index(s...
['Runtime Error', 'Accepted']
['s923682046', 's240206111']
[3064.0, 25208.0]
[18.0, 391.0]
[602, 412]
p03425
u488497128
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import sys\nimport numpy as np\nimport itertools\n\nN = int(sys.stdin.readline().strip())\ndct = {}\ndct["M"] = 0\ndct["A"] = 0\ndct["R"] = 0\ndct["C"] = 0\ndct["H"] = 0\nchar_list = ["M", "A", "R", "C", "H"]\n\nfor _ in range(N):\n name = sys.stdin.readline().strip()\n first = name[0]\n dct[first] += 1\n\nc...
['Runtime Error', 'Accepted']
['s111183614', 's789963108']
[12420.0, 12392.0]
[198.0, 215.0]
[419, 461]
p03425
u502486340
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
[' n = int(input())\n \n M = 0\n A = 0\n R = 0\n C = 0\n H = 0\n \n res = 0\n \n for i in range(n):\n char = input()[0]\n if char == "M":\n M += 1\n elif char == "A":\n A += 1\n elif char == "R":\n R += 1\n elif char...
['Runtime Error', 'Accepted']
['s637927854', 's041301566']
[2940.0, 3188.0]
[17.0, 160.0]
[631, 482]
p03425
u513081876
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["import itertools\nN = int(input())\nMARCH = [0, 0, 0, 0, 0]\nfinal_ans = 0\nfor i in range(N):\n a = input()\n if a[0] =='M':\n MARCH[0] += 1\n elif a[0] =='A':\n MARCH[1] += 1\n elif a[0] =='R':\n MARCH[2] += 1\n elif a[0] =='C':\n MARCH[3] += 1\n elif a[0] =='H':\n ...
['Runtime Error', 'Accepted']
['s103750412', 's393960985']
[3064.0, 15852.0]
[181.0, 204.0]
[430, 545]
p03425
u539517139
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n=int(input())\nl=[0]*5\nm='MARCH'\nfor i in range(n):\n s=input()\n f=s[0]\n for i in range(5):\n if f==m[i]:\n l[i]+=1\n break\nx=0\nfor i in range(3):\n for j in range(i+1,4):\n for k in range(j+1,5):\n x+=a[i]*a[j]*a[k]\nprint(x)", "n=int(input())\nl=[0]*5\nm='MARCH'\nfor i in range(n):\n...
['Runtime Error', 'Accepted']
['s441359218', 's022437646']
[3064.0, 3060.0]
[252.0, 257.0]
[243, 243]
p03425
u547167033
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n=int(input())\ns=[input() for i in range(n)]\ncnt=[0]*5\nfor t in s:\n if t[0]=='M':\n cnt[0]+=1\n elif t[0]=='A':\n cnt[1]+=1\n elif t[0]=='R':\n cnt[2]+=1\n elif t[0]=='C':\n cnt[3]+=1\n elif t[0]=='H':\n cnt[4]+=1\nans=0\nfor v in itertools.combinations([0,1,2,3,4],3):\n ans+=cnt[v[0]]*cnt[v[...
['Runtime Error', 'Accepted']
['s733067528', 's358506644']
[9772.0, 9776.0]
[172.0, 167.0]
[326, 343]
p03425
u562015767
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import numpy as np\nfrom scipy.special import comb\n\nn = int(input())\na = []\nfor _ in range(n):\n b = list(map(str,input()))\n a.append(b)\n\nans = [0]*5\n\nfor i in range(n):\n tmp = a[i][0]\n if tmp == "M":\n ans[0] += 1\n elif tmp == "A":\n ans[1] += 1\n elif tmp == "R":\n ...
['Runtime Error', 'Accepted']
['s344761792', 's637295427']
[14492.0, 21068.0]
[188.0, 362.0]
[831, 475]
p03425
u583507988
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n = int(input())\ns = [list(input()) for i in range(n)]\n\n\nans = 0\nfor i in range(n):\n for j in range(i+1,n):\n for k in range(j+1,n):\n p = s[i][0]\n q = s[j][0]\n r = s[k][0]\n if (p=='M'or'A'or'C'or'R'or'H') and (q=='M'or'A'or'C'or'R'or'H') and (r=='M'or'A'or'C'or'R'or'H') and (p!=q) a...
['Wrong Answer', 'Accepted']
['s270847142', 's049788309']
[22336.0, 9096.0]
[2206.0, 147.0]
[365, 287]
p03425
u594956556
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["N = int(input())\n\nmarch = 'MARCH'\nmdict = {s:0 for s in march}\n\nfor i in range(N):\n S = input()\n mdict[S[0]] += 1\n \nlst = [mdict[key] for key in mdict]\nans = 0\nfor i in range(3):\n for j in range(i+1, 4):\n for k in range(j+1, 5):\n ans += lst[i] * lst[j] * lst[k]\n \nprint(ans)\n", "N = i...
['Runtime Error', 'Accepted']
['s060151743', 's131139393']
[3064.0, 3064.0]
[162.0, 175.0]
[292, 314]
p03425
u595289165
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['from collections import Counter\nmarch = "MARCH"\nn = int(input())\ninitial = Counter([input()[0] for _ in range(n)])\nans = []\nfor i, num in initial.items():\n if i in march:\n ans.append(num)\n\nx = len(ans)\nif x < 3:\n print(0)\nelif x >= 3:\n y = 0\n for i in range(1, x-1):\n for j in ...
['Runtime Error', 'Accepted']
['s612609160', 's146344713']
[4224.0, 4224.0]
[141.0, 141.0]
[417, 415]
p03425
u597436499
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n = int(input())\ns = []\nfor i in range(n):\n s.append(input()[0])\n\ndef qwe(y):\n m = 0\n a = 0\n r = 0\n c = 0\n h = 0\n for i in y:\n if i == 'M':\n m += 1\n elif i == 'A':\n a += 1\n elif i == 'R':\n r += 1\n elif i == 'C':\n ...
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s059347086', 's382252839', 's607568420', 's965624997', 's315655829']
[4016.0, 4064.0, 4040.0, 4076.0, 4040.0]
[160.0, 156.0, 161.0, 146.0, 154.0]
[1074, 1358, 1519, 1497, 1545]
p03425
u597455618
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["import sys\nimport itertools\n\nn = int(input())\na = [i.rstrip() for i in sys.stdin.readlines() if i.rstrip()[0] in ['M','A','R','C','H'] ]\n\nprint(len(list(itertools.combinations(a, 3))))\n", "import sys\nimport itertools\n\nn = int(input())\nl = {}\nfor i in sys.stdin.readlines():\n i = i.rstrip()\n if i[0]...
['Wrong Answer', 'Accepted']
['s139557484', 's671895210']
[1964704.0, 16936.0]
[2226.0, 84.0]
[185, 329]
p03425
u604262137
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["import numpy as np\nN = int(input())\nS = [None]*5\nfor i in range(N):\n S[i] = input()\n\nS_M = [S[i] for i in range(N) if S[i][0] == 'M']\nS_A = [S[i] for i in range(N) if S[i][0] == 'A']\nS_R = [S[i] for i in range(N) if S[i][0] == 'R']\nS_C = [S[i] for i in range(N) if S[i][0] == 'C']\nS_H = [S[i] for i in ran...
['Runtime Error', 'Runtime Error', 'Accepted']
['s243733460', 's795927986', 's298460627']
[12524.0, 12060.0, 28588.0]
[152.0, 150.0, 499.0]
[858, 739, 617]
p03425
u614875193
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["N=int(input())\nM,A,R,C,H=0,0,0,0,0\nfor i in range(N):\n s=input()[0]\n if s=='M':\n M+=1\n elif s=='A':\n A+=1\n elif s=='R':\n R+=1\n elif s=='C':\n C+=1\n elif s=='H':\n H+=1\n\nprint(M,A,R,C,H)\n\nprint(M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + \\\n M*C*H +...
['Wrong Answer', 'Accepted']
['s130500132', 's134645824']
[3064.0, 3064.0]
[170.0, 161.0]
[330, 312]
p03425
u617116410
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import re\nfrom itertools import groupby\n\ndef nCr(n, r):\n """\n Calculate the number of combination (nCr = nPr/r!).\n The parameters need to meet the condition of n >= r >= 0.\n It returns 1 if r == 0, which means there is one pattern\n to choice 0 items out of the number of n.\n """\n\n # 10C...
['Wrong Answer', 'Accepted']
['s630806986', 's810021288']
[20976.0, 11260.0]
[292.0, 301.0]
[988, 716]
p03425
u618512227
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['N = int(input())\nmember = [0,0,0,0,0]\nans = 0\nfor _ in range(N):\n a = input().split()\n if a[0] == "M":\n member[0] += 1\n elif a[1] == "A":\n member[1] += 1\n elif a[2] == "R":\n member[2] += 1\n elif a[3] == "C":\n member[3] += 1\n elif a[4] == "H":\n member[...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s460516600', 's814448614', 's861673512', 's900279578', 's099491684']
[3064.0, 3064.0, 3064.0, 3064.0, 3064.0]
[17.0, 191.0, 18.0, 190.0, 236.0]
[455, 455, 455, 455, 453]
p03425
u620846115
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['n = int(input())\nMnum = 0\nAnum = 0\nRnum = 0\nCnum = 0\nHnum = 0\nfor i in range(n):\n a = input()\n if a[0] == "M":\n Mnum+=1\n elif a[0] == "A":\n Anum+=1\n elif a[0] == "R":\n Rnum+=1\n elif a[0] == "C":\n Cnum+=1\n elif a[0] == "H":\n Hnum+=1\nalist = []\nalist.append(Mnum)\nalist.append(An...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s175413295', 's191340947', 's551710493', 's704115403', 's763899631', 's467512794']
[9540.0, 8976.0, 9424.0, 9528.0, 9452.0, 9420.0]
[152.0, 21.0, 152.0, 157.0, 153.0, 155.0]
[532, 442, 433, 504, 529, 201]
p03425
u620945921
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["import itertools\n\nn=int(input())\nlist1=[]\nss=['M', 'A', 'R', 'C', 'H']\n\nfor j in range(n):\n s=input()\n for k in range(5):\n if s[0]==ss[k]:\n list1.append(s[0])\n\n#list1.sort()\n\nlist2=list(itertools.combinations(list1, 3))\n\ncnt=0\n#for j in range(len(list2)):\n# if len(list2[j])==len(set(list2...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s058588225', 's585414039', 's875939784', 's944209976', 's472983922']
[1816760.0, 1950964.0, 1824696.0, 3892.0, 3064.0]
[2218.0, 2236.0, 2219.0, 265.0, 170.0]
[332, 326, 332, 333, 361]
p03425
u626228246
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import itertools\nfrom collections import Counter\nn = int(input())\ns = [input()[0] for _ in range(n)]\ncnt = Counter(s)\nprint(cnt)\n\nans = 0\nfor x,y,z in itertools.combinations("MARCH",3):\n # print(x,y,z)\n ans += cnt[x]*cnt[y]*cnt[z]\n #print(cnt[x],cnt[y],cnt[z])\n \nprint(ans)', "import sys\nimport ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s273154212', 's413767234', 's356884211']
[10256.0, 16760.0, 10068.0]
[135.0, 158.0, 137.0]
[282, 609, 283]
p03425
u626337957
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["N = int(input())\nnames_dic = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}\nFIRST = ('M', 'A', 'R', 'C', 'H')\nfor _ in range(N):\n nams = input()\n if name[0] in FIRST:\n names_dic[name[0]] += 1\nans = 0\nfor i in range(5):\n for j in range(i+1, 5):\n for k in range(j+1, 5):\n ans += names_dic[FIRST[i]]*names_d...
['Runtime Error', 'Accepted']
['s257585384', 's805780125']
[3064.0, 3064.0]
[17.0, 172.0]
[350, 331]
p03425
u627530854
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['from collections import Counter\nfrom itertools import combinations, reduce\n\nimport operator\n\nGOOD_LETTERS = "MARCH"\nPEOPLE = 3\n\nn = int(input())\nc = Counter()\n\nfor _ in range(n):\n first = input()[0]\n if first in GOOD_LETTERS:\n c.update(first)\n \nways = 0\nfor tup in combinations(GOOD_LETTERS, P...
['Runtime Error', 'Accepted']
['s649287443', 's798340276']
[3316.0, 3572.0]
[21.0, 550.0]
[378, 396]
p03425
u635974378
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["import itertools as it\n\ndef c(n,k):\n if k>n:\n return 0\n ret = 1\n for i in range(n, n-k, -1):\n ret *= i\n for i in range(k, 1, -1):\n ret /= i\n return ret\n\n\nn = int(input())\ndic = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}\nfor person in range(n):\n name = input()\n if name[0] in 'MARCH':\n dic...
['Runtime Error', 'Accepted']
['s361694075', 's032748425']
[3064.0, 3064.0]
[17.0, 175.0]
[418, 420]
p03425
u637551956
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["from itertools import combinations\nN=int(input())\nL = [str(input()) for i in range(N)]\ncount_M=0\ncount_A=0\ncount_R=0\ncount_C=0\ncount_H=0\nfor i in L:\n if i[0]=='M':count_M+=1\n elif i[0]=='A':count_A+=1\n elif i[0]=='R':count_R+=1\n elif i[0]=='C':count_C+=1\n elif i[0]=='H':count_H+=1\nname_li...
['Wrong Answer', 'Accepted']
['s040918354', 's056088247']
[9776.0, 9776.0]
[181.0, 185.0]
[443, 450]
p03425
u639691968
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["N = int(input())\nnum = [0,0,0,0,0]\nfor i in range(N):\n a = input()\n if a[0]=='M':\n num[0] += 1\n if a[0]=='A':\n num[1] += 1\n if a[0]=='R':\n\tnum[2] += 1\n if a[0]=='C':\n\tnum[3] += 1\n if a[0]=='H':\n\tnum[4] += 1\n\n\nnum_1 = num[0]*num[1]*num[2]\nnum_2 = num[0]*num[1]*num[3]\nnum_3 = num[0]*num...
['Runtime Error', 'Accepted']
['s866945781', 's920835114']
[2940.0, 3064.0]
[17.0, 198.0]
[615, 342]
p03425
u644778646
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['N = int(input())\nSdic = {}\nL = ["M","A","R","C","H"]\nfor i in L:\n Sdic[i] = []\n\ntN = N\nfor i in range(N):\n s = input()\n if s[0] in L:\n Sdic[s[0]].append(s)\n else:\n tN -= 1\n\ncnt = 0\nfor val in Sdic.values():\n if len(val) == 0:\n cnt += 1\nif cnt >=3:\n print(0)\n ...
['Wrong Answer', 'Accepted']
['s425968666', 's814403155']
[10152.0, 3064.0]
[174.0, 181.0]
[717, 335]
p03425
u659753499
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["from itertools import combinations\nN = int(input())\nS = Counter()\nfor _ in range(N):\n S[input()[0]] += 1\nprint(sum([S[p0]*S[p1]*S[p2] for p0,p1,p2 in combinations('MARCH', 3)]))", "from itertools import combinations\nN = int(input())\nd = [0]*128\nfor _ in range(N): dic[ord(input()[0])] += 1\nprint(sum([d[ord(p...
['Runtime Error', 'Runtime Error', 'Accepted']
['s243827065', 's504982879', 's363143623']
[3060.0, 3060.0, 3060.0]
[18.0, 18.0, 159.0]
[178, 197, 210]
p03425
u663710122
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['m,a,r,c,h = [0,0,0,0,0]\nN = int(input())\n\nfor i in range(N):\n', "m, a, r, c, h = [0] * 5\n\nN = int(input())\n\nfor _ in range(N):\n s = input()[0]\n\n if s == 'M':\n m += 1\n elif s == 'A':\n a += 1\n elif s == 'R':\n r += 1\n elif s == 'C':\n c += 1\n elif s == 'H':...
['Runtime Error', 'Accepted']
['s686094722', 's429639575']
[2940.0, 3060.0]
[17.0, 162.0]
[61, 435]
p03425
u671252250
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['# coding: utf-8\n# Your code here!\nimport math\nfrom collections import Counter\n\ndef P(n, r):\n return math.factorial(n)//math.factorial(n-r)\n\ndef C(n, r):\n return P(n, r)//math.factorial(r)\n\nN = int(input())\narr = [input() for i in range(N)]\nmar_arr = [j for j in arr if j[0] == "M" or j[0] == "A" or ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s126820227', 's490877129', 's816673160']
[12932.0, 12944.0, 3828.0]
[613.0, 614.0, 47.0]
[704, 703, 401]
p03425
u680851063
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n=int(input())\n\nl=[]\nfor i in range(n):\n l+=[input()[0]]\n\nmarch=[0]*5\nfor j in range(n):\n if l[j]=='M':\n march[0]+=1\n elif l[j]=='A':\n march[1]+=1\n elif l[j]=='R':\n march[2]+=1\n elif l[j]=='C':\n march[3]+=1\n elif l[j]=='H':\n march[4]+=1\nprint(marc...
['Wrong Answer', 'Accepted']
['s034401773', 's234701186']
[3888.0, 3992.0]
[193.0, 198.0]
[410, 395]
p03425
u686036872
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['from itertools import combinations\nimport collections\n\nN = int(input()) \n\nA = []\nfor i in range(N):\n A.append(input()[0])\n\nAA = set(A)\nC = collections.Counter(A)\nprint(sum(C[a]*C[b]*C[c] for a, b, c combinations(AA, 3)))', 'from itertools import combinations\nimport collections\n\nN = int(input()) \n\nA...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s334828320', 's853813100', 's718929777']
[2940.0, 4224.0, 4232.0]
[17.0, 162.0, 146.0]
[223, 226, 219]
p03425
u687044304
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['#-*- coding:utf-8 -*-\n\ndef _is_march(c):\n if (c == "M") or (c == "A") or (c == "R") or (c == "C") or (c == "H"):\n return True\n return False\n\nif __name__ == "__main__":\n N = int(input())\n march = []\n for i in range(N):\n name = input()\n if _is_march(name[0]):\n ...
['Wrong Answer', 'Accepted']
['s752133260', 's918618938']
[9752.0, 3064.0]
[175.0, 168.0]
[425, 454]
p03425
u691018832
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import Counter\nfrom scipy.misc import comb\n\nn = int(readline())\ns = [input()[0] for i in range(n)]\nmemo = list(Counter(s).items())\ncheck = ['...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s547192239', 's616767269', 's889638688']
[23484.0, 14320.0, 4524.0]
[521.0, 174.0, 89.0]
[469, 484, 822]
p03425
u691896522
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n = int(input())\ndata = [0 for i in range(5)]\nfor i in range(n):\n k = input()\n if k[0] == 'M':\n data[0] += 1\n elif k[0] == 'A':\n data[1] += 1\n elif k[0] == 'R':\n data[2] += 1\n elif k[0] == 'C':\n data[3] += 1\n elif k[0] == 'H':\n data[4] += 1\ntotal = 0\...
['Wrong Answer', 'Accepted']
['s574226668', 's703547528']
[3064.0, 3064.0]
[167.0, 168.0]
[455, 443]
p03425
u694810977
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['from collections import Counter\nfrom itertools import combinations\n\nn = int(input())\nl = [input()[0] for _ in range(n)]\nlc = Counter(l)\nprint(lc)\n\ncon = []\nfor c in "MARCH":\n if c in lc:\n con.append(lc[c])\nans = 0\nfor a, b, c in combinations(con, 3):\n ans += a * b * c\nprint(ans)\n', 'from ...
['Wrong Answer', 'Accepted']
['s447906357', 's536404375']
[4224.0, 4224.0]
[139.0, 141.0]
[293, 283]
p03425
u698771758
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import itertools as ite\nN=int(input())\nC=[0]*N\nJ="MARCH"\nfor i in range(N):\n C[J.find(input()[0])]+=1\nans=0\nfor i,j,k in list(ite.combinations(range(5),3)):\n ans+=C[i]*C[j]*C[k]\nprint(ans)\n', 'import itertools as ite\nN=int(input())\nC=[0]*6\nJ="MARCH"\nfor i in range(N):\n C[J.find(input()[0])]+=1...
['Runtime Error', 'Accepted']
['s941879160', 's005063931']
[3828.0, 3060.0]
[203.0, 192.0]
[195, 195]
p03425
u698919163
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["N = int(input())\nS = [input() for i in range(N)]\n\nS_first = [S[i][0] for i in range(N)]\nmarch = ['M','A','R','C','H']\nmarch_number = [0]*5\n\nfor i in range(N):\n march_number[i] = S.count(march[i])\n\nimport itertools\nptr = list(itertools.combinations(march_number,3))\n\nans = 0\nseki = 1\n\nfor i in range(...
['Runtime Error', 'Accepted']
['s792144930', 's834428846']
[10520.0, 10648.0]
[155.0, 163.0]
[402, 316]
p03425
u711768617
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import itertools\nn = int(input())\nnames = [input() for i in range(n)]\nnames = [i for i in names if i[0] in "MARCH"]\n\n\nprint(len(list(itertools.combinations(seq,3))))', 'import itertools\nn = int(input())\ncounters = {"M":0,"A":0,"R":0,"C":0,"H":0}\n\nfor _ in range(n):\n s = input()[0]\n \n if s in "MARCH":\...
['Runtime Error', 'Accepted']
['s772228175', 's080140629']
[16756.0, 9116.0]
[141.0, 145.0]
[165, 297]
p03425
u716043626
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n = int(input())\ncnt = [0,0,0,0,0]\ncomp = 'MARCH'\nans = 0\n\nfor i in range(N):\n word = input()\n for j in range(len(comp)):\n if word[0] == comp[j]:\n cnt[j] += 1\n\nfor i in range(len(cnt)):\n for j in range(i+1,len(cnt)):\n for k in range(j+1,len(cnt)):\n ans += cnt...
['Runtime Error', 'Accepted']
['s291209112', 's557278960']
[3064.0, 3064.0]
[18.0, 292.0]
[336, 319]
p03425
u729133443
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["from itertools import*;d={}\nfor t in open(0).read().split():d[t]=d.get(t,0)+1\ng=d.get;print(sum(g(p,0)*g(q,0)*g(r,0)for p,q,r in combinations('MARCH',3)))", "from itertools import*;d={};g=d.get\nfor t in open(0).read().split():d[t]=g(t,0)+1\nprint(sum(g(p,0)*g(q,0)*g(r,0)for p,q,r in combinations('MARCH',3)))", "fr...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s496014535', 's739922864', 's437144013']
[20664.0, 20664.0, 17832.0]
[65.0, 60.0, 53.0]
[154, 150, 109]
p03425
u760961723
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['N = int(input())\ns = [input() for _ in range(N)]\n\nprint(s)\n\nMx,Ax,Rx,Cx,Hx=0,0,0,0,0\n\nfor n in range(N):\n if s[n][0] =="M":\n Mx += 1\n elif s[n][0] =="A":\n Ax += 1\n elif s[n][0] =="R":\n Rx += 1\n elif s[n][0] =="C":\n Cx += 1\n elif s[n][0] =="H":\n Hx += 1\n\nMAR = Mx * Ax * Rx\nMAC...
['Wrong Answer', 'Accepted']
['s950325042', 's350631764']
[13076.0, 9776.0]
[186.0, 176.0]
[515, 505]
p03425
u773686010
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['N = int(input())\nM_Dict = {"M":0,"A":0,"R":0,"C":0,"H":0}\nfor i in range(N):\n moji = str(input())\n if moji[0] in M_Dict.keys():\n M_Dict[moji[0]] += 1\nM_Dict = {k: v for k, v in M_Dict.items() if v != 0} \nif len(M_Dict) < 3:\n ans = 0\nelse:\n ans = 0\n for k in itertools.combinations(l...
['Runtime Error', 'Accepted']
['s857530612', 's213055840']
[9240.0, 9228.0]
[162.0, 166.0]
[402, 439]
p03425
u781262926
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["from itertools import combinations\nn, *S = open(0).read().split()\nn = int(n)\nmarch = []\nfor c in 'MARCH':\n march.append(len([s for s in S if s[0] == c]))\nprint(march)\nans = 0\nfor a, b, c in combinations(march, 3):\n if a*b*c != 0:\n print(a,b,c)\n ans += a*b*c\nprint(ans)", "from itertools imp...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s119215918', 's743496385', 's226540974']
[10864.0, 10988.0, 10864.0]
[59.0, 62.0, 59.0]
[284, 244, 231]
p03425
u787456042
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['from itertools import*;N,*S=open(0);print(sum(a*b*c for a,b,c in combinations(sum(1for s in S if s[0]==c)for c in"MARCH",3)))', 'from itertools import*;N,*S=open(0);print(sum(a*b*c for a,b,c in combinations(sum(1for s in S if s[0]==c)for c in"MARCH",3)))', 'from itertools import*;N,*S=open(0);print(sum(a*b*c for a,b,...
['Runtime Error', 'Runtime Error', 'Accepted']
['s340392411', 's538617656', 's791786418']
[2940.0, 2940.0, 9896.0]
[17.0, 17.0, 57.0]
[125, 125, 127]
p03425
u798731634
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n = int(input())\ns = [input() for i in range(n)]\n\nf = [a for a in s if s.startswith('M')]\ng = [b for b in s if s.startswith('A')]\nh = [c for c in s if s.startswith('R')]\ni = [d for d in s if s.startswith('C')]\nj = [e for e in s if s.startswith('H')]\n\nk = len(f)*len(g)*len(h)\nl = len(f)*len(g)*len(i)\nm = le...
['Runtime Error', 'Accepted']
['s432011850', 's588984201']
[9776.0, 10540.0]
[132.0, 204.0]
[538, 538]
p03425
u802963389
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import collections\nimport itertools\n\nN = int(input())\ns = [input()[0] for _ in range(N)]\nc = collections.Counter(s)\n\n# print(c)\n\nl = list(itertools.combinations(c,3))\n\n# print(l)\n\nans = sum([c[i[0]] * c[i[1]] * c[i[2]] for i in l])\n\nprint(ans)', 'from collections import Counter\nfrom itertools import c...
['Wrong Answer', 'Accepted']
['s738987533', 's358294203']
[4476.0, 5252.0]
[145.0, 149.0]
[243, 357]
p03425
u812137330
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['n = int(input())\n\nd = {"M":0,"R":0,"A":0,"C":0,"H":0}\nS = []\nnum = 0\n\nfor i in range(n):\n S.append(input())\n\n\nfor s in S:\n \n if s[0] in list(d.keys()):\n d[s[0]] += 1\n\n\n\nfor al1 in list(d.keys()):\n for al2 in list(d.keys()):\n for al3 in list(d.keys()):\n if al1 !...
['Wrong Answer', 'Accepted']
['s645870429', 's234852482']
[9752.0, 9760.0]
[202.0, 209.0]
[491, 456]
p03425
u813102292
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['n = int(input())\ns = []\nfor i in range(n):\n s.append(input())\ntmp_nums = {"M":0, "A":0, "R":0, "C":0, "H":0}\nfor i in range(n):\n tmp_nums[s[i][0]] += 1\nnums=[]\nfor i in tmp_nums.values():\n nums.append(i)\np = [0,0,0,0,0,0,1,1,1,2]\nq = [1,1,1,2,2,3,2,2,3,3]\nr = [2,3,4,3,4,4,3,4,4,4]\nsum = 0\nfor i...
['Runtime Error', 'Accepted']
['s948775274', 's891376817']
[9776.0, 9772.0]
[166.0, 185.0]
[374, 413]
p03425
u814781830
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['N = int(input())\nS = []\nfor i in range(N):\n s = input()\n if s[0] in [ \'M\',\'A\',\'R\',\'C\',\'H\' ]:\n S.append(s)\n\nS = list(set(S))\n\nN = len(S)\nselected = [""] * 2\ncnt = 0\nfor i in range(N-2):\n selected = [""] * 2\n selected[0] = S[i][0]\n for k in range(i+1, N-1):\n if S[k...
['Wrong Answer', 'Accepted']
['s474426853', 's091880585']
[15908.0, 12504.0]
[2104.0, 309.0]
[485, 319]
p03425
u815878613
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import itertools\n\nN = int(input())\nS = [input() for _ in range(N)]\n\ncnt = [0 for _ in range(5)]\nfor s in S:\n if s[0] == "M":\n cnt[0] += 1\n elif s[1] == "A":\n cnt[1] += 1\n elif s[2] == "R":\n cnt[2] += 1\n elif s[3] == "C":\n cnt[3] += 1\n elif s[4] == "H":\n ...
['Runtime Error', 'Accepted']
['s925647334', 's634706671']
[15968.0, 16112.0]
[137.0, 149.0]
[407, 407]
p03425
u836737505
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['from collections import defaultdict\nfrom scipy.misc import comb\n#ID\nb = defaultdict(lambda: len(b))\nn = int(input())\nhed = ["M","A","R","C","H"]\nfor i in hed:\n b[i] \nli = [0]*5\nfor _ in range(n):\n a = input()\n if a[0] in hed:\n li[b[a[0]]] += 1\n\nc = [i for i in li if i != 0]\nprint(int(co...
['Wrong Answer', 'Accepted']
['s179373763', 's379065085']
[15956.0, 3064.0]
[372.0, 265.0]
[342, 257]
p03425
u839509562
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["import sys\nfrom itertools import combinations\nfrom collections import Counter\ninput = sys.stdin.readline\n\n\ndef log(*args):\n print(*args, file=sys.stderr)\n\n\ndef main():\n n = int(input().rstrip())\n s = [input()[0] for _ in range(n)]\n s = [v for v in range(n)]\n c = Counter(s)\n ans = 0\n ...
['Wrong Answer', 'Accepted']
['s933534711', 's804698655']
[21752.0, 10140.0]
[57.0, 47.0]
[435, 405]
p03425
u842230338
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['from collections import Counter\nfrom math import factorial\nN = int(input())\nS = [input()[0:1:] for i in range(N)]\n\nmarch = ["M","A","R","C","H"]\nlist = []\nc = Counter(S)\nfor k,v in c.items():\n if k in march:\n list.append(v)\n\nans = 0\nif len(list) >= 3:\n for i in range(len(list)):\n fo...
['Wrong Answer', 'Accepted']
['s293573900', 's052984056']
[4464.0, 4348.0]
[254.0, 246.0]
[570, 529]
p03425
u844005364
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['from collections import combinations\n\nn = int(input())\n\ncount = {x:0 for x in "MARCH"}\n\nfor _ in range(n):\n s = input()[0]\n if s in count:\n count[s] += 1\n\nsum_count = 0\nfor a, b, c in combinations("MARCH", 3):\n sum_count += count[a] * count[b] * count[c]\n\nprint(sum_count)', 'from itertools import...
['Runtime Error', 'Accepted']
['s495372380', 's054630206']
[3316.0, 3060.0]
[21.0, 172.0]
[278, 281]
p03425
u845333844
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n=int(input())\nl=[0]*10\nfor i in range(n):\n x=input()\n y=x[0]\n if y=='M':\n l[0]+=1\n elif y=='A':\n l[1]+=1\n elif y=='R':\n l[2]+=1\n elif y=='C':\n l[3]+=1\n elif y=='H':\n l[4]+=1\nans=0\nfor i in range(3):\n for j in range(i+1,i+4):\n for k in range(j+1,j+4):\n sum+=l[i]*l[j]*...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s293266189', 's860262088', 's458520308']
[3064.0, 3060.0, 3064.0]
[170.0, 171.0, 172.0]
[315, 225, 314]
p03425
u853900545
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n=int(input())\nm,a,r,c,h=0,0,0,0,0\nfor i in range(n):\n s=input()\n if s[0]=='M':\n m+=1\n elif s[0]=='A':\n a+=1\n elif s[0]=='R':\n r+=1\n elif s[0]=='C':\n c+=1\n elif s[0]=='H':\n h+=1\nx=del ([m,a,r,c,h],0)\nx.sort()\nl=len(x)\nif l<3:\n print(0)\nelif l=...
['Runtime Error', 'Accepted']
['s117634450', 's327571607']
[3060.0, 3064.0]
[17.0, 165.0]
[369, 581]
p03425
u856555908
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["x = input()\ncount = [0 for i in range(5)]\nfor i in x:\n name = input()\n if name[0] == 'M':\n count[0] += 1\n elif name[0] == 'A':\n count[1] += 1\n elif name[0] == 'R':\n count[2] += 1\n elif name[0] == 'C':\n count[3] += 1\n elif name[0] == 'H':\n count[4] += 1...
['Wrong Answer', 'Accepted']
['s360120285', 's928857553']
[3188.0, 3064.0]
[17.0, 163.0]
[498, 510]
p03425
u859897687
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['n=int(input())\nm=[0,0,0,0,0]\nfor i in range(n):\n s=input()\n if s[0]=="M":\n m[0]+=1\n elif s[0]=="A":\n m[1]+=1\n elif s[0]=="R":\n m[2]+=1\n elif s[0]=="C":\n m[3]+=1\n elif s[0]=="H":\n m[4]+=1\nans=0\nfor i in range(3):\n for j in range(i,4):\n for k in range(j,5):\n ans+=m[i]*m[j...
['Wrong Answer', 'Accepted']
['s713092749', 's250128843']
[3064.0, 3064.0]
[177.0, 182.0]
[317, 313]
p03425
u863442865
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["\ndef main():\n import sys\n #input = sys.stdin.readline\n sys.setrecursionlimit(10000000)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations\n #from itertools import accumulate, product\n from bisect import bisect...
['Wrong Answer', 'Accepted']
['s272387822', 's810687576']
[3316.0, 3316.0]
[177.0, 184.0]
[929, 935]
p03425
u884982181
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['n = int(input())\nm = 0\na = 0\nr = 0\nc = 0\nh = 0\nfor i in range(n):\n s = input()\n if s[0] == "M":\n m += 1\n if s[0] == "A":\n a += 1\n if s[0] == "R":\n r += 1\n if s[0] == "C":\n c += 1\n if s[0] == "H":\n H += 1\nans = m * a * r +m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+r*c*h+a*c*h\npri...
['Runtime Error', 'Accepted']
['s419478113', 's870713907']
[3064.0, 3064.0]
[181.0, 188.0]
[306, 306]
p03425
u887207211
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["N = int(input())\nname = {}\nfor i in range(N):\n S = input()\n if(S[0] in ['M', 'A', 'R', 'C', 'H']):\n if(S[0] not in name):\n name[S[0]] = 1\n else:\n name[S[0]] += 1\nans = 1\ncnt = 0\nfor k, v in name.items():\n k,v\n if(v >= 2):\n ans *= v\n else:\n cnt += 1\nprint(ans*cnt+cnt//3)", '...
['Wrong Answer', 'Accepted']
['s333496058', 's411581361']
[3188.0, 3316.0]
[184.0, 161.0]
[297, 210]
p03425
u893063840
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['n = int(input())\ns = [input()[0] for _ in range(n)]\n\nfrom collections import Counter\n\nc = Counter(s)\n\nc = list(c.values())\n\nc_len = len(c)\n\nans = 0\nfor i in range(c_len):\n for j in range(i+1, c_len):\n for k in range(j+1, c_len):\n ans += c[i] * c[j] * c[k]\n\nprint(ans)\n', 'n = int...
['Wrong Answer', 'Accepted']
['s975072003', 's203620681']
[4120.0, 3864.0]
[142.0, 140.0]
[289, 339]
p03425
u896726004
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["from itertools import (\n accumulate, \n groupby, \n permutations, \n combinations, \n product, \n)\n\nn = int(input())\nSm, Sa, Sr, Sc, Sh = set(), set(), set(), set(), set()\nfor _ in range(n):\n s = input()\n if s[0]=='M':\n Sm.add(s)\n elif s[0]=='A':\n Sa.add(s)\n el...
['Wrong Answer', 'Accepted']
['s683893761', 's671932462']
[14316.0, 14316.0]
[195.0, 184.0]
[688, 666]
p03425
u916637712
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import numpy as np\nnum=int(input())\n#valid=["M","A","R","C","H"]\narr=np.zeros(5)\n#print(arr)\n\nfor i in range(num):\n chara=list(input())[0]\n if chara == "M":\n arr[0]+=1\n if chara == "A":\n arr[1]+=1\n if chara == "R":\n arr[2]+=1\n if chara == "C":\n arr[3]+=1\n ...
['Wrong Answer', 'Accepted']
['s937956419', 's877506982']
[21380.0, 21504.0]
[1744.0, 1458.0]
[533, 534]
p03425
u922449550
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["from collections import defaultdict\nimport itertools\n\nd = defaultdict(int)\nN = int(input())\nfor i in range(N):\n s = input()[0].lower()\n d[s] += 1\n\nn = [d['m'], d['a'], d['r'], d['r'], d['h']]\nans = 0\n\na = itertools.combinations(n, 3)\nfor aa in a:\n t = 1\n for aaa in aa:\n t *= aaa\n ans += t\n\n...
['Wrong Answer', 'Accepted']
['s646601820', 's003390169']
[3316.0, 3444.0]
[193.0, 186.0]
[309, 309]
p03425
u923659712
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['m=0\na=0 \nr=0\nc=0\nh=0\nfor j in range(n):\n if s[j][0]=="M":\n m+=1\n elif s[j][0]=="A":\n a+=1\n elif s[j][0]=="R":\n r+=1\n elif s[j][0]=="C":\n c+=1\n elif s[j][0]=="H":\n h+=1\n \nans=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*c*h+a*r*h+r*c*h\n\nprint(ans)', 'n=int(input())\ns=[]\nfor i...
['Runtime Error', 'Accepted']
['s307248772', 's120644592']
[3064.0, 9772.0]
[18.0, 190.0]
[268, 327]
p03425
u934868410
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n = int(input())\ncount = [0]*5\nd = {'M': 0, 'A': 1, 'R': 2, 'C':3, 'H': 4}\n\nfor i in range(n):\n s = input()\n if s[0] in 'MARCH':\n count[d[s[0]]] += 1\n\nans = 0\nfor i in range(5):\n for j in range(i+1, 5):\n for k in range(j+1, 5):\n ans += count[i] * count[j] * count[k]]\nprint(ans)", "n = int(...
['Runtime Error', 'Accepted']
['s418523965', 's122948316']
[3064.0, 3064.0]
[18.0, 171.0]
[292, 291]
p03425
u948521599
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import itertools\nN = int(input())\nSK = {"M":0,"A":1,"R":2,"C":3,"H":4}\nSD = [0]*5\ndel_list = []\nA = ["M","A","R","C","H"]\nfor x in range(N):\n tmp = str(input())\n if tmp[0] in A:\n SD[SK[tmp[0]]] +=1\nC = 0\nfor x in range(5)\n if SD[x] == 0 :\n del_list.append(x)\n C +=1\ndel_lis...
['Runtime Error', 'Accepted']
['s516722740', 's179807128']
[3064.0, 3064.0]
[17.0, 206.0]
[521, 522]
p03425
u955125992
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["from collections import Counter\nimport itertools\n\nn = int(input())\n\ns = [str(input()) for _ in range(n)]\ninitial = [''] * n\n\nfor i in range(n):\n initial[i] = s[i][0]\n\nreg = Counter(initial)\nele = []\n\nfor i, j in reg.items():\n ele.append(i)\nans = 0\nfor A in itertools.combinations(ele, 3):\n #...
['Wrong Answer', 'Accepted']
['s204327366', 's275031895']
[10880.0, 10880.0]
[191.0, 185.0]
[385, 437]
p03425
u969211566
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
['import itertools \nn = int(input())\ns = [input() for _ in range(n)]\n\nmarch = [0]*5\nans = 0\nfor i in range(n):\n if s[i][0] == "M":\n march[0] += 1\n elif s[i][0] == "A":\n march[1] += 1\n elif s[i][0] == "R":\n march[2] += 1\n elif s[i][0] == "C":\n march[3] += 1\n elif s[i][0] == "H":\n marc...
['Wrong Answer', 'Accepted']
['s617175278', 's688374725']
[9776.0, 9776.0]
[172.0, 181.0]
[467, 454]
p03425
u970197315
2,000
262,144
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to ch...
["n=int(input())\nc=0\nd=set()\nfor i in range(n):\n s=input()\n if s[0]==('M' or 'A' or 'C' or 'R' or 'H'):\n if s not in d:\n c+=1\n d.add(s)\nans=0\nif c<3:\n print(ans)\nelse:\n ans=(c*(c-1)*(c-2))//6\n", 'n = int(input())\nfrom collections import Counter\nc = Counter()\nfor...
['Wrong Answer', 'Accepted']
['s419976918', 's705308768']
[14316.0, 9476.0]
[202.0, 158.0]
[231, 415]
p03426
u017810624
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['h,w,d=map(int,input().split())\nl=[list(map(int,input().split())) for i in range(h)]\nL=[0 for i in range(h*w)]\nfor i in range(h):\n for j in range(w):\n L[l[i][j]-1]=[i,j]\n\nsumL=[0 for i in range(h*w+1)]\nfor i in range(h*w):\n if i>=d:\n sumL[i+1]=sumL[i+1-d]+abs(L[i][0]-L[i-d][0])+abs(L[i][1]-L[i-d][1])...
['Wrong Answer', 'Accepted']
['s406316860', 's492218982']
[45780.0, 45080.0]
[623.0, 629.0]
[447, 436]
p03426
u037430802
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['h,w,d = map(int, input().split())\n\na = [[0 for _ in range(w)] for _ in range(h)]\nmasu = {}\nfor i in range(h):\n a[i] = list(map(int, input().split())\n for j in range(w):\n masu[a[i][j]] = (i,j)\n"""\nmasu = {}\nfor i in range(h):\n for j in range(w):\n masu[a[i][j]] = (i,j)\n"""\npoint = [...
['Runtime Error', 'Accepted']
['s850874797', 's975327346']
[2940.0, 31396.0]
[17.0, 568.0]
[628, 651]
p03426
u046187684
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['from itertools import product\n\n\ndef solve(string):\n h, w, d, *a = map(int, string.split())\n a, q, lr = a[:h * w], a[h * w], a[h * w + 1:]\n n = h * w\n index = [a.index(i + 1) for i in range(h * w)]\n costs = [\n [0 if j <= i or (j - i) % d != 0 else n * (j - i) // d for j in range(n)] for ...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s199675626', 's236417550', 's789855164', 's954794831']
[36748.0, 36940.0, 37004.0, 37112.0]
[2105.0, 330.0, 2105.0, 417.0]
[1112, 836, 1220, 913]
p03426
u146597538
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['h,w,d= map(int, input().split())\na = {}\nfor y in range(h):\n line = list(map(int, input().split()))\n for x in range(len(line)):\n a[line[x]-1] = (y,x)\n\n\n\n\n# 1,2,3,4,5,6,7,8,9\n\n\n\n\nnum = len(a)\ndp = [0]*num\nfor i in range(num-1, -1, -1):\n print(i)\n if i+d <= num-1:\n x, y = ...
['Wrong Answer', 'Accepted']
['s146504612', 's668651296']
[26416.0, 26480.0]
[600.0, 579.0]
[1219, 1206]
p03426
u163320134
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['h,w,k=map(int,input().split())\npos=[0]*(h*w+1)\nfor _ in range(h):\n tmp=list(map(int,input().split()))\n for i in range(w):\n pos[tmp[w]]=[i+1,w+1]\nprint(pos)h,w,k=map(int,input().split())\npos=[0]*(h*w+1)\nfor i in range(h):\n tmp=list(map(int,input().split()))\n for j in range(w):\n pos[tmp[j]]=[i+1,j+...
['Runtime Error', 'Accepted']
['s111220558', 's900189079']
[2940.0, 22440.0]
[18.0, 1108.0]
[687, 527]
p03426
u175034939
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['h,w,d = map(int,input().split())\nhw = [[] for _ in range(h*w+1)]\nhw[0] = [0,0]\nfor i in range(h):\n row = list(map(int,input().split()))\n for j in range(w):\n hw[row[j]] = [i,j]\nprint(hw)\n\na = [0 for _ in range(h*w+1)]\nfor i in range(d+1,h*w+1):\n a[i] = a[i-d] + abs(hw[i][0] - hw[i-d][0]) + a...
['Wrong Answer', 'Accepted']
['s949235588', 's456877562']
[18084.0, 17188.0]
[1035.0, 996.0]
[427, 405]
p03426
u187205913
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['h,w,d = map(int,input().split())\na = [list(map(int,input().split())) for _ in range(h)]\nq = int(input())\nl = [list(map(int,input().split())) for _ in range(q)]\ndic = {0:[0]}\nfor i in range(1,d+1):\n list = []\n for j in range(i,h*w,d):\n for y in range(len(a)):\n if j in a[y]:\n ...
['Runtime Error', 'Accepted']
['s615862802', 's967305686']
[31376.0, 47728.0]
[2105.0, 567.0]
[908, 419]
p03426
u210827208
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['H,W,D=map(int,input().split())\nA=[list(map(int,input().split())) for _ in range(H)]\nQ=int(input())\nX=[[0,0] for _ in range(H*W)]\nfor i in range(H):\n for j in range(W):\n X[A[i][j]][0]=i\n X[A[i][j]][1]=j\nM=[0]*(H*W+1)\nfor d in range(D+1,H*W+1):\n M[d]=abs(X[d][0]-X[d-D][0])+abs(X[d][1]-...
['Runtime Error', 'Accepted']
['s726626662', 's076806757']
[16116.0, 20712.0]
[95.0, 957.0]
[399, 401]
p03426
u232852711
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
["h, w, d = list(map(int, input().split()))\na = [list(map(int, input().split())) for _ in range(h)]\nq = int(input())\nlr = [list(map(int, input().split())) for _ in range(q)]\n\na_and_pos = {}\nfor i in range(h):\n for j in range(w):\n a_and_pos[a[i][j]] = (i, j)\n\npaths = {}\nfor rem in range(1, d+1):\n ...
['Wrong Answer', 'Accepted']
['s793134612', 's079373556']
[1889396.0, 47720.0]
[2232.0, 595.0]
[694, 496]
p03426
u255001744
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
["def calc(prepoint, nextpoint):\n return abs(nextpoint[0]-prepoint[0]) + abs(nextpoint[1]-prepoint[1])\n\ndef search(i,A):\n for h in range(H):\n if L in A[h]:\n return (h,A[h].index(L))\ndef main():\n H,W,D = map(int,input().split())\n A = [list(map(int, input().split())) for i in range(...
['Runtime Error', 'Accepted']
['s864934209', 's810609600']
[31884.0, 42320.0]
[375.0, 714.0]
[997, 701]
p03426
u267325300
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['H, W, D = map(int, input().split())\nA = [0] * H * W\nfor i in range(H):\n temp = list(map(int, input().split()))\n for j in range(len(temp)):\n A[temp[j] - 1] = (i + 1, j + 1)\n\nQ = int(input())\nL = []\nR = []\nfor _ in range(Q):\n l, r = map(int, input().split())\n L.append(l)\n R.append(r)\...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s123647011', 's721217892', 's807859337', 's996668782']
[21284.0, 21284.0, 31328.0, 30888.0]
[2105.0, 2105.0, 482.0, 639.0]
[675, 698, 848, 953]
p03426
u272557899
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['h,w,d = map(int, input().split())\na = []\n\nPY = [list(map(int, input().split())) + [i] for i in range(h)]\nfor i in range(h):\n a.append([int(m) for m in input().split()])\n\nq = int(input())\nlr = []\nfor i in range(q):\n lr.append([int(m) for m in input().split()])\n\nrea = []\nfor i in range(h * w):\n r...
['Runtime Error', 'Accepted']
['s108181350', 's328086607']
[6644.0, 47332.0]
[39.0, 901.0]
[952, 1094]
p03426
u273201018
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['import cython\n\n\nH, W, D = map(int, input().split())\n\nA = [False] * (H * W + 1)\n\nfor i in range(H):\n l = list(map(int, input().split()))\n for j in range(W):\n A[l[j]] = (i, j)\n\nQ = int(input())\n\nfor i in range(Q):\n L, R = map(int, input().split())\n cost = 0\n while L != R:\n ...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s015576435', 's454302877', 's999566190', 's607266068']
[3064.0, 3064.0, 22780.0, 24512.0]
[18.0, 18.0, 2105.0, 970.0]
[467, 431, 607, 445]
p03426
u285891772
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
["import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgett...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s138074478', 's391228105', 's927882198', 's934045385', 's619980032']
[45064.0, 44904.0, 44944.0, 53184.0, 50768.0]
[205.0, 344.0, 206.0, 617.0, 519.0]
[1378, 1445, 1383, 1528, 1529]
p03426
u309977459
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['H, W, D = map(int, input().split())\nA = [list(map(int, input().split())) for _ in range(H)]\nQ = int(input())\npos = [None]*(H*W+1)\nfor i, elem in enumerate(A):\n for j, a in enumerate(elem):\n pos[a] = (i, j)\nacc = [[] for _ in range(D+1)]\nfor i in range(1, D+1):\n tmp = i\n s = 0\n acc[i].app...
['Runtime Error', 'Accepted']
['s952482209', 's290205753']
[24112.0, 24240.0]
[323.0, 1091.0]
[605, 623]
p03426
u343523393
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
["import sys\nimport math\nimport numpy as np\nstdin = sys.stdin\n \nni = lambda: int(ns())\nna = lambda: list(map(int, input().split()))\nns = lambda: input()\nH,W,D = na()\nf= [list(map(int,input().split())) for i in range(H)]\n#print(f)\nf = np.array(f)\nQ=int(input())\n'''\nli = [0]*(H*W+2)\nfor i in range(1,D+1):\...
['Wrong Answer', 'Accepted']
['s908288778', 's565238338']
[33320.0, 35560.0]
[1523.0, 1546.0]
[903, 983]
p03426
u346308892
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['\n#import numpy as np\n\n\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\nH, W, D = acinput()\n# Ad={}\nAd = [0]*(H*W+1)\nfor i in range(H):\n ar = acinput()\n ...
['Wrong Answer', 'Accepted']
['s920811703', 's416240908']
[16888.0, 14396.0]
[1038.0, 1009.0]
[970, 971]
p03426
u347640436
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['H, W, D = map(int, input().split())\nA = [list(map(int, input().split())) for _ in range(H)]\n\nd = {}\nfor y in range(H):\n for x in range(W):\n d[A[y][x]] = (y, x)\n\nt = [[0] * (H * W // D + 1) for _ in range(D)]\nfor i in range(D):\n j = 0\n if i == 0:\n j = 1\n while i + (j + 1) * D <= ...
['Runtime Error', 'Accepted']
['s565873746', 's534134760']
[28136.0, 34964.0]
[200.0, 388.0]
[658, 732]
p03426
u350997995
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['#19:38\n#20:19\n\nH,W,D = map(int,input().split())\nMAX = H*W\nA = [list(map(int,input().split())) for i in range(H)]\nPoint = [0]*(MAX+1)\nfor h in range(H):\n for w in range(W):\n Point[A[h][w]] = (h,w)\nK = []\nfor i in range(1,D+1):\n List = []\n n = i\n h,w = Point[n]\n cost = 0\n while ...
['Wrong Answer', 'Accepted']
['s409104936', 's291754700']
[25252.0, 24304.0]
[1118.0, 1022.0]
[650, 578]
p03426
u365364616
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['h, w, d = map(int, input().split())\nx = []\nz = [[0, 0] for i in range(h * w)]\nfor i in range(h):\n x.append(list(map(int, input().split())))\n for j in range(w):\n z[x[i][j] - 1] = [i + 1, j + 1]\nprint(z)\ns = [0 for _ in range(d)]\nfor i in range(d):\n a = z[max(0, i - 1)]\n b = z[d + i - 1]\n...
['Runtime Error', 'Accepted']
['s152479360', 's558015132']
[26388.0, 25372.0]
[721.0, 656.0]
[920, 936]
p03426
u391475811
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['H,W,D=map(int,input().split())\nd=[[0,0] for i in range(H*W+1)]\nd2=[0 for i in range(H*W+1)]\nfor j in range(H):\n a=[int(x) for x in input().split()]\n for k in range(W):\n d[a[k]]=[j+1,k+1]\nfor l in range(D+1,H*W+1-D):\n d2[l]=abs(d[l][0]-d[l-D][0])+abs(d[l][1]-d[l-D][1])\nfor m in range(D+1,H*W+1-D):\n d2...
['Wrong Answer', 'Accepted']
['s638877875', 's186221910']
[17552.0, 17680.0]
[1003.0, 1024.0]
[452, 448]
p03426
u411537765
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['H, W, D = map(int, input().split())\nA = []\nC = [0 for _ in range(H * W + 1)]\nfor h in range(H):\n A.append(list(map(int, input().split())))\nfor i in range(H):\n for j in range(W):\n C[A[i][j]] = (i, j)\nh = [0 for _ in range(H * W + 1)]\nfor i in range(D):\n s = 0\n for j in range(i, H * W, D):...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s594317984', 's787246435', 's703281618']
[20232.0, 20372.0, 18096.0]
[1079.0, 1088.0, 1051.0]
[612, 630, 601]
p03426
u411858517
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['H, W, D = map(int, input().split())\nA = [list(map(int, input().split())) for _ in range(H)]\nQ = int(input())\nLR = [list(map(int, input().split())) for _ in range(Q)]\n\nres = 0\nfor i in range(10 **7):\n res += 1\n \n \nprint(res)', 'H, W, D = map(int, input().split())\nA = [list(map(int, input().split())) for ...
['Wrong Answer', 'Time Limit Exceeded', 'Accepted']
['s215500943', 's662803744', 's844719808']
[31052.0, 32464.0, 48176.0]
[1461.0, 2105.0, 633.0]
[226, 226, 671]
p03426
u437068347
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['import collections\nimport itertools\nfrom pprint import pprint as pp\n\nH,W,D = tuple(map(int, input().split()))\nA = [tuple(map(int, input().split())) for _ in range(H)]\nQ = int(input())\nLR = [tuple(map(int, input().split())) for _ in range(Q)]\n\nArev = [None] * (H*W+1)\nfor h in range(H):\n for w in range(W):\...
['Runtime Error', 'Accepted']
['s770489490', 's543131015']
[55580.0, 47544.0]
[2107.0, 695.0]
[764, 770]
p03426
u474270503
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['H, W, D=map(int, input().split())\npos={}\nfor i in range(H):\n A=list(map(int, input().split()))\n for j in range(W):\n pos[A[j]]=(i, j)\np=[0]*(H*W)\nfor i in range(D+1,H*W+1):\n p[i]=p[i-D]+abs(pos[i][0]-pos[i-D][0])+abs(pos[i][1]-pos[i-D][1])\nQ=int(input())\nfor _ in range(Q):\n L, R=map(int, ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s259530157', 's792145498', 's267077622']
[21672.0, 24996.0, 22568.0]
[228.0, 977.0, 969.0]
[345, 356, 347]
p03426
u476604182
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
["H, W, D, *L = map(int, open('0').read().split())\nA = L[:W*H]\nQ = L[H*W]\ninf = []\nfor l,r in zip(*[iter(L[H*W+1:])]*2):\n inf += [(l,r)]\ndic = {A[i*W+j]:(i,j) for i in range(H) for j in range(W)}\nls = [[] for i in range(D)]\nfor i in range(D):\n s = i if i!=0 else D\n ls[i].append(0)\n m = s\n n = s\n whil...
['Runtime Error', 'Accepted']
['s105676480', 's480635903']
[3064.0, 46104.0]
[17.0, 409.0]
[705, 703]
p03426
u497046426
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['import numpy as np\n\nH, W, D = map(int, input().split())\npos = [None]*(H*W)\n\nfor i in range(H):\n row = list(map(int, input().split()))\n for j in row:\n pos[row[j]] = (i, j)\n\nQ = int(input())\nfor _ in range(Q):\n L, R = map(int, input().split())\n if L == R:\n print(0)\n else:\n ...
['Runtime Error', 'Accepted']
['s804920073', 's829639581']
[13156.0, 35984.0]
[151.0, 1029.0]
[629, 575]
p03426
u518042385
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['h,w,d=map(int,input().split())\nl={}\nfor i in range(h):\n l1=list(map(int,input().split()))\n for j in l1:\n l[j]=[l1.index(j)+1,i+1]\nli=[]\nfor i in range(1,d+1):\n l11=[]\n c=0\n x=l[i][0]\n y=l[i][1]\n while i<=h*w:\n c+=abs(x-l[i][0])+abs(y-l[i][1])\n l11.append(c)\n x=l[i][0]\n y=l[i][1]\...
['Runtime Error', 'Accepted']
['s502022856', 's254872156']
[32032.0, 34208.0]
[600.0, 1263.0]
[497, 501]
p03426
u536113865
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['ai = lambda: list(map(int, input().split()))\n\nh,w,d = ai()\nph = [0 for _ in range(h*w + 1)]\npw = [0 for _ in range(h*w + 1)]\n\nfor i in range(h):\n a = ai()\n for j in range(w):\n ph[a[j]] = i\n pw[a[j]] = j\n\n\nscore = [0 for _ in range(h*w + 1)]\nfor i in range(d+1, h*w+1):\n score[i] =...
['Wrong Answer', 'Accepted']
['s343572949', 's656525684']
[10984.0, 15036.0]
[990.0, 497.0]
[451, 475]
p03426
u545368057
2,000
262,144
We have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j). The integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}. You, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by...
['H,W,D = map(int, input().split())\nfields = []\namaris = [[0] * (H*W) for i in range(D)] \nfor i in range(H):\n row = list(map(int, input().split()))\n がいくつかで分類\n for j,e in enumerate(row):\n n = (e-1) // D\n m = (e-1) % D\n amaris[m][n] = (i,j)\n\n# print(amaris[:10])\nごとに累積和を取っておく\nacc...
['Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s429972327', 's573104124', 's953227111']
[1818484.0, 1927924.0, 39880.0]
[2215.0, 2223.0, 1110.0]
[905, 655, 875]