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
|
|---|---|---|---|---|---|---|---|---|---|---|
p02713
|
u840958781
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['k = int(input())\n \ndef gcd2(a,b):\n if b == 0:\n return a\n return gcd2(b,a%b)\n\ndef gcd3(a,b,c):\n return gcd2(gcd2(a,b), c)\n\nans = 0\nfor a in range(1,k+1):\n for b in range(i,k+1):\n for c in range(j, k+1):\n if a == b == c:\n ans += gcd3(a,b,c)\n elif a == b or b == c:\n ans += gcd3(a,b,c)*3\n else:\n ans += gcd3(a,b,c)*6\n\nprint(ans)', 'k = int(input())\n \ndef gcd2(a,b):\n if b == 0:\n return a\n return gcd2(b,a%b)\n\ndef gcd3(a,b,c):\n return gcd2(gcd2(a,b), c)\n\nans = 0\nfor i in range(1,k+1):\n for j in range(i,k+1):\n for m in range(j, k+1):\n if i == j == m:\n ans += gcd3(i,j,m)\n elif i == j or j == m:\n ans += gcd3(i,j,m)*3\n else:\n ans += gcd3(i,j,m)*6\n\nprint(ans)\n']
|
['Runtime Error', 'Accepted']
|
['s166597595', 's485584825']
|
[9216.0, 9200.0]
|
[23.0, 1367.0]
|
[429, 430]
|
p02713
|
u845573105
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['function GCM(x, y):\n if x == y:\n return x\n if x < y:\n s = x\n x = y\n y = s\n \n a = x%y\n if a == 0:\n return y\n return GCM(y, a)\n\nk = int(input())\nres = 0\nsame1 = 0\nsame2 = 0\nrate = [6,3,1]\nfor p in range(1,k+1):\n for q in range(p, k+1):\n same1 = int(p==q)\n gcm = GCM(q,p)\n for r in range(q, k+1):\n same2 = int(q==r)\n gcm = GCM(r,gcm)\n res += gcm*rate[same1+same2]\nprint(res)\n \n\n \n \n \t\n ', 'def compute_gcm(x, y):\n if x == y:\n return x\n if x < y:\n s = x\n x = y\n y = s\n if x==1:\n return 1\n a = x%y\n if a == 0:\n return y\n return compute_gcm(y, a)\n\nprint(compute_gcm(4,compute_gcm(2,2)))\nk = int(input())\nres = k**3-(k-1)**3\nsame1 = 0\nsame2 = 0\nrate = [6,3,1]\nfor p in range(2,k+1):\n for q in range(p, k+1):\n same1 = int(p==q)\n gcm1 = compute_gcm(q,p)\n for r in range(q, k+1):\n same2 = int(q==r)\n gcm = compute_gcm(r,gcm1)\n res += gcm*rate[same1+same2]\n \nprint(res)', 'def compute_gcm(x, y):\n if x == y:\n return x\n if x < y:\n s = x\n x = y\n y = s\n if x==1:\n return 1\n a = x%y\n if a == 0:\n return y\n return compute_gcm(y, a)\n\n#print(compute_gcm(4,compute_gcm(2,2)))\nk = int(input())\nres = k**3-(k-1)**3\nsame1 = 0\nsame2 = 0\nrate = [6,3,1]\nfor p in range(2,k+1):\n for q in range(p, k+1):\n same1 = int(p==q)\n gcm1 = compute_gcm(q,p)\n for r in range(q, k+1):\n same2 = int(q==r)\n gcm = compute_gcm(r,gcm1)\n res += gcm*rate[same1+same2]\n \nprint(res)']
|
['Runtime Error', 'Wrong Answer', 'Accepted']
|
['s211461919', 's775197255', 's823127146']
|
[9040.0, 9240.0, 9236.0]
|
[19.0, 703.0, 765.0]
|
[438, 616, 617]
|
p02713
|
u845650912
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['def euclidean(a, b):\n r = a % b\n if r == 0:\n return b\n return euclidean(b,r)\n\n\n\nN = int(input())\n\ns = 0\n\nfor i in range(N):\n for j in range(N):\n for k in range(N):\n s +=euclidean(euclidean(i+1,j+1),k+1)', 'import math\n\n\nN = int(input())\n\ns = 0\n\nfor i in range(N):\n for j in range(N):\n ss = math.gcd(i+1,j+1)\n for k in range(N):\n s +=math.gcd(ss,k+1)\n\nprint(s)\n']
|
['Wrong Answer', 'Accepted']
|
['s519491721', 's802732140']
|
[9096.0, 9164.0]
|
[2205.0, 1536.0]
|
[239, 182]
|
p02713
|
u848654125
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import scipy as sp\nfrom itertools import combinations_with_replacement as com\n\ndef tri_gcd(a, b, c):\n return sp.gcd(a, sp.gcd(b, c))\n\ndef make_divisors(n):\n divisors = []\n for i in range(2, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n return set(divisors)\n\nN = int(input())\nans = 0\nduplication = 1\ncount_for = 0\nfor a in range(N+1):\n for b in make_divisors(a):\n for c in make_divisors(b):\n if len(set([a,b,c])) == 3:\n duplication = 6\n if len(set([a,b,c])) == 2:\n duplication = 3\n if len(set([a,b,c])) == 1:\n duplication = 1\n ans += duplication * tri_gcd(a, b, c)\n print(a,b,c)\n count_for += 1\nprint(ans)', 'import scipy as sp\nimport numpy as np\nimport math\n\n\nN = int(input())\n\nans = 0\nfor a in range(N+1):\n for b in range(N+1):\n d = math.gcd(a, b)\n for c in range(N+1):\n\n ans += math.gcd(c, d)\n\nprint(ans)', 'import scipy as sp\nimport numpy as np\nimport math\n\n\nN = int(input())\n\nans = 0\nfor a in range(1, N+1):\n for b in range(1, N+1):\n d = math.gcd(a, b)\n for c in range(1, N+1):\n\n ans += math.gcd(c, d)\n\nprint(ans)']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s132776560', 's768277391', 's111711420']
|
[31200.0, 31120.0, 31140.0]
|
[125.0, 1477.0, 1410.0]
|
[831, 226, 235]
|
p02713
|
u849756457
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['\ndef q3():\nimport math\n k = int(input())\n sum_n = 0\n gcd_2_dict = {}\n def gcd(n1, n2):\n if n1 < n2:\n sorted_nums = tuple([n1, n2])\n else:\n sorted_nums = tuple([n2, n1])\n if sorted_nums in gcd_2_dict:\n return gcd_2_dict[sorted_nums]\n gcd_num = math.gcd(n1, n2)\n gcd_2_dict[sorted_nums] = gcd_num\n return gcd_num\n\n for a in range(1, k + 1):\n for b in range(1, k + 1):\n for c in range(1, k + 1):\n sorted_nums = sorted([a, b, c])\n sum_n += gcd(gcd(sorted_nums[0], sorted_nums[1]), sorted_nums[2])\n\n print(sum_n)\n\nq3()', '\nfrom math import gcd\n\nK = int(input())\n\na = 0\nfor ai in range(1, K + 1):\n for bi in range(1, K + 1):\n gcd_ab = gcd(ai, bi)\n for ci in range(1, K + 1):\n a += gcd(gcd_ab, ci)\n\nprint(a)']
|
['Runtime Error', 'Accepted']
|
['s724680739', 's873451215']
|
[8944.0, 9168.0]
|
[20.0, 1078.0]
|
[654, 195]
|
p02713
|
u851125702
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['mport math\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\n\nN=int(input())\nS=0\nT=0\nfor i in range(1,N+1):\n for j in range(i+1,N+1):\n for k in range(j+1,N+1):\n S+=gcd(i,j,k)\nfor i in range(1,N+1):\n for j in range(i+1,N+1):\n T+=gcd(i,j,j)\n T+=gcd(i,j,j)\nprint(6*S+3*T+N*(N+1)//2)', 'import math\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\n\nN=int(input())\nS=0\nT=0\nfor i in range(1,N+1):\n for j in range(i+1,N+1):\n for k in range(j+1,N+1):\n S+=gcd(i,j,k)\nfor i in range(1,N+1):\n for j in range(i+1,N+1):\n T+=gcd(i,j,j)\n T+=gcd(i,j,j)\nprint(6*S+3*T+N*(N+1)//2)']
|
['Runtime Error', 'Accepted']
|
['s883882332', 's320811001']
|
[9012.0, 9632.0]
|
[23.0, 640.0]
|
[362, 363]
|
p02713
|
u854992222
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nk = int(input())\nsum =0\nfor a in range(1, k+1):\n for b in range(1, k+1):\n x = gcd(a, b)\n for c in range(1, k+1):\n sum += gcd(x, c)\nprint(sum)', 'import math\nk = int(input())\nsum =0\nfor a in range(1, k+1):\n for b in range(1, k+1):\n x = math.gcd(a, b)\n for c in range(1, k+1):\n sum += math.gcd(x, c)\nprint(sum)']
|
['Runtime Error', 'Accepted']
|
['s047413451', 's934752491']
|
[9188.0, 9184.0]
|
[22.0, 1498.0]
|
[185, 195]
|
p02713
|
u856282038
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['def gcd(a,b):\n if a<b:\n tmp = a\n a = b\n b = tmp\n r = a % b\n while r!=0:\n a = b\n b = r\n r = a % b\n return b\n \ndef main():\n K = int(input())\n list_ = []\n sum_ = 0\n for i in range(K):\n for j in range(K):\n a = gcd(i,j)\n list_.append(a)\n for i in list_:\n for j in range(K):\n a = gcd(i,j)\n sum_ += a\n print(sum_)\n\nmain()\n ', 'def gcd(a,b):\n if a<b:\n tmp = a\n a = b\n b = tmp\n r = a % b\n while r!=0:\n a = b\n b = r\n r = a % b\n return b\n \ndef main():\n K = int(input())\n list_ = []\n sum_ = 0\n for i in range(1,K+1):\n for j in range(1,K+1):\n a = gcd(i,j)\n list_.append(a)\n for i in list_:\n for j in range(1,K+1):\n a = gcd(i,j)\n sum_ += a\n print(sum_)\n\nmain()\n ']
|
['Runtime Error', 'Accepted']
|
['s620953610', 's979208798']
|
[9192.0, 9444.0]
|
[22.0, 1323.0]
|
[442, 454]
|
p02713
|
u863964720
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nfrom functools import reduce\nfrom math import gcd\nK = int(input())\nA=[]\nB=[]\nfor a in range(1,K+1):\n for b in range(1,K+1):\n A.append(gcd(a,b))\nfor x in range(len(A)):\n for c in range(1,K+1):\n B.append(gcd(A[x],c))\nfor i in range(len(B)):\n sum +=B[i]\nprint(sum)\n', 'import math\nfrom functools import reduce\nfrom math import gcd\nK = int(input())\nA=[]\nB=[]\nsum=0\nfor a in range(1,K+1):\n for b in range(1,K+1):\n A.append(gcd(a,b))\nfor c in range(1,K+1):\n for d in range(1,K+1):\n B.append(gcd(A[c],d))\n sum+=B[c]\nprint(sum)', 'import math\nfrom functools import reduce\nfrom math import gcd\nK = int(input())\nA=[]\nB=[]\nsum=0\nfor a in range(1,K+1):\n for b in range(1,K+1):\n A.append(gcd(a,b))\nfor c in range(1,K+1):\n for d in range(1,K+1):\n B.append(gcd(A[c],d)\n sum+=B[c]\nprint(sum)', 'import math\n \n \nN = int(input())\n \ns = 0\n \nfor i in range(N):\n for j in range(N):\n ss = math.gcd(i+1,j+1)\n for k in range(N):\n s +=math.gcd(ss,k+1)\n \nprint(s)']
|
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
|
['s229619997', 's568173049', 's732930231', 's968289505']
|
[72012.0, 9748.0, 9056.0, 9168.0]
|
[1476.0, 32.0, 23.0, 1456.0]
|
[297, 280, 279, 186]
|
p02713
|
u864273141
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nfrom functools import reduce\nk=int(input())\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\nans=0\nfor i in range(1,k+1):\n for j in range(i,k+1):\n for l in range(j,k+1):\n if l==i:\n ans+=gcd(i,j,l)\n elif i==j or j==l:\n ans+=2*gcd(i,j,l)\n else:\n ans+=gcd(i,j,l)\nprint(ans)\n\n', 'import math\nfrom functools import reduce\nk=int(input())\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\nans=0\nfor i in range(1,k+1):\n for j in range(j,k+1):\n for l in range(l,k+1):\n if l==i:\n ans+=gcd(i,j,l)\n elif i==j or j==l:\n ans+=2*gcd(i,j,l)\n else:\n ans+=gcd(i,j,l)\nprint(ans)\n', 'import math\nfrom functools import reduce\nk=int(input())\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\nans=0\nfor i in range(1,k+1):\n for j in range(i,k+1):\n for l in range(j,k+1):\n if l==i:\n ans+=gcd(i,j,l)\n elif i==j or j==l:\n ans+=3*gcd(i,j,l)\n else:\n ans+=6*gcd(i,j,l)\nprint(ans)\n\n\n\n']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s372891419', 's496171203', 's351025516']
|
[9624.0, 9596.0, 9656.0]
|
[784.0, 25.0, 814.0]
|
[331, 330, 335]
|
p02713
|
u868628468
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['K = int(input())\nans = 0\nfor i in range(1,K+1):\n for j in range(1,K+1):\n for k in range(1,K+1):\n if j < k:\n j,k = k,j\n temp = gcd(j,k)\n if i < temp:\n i,temp = temp,i\n ans += gcd(i,temp)\nprint(ans)', 'import math\n \nk = int(input()) + 1\nans = 0\n \nfor a in range(1, k):\n for b in range(1, k):\n d = math.gcd(a, b)\n for c in range(1, k):\n ans += math.gcd(d, c)\n \nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s350111505', 's732908961']
|
[9196.0, 9112.0]
|
[22.0, 1388.0]
|
[280, 196]
|
p02713
|
u870297120
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nfrom functools import reduce\nimport itertools\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\nk = int(input())\nans = 0\n\nseq = [i for i in range(1, k+1)]\nb = list(itertools.combinations_with_replacement(seq,3))\n\nfor a in b:\n if a[0] == a[1] == a[2]:\n ans += gcd(a[0], a[1], a[2])\n else:\n ans += gcd(a[0], a[1], a[2])*(n+1)\nprint(ans)', 'from math import gcd\n \nn = int(input())\n \nans = 0\n \nfor i in range(1,n+1):\n for j in range(1,n+1):\n for k in range(1,n+1):\n ans += gcd(gcd(i,j),k)\n \nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s532529760', 's179328246']
|
[105980.0, 9180.0]
|
[189.0, 1884.0]
|
[374, 173]
|
p02713
|
u872704421
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['n=int(input())\n\ntotal=0\nfor nn in range(1,n+1):\n for k in range(1,n+1):\n for l in range(1,n+1):\n total+=math.gcd(nn,math.gcd(k,l))\n\nprint(total)', 'import math\n\nn=int(input())\n \ndef diffs(n):\n total=0\n for k in range(1,n):\n for l in range(k+1,n):\n total+=math.gcd(n,math.gcd(k,l))*6\n for k in range(1,n):\n total+=math.gcd(n,k)*6\n total += n\n return total\n\nsum=0\nfor i in range(1,n+1):\n sum += diffs(i)\n\nprint(sum)']
|
['Runtime Error', 'Accepted']
|
['s837648972', 's324059062']
|
[9180.0, 9200.0]
|
[20.0, 342.0]
|
[153, 282]
|
p02713
|
u878291720
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import fractions\nK = int(input())\nA = [i for i in range(1, K+1)]\nB = [i for i in range(1, K+1)]\nC = [i for i in range(1, K+1)]\n \ncnt = 0\nfor a in A:\n for b in B:\n for c in C:\n N = [a,b,c]\n ans = N[0]\n for i in range(1, 3):\n ans = fractions.gcd(ans, N[i])\n cnt += ans\nprint(cnt)', 'import fractions\nK = int(input())\nA = [i for i in range(1, K)]\nB = [i for i in range(1, K)]\nC = [i for i in range(1, K)]\n\ncnt = 0\nfor a in A:\n for b in B:\n for c in C:\n N = [a,b,c]\n ans = N[0]\n for i in range(1, 3):\n ans = fractions.gcd(ans, a[i])\n cnt += ans\nprint(cnt)', 'from fractions import gcd\nK = int(input())\nA = B = C = [i for i in range(1, K+1)]\ncnt = sum([gcd(gcd(a,b),c) for a in A for b in B for c in C]) \nprint(cnt)', 'import fractions\nK = int(input())\nA = B = C = [i for i in range(1, K+1)]\n \ncnt = 0\nfor a in A:\n for b in B:\n for c in C:\n ans = fractions.gcd(a, b)\n ans = fractions.gcd(ans, c)\n cnt += ans\nprint(cnt)', 'def gcd(a, b):\n for i in range(200):\n a, b = b, a%b\n return a if b == 0\n \nK = int(input())\nA = B = C = [i for i in range(1, K+1)]\ncnt = sum([gcd(gcd(a,b),c) for a in A for b in B for c in C]) \nprint(cnt)', 'def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n \nK = int(input())\nA = B = C = [i for i in range(1, K+1)]\n\nL = [gcd(a,b) for a in A for b in B]\n\ncnt = sum([gcd(l,c) for l in L for c in C]) \nprint(cnt)']
|
['Time Limit Exceeded', 'Runtime Error', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Accepted']
|
['s009204546', 's725584971', 's749425821', 's767342761', 's960055987', 's672526284']
|
[10616.0, 10456.0, 21616.0, 10620.0, 8952.0, 71724.0]
|
[2205.0, 30.0, 2206.0, 2205.0, 24.0, 1350.0]
|
[308, 301, 157, 218, 219, 220]
|
p02713
|
u881816188
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['from math import gcd\n\nk=int(input())\nans=0\nfor i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n ans+=gcd(math.gcd(i,j), l)\n #print(gcd(i,j,l))\nprint(ans)', 'import math\nfrom functools import reduce\n\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\nk=int(input())\nans=0\nfor i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n ans+=gcd(i,j,k)\n #print(gcd(i,j,l))\nprint(ans)', 'from math import gcd\n\nk=int(input())\nans=0\nfor i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n ans+=gcd(gcd(i,j), l)\n #print(gcd(i,j,l))\nprint(ans)']
|
['Runtime Error', 'Wrong Answer', 'Accepted']
|
['s921390460', 's925215995', 's614143373']
|
[9204.0, 9564.0, 9180.0]
|
[24.0, 2205.0, 1920.0]
|
[204, 271, 199]
|
p02713
|
u884323674
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['\nmax_codiv = []\n \n\nn = int(input())\n \nimport math\n\nfor i in range(1, n+1):\n for j in range(1, n+1):\n \ti_j = math.gcd(i, j)\n for k in range(1, n+1):\n i_j_k = math.gcd(i_j, k)\n max_codiv.append(i_j_k)\nprint(sum(max_codiv))', '\nmax_codiv = []\n \n\nn = int(input())\n \nimport math\n\nfor i in range(1, n+1):\n\tfor j in range(1, n+1):\n\t\ti_j = math.gcd(i, j)\n\t\tfor k in range(1, n+1):\n\t\t\ti_j_k = math.gcd(i_j, k)\n\t\t\tmax_codiv.append(i_j_k)\nprint(sum(max_codiv))']
|
['Runtime Error', 'Accepted']
|
['s683892544', 's258787459']
|
[9028.0, 71656.0]
|
[24.0, 1681.0]
|
[395, 365]
|
p02713
|
u884601206
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nn=int(input())\nans=0\nfor i in range(1,k+1):\n\t\n for j in range(1,k+1):\n\t\t\n for l in range(1,k+1):\n\t\t\t\n ans+=math.gcd(i,math.gcd(j,l))\n\nprint(ans)', 'import math\n\nK = int(input())\n\nans = 0\nfor i in range(1, K+1):\n for j in range(1, K+1):\n x = math.gcd(i, j)\n for k in range(1, K+1):\n ans += math.gcd(x, k)\n\nprint(ans)\n']
|
['Runtime Error', 'Accepted']
|
['s636935554', 's935069204']
|
[9176.0, 9116.0]
|
[20.0, 1377.0]
|
[201, 196]
|
p02713
|
u891687930
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['from math import gcd\nimport itertools\nn = int(input())\nans = 0\n\nfor C in itertools.combinations_with_replacement(range(1,n+1),3):\n ans += gcd(gcd(C[0],C[1]),C[2])\nprint(ans)', 'from math import gcd\n \nn = int(input())\nans = 0\n\nfor a in range(1,n+1):\n for b in range(1,n+1):\n for c in range(1,n+1):\n ans += gcd(gcd(a,b),c)\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s992633486', 's947530884']
|
[9184.0, 9168.0]
|
[422.0, 1890.0]
|
[176, 175]
|
p02713
|
u892487306
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
["def gcd(a, b):\n # `a >= b` is sopposed\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n\ndef main():\n K = 200\n answer = 0\n for a in range(1, K + 1):\n for b in range(a, K + 1):\n gcd_ab = gcd(b, a)\n for c in range(b, K + 1):\n gcd_abc = gcd(c, gcd_ab)\n if a < b < c:\n pattern_num = 6\n elif a == b < c or a < b == c:\n pattern_num = 3\n else:\n pattern_num = 1\n answer += pattern_num * gcd_abc\n print(answer)\n\n\nif __name__ == '__main__':\n main()", "def gcd(a, b):\n # `a >= b` is sopposed\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n\ndef main():\n K = 200\n gcd_memo = [[0 for _ in range(K + 1)] for _ in range(K + 1)]\n for a in range(1, K + 1):\n for b in range(a, K + 1):\n left, right = max([a, b]), min([a, b])\n gcd_ab = gcd(left, right)\n gcd_memo[a][b] = gcd_ab\n gcd_memo[b][a] = gcd_ab\n answer = 0\n for a in range(1, K + 1):\n for b in range(1, K + 1):\n gcd_ab = gcd_memo[a][b]\n answer += sum(gcd_memo[gcd_ab])\n print(answer)\n\n\nif __name__ == '__main__':\n main()", "def gcd(a, b):\n # `a >= b` is sopposed\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n\ndef main():\n K = int(input())\n gcd_memo = [[0 for _ in range(K + 1)] for _ in range(K + 1)]\n for a in range(1, K + 1):\n for b in range(a, K + 1):\n left, right = max([a, b]), min([a, b])\n gcd_ab = gcd(left, right)\n gcd_memo[a][b] = gcd_ab\n gcd_memo[b][a] = gcd_ab\n answer = 0\n for a in range(1, K + 1):\n for b in range(1, K + 1):\n gcd_ab = gcd_memo[a][b]\n answer += sum(gcd_memo[gcd_ab])\n print(answer)\n\n\nif __name__ == '__main__':\n main()"]
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s235535499', 's604308600', 's054848458']
|
[9148.0, 9324.0, 9512.0]
|
[415.0, 91.0, 84.0]
|
[640, 645, 654]
|
p02713
|
u892882715
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\n\nK = int(input())\n\ndef gcd(a, b, c):\n g = math.gcd(a, b)\n return math.gcd(g, c)\n\nresult = sum((gcd(a, b, c) for a in range(1, K + 1) for b in range(1, K + 1) for c in range(1, K + 1)))', 'import math\n\nK = 200 #int(input())\n\ntotal = 0\nfor a in range(1, K + 1):\n for b in range(1, K + 1):\n ab = math.gcd(a, b)\n for c in range(1, K + 1):\n total += math.gcd(ab, c)\n\nprint(total)', 'import math\n\nK = int(input())\n\ntotal = 0\nfor a in range(1, K + 1):\n for b in range(1, K + 1):\n ab = math.gcd(a, b)\n if ab == 1:\n total += K\n else:\n for c in range(1, K + 1):\n total += math.gcd(ab, c)\n\nprint(total)']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s192714284', 's550650299', 's791776654']
|
[9192.0, 9100.0, 9184.0]
|
[2195.0, 1457.0, 608.0]
|
[202, 214, 274]
|
p02713
|
u896726004
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['from itertools import (\n accumulate, \n groupby, \n permutations, \n combinations, \n product, \n combinations_with_replacement, \n)\n\nimport fractions\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(fractions.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(fractions.gcd, numbers)\n\n\nN = int(input())\nans = 0\nfor v in product(range(1, N+1), repeat=3):\n ans += gcd_list(v)\n\nprint(ans)', 'from itertools import (\n accumulate, \n groupby, \n permutations, \n combinations, \n product, \n combinations_with_replacement, \n)\n\nimport fractions\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(fractions.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(fractions.gcd, numbers)\n\n\nN = int(input())\nans = 0\nfor i, j, k in combinations_with_replacement(range(1, N+1), 3):\n if i==j==k:\n ans += i\n elif i==j:\n ans += gcd(i, k)*3\n elif j==k:\n ans += gcd(j, i)*3\n elif i==k:\n ans += gcd(i, j)*3\n else:\n ans += gcd_list([i, j, k])*6\nprint(ans)', 'from itertools import (\n accumulate, \n groupby, \n permutations, \n combinations, \n product, \n combinations_with_replacement, \n)\n\nimport fractions, math\nfrom functools import reduce\n\ndef gcd_list(numbers):\n return reduce(math.gcd, numbers)\n\n\nN = int(input())\nans = 0\nfor i, j, k in combinations_with_replacement(range(1, N+1), 3):\n if i==j==k:\n ans += i\n elif i==j:\n ans += math.gcd(i, k)*3\n elif j==k:\n ans += math.gcd(j, i)*3\n elif i==k:\n ans += math.gcd(i, j)*3\n else:\n ans += gcd_list([i, j, k])*6\nprint(ans)']
|
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
|
['s613116110', 's677377258', 's351004069']
|
[10700.0, 10724.0, 10528.0]
|
[2205.0, 2206.0, 888.0]
|
[618, 821, 775]
|
p02713
|
u896741788
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['k=int(input())+1\nfrom math import gcd\nprint(sum(gcd(gcd(i,j),r) for i in range(1,k) for j in range(1,k) for r in range(1,k) )\nk=int(input())+1\nfrom math import gcd\nprint(sum( gcd(gcd(i,j),r) for i in range(1,k) for j in range(1,k) for r in range(1,k) ))\n', 'k=int(input())+1\nfrom math import gcd\nprint(sum(gcd(gcd(i,j),r) for i in range(1,k) for j in range(1,k) for r in range(1,k) )\n', 'k=int(input())+1\nfrom math import gcd\nprint(sum( gcd(gcd(i,j),r) for i in range(1,k) for j in range(1,k) for r in range(1,k) ))\n']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s614441011', 's768787468', 's596018105']
|
[9016.0, 9020.0, 9168.0]
|
[22.0, 20.0, 1254.0]
|
[260, 129, 131]
|
p02713
|
u896838289
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import io\n\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\n\ndef __main__():\n K = int(input())\n\n ans = 0\n for a in range(1,K+1):\n for b in range(1,K+1):\n for c in range(1,K+1):\n ans += gcd(c, gcd(a, b))\n\n print(ans)', 'import numpy as np\n\n\ndef gcd(a, b):\n while b > 0 :\n a, b = b, a%b\n\n return a\n\n\nK = int(input())\nans = 0\nfor a in range(1,K+1):\n for b in range(1,K+1):\n g = gcd(a, b)\n for c in range(1,K+1):\n ans += gcd(c, g)\n\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s370031687', 's858827434']
|
[9124.0, 27168.0]
|
[23.0, 1714.0]
|
[285, 260]
|
p02713
|
u901598613
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['n=int(input())\nimport math\nans=0\nfor i in range(2,n+1):\n for j in range(1,n+1):\n ij=math.gcd(i,j)\n if ij==1:\n ans+=n\n else:\n for k in range(1,n+1):\n ans+=math.gcd(ij,k)\nprint(ans)', 'n=int(input())\nimport math\nans=0\nfor i in range(1,n+1):\n for j in range(1,n+1):\n ij=math.gcd(i,j)\n if ij==1:\n ans+=n\n else:\n for k in range(1,n+1):\n ans+=math.gcd(ij,k)\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s165922580', 's258433250']
|
[9180.0, 9172.0]
|
[590.0, 617.0]
|
[240, 240]
|
p02713
|
u906501980
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['def main():\n k = int(input())\n gcds = list(sorted([gcd(i, j) for i in range(1, k+1) for j in range(1, k+1)]))\n j = 0\n s = list(set(gcds))\n m = k**2-1\n gcdss = [0]*len(s)\n for i, l in enumerate(s):\n while gcds[j] == l:\n j += 1\n gcdss[i] += 1\n if j == m:\n break\n ans = sum([gcd(i, j)*n for i in range(1, k+1) for j, n in zip(s, gcdss)])\n print(ans)\n \n \ndef gcd(a, b):\n if a < b:\n a, b = b, a\n if a % b == 0:\n return b\n else:\n return gcd(b, a%b)\n\n\nif __name__ == "__main__":\n main()', 'def main():\n k = int(input())\n gcds = []\n for i in range(1, k+1):\n for j in range(1, k+1):\n gcds.append(gcd(i, j))\n ans = {i:0 for i in set(gcds)}\n for i in gcds:\n ans[i] += 1\n out = 0\n for i, v in ans.items():\n for j in range(1, k+1):\n out += gcd(i, j)*v\n print(out)\n\ndef gcd(x, y):\n r = x % y\n while r:\n x, y, r = y, r, y%r\n return y\n\nif __name__ == "__main__":\n main()']
|
['Runtime Error', 'Accepted']
|
['s958479963', 's597326422']
|
[9712.0, 9372.0]
|
[71.0, 44.0]
|
[600, 457]
|
p02713
|
u907223098
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n \nk=int(input())\nr=0\nl=[]\n\nfor i in range(k):\n for j in range(k):\n for l in range(k):\n if i<=j and j<=k:\n l.append([i+1,j+1,k+1])\nfor s in l:\n r+=gcd(s[0],s[1],s[2])\nprint(r)\n', 'import math\n \nk=int(input())\nr=0\nls=[]\n\nfor i in range(k):\n for j in range(k):\n a=math.gcd(i+1,j+1)\n for l in range(k):\n r+=math.gcd(a,l+1)\nprint(r)']
|
['Runtime Error', 'Accepted']
|
['s797151378', 's460268181']
|
[9480.0, 9172.0]
|
[23.0, 1494.0]
|
[291, 161]
|
p02713
|
u907446975
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['a=str(input())\nif \'7\' in a:\n print("Yes")\nelse:\n print("No")', 'from math import gcd\nk=int(input())\nre=0\nfor i in range(1,k+1):\n for j in range(1,k+1):\n v=gcd(i,j)\n for l in range(1,k+1):\n re+=gcd(v,l)\nprint(re)\n']
|
['Wrong Answer', 'Accepted']
|
['s233734696', 's994719272']
|
[9092.0, 9088.0]
|
[20.0, 1181.0]
|
[66, 176]
|
p02713
|
u914948583
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\n\nk = int(input())\nans = 0\nfor a in range(1, k+1):\n for b in range(1, k+1):\n ab = math.gcd(a, b)\n if ab == 1:\n ans += k\n continue\n for k in range(1, k+1):\n ans += math.gcd(ab,k)\n\nprint(ans)', '\nimport math\n\nk = int(input())\nans = 0\nfor a in range(1, k+1):\n for b in range(1, k+1):\n ab = math.gcd(a, b)\n if ab == 1:\n ans += k\n continue\n for c in range(1, k+1):\n ans += math.gcd(ab,c)\n\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s619380498', 's489302276']
|
[9140.0, 9188.0]
|
[35.0, 598.0]
|
[249, 258]
|
p02713
|
u915879510
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nfrom functools import reduce\n \nk = int(input())\nk+=1\n\nsum = 0\nfor c in range(1,k):\n for b in range(1,k):\n for a in range(1,k):\n sum+=reduce(math.gcd, [a,b,c])', 'import math\nfrom functools import reduce\n \nk = int(input())\nk+=1\n\nsum = 0\nfor a in range(1,k):\n for b in range(a,k):\n for c in range(b,k):\n t = len(set([a,b,c]))\n if t==1:\n sum+= reduce(math.gcd, [a,b,c])\n elif t==2:\n sum+= 3*reduce(math.gcd, [a,b,c])\n else:\n sum+= 6*reduce(math.gcd, [a,b,c])\n\nprint(sum)']
|
['Wrong Answer', 'Accepted']
|
['s591997482', 's472534571']
|
[9564.0, 9632.0]
|
[2206.0, 1073.0]
|
[180, 351]
|
p02713
|
u916662650
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import fractions\n\nK = int(input())\nresult = 0\nsum = 0\n\nfor a in range(1,K+1):\n for b in range(1,K+1):\n for c in range(1,K+1):\n result = fractions.gcd(a, b)\n result = fractions.gcd(result, c)\n sum = sum + result\n\nprint(sum) ', 'import math\nK = int(input())\nresult = 0\nsum = 0\n\nfor a in range(1,K+1):\n for b in range(1,K+1):\n result = math.gcd(a, b)\n for c in range(1,K+1):\n sum += math.gcd(result, c)\n\nprint(sum) \n']
|
['Time Limit Exceeded', 'Accepted']
|
['s253355898', 's381535544']
|
[10656.0, 9172.0]
|
[2206.0, 1407.0]
|
[267, 225]
|
p02713
|
u922172470
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['k = int(input())\n\nsum = 0\nfor a in range(1, k+1):\n for b in range(1, k+1):\n for c in range(1,k+1):\n sum += gcd(gcd(a,b), c)\n\nprint(sum)', 'def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef resolve():\n k = int(input())\n\n tmp = []\n for a in range(1, k+1):\n for b in range(1, k+1):\n tmp.append(gcd(a,b))\n\n ans = 0\n for c in range(1,k+1):\n for i in tmp:\n ans += gcd(i, c)\n \n print(ans)\n \nresolve()']
|
['Runtime Error', 'Accepted']
|
['s587713433', 's434859812']
|
[9172.0, 9300.0]
|
[22.0, 1427.0]
|
[156, 334]
|
p02713
|
u924717835
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nK = int(input())\nsum = 0\nfor a in range(1,K+1):\n for b in range(1,K+1):\n for c in range(1,K+1):\n ans+=math.gcd(math.gcd(a,b),c)\nprint(sum(list))\n', 'import math\nK = int(input())\nsum = 0\nfor a in range(1,K+1):\n for b in range(1,K+1):\n x = math.gcd(a,b)\n for c in range(1,K+1):\n sum+=math.gcd(x,c)\nprint(sum)']
|
['Runtime Error', 'Accepted']
|
['s715219975', 's173122892']
|
[9136.0, 9132.0]
|
[22.0, 1286.0]
|
[178, 185]
|
p02713
|
u927282564
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nfrom functools import reduce\nimport itertools\nimport numpy as np\n\n\ndef gcd_list(numbers):\n return reduce(math.gcd, numbers)\n\n\nK = int(input())\n\nl = [i for i in range(1, K + 1)]\n\ntemp_1 = np.array([])\nfor j in itertools.combinations(l, 3):\n temp_1=np.append(temp_1,gcd_list(list(j)))\n\na=np.sum(temp_1)*6\n\ntemp_2 = np.array([])\n\nfor j in itertools.combinations(l, 2):\n temp_2=np.append(temp_2,gcd_list(list(j[0],j[0],j[1])))\n temp_2=np.append(temp_2,gcd_list(list(j[0],j[1],j[1])))\n \nb=np.sum(temp_2)*3\n\ntemp_3 = np.array([])\nfor i in l:\n temp_3 = np.append(temp_3, gcd_list([i, i, i]))\n\nprint(int(np.sum(temp_3)+a+b))\n', 'import math\nfrom functools import reduce\nimport itertools\nimport numpy as np\n\nK = int(input())\n\n\n\nans = 0\nfor i in range(1, K + 1):\n for j in range(i, K + 1):\n for k in range(j, K + 1):\n if i == j and j == k:\n dup_num = 1\n elif i == j or j == k:\n dup_num = 3\n else:\n dup_num = 6\n ans += math.gcd(math.gcd(i, j), k) * dup_num\n\nprint(ans)\n']
|
['Runtime Error', 'Accepted']
|
['s739017278', 's973114907']
|
[27996.0, 27040.0]
|
[2206.0, 768.0]
|
[647, 436]
|
p02713
|
u928784113
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nfrom fractions import gcd\nfrom copy import deepcopy\nimport math\nimport queue\n\nMod = 1000000007\nimport sys\nsys.setrecursionlimit(100000) \n \ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[py] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n k = int(input())\n ans = 0\n for i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n ans += gcd(gcd(i,j),l)\n\n print(ans)\nif __name__ == "__main__":\n main() ', 'def main(): #startline-------------------------------------------\n k = int(input())\n ans = 0\n for i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n ans += gcd(gcd(i,j),l)\n\n print(ans)\nif __name__ == "__main__":\n main() ', 'import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nfrom fractions import gcd\nfrom copy import deepcopy\nimport math\nimport queue\n\nMod = 1000000007\nimport sys\nsys.setrecursionlimit(100000) \n \ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[py] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n k = int(input())\n ans = 0\n for i in range(k+1):\n for j in range(k+1):\n for l in range(k+1):\n ans += gcd(gcd(i,j),l)\n\n print(ans)\nif __name__ == "__main__":\n main() ', 'import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nfrom fractions import gcd\nfrom copy import deepcopy\nimport math\nimport queue\n\nMod = 1000000007\nimport sys\nsys.setrecursionlimit(100000) \n \ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[py] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n k = int(input())\n ans = 0\n for i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n ans += gcd(gcd(i,j),l)\n\n print(ans)\nif __name__ == "__main__":\n main() ', 'import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nfrom fractions import gcd\nfrom copy import deepcopy\nimport math\nimport queue\nimport numpy as np\n\nMod = 1000000007\nimport sys\nsys.setrecursionlimit(100000) \n \ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[py] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n k = int(input())\n ans = 0\n l = [i for i in range(1,k+1)]\n p_list = list(itertools.combinations_with_replacement(l,3))\n for i in p_list:\n ans += gcd(gcd(i[0],i[1]),i[2])*(6//math.factorial((4-len(set(i)))))\n print(ans)\nif __name__ == "__main__":\n main() ', 'from fractions import gcd\ndef main(): #startline-------------------------------------------\n k = int(input())\n ans = 0\n for i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n ans += gcd(gcd(i,j),l)\n\n print(ans)\nif __name__ == "__main__":\n main() ', 'from fraction import gcd\ndef main(): #startline-------------------------------------------\n k = int(input())\n ans = 0\n for i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n ans += gcd(gcd(i,j),l)\n\n print(ans)\nif __name__ == "__main__":\n main() ', 'from math import gcd\ndef main(): #startline-------------------------------------------\n k = int(input())\n ans = 0\n for i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n ans += gcd(gcd(i,j),l)\n\n print(ans)\nif __name__ == "__main__":\n main() ']
|
['Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Accepted']
|
['s020772100', 's334718329', 's401086591', 's571070558', 's591845037', 's739374196', 's780703436', 's848606297']
|
[11044.0, 9172.0, 11024.0, 10952.0, 123636.0, 10628.0, 9120.0, 9184.0]
|
[2206.0, 21.0, 2206.0, 2206.0, 2209.0, 2206.0, 22.0, 1309.0]
|
[1749, 340, 1743, 1749, 1831, 366, 365, 361]
|
p02713
|
u932868243
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nk=int(input())\nlist=[]\nfor a in range(1,k+1):\n for b in range(1,k+1):\n for c in range(1,k+1):\n list.append(math.gcd((a,b),c))\nprint(sum(list))', 'import math\nk=int(input())\nlist=[]\nfor a in range(1,k+1):\n for b in range(1,k+1):\n for c in range(1,k+1):\n list.append(math.gcd(gcd(a,b),c))\nprint(sum(list))', 'import math\nk=int(input())\nlist=[]\nfor a in range(1,k+1):\n for b in range(1,k+1):\n t=math.gcd(a,b)\n for c in range(1,k+1):\n list.append(math.gcd(t,c))\nprint(sum(list))']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s108036620', 's851671502', 's503994370']
|
[9184.0, 9180.0, 71496.0]
|
[24.0, 21.0, 1509.0]
|
[163, 166, 179]
|
p02713
|
u934788990
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['from math import math\n\nk = int(input())\ncount = 0\nfor i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n count += gcd(gcd(j,l),i)\nprint(count)\n', 'from math import gcd\nK=int(input())\nans=0 \n \nfor i in range(1,K+1):\n for j in range(1,K+1):\n for l in range(1,K+1):\n ans+= gcd(gcd(l,j),i)\n \nprint(ans)\n']
|
['Runtime Error', 'Accepted']
|
['s942908614', 's294611228']
|
[9044.0, 9168.0]
|
[19.0, 1915.0]
|
[181, 161]
|
p02713
|
u941438707
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['n=int(input())\na=0\nfor i in range(n+1):\n for j in range(n+1):\n for k in range(n+1):\n a+=g[g[i][j]][k]\nprint(a)', 'from math import *\ng=[[0]*202 for _ in range(202)]\nfor i in range(1,201):\n for j in range(1,201):\n g[i][j]=gcd(i,j)\nn=int(input())\na=0\nfor i in range(n+1):\n for j in range(n+1):\n for k in range(n+1):\n a+=g[g[i][j]][k]\nprint(a)']
|
['Runtime Error', 'Accepted']
|
['s392921091', 's723897774']
|
[9164.0, 9516.0]
|
[24.0, 1400.0]
|
[131, 257]
|
p02713
|
u941645670
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['n = int(input())\nresult = [0]*n**3\nfor a in range(n):\n for b in range(n):\n for c in range(n):\n if a > b:\n result[n*n*a +n*b + c]= result[n*n*b +n*a + c]\n elif b > c:\n result[n*n*a +n*b + c]= result[n*n*a +n*c + b]\n else:\n result[n*n*a +n*b + c] = gcd(a+1, gcd(b+1,c+1))\nprint(sum(result))', 'n = int(input())\nanswer = 0\n\ndef gcd(i, j):\n while j:\n i, j = j, i % j\n return i\n\nfor a in range(1,n+1):\n for b in range(1,n+1):\n d = gcd(a,b)\n for c in range(1, n+1):\n answer += gcd(c, d)\nprint(answer)']
|
['Runtime Error', 'Accepted']
|
['s438371212', 's146111990']
|
[71376.0, 9140.0]
|
[102.0, 1580.0]
|
[376, 243]
|
p02713
|
u947327691
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['from fractions import gcd\nk=int(input())\nsum=0\nfor l in range(1,k+1):\n for m in range(1,k+1):\n for n in range(1,k+1):\n sum += gcd(gcd(l,m),n)\n\nprint(sum)', 'from fractions import gcd\nk=int(input())\nr1=[]\nr2=[]\nfor l in range(1,k+1):\n for m in range(1,k+1):\n r1.append(gcd(l,m))\n\nfor i in range(len(r1)):\n for j in range(1,k+1):\n r2.append(gcd(r1[i],j))\n\nprint(sum(r2))', 'from math import gcd\nk=int(input())\n\nsum=0\n\nfor i in range(1,k+1):\n for j in range(1,k+1):\n for l in range(1,k+1):\n sum += gcd(gcd(i,j),l)\n\nprint(sum)']
|
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
|
['s344903645', 's397422752', 's505394384']
|
[10652.0, 30244.0, 9176.0]
|
[2206.0, 2206.0, 1930.0]
|
[174, 231, 171]
|
p02713
|
u948233576
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\n\nK=2\ncount = 0\nfor a in range(1,K+1):\n for b in range(1,a+1):\n for c in range(1,b+1):\n print(a,b,c)\n _z=math.gcd(a,b)\n if a==b and b==c:\n k=1\n else:\n k=3\n count += k * math.gcd(_z,c)\nprint(count)\n', 'import math\n\nK=int(input())\ncount = 0\nfor a in range(1,K+1):\n for b in range(1,a+1):\n for c in range(1,b+1):\n _z=math.gcd(a,b)\n count += math.gcd(_z,c)\nprint(count)', 'import math\n\nK=int(input())\ncount = 0\nfor a in range(1,K+1):\n for b in range(1,a+1):\n for c in range(1,b+1):\n _z=math.gcd(a,b)\n if a==b and b==c:\n k=1\n elif a==b or b==c or c==a:\n k=3\n else:\n k=6\n count += k * math.gcd(_z,c)\nprint(count)']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s457555960', 's983391313', 's023197906']
|
[9060.0, 9172.0, 9212.0]
|
[20.0, 450.0, 657.0]
|
[303, 178, 347]
|
p02713
|
u953110527
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nK = int(input())\ncount = 0\nfor i in range(1,K+1):\n for j in range(i,K+1):\n for k in range(1,K+1):\n if i != j:\n count += math.gcd(math.gcd(i,j),k)\n else:\n count += math.gcd(math.gcd(i,j),k)\nprint(count)', 'import math\nK = int(input())\ncount = 0\nfor i in range(1,K+1):\n for j in range(i,K+1):\n for k in range(1,K+1):\n if i != j:\n count += 2 * math.gcd(math.gcd(i,j),k)\n else:\n count += math.gcd(math.gcd(i,j),k)\nprint(count)']
|
['Wrong Answer', 'Accepted']
|
['s263634859', 's698927203']
|
[9192.0, 9064.0]
|
[1332.0, 1359.0]
|
[275, 279]
|
p02713
|
u955123468
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['from math import gcd\nkey = int(input())\nsin = 0\nfor i in range(1,k+1):\n for j in range(1,k+1):\n tmp = gcd(i,j)\n for m in range(1,k+1):\n sin += gcd(m,tmp)\nprint(sin)', 'from math import gcd\nkey = int(input())\nsin = 0\nfor i in range(1,key+1):\n for j in range(1,key+1):\n temp = gcd(i,j)\n for m in range(1,key+1):\n sin += gcd(m,temp)\nprint(sin)']
|
['Runtime Error', 'Accepted']
|
['s634918145', 's059740081']
|
[9108.0, 9184.0]
|
[22.0, 1126.0]
|
[192, 200]
|
p02713
|
u961674365
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['def gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\n\n\nk=input()\nans=0\nfor i in range(1,k+1):\n for j in range(1,k+1):\n d=gcd(i,j)\n for l in range(1,k+1):\n if d!=1:\n ans+=gcd(d,l)\n else:\n ans+=1\n\n\nprint(ans)', 'import sys\nsys.setrecursionlimit(4100000)\n\n\ndef gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\n\n\nk=int(input())\nans=0\nfor i in range(1,k+1):\n for j in range(1,k+1):\n d=gcd(i,j)\n for l in range(1,k+1):\n if d!=1:\n ans+=gcd(d,l)\n else:\n ans+=1\n\n\nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s654396266', 's274743551']
|
[9128.0, 9196.0]
|
[21.0, 1894.0]
|
[254, 303]
|
p02713
|
u961945062
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\nN = int(input())\ni = 0\n\nfor a in range(1, N+1):\n for b in range(1, N+1):\n for c in range(1, N+1):\n i += gcd(a, b, c)\n', 'from math import gcd \nN = int(input())\ni = 0\n \nfor a in range(1, N+1):\n for b in range(1, N+1):\n for c in range(1, N+1):\n i += gcd(gcd(a, b), c)\n \nprint(i)']
|
['Wrong Answer', 'Accepted']
|
['s810815684', 's948368582']
|
[9628.0, 9176.0]
|
[2205.0, 1889.0]
|
[237, 187]
|
p02713
|
u964299793
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['k=int(input())\nans=0\nfrom fractions import gcd\nimport functools \nfor a in range(1,k+1):\n for b in range(1,k+1):\n for c in range(1,k+1):\n @functools.lru_cache(None) \n def gc(x,y):\n if x>y:\n x,y=y,x\n return gcd(x,y)\n\n ans+=gcd(a,gcd(b,c))\nprint(ans)\n\n', 'k=int(input())\nans=0\nfrom fractions import gcd\nfor a in range(1,k+1):\n for b in range(1,k+1):\n t=gcd(a,b)\n for c in range(1,k+1):\n ans+=gcd(c,t)\nprint(ans)\n\n', 'k=int(input())\nans=0\nfrom fractions import gcd\nfor a in range(1,k+1):\n for b in range(1,k+1):\n for c in range(1,k+1):\n# print(a,b,c)\n ans+=gcd(a,gcd(b,c))\nprint(ans)\n\n', 'k=int(input())\nans=0\nfrom math import gcd\nfor a in range(1,k+1):\n for b in range(1,k+1):\n t=gcd(a,b)\n for c in range(1,k+1):\n ans+=gcd(c,t)\nprint(ans)\n\n']
|
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
|
['s069678845', 's239113918', 's901201686', 's117031255']
|
[10752.0, 10616.0, 10668.0, 9172.0]
|
[2206.0, 2205.0, 2206.0, 1117.0]
|
[341, 185, 199, 180]
|
p02713
|
u966311314
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\nK = int(input())\nsum = 0\nfor i in range(1, K+1):\n for j in range(1, K+1):\n for k in range(1, K+1):\n sum += gcd(i,j,k)\nprint(sum)', 'import math\nK=int(input())\nans=0\nfor i in range(1,K+1):\n for j in range(1,K+1):\n tmp=math.gcd(i,j)\n for k in range(1,K+1):\n ans+=math.gcd(tmp,k) \nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s589155362', 's505058876']
|
[9168.0, 9184.0]
|
[23.0, 1392.0]
|
[207, 192]
|
p02713
|
u966880389
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import numpy as np\nimport math\n\nnum = int(input())\na = 1\nsum = 0\n\ndef gcd(a, b, c):\n num = np.array([a, b, c])\n return np.gcd(np.gcd.reduce(num))\n\ndef loopC(a, b, num):\n c = 1\n sum = 0\n while c <= num:\n ans = gcd(a, b, c)\n sum += ans\n c += 1\n return sum\n\ndef loopB(a, num):\n b = 1\n sum = 0\n while b <= num:\n ans = loopC(a, b, num)\n b += 1\n sum += ans\n return sum\n\nwhile a <= num:\n ans = loopB(a, num)\n sum += ans\n a += 1\n\nprint(sum)', 'import math\n\nnum = int(input())\nsum = 0\n\nfor a in range(1, num + 1):\n for b in range(1, num + 1):\n gcd_ab = math.gcd(a, b)\n for c in range(1, num + 1):\n sum += math.gcd(gcd_ab, c)\n\nprint(sum)']
|
['Runtime Error', 'Accepted']
|
['s764182172', 's667061094']
|
[27180.0, 9128.0]
|
[108.0, 1345.0]
|
[469, 203]
|
p02713
|
u968404618
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nk = int(input())\n\nans = 0\nfor a in range(k+1, 1, -1):\n for b in range(k+1, 1, -1):\n for c in range(k+1, 1, -1):\n ans += math.gcd(a, math.gcd(b, c))\nprint(ans)', 'import math\n\nk = int(input())\n\nans = 0\nfor a in range(1, k+1):\n for b in range(1, k+1):\n tmp = math.gcd(a, b)\n for c in range(1, k+1):\n ans += math.gcd(tmp, c)\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s540386231', 's253682728']
|
[9184.0, 9184.0]
|
[2205.0, 1338.0]
|
[191, 198]
|
p02713
|
u973972117
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['N = int(input())\ns = 0\nfor i in range(0,N):\n if (i+1) % 3 1= 0 or (i+1) % 5 != 0:\n s = s + (i+1)\nprint(s)', 'K = int(input())\nS = 0\n\ndef gcd(a,b):\n while b != 0:\n a, b = b, a % b\n if b ==0:\n return a\nA1 = [0,0]\nA2 = [0,0,0]\nfor i in range(1, K):\n S = S + i\n\nif K > 1:\n for j in range(1, K):\n A1[0] = j\n for k in range(j+1,K+1):\n A1[1] = k\n S += 6 * gcd(A1[1],A1[0])\n\nif K > 2:\n for i1 in range(1, K-1):\n A2[0] = i1\n for k1 in range(i1+1, K):\n A2[1] = k1\n for j1 in range(k1+1,K+1):\n A2[2] = j1\n G3 = gcd(A2[2],A2[1])\n if G3 >= A2[0]:\n S += 6 * gcd(G3,A2[0])\n else:\n S += 6 * gcd(A2[0],G3)\n \nprint(S)', 'K = int(input())\nS = 0\n\ndef gcd(a,b):\n while b != 0:\n a, b = b, a % b\n if b ==0:\n return a\nA1 = [0,0]\nA2 = [0,0,0]\nfor i in range(1, K+1):\n S = S + i\n\nif K > 1:\n for j in range(1, K):\n A1[0] = j\n for k in range(j+1,K+1):\n A1[1] = k\n S += 6 * gcd(A1[1],A1[0])\n\nif K > 2:\n for i1 in range(1, K-1):\n A2[0] = i1\n for k1 in range(i1+1, K):\n A2[1] = k1\n for j1 in range(k1+1,K+1):\n A2[2] = j1\n G3 = gcd(A2[2],A2[1])\n if G3 >= A2[0]:\n S += 6 * gcd(G3,A2[0])\n else:\n S += 6 * gcd(A2[0],G3)\nprint(S)']
|
['Runtime Error', 'Wrong Answer', 'Accepted']
|
['s458517860', 's664214740', 's571420563']
|
[9004.0, 9252.0, 9240.0]
|
[22.0, 971.0, 899.0]
|
[109, 713, 694]
|
p02713
|
u975445930
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nfrom functools import reduce\n\nk = int(input())\nans = 0\n\ndef gcd(numbers):\n return reduce(math.gcd, numbers)\n\nfor i in range(k):\n for j in range(k):\n for k in range(k):\n ans += gcd([i+1, j+1, k+1])\n\nprint(ans)', 'from math import gcd\n\ndef solve():\n K = int(input())+1\n ans = 0\n for i in range(1,K):\n for j in range(1,K):\n for k in range(1,K):\n ans += gcd(gcd(i, j),k)\n return ans\n\nprint(solve())']
|
['Wrong Answer', 'Accepted']
|
['s004453983', 's843211935']
|
[9628.0, 9176.0]
|
[32.0, 1402.0]
|
[232, 227]
|
p02713
|
u982152304
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import numpy as np\nimport math\nK = int(input())\nmemo = np.zeros((K,K),int)\ns = 0\nfor i in range(K):\n for j in range(i,K+1):\n for k in range(j,K+1):\n if memo[i][j] != 0:\n if memo[memo[i][j]-1][k] != 0:\n s += memo[memo[i][j]-1][k]\n else:\n memo[memo[i][j]-1][k] = math.gcd(memo[i][j],k+1)\n memo[k][memo[i][j]-1] = memo[memo[i][j]-1][k]\n s += memo[k][memo[i][j]-1]\n else:\n \n memo[i][j] = math.gcd(i+1,j+1)\n memo[j][i] = memo[i][j]\n if memo[memo[i][j]-1][k] != 0:\n s += memo[memo[i][j]-1][k]\n else:\n memo[memo[i][j]-1][k] = math.gcd(memo[i][j],k+1)\n memo[k][memo[i][j]-1] = memo[memo[i][j]-1][k]\n s += memo[k][memo[i][j]-1]\nprint(s)\n', 'import numpy as np\nimport math\nK = int(input())\nmemo = np.zeros((K,K),int)\ns = 0\nfor i in range(K):\n for j in range(i,K):\n for k in range(j,K):\n if i == j and j == k:\n rate = 1\n elif i == j or j == k or i == k:\n rate = 3\n else:\n rate = 6\n s += math.gcd(math.gcd(i+1,j+1),k+1) * rate\nprint(s)\n']
|
['Runtime Error', 'Accepted']
|
['s251235154', 's061579417']
|
[27292.0, 27204.0]
|
[106.0, 778.0]
|
[763, 337]
|
p02713
|
u982749462
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['import math\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(math.gcd, numbers)\n \nk = int(input())\ns = 0\nfor i in range(k):\n for j in range(k):\n for h in range(k):\n s += gcd(i,j,h)\nprint(s)', 'import math\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(math.gcd, numbers)\n \nn,k = map(int, input().split())\ns = 0\nfor i in range(k):\n for j in range(k):\n for h in range(k):\n s += gcd(i+1,j+1,h+1)\nprint(s)\n', 'import math\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(math.gcd, numbers)\n \nk = int(input())\ns = 0\nl = []\nfor i in range(k):\n for j in range(k):\n l.append(math.gcd(i+1,j+1))\nfor h in range(k):\n for n in l:\n s += math.gcd(h+1, n)\nprint(s)\n']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s782656090', 's790405359', 's291048121']
|
[9640.0, 9580.0, 9848.0]
|
[2205.0, 23.0, 1414.0]
|
[278, 300, 332]
|
p02713
|
u983327168
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['k=int(input())\n ans=0\n for x in range(1,k+1):\n for y in range(1,k+1):\n for z in range(1,k+1):\n if math.gcd(x,y)==1:\n ans+=1\n \n elif math.gcd(math.gcd(x,y),z)==1: \n ans+=1\n else: \n ans+=math.gcd(math.gcd(x,y),z)\n print(ans)', 'import numpy as np\nK=int(input())\nx = np.arange(1, K + 1)\nnums = np.gcd.outer(np.gcd.outer(x, x), x)\nprint(nums.sum())']
|
['Runtime Error', 'Accepted']
|
['s981003200', 's088247560']
|
[8952.0, 89112.0]
|
[24.0, 214.0]
|
[363, 118]
|
p02713
|
u984276646
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['K = int(input())\ndef gcd(x, y):\n a, b = x, y\n while b != 0:\n a, b = b, a % b\n return a\ngcds = [[0 for j in range(K)] for i in range(K)]\nfor i in range(K):\n for j in range(K):\n gcds[i][j] = gcd(i+1, j+1)\nS = 0\nfor i in range(K):\n for j in range(K):\n for k in range(K):\n S += gcds[gcds[i][j]][k]\nprint(S)', 'K = int(input())\nmod = int(1e9) + 7\nX = [0 for _ in range(K)]\ndef doubling(n, m):\n y = 1\n base = n\n while m != 0:\n if m % 2 == 1:\n y *= base\n y %= mod\n base *= base\n base %= mod\n m //= 2\n return y\nSS = 0\nfor i in range(K, 0, -1):\n d = K // i\n S = doubling(d, 3)\n if d > 1:\n for j in range(2, d+1):\n S -= X[j*i-1]\n S %= mod\n X[i-1] = S\n SS += i * S\n SS %= mod\nprint(SS)']
|
['Runtime Error', 'Accepted']
|
['s161042541', 's613636542']
|
[9484.0, 9164.0]
|
[1310.0, 22.0]
|
[321, 413]
|
p02713
|
u986025116
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['from math import gcd\nN = int(input())\nsum = 0\nfor i in range(1, N+1):\n for j in range(1, N+1):\n\t\ttmp=gcd(j,k);\n for k in range(1, N+1):\n sum += gcd(i, tmp)\nprint(sum)', 'from math import gcd\nN = int(input())\nsum = 0\nfor i in range(1, N+1):\n for j in range(1, N+1):\n\t\ttmp=gcd(j,k)\n for k in range(1, N+1):\n sum += gcd(i, tmp)\nprint(sum)\n', 'from math import gcd\nN = int(input())\nsum = 0\nfor i in range(1, N+1):\n for j in range(1, N+1):\n tmp=gcd(i,j)\n for k in range(1, N+1):\n sum += gcd(tmp,k)\nprint(sum)']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s011833412', 's862163959', 's124025819']
|
[8960.0, 9028.0, 9176.0]
|
[22.0, 22.0, 1204.0]
|
[187, 187, 191]
|
p02713
|
u991269553
| 2,000
| 1,048,576
|
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
|
['k = int(input())\n\n#acd_list = []\nall_num = [i for i in range(1,k + 1)]\nans = 0 \n\n#comb_list = list(itertools.combinations(all_num, 3))\n#print(comb_list)\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(math.gcd, numbers)\n\nresult = []\nfor i in all_num:\n for j in all_num:\n for k in all_num:\n result.append([i, j, k])\n\nfor a,b,c in result:\n#for a,b,c in comb_list:\n s = gcd(a, b,c)\n ans += s\nprint(ans)', 'import math\n \nk = int(input()) + 1\nans = 0\n \nfor a in range(1, k):\n for b in range(1, k):\n d = math.gcd(a, b)\n for c in range(1, k):\n ans += math.gcd(d, c)\n \nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s370346280', 's376553403']
|
[482856.0, 9180.0]
|
[2218.0, 1431.0]
|
[466, 196]
|
p02714
|
u004482945
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["n=int(input())\ns=list(input())\nans=s.count('R')*s.count('G')*s.count('B')\nfor i in range(n):\n if s[i]=='R':\n s[i]=1\n elif s[i]=='G':\n s[i]=2\n elif s[i]=='B':\n s[i]=4\nfor i in range(n):\n for j in range(i+1,n):\n k=2*j-i\n if k>=n:\n continue\n if s[i]+s[j]+s[k]==7:\n ans-=1\nprint(ans)\n", "n=int(input())\ns=list(input())\nans=s.count('R')*s.count('G')*s.count('B')\nfor i in range(n):\n if s[i]=='R':\n s[i]=1\n elif s[i]=='G':\n s[i]\n elif s[i]=='B':\n s[i]=4\nfor i in range(n):\n for j in range(i+1,n):\n k=2*j-i\n if k>=n:\n continue\n if s[i]+s[j]+s[k]==7:\n ans-=1\nprint(ans)", "n=int(input())\ns=list(input())\nans=s.count('R')*s.count('G')*s.count('B')\nfor i in range(n):\n if s[i]=='R':\n s[i]=1\n elif s[i]=='G':\n s[i]\n elif s[i]=='B':\n s[i]=4\nfor i in range(n):\n for j in range(i+1,n):\n k=2*j-i\n if k>=n:\n continue\n if s[i]+s[j]+s[k]==7:\n ans-=1\nprint(ans)", "n=int(input())\ns=list(input())\nans=s.count('R')*s.count('G')*s.count('B')\nfor i in range(n):\n if s[i]=='R':\n s[i]=1\n elif s[i]=='G':\n s[i]=2\n elif s[i]=='B':\n s[i]=4\nfor i in range(n):\n for j in range(i+1,n):\n k=2*j-i\n if k>=n:\n continue\n if s[i]+s[j]+s[k]==7:\n ans-=1\nprint(ans)\n"]
|
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
|
['s010979186', 's158219774', 's936458208', 's734710205']
|
[8948.0, 9032.0, 9220.0, 9148.0]
|
[21.0, 24.0, 24.0, 1691.0]
|
[331, 328, 329, 323]
|
p02714
|
u017050982
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['N = int(input())\nR = []\nG = []\nB = []\ns =input()\nans = 0\nfor i in range(N):\n if s[i] == "R":\n R.append(i)\n elif s[i] == "G":\n G.append(i)\n else:\n B.append(i)\nsB = set(B)\nprint(sB)\nans = len(R) * len(G) * len(B)\nfor r in R:\n for g in G:\n i = min(r,g)\n j = max(r,g)\n sa = j - i\n if i - sa in sB:\n ans -= 1\n if j + sa in sB:\n ans -= 1\n if (i + j) / 2 in sB:\n ans -= 1\nprint(ans)', 'N = int(input())\nR = []\nG = []\nB = []\ns =input()\nans = 0\nfor i in range(N):\n if s[i] == "R":\n R.append(i)\n elif s[i] == "G":\n G.append(i)\n else:\n B.append(i)\nsB = set(B)\nans = len(R) * len(G) * len(B)\nfor r in R:\n for g in G:\n i = min(r,g)\n j = max(r,g)\n sa = j - i\n if i - sa in sB:\n ans -= 1\n if j + sa in sB:\n ans -= 1\n if (i + j) / 2 in sB:\n ans -= 1\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s208372647', 's273006827']
|
[9328.0, 9340.0]
|
[1261.0, 1311.0]
|
[483, 473]
|
p02714
|
u030726788
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["n = int(input())\ns = input()\n\nr = [0] * n\ng = [0] * n\nb = [0] * n\ndc = {'R':[0]*n,'G':[0]*n,'B':[0]*n}\nfor i in range(n-1):\n dc['R'][i] = dc['R'][i + 1]\n dc['G'][i] = dc['G'][i + 1]\n dc['B'][i] = dc['B'][i + 1]\n dc[s[i]] += 1\n# print(r)\n# print(g)\n# print(b)\ndcc = {('R','G'):'B',('R','B'):'G',('B','G'):'R',('G','R'):'B',('B','R'):'G',('G','B'):'R'}\nif(n <= 3):print(0)\nelse:\n c = 0\n for i in range(n):\n for j in range(i+1,n):\n if(s[i] == s[j]):continue\n d = j - i\n c += dc[dcc[(s[i],s[j])]][j]\n k = j + d\n if(k < n):\n if(s[k] == dcc[(s[i],s[j])]):c -= 1\nprint(c)", "n = int(input())\ns = input()\nd = [0,0,0]\nfor i in s:\n if(i == 'R'):d[0] += 1\n elif(i == 'G'):d[1] += 1\n elif(i == 'B'):d[2] += 1\nc = d[0] * d[1] * d[2]\n\nfor i in range(n):\n for j in range(i+1,n):\n k = 2 * j - i\n if(k >= n):continue\n if(s[i] == s[j]):continue\n if(s[j] == s[k]):continue\n if(s[i] == s[k]):continue\n c -= 1\n\nprint(c)"]
|
['Runtime Error', 'Accepted']
|
['s135307225', 's543877125']
|
[9284.0, 9216.0]
|
[23.0, 1884.0]
|
[659, 384]
|
p02714
|
u033524082
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['n=int(input())\ns=input()\nans=0\nr=[]\ng=[]\nb=[]\nfor i in range(n):\n tmp=s[i]\n if tmp=="R":\n r.append(i+1)\n elif tmp=="G":\n g.append(i+1)\n else:\n b.append(i+1)\nfor i in r:\n for j in g:\n for k in b:\n if (i<j and j<k and i<k) or (i<k and k<j and i<j):\n continue\n if j-i==k-j:\n continue\n else:\n ans+=1\nprint(ans)', 'n=int(input())\ns=input()\nr=s.count("R")\ng=s.count("G")\nb=s.count("B")\nans=r*g*b\nfor i in range(n):\n for j in range(n):\n if i+j+j>=n:\n break\n s1=s[i]\n s2=s[i+j]\n s3=s[i+j*2]\n if s1!=s2 and s2!=s3 and s1!=s3:\n ans-=1\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s257772468', 's475850915']
|
[9260.0, 9212.0]
|
[2205.0, 1760.0]
|
[427, 285]
|
p02714
|
u036514535
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["N = int(input())\nS = input()\nSr = Sg = Sb = 0\nfor c in S:\n if c == 'R':\n Sr += 1\n elif c == 'G':\n Sg += 1\n else:\n Sb += 1\nA = Sr * Sg * Sb\nfor sep in range(1,(N-1)//2):\n for i in range(N-2*sep):\n if S[i] != S[i+sep] and S[i+sep] != S[i+2*sep] and S[i] != S[i+2*sep]:\n A -= 1\nprint(A)\n", "N = int(input())\nS = input()\nSr = Sg = Sb = 0\nfor c in S:\n if c == 'R':\n Sr += 1\n elif c == 'G':\n Sg += 1\n else:\n Sb += 1\nA = Sr * Sg * Sb\nfor sep in range(1,(N+1)//2):\n for i in range(N-2*sep):\n if S[i] != S[i+sep] and S[i+sep] != S[i+2*sep] and S[i] != S[i+2*sep]:\n A -= 1\nprint(A)\n"]
|
['Wrong Answer', 'Accepted']
|
['s133073953', 's718184076']
|
[9200.0, 9184.0]
|
[1352.0, 1395.0]
|
[335, 335]
|
p02714
|
u038613676
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['# -*- coding: utf-8 -*-\n\nimport sys\nargs = sys.argv\n\ndebug_flg = False\ndef debug(val1,val2="",val3="",val4=""):\n global debug_flg\n if debug_flg:\n print(val1,val2,val3,val4,sep=" , ")\n\nif len(args) != 2:\n n= int(input())\n s= input()\nelse:\n debug_flg = True\n if args[1] == "2":\n n=39\n s="RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"\n else:\n n=4\n s="RRGB"\n\nsnum = []\nfor i in range(0,n):\n snum.append(s[i-1])\n\nret =0\nfor i in range(1,n-1):\n for j in range(i,n):\n if snum[i-1] == snum[j-1]:\n continue\n for k in range(j,n+1):\n if j-i == k-j:\n continue\n if snum[i-1] == snum[k-1]:\n continue\n if snum[j-1] == snum[k-1]:\n continue\n ret += 1\n\nprint(ret)\n\n\n\n\n', '# -*- coding: utf-8 -*-\n\nimport sys\nargs = sys.argv\n\ndebug_flg = False\ndef debug(val1,val2="",val3="",val4=""):\n global debug_flg\n if debug_flg:\n print(val1,val2,val3,val4,sep=" , ")\n\nif len(args) != 2:\n n= int(input())\n s= input()\nelse:\n debug_flg = True\n if args[1] == "2":\n n=39\n s="RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"\n else:\n n=4\n s="RRGB"\n\nsnum = []\nfor i in range(0,n):\n if s[i-1] == "R":\n snum.append(0)\n elif s[i-1] == "G":\n snum.append(1)\n elif s[i-1] == "B":\n snum.append(2)\n\nret =0\nfor i in range(1,n-1):\n for j in range(i,n):\n if snum[i-1] == snum[j-1]:\n continue\n for k in range(j,n+1):\n if j-i == k-j:\n continue\n if snum[i-1] == snum[k-1]:\n continue\n if snum[j-1] == snum[k-1]:\n continue\n ret += 1\n\nprint(ret)', 'def main():\n n= int(input())\n s= input()\n\n r = s.count("R")\n g = s.count("G")\n b = s.count("B")\n\n ans = r * g * b\n snum = tuple(s[:])\n for i in range(1,n-1):\n for j in range(i,n):\n k = j * 2 - i\n if k > n:\n break\n\n if snum[i-1] != snum[j-1] and snum[i-1] != snum[k-1] and snum[j-1] != snum[k-1]:\n ans -= 1\n\n print(ans)\n\n\nif __name__ == \'__main__\':\n main()\n\n']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s039042564', 's548407187', 's548426615']
|
[9244.0, 9204.0, 9128.0]
|
[2205.0, 2205.0, 1064.0]
|
[821, 931, 457]
|
p02714
|
u049679412
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["import collections\nn = int(input())\na = list(input())\nb = collections.Counter(a)\nans =b['R']*b['G']*b['B']\nprint(b,ans)\nfor i in range(n-2):\n for j in range(i+1,n-1):\n if a[i] == a[j]:\n continue\n c = j*2 -i\n if c < n:\n if a[i] != a[j] and a[i] != a[c] and a[j] != a[c]:\n ans -= 1\nprint(ans)", "import sys\ninput = sys.stdin.readline\nn = int(input())\ns = input()\ns = s.replace('R','0')\ns = s.replace('G','1')\ns = s.replace('B','2')\ns = tuple(map(int,s))\nrgb = [[0 for _ in range(3)] for _ in range(n+1)]\nfor i in range(n):\n for j in range(3):\n rgb[i+1][j] = rgb[i][j]\n rgb[i+1][s[i]] = rgb[i][s[i]] +1\nrgb = tuple(rgb)\nans = 0\nfor i in range(n):\n a = s[i]\n for j in range(i+1,n):\n b = s[j]\n if a != b:\n c = 3 -a- b\n ans += rgb[n][c] - rgb[j+1][c]\n if 2*j-i < n and s[2*j-i] == c:\n ans -= 1\n\nprint(ans)\n", "import collections\nn = int(input())\na = input()\na = a.replace('R','1')\na = a.replace('G','2')\na = a.replace('B','3')\na = tuple(map(int,list(a)))\nb = collections.Counter(a)\nans =b[3]*b[1]*b[2]\nfor i in range(n-2):\n for j in range(i+1,n):\n if a[i] == a[j]:\n continue\n c = j*2 -i\n if c < n:\n if a[i]+a[j]+a[c]==6:\n ans -= 1\n else:\n break\nprint(ans)"]
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s571719402', 's825305893', 's501119685']
|
[9440.0, 9276.0, 9424.0]
|
[2110.0, 24.0, 1186.0]
|
[351, 587, 424]
|
p02714
|
u050805798
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['from sys import stdin\nn = int(input())\ns = stdin.readline()\nrind = []\ngind = []\nbind = []\nans = 0\nfor i in range(n):\n if s[i] == "R":\n rind.append(i+1)\n elif s[i] == "G":\n gind.append(i+1)\n else:\n bind.append(i+1)\nprint(rind,gind,bind)\nfor i in range(len(rind)):\n for j in range(len(gind)):\n for k in range(len(bind)):\n ind = [rind[i],gind[j],bind[k]]\n a = sorted(ind)\n if a[0] + a[2] != 2*a[1]:\n ans += 1\nprint(ans)\n', 'from sys import stdin\nn = int(input())\ns = stdin.readline()\nr = 0\ng = 0 \nb = 0\nfor i in range(n):\n if s[i] == "R":\n r += 1\n elif s[i] == "G":\n g += 1\n else:\n b += 1\ncount1 = r*g*b\ncount2 = 0\nfor i in range(0,n-3):\n for j in range(i+1,n-2):\n if 2*j-i<=n-1:\n if (s[i] != s[j])and(s[i] != s[2*j-i])and(s[j] != s[2*j-i]):\n count2 += 1\nprint(count1-count2)', 'from sys import stdin\nn = int(input())\ns = stdin.readline()\nrind = []\ngind = []\nbind = []\nans = 0\nfor i in range(n):\n if s[i] == "R":\n rind.append(i+1)\n elif s[i] == "G":\n gind.append(i+1)\n else:\n bind.append(i+1)\nfor i in range(len(rind)):\n for j in range(len(gind)):\n for k in range(len(bind)):\n if (rind[i]+gind[j]!=2*bind[k])and(gind[j]+bind[k]!=rind[i])and(bind[k]+rind[i]!=gin[j]):\n ans += 1\nprint(ans)\n', 'from sys import stdin\nn = int(input())\ns = stdin.readline()\nr = 0\ng = 0 \nb = 0\nfor i in range(n):\n if s[i] == "R":\n r += 1\n elif s[i] == "G":\n g += 1\n else:\n b += 1\ncount1 = r*g*b\ncount2 = 0\nfor i in range(0,n-2):\n for j in range(i+1,n-1):\n if 2*j-i<=n-1:\n if (s[i] != s[j])and(s[i] != s[2*j-i])and(s[j] != s[2*j-i]):\n count2 += 1\nprint(count1-count2)']
|
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
|
['s333178127', 's425816750', 's553064342', 's506779649']
|
[9224.0, 9220.0, 9284.0, 9248.0]
|
[2206.0, 1983.0, 21.0, 1996.0]
|
[505, 416, 475, 416]
|
p02714
|
u052244548
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["import itertools\nfrom collections import Counter\n\nN = int(input())\nS = input()\n\nC=Counter(S)\nr = C['R']\ng = C['G']\nb = C['B']\n\n\ncnt = r * g * b\n\nfor i in range(0,N-2):\n for j in range(i,N-1):\n k = j + j - i\n if k < N:\n if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]):\n cnt -= 1\n\nprint(cnt)", "import itertools\nfrom collections import Counter\n\nN = int(input())\nS = input()\n\nC=Counter(S)\nr = C['R']\ng = C['G']\nb = C['B']\n\n\ncnt = r * g * b\n\nsum = 0\nfor i in range(0,N-2):\n for j in range(i,N-1):\n k = j + j - i\n if k < N\n if (S[i] != S[j]) and (S[i] != S[k] and S[j] != S[k]):\n cnt -= 1\n\nprint(cnt)\n", "from collections import Counter\n\ndef SUMCHK():\n N = int(input())\n S = input()\n\n C=Counter(S)\n r = C['R']\n g = C['G']\n b = C['B']\n\n\n cnt = r * g * b\n\n for i in range(0,N-2):\n for j in range(i,N-1):\n k = j + j - i\n if k < N:\n if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n cnt -= 1\n\n print(cnt)\n\nSUMCHK()\n"]
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s022584843', 's446252140', 's890981153']
|
[8924.0, 9052.0, 9484.0]
|
[26.0, 22.0, 1055.0]
|
[335, 346, 398]
|
p02714
|
u053035261
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["n = int(input())\ns = input()\nans = 0\nans_list = []\n\nR_index = []\nG_index = []\nB_index = []\n\nfor i in range(n):\n if s[i] == 'R':\n R_index.append(i)\n elif s[i] == 'G':\n G_index.append(i)\n elif s[i] == 'B':\n B_index.append(i)\n\nans = len(R_index) * len(G_index) * len(B_index)\n\nfor j in range(1, n-1):\n for i in range(min(n-j-1,j)):\n if s[j-i] != s[j] and s[j] != s[j+i] and s[j-i] != s[j+i]:\n ans -= 1\n\n\nprint(ans)\n", "n = int(input())\ns = input()\nans = 0\nans_list = []\n\nR_index = []\nG_index = []\nB_index = []\n\nfor i in range(n):\n if s[i] == 'R':\n R_index.append(i)\n elif s[i] == 'G':\n G_index.append(i)\n elif s[i] == 'B':\n B_index.append(i)\n\nans = len(R_index) * len(G_index) * len(B_index)\n\nfor j in range(1, n-1):\n for i in range(min(n-j-1,j)+1):\n # print(j,i)\n # print(min(n-j-1,j))\n #\n # print(s[j-i],s[j],s[j+i])\n if s[j-i] != s[j] and s[j] != s[j+i] and s[j-i] != s[j+i]:\n # print('here')\n ans -= 1\n\nprint(ans)\n"]
|
['Wrong Answer', 'Accepted']
|
['s251118573', 's118664237']
|
[9328.0, 9264.0]
|
[1162.0, 1223.0]
|
[463, 589]
|
p02714
|
u061566631
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['import sys\nimport collections\n\n\ndef main():\n input = sys.stdin.readline\n N = int(input())\n S = input()\n A = S.count(\'R\')*S.count(\'G\')*S.count(\'B\')\n total = 0\n for j in range(1, N-1):\n for i in range(j):\n k = 2*j-i\n order += 1\n if k < len(S):\n if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n total += 1\n print(A - total)\n\n\ndef main2():\n N = int(input())\n S = input()\n A = S.count(\'R\')*S.count(\'G\')*S.count(\'B\')\n order = 0\n for i in range(N-2):\n for j in range(i+1, N-1):\n order += 1\n if 2*j-i < N:\n if S[i] != S[j] and S[i] != S[2*j-i] and S[j] != S[2*j-i]:\n A -= 1\n print(A)\n print(order)\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\n\n\ndef main():\n input = sys.stdin.readline\n N = int(input())\n S = input().strip()\n A = S.count(\'R\')*S.count(\'G\')*S.count(\'B\')\n assert 1 <= N <= 4000\n assert N == len(S)\n total = 0\n for j in range(1, N-1):\n for i in range(j):\n k = 2*j-i\n if k < len(S):\n if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n total += 1\n print(A - total)\n\n\nif __name__ == "__main__":\n main()\n']
|
['Runtime Error', 'Accepted']
|
['s069615126', 's518396221']
|
[9368.0, 9148.0]
|
[23.0, 1449.0]
|
[812, 474]
|
p02714
|
u088115428
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['n = int(input())\ns = input()\nr = s.count("R");g = s.count("G");b = s.count("B")\ncount = r*g*b\nprint(count)\nfor j in range(n):\n for i in range(j):\n if (k:=2*j-i)<n:\n if s[i]!=s[k]!=s[j]!=s[i]:\n count-=1 \nprint(count)', 'n = int(input())\ns = input()\nr,g,b = 0,0,0\nr = s.count("R");g = s.count("G");b = s.count("B")\ncount = r*g*b\nprint(count)\nfor j in range(n):\n for i in range(j):\n if (k:=2*j-i)<n:\n if s[i]!=s[k]!=s[j]!=s[i]:\n count-=1 \nprint(count)', 'n = int(input())\ns = input()\nr,g,b = 0,0,0\nr = s.count("R");g = s.count("G");b = s.count("B")\nk=0 \ncount = r*g*b\nprint(count)\nfor j in range(n):\n for i in range(j):\n if (k==2*j-i)<n:\n if s[i]!=s[k]!=s[j]!=s[i]:\n count-=1 \nprint(count)', 'n = int(input())\ns = input()\nr = s.count("R");g = s.count("G");b = s.count("B")\ncount = r*g*b\nfor j in range(n):\n for i in range(j):\n if (k:=2*j-i)<n:\n if s[i]!=s[k]!=s[j]!=s[i]:\n count-=1 \nprint(count)\n']
|
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s603727295', 's620585152', 's699383982', 's880776392']
|
[9196.0, 9144.0, 9200.0, 9192.0]
|
[1688.0, 1804.0, 2206.0, 1725.0]
|
[233, 247, 255, 221]
|
p02714
|
u094191970
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['k=int(input())\nl=[1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]\nprint(l[k-1])', "from collections import Counter\n\nn=int(input())\ns=input()\nc=Counter(s)\n\nans=c['R']*c['G']*c['B']\n\nlim=n//2\nfor i in range(1,n//2+1):\n for j in range(i,n-i):\n l=s[j-i]\n m=s[j]\n r=s[j+i]\n if l!=m and m!=r and r!=l:\n ans-=1\n\nprint(ans)"]
|
['Runtime Error', 'Accepted']
|
['s399931659', 's292405314']
|
[9384.0, 9408.0]
|
[22.0, 1304.0]
|
[1670, 250]
|
p02714
|
u104282757
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['def solve(n, s):\n\n r_list = [i for i in range(n) if s[i] == "R"]\n g_list = [i for i in range(n) if s[i] == "G"]\n \n b_dict = {i: 1 for i in range(n) if s[i] == "B"}\n\n res = len(r_list) * len(g_list) * len(b_list)\n for i in r_list:\n for j in g_list:\n # candidate\n m, n = min(i, j), max(i, j)\n if n + (n - m) in b_dict.keys():\n res -= 1\n if m - (n - m) in b_dict.keys():\n res -= 1\n if (n - m) % 2 == 0 and (n + m) // 2 in b_dict.keys():\n res -= 1\n\n return res\n\n\ndef main():\n n = int(input())\n s = input()\n res = solve(n, s)\n print(res)\n\n\ndef test():\n assert solve(4, "RRGB") == 1\n assert solve(39, "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB") == 1800\n\n\nif __name__ == "__main__":\n test()\n main()\n', 'def solve(n, s):\n\n r_list = [i for i in range(n) if s[i] == "R"]\n g_list = [i for i in range(n) if s[i] == "G"]\n \n b_dict = {i: 1 for i in range(n) if s[i] == "B"}\n\n res = len(r_list) * len(g_list) * len(b_dict.keys())\n for i in r_list:\n for j in g_list:\n # candidate\n m, n = min(i, j), max(i, j)\n if n + (n - m) in b_dict.keys():\n res -= 1\n if m - (n - m) in b_dict.keys():\n res -= 1\n if (n - m) % 2 == 0 and (n + m) // 2 in b_dict.keys():\n res -= 1\n\n return res\n\n\ndef main():\n n = int(input())\n s = input()\n res = solve(n, s)\n print(res)\n\n\ndef test():\n assert solve(4, "RRGB") == 1\n assert solve(39, "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB") == 1800\n\n\nif __name__ == "__main__":\n test()\n main()\n']
|
['Runtime Error', 'Accepted']
|
['s267667014', 's963998589']
|
[9120.0, 9196.0]
|
[22.0, 1173.0]
|
[890, 897]
|
p02714
|
u108898293
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["a=int(input())\nb=str(input())\nsum=0\n\nriron_sum=b.count('R')*b.count('G')*b.count('B')\nprint(riron_sum)\nfor i in range(0,a):\n for n in range(0,a+1):\n j = i+n\n k = j+n\n #print(j)\n #print(k)\n if k>=a:\n \tbreak\n\n if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:\n riron_sum-=1\n\nprint(riron_sum)", "a=int(input())\nb=str(input())\nsum=0\n\nriron_sum=b.count('R')*sum=b.count('G')*sum=b.count('B')\nfor i in range(1,a):\n for n in range(1,i):\n if i+n>N:\n j = i+d\n k = j+d\n if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:\n riron_sum-=1\n\nprint(riron_sum)", "a=int(input())\nb=str(input())\nsum=0\n\nriron_sum=b.count('R')*b.count('G')*b.count('B')\n\nfor i in range(0,a):\n for n in range(1,a):\n j = i+n\n k = j+n\n #print(j)\n #print(k)\n if k>=a:\n \tbreak\n\n if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:\n riron_sum-=1\n\nprint(riron_sum)"]
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s252448593', 's609339312', 's716847572']
|
[9204.0, 9132.0, 9200.0]
|
[1410.0, 22.0, 1389.0]
|
[351, 301, 333]
|
p02714
|
u111652094
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["\nN=int(input())\nS=str(input())\n\nR=[0]\nG=[0]\nB=[0]\n\nfor i in range(N):\n if S[i]=='R':\n R.append(i)\n elif S[i]=='G':\n G.append(i)\n elif S[i]=='B':\n B.append(i)\n\nr=len(R)\ng=len(G)\nb=len(B)\n\nans=r*g*b\n\nfor i in range(r):\n for j in range(g):\n for k in range(b):\n if G[j]-R[i]==B[k]-G[j]:\n ans=ans-1\n\nprint(ans)", "N=int(input())\nS=str(input())\n\nr=S.count('R')\ng=S.count('G')\nb=S.count('B')\n\nans=r*g*b\ndib=0\nm=0\n\nfor i in range(N-2):\n m=(N-i)//2+1\n for j in range(i+1,m):\n dib=j-i\n if j+dib<=N-1:\n if S[i]!=S[j] and S[i]!=S[j+dib] and S[j]!=S[j+dib]:\n ans=ans-1\n \nprint(ans)", "N=int(input())\nS=str(input())\n\nr=S.count('R')\ng=S.count('G')\nb=S.count('B')\n\n\nans=r*g*b\ndib=0\nm=0\n\nfor i in range(N-2):\n m=(N+i)//2+1\n for j in range(i+1,m):\n dib=j-i\n if j+dib<=N-1:\n if S[i]!=S[j] and S[i]!=S[j+dib] and S[j]!=S[j+dib]:\n ans=ans-1\n \nprint(ans)\n"]
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s008865449', 's575665720', 's671243603']
|
[9224.0, 9168.0, 9148.0]
|
[2205.0, 529.0, 1495.0]
|
[371, 332, 334]
|
p02714
|
u113991073
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['print(sum([x for x in range(a,int(input())+1) if (x%3!=0)and(x%5!=0)]))', 'n=int(input())\ns=input()\n\nr_cnt=s.count("R")\ng_cnt=s.count("G")\nb_cnt=s.count("B")\n\nans=r_cnt*g_cnt*b_cnt\n\nfor i in range(n):\n for d in range(n):\n j=i+d\n k=j+d\n if k>=n:break\n if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:\n ans -= 1\n\nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s461833071', 's906913823']
|
[9108.0, 9144.0]
|
[21.0, 1487.0]
|
[71, 284]
|
p02714
|
u116038906
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['\nN= int(input())\nS =input()\n\n\n#\nR_index=[]\nG_index=[]\nB_index=[]\nfor i,v in enumerate(S):\n if v =="R":\n R_index.append(i)\n if v =="G":\n G_index.append(i)\n if v =="B":\n B_index.append(i)\n\n\nR_B =[]\nB_G =[]\ncount_ij_jk_onaji =0\nfor r in R_index:\n for g in G_index:\n if g-(r-g)<N :\n if S[g-(r-g)]=="B" and r<g:\n count_ij_jk_onaji +=1\n print(g,r,g-(r-g),"B")\nfor b in B_index:\n for r in R_index:\n if r-(b-r)<N :\n if S[r-(b-r)] == "G" and b<r:\n count_ij_jk_onaji +=1\n print(r,b,r-(b-r),"G")\nfor g in G_index:\n for b in B_index:\n if b-(g-b)<N :\n if S[b-(g-b)] =="R" and g<b:\n count_ij_jk_onaji +=1\n print(b,g,b-(g-b),"R")\n\n \n\nkotae_all = len(R_index) * len(G_index) * len(B_index) \nprint(kotae_all -count_ij_jk_onaji)\n\nprint(kotae_all , count_ij_jk_onaji)', '\nN= int(input())\nS =input()\n\nfrom collections import Counter\nc = Counter(S)\ncount_all =c["R"] * c["G"] * c["B"]\ncount =0\nfor i,v in enumerate(S):\n for j in range(1,(N+1)//2):\n if 0 <= i-j and i+j <N: \n if S[i-j]=="R" and S[i] =="G" and S[i+j] =="B":\n print(i-j,i,i+j)\n count +=1\n if S[i-j]=="R" and S[i] =="B" and S[i+j] =="G":\n print(i-j,i,i+j)\n count +=1\n if S[i-j]=="G" and S[i] =="R" and S[i+j] =="B":\n print(i-j,i,i+j)\n count +=1\n if S[i-j]=="G" and S[i] =="B" and S[i+j] =="R":\n print(i-j,i,i+j)\n count +=1\n if S[i-j]=="B" and S[i] =="G" and S[i+j] =="R":\n print(i-j,i,i+j)\n count +=1\n if S[i-j]=="B" and S[i] =="R" and S[i+j] =="G":\n count +=1\n print(i-j,i,i+j)\n\nprint(count_all - count)', "\nN= int(input())\nS =input().strip()\n\n\nR =set([i for i, x in enumerate(S) if x == 'R'])\nG =set([i for i, x in enumerate(S) if x == 'G'])\nB =set([i for i, x in enumerate(S) if x == 'B'])\n\n\ncount =0\nrgb =[]\nfor i in R:\n for j in G:\n k1 =j +(j -i)\n if k1 in B: \n count +=1\n\nfor i in B:\n for j in R:\n k1 =j +(j -i)\n if k1 in G: \n count +=1\n\nfor i in G:\n for j in B:\n k1 =j +(j -i)\n if k1 in R: \n count +=1\n\nall =len(R) *len(G) *len(B)\nprint(all -count)"]
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s053335472', 's708939360', 's609558671']
|
[17272.0, 10768.0, 9312.0]
|
[1985.0, 2242.0, 973.0]
|
[1077, 964, 672]
|
p02714
|
u116233709
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['n = 39\ns = str(input())\nr = []\ng = []\nb = []\nfor i in range(n):\n if s[i] == "R":\n r.append(i+1)\n elif s[i] == "G":\n g.append(i+1)\n else:\n b.append(i+1)\ncnt = 0\nfor i in r:\n for j in g:\n if (i+j)%2==0:\n if (i + j) // 2 in b:\n cnt += 1\n if (2 * j) - i in b:\n cnt += 1\n if (2 * i) - j in b:\n cnt += 1\nprint((len(r) * len(g) * len(b))-cnt)', 'n = int(input())\ns = str(input())\nr = []\ng = []\nb = []\nfor i in range(n):\n if s[i] == "R":\n r.append(i+1)\n elif s[i] == "G":\n g.append(i+1)\n else:\n b.append(i+1)\ncnt=len(r)*len(g)*len(b)\nif n<=3:\n print(0)\n exit()\nfor i in range(n-2):\n for j in range(i+1,n-1):\n if j*2-i<n:\n if s[i]!=s[j] and s[j]!=s[j*2-i] and s[j*2-i]!=s[i]:\n cnt-=1\nprint(cnt)']
|
['Runtime Error', 'Accepted']
|
['s154876919', 's222207537']
|
[9164.0, 9224.0]
|
[22.0, 1835.0]
|
[437, 418]
|
p02714
|
u119947188
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["N = int(input())\nS = input()\ncount_R = 0\ncount_G = 0\ncount_B = 0\ncount = 0\nfor i in range(N):\n if S[i] == 'R':\n count_R = count_R+1\n elif S[i] == 'G':\n count_G = count_G+1\n else:\n count_B = count_B+1\ncount = count_R*count_G*count_B\n\nfor i in range(N):\n for j in range(i+1,N):\n if S[i] != S[j]:\n k = 2*j-1\n if k>N:\n break\n else:\n if S[i] != S[k] and S[j] != S[k]:\n count = count-1\nprint(count)", "N = int(input())\nS = input()\ncount_R = 0\ncount_G = 0\ncount_B = 0\ncount = 0\nfor i in range(N):\n if S[i] == 'R':\n count_R = count_R+1\n elif S[i] == 'G':\n count_G = count_G+1\n else:\n count_B = count_B+1\ncount = count_R*count_G*count_B\n\nfor i in range(N):\n for j in range(i+1,N):\n if S[i] != S[j]:\n k = 2*j-i\n if k>=N:\n break\n else:\n if S[i] != S[k] and S[j] != S[k]:\n count = count-1\nprint(count)"]
|
['Runtime Error', 'Accepted']
|
['s443485962', 's454529811']
|
[9080.0, 9184.0]
|
[602.0, 1132.0]
|
[464, 465]
|
p02714
|
u123648284
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['N = int(input())\nS = list(input())\n\nres = 0\nfor i in range(N-2):\n for j in range(i+1, N-1):\n for k in range(j+1, N):\n if j - i == k - j:\n continue\n if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:\n res += 1\n', 'N = int(input())\nS = list(input())\n\nr = len([s for s in S if s == "R"])\ng = len([s for s in S if s == "G"])\nb = len([s for s in S if s == "B"])\n\nres = r * g * b\n\nfor i in range(N-2):\n for j in range(i+1, N-1):\n k = j + (j - i)\n if k >= N:\n break\n if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:\n res -= 1\n\nprint(res)\n']
|
['Wrong Answer', 'Accepted']
|
['s748373462', 's447600649']
|
[9180.0, 9220.0]
|
[2205.0, 1254.0]
|
[271, 366]
|
p02714
|
u125545880
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['import sys\n#import copy\nimport numpy as np\n#import itertools\n#import collections\n#from collections import deque\n#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson\n#from scipy.sparse import csr_matrix\n\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline\nread = sys.stdin.buffer.read\n\ndef main():\n # input\n N = int(readline())\n #S = np.array(list(readline()))\n S = np.array(list(read().rstrip()), np.int8)\n #print(S)\n\n R = np.sum(S == ord(\'R\'))\n G = np.sum(S == ord(\'G\'))\n B = np.sum(S == ord(\'B\'))\n\n ans = R*G*B\n\n for i in range(N-2):\n for j in range(i+1, N-1):\n k = 2 * j - i\n if k >= N:\n break\n if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n ans -= 1\n\n print(ans)\n #print(\'end\')\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\n#import copy\n#import numpy as np\n#import itertools\nimport collections\n#from collections import deque\n#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson\n#from scipy.sparse import csr_matrix\n\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline\nread = sys.stdin.read\ncount = collections.Counter\n\ndef main():\n N = int(readline())\n S = input()\n\n values = list(count(S).values())\n if len(values) < 3:\n print(0)\n return\n \n ans = values[0] * values[1] * values[2]\n\n for i in range(N-2):\n for j in range(i+1, N-1):\n k = 2 * j - i\n if k >= N:\n break\n if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n ans -= 1\n\n print(ans)\n #print(\'end\')\n\n\nif __name__ == "__main__":\n main()\n']
|
['Runtime Error', 'Accepted']
|
['s999914903', 's446976369']
|
[27076.0, 9468.0]
|
[137.0, 801.0]
|
[884, 845]
|
p02714
|
u127499732
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["def main():\n n, s = int(input()), input()\n r, g, b = 0, 0, 0\n for i in s:\n if i == 'R':\n r += 1\n if i == 'G':\n g += 1\n if i == 'b':\n b += 1\n\n ans = r * g * b\n s = tuple(s)\n v = {'R', 'G', 'B'}\n for i in range(n - 2):\n for j in range(n // 2 + 1):\n if i + j + j < n:\n if v == {s[i], s[i + j], s[i + j + j]}:\n ans -= 1\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", 'def main():\n from collections import Counter\n n, s = int(input()), input()\n c = Counter(s)\n d = list(c.values())\n if len(d) <3:\n print(0)\n exit()\n ans = d[0] * d[1] * d[2]\n rgb = {"R", "G", "B"}\n for i in range(1, n // 2 + 1):\n for j in range(i):\n x = s[j::i]\n for a, b, c in zip(x, x[1:], x[2:]):\n g = {a, b, c}\n if g == rgb:\n ans -= 1\n\n print(ans)\n\n\nif __name__ == \'__main__\':\n main()\n']
|
['Wrong Answer', 'Accepted']
|
['s101136041', 's636300822']
|
[9148.0, 9084.0]
|
[1343.0, 1390.0]
|
[498, 509]
|
p02714
|
u132687480
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["def binary_search(target, left, right, nums):\n if(left > right):\n return -1\n mid = (right-left)//2 + left\n if(nums[mid] == target):\n return mid\n elif(nums[mid] < target):\n return binary_search(target, mid+1, right, nums)\n else:\n return binary_search(target, left, mid-1, nums)\ndef Main(N, S):\n ans = 0\n d = {'R':[], 'G':[], 'B':[]}\n for i, c in enumerate(S):\n d[c].append(i)\n print(d)\n lenb = len(d['B'])\n for i in d['R']:\n for j in d['G']:\n for k in d['B']:\n if abs(j-i) != abs(k-j) and abs(j-i) != abs(k-i) and abs(k-j) != abs(i-k):\n ans += 1\n return ans\n \n \n\ndef main():\n N = int(input())\n S = str(input())\n print(Main(N,S))\n\nif __name__ == '__main__':\n main()", "import numpy as np\ndef Main(N, S):\n num = [0]*3\n for c in S:\n if c == 'R':\n num[0] += 1\n elif c == 'G':\n num[1] += 1\n else:\n num[2] += 1\n ans = np.prod(num)\n sub = 0\n i = 0\n j = 1\n while(i-2 < N):\n while(i+2*j < N):\n a = i\n b = i+j\n c = i+2*j\n if S[a] != S[b] and S[a] != S[c] and S[b] != S[c]:\n sub += 1\n j += 1\n i += 1\n j = 1\n return ans - sub\n \n \n\ndef main():\n N = int(input())\n S = str(input())\n print(Main(N,S))\n\nif __name__ == '__main__':\n main()"]
|
['Wrong Answer', 'Accepted']
|
['s397788005', 's108936171']
|
[9288.0, 26980.0]
|
[2206.0, 1206.0]
|
[808, 643]
|
p02714
|
u135116520
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['import collections\nN=int(input())\nS=list(input())\ns=collections.Counter(S)\nm=0\nm+=s["R"]*s["G"]*s["B"]\nfor i in range(N-2):\n for j in range(i+1,N-1):\n k=2*j-i\n if k>=N:\n break\n if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:\n m-=1', 'import collections\nN=int(input())\nS=list(input())\ns=collections.Counter(S)\nm=0\nm+=s["R"]*s["G"]*s["B"]\nfor i in range(N-2):\n for j in range(i+1,N-1):\n k=2*j-i\n if k>=N:\n break\n if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:\n m-=1\nprint(m)', 'import collections\nN=int(input())\nS=list(input())\ns=collections.Counter(S)\nm=s["R"]*s["G"]*s["B"]\ns=0\nfor i in range(1,N-1):\n for j in range(i,N):\n k=2*j-i\n if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:\n s+=1\nprint(m-s)', 'import collections\nN=int(input())\nS=list(input())\ns=collections.Counter(S)\nm=s["R"]*s["G"]*s["B"]\nfor i in range(N-2):\n for j in range(i+1,N-1):\n k=2*j-i\n if k>=N:\n break\n if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:\n m-=1', 'import collections\nN=int(input())\nS=list(input())\ns=collections.Counter(S)\nm=s["R"]*s["G"]*s["B"]\nfor i in range(N-2):\n for j in range(i+1,N-1):\n k=2*j-i\n if k>=N:\n break\n if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:\n m-=1\nprint(m)', 'import collections\nN=int(input())\nS=input()\ns=collections.Counter(S)\nm=s["R"]*s["G"]*s["B"]\nfor i in range(N-2):\n for j in range(i+1,N-1):\n k=2*j-i\n if k>N:\n break\n if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:\n m-=1\nprint(m)', 'import collections\nN=int(input())\nS=input()\ns=collections.Counter(S)\nm=s["R"]*s["G"]*s["B"]\nfor i in range(N-2):\n for j in range(i+1,N-1):\n k=2*j-i\n if k>N:\n break\n else:\n if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:\n m-=1\nprint(m)\n', "N = int(input())\nS = list(input())\n\nR = 0\nG = 0\nB = 0\n\nfor i in range(N):\n\tif S[i] == 'R':\n\t\tR += 1\n\telif S[i] == 'G':\n\t\tG += 1\n\telse:\n\t\tB += 1\nans = R * G * B\nfor i in range(N - 2):\n\tfor j in range(i + 1, N - 1):\n\t\tk = j + (j - i)\n\t\tif k >= N:\n\t\t\tbreak\n\t\tif S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n\t\t\tans -= 1\nprint(ans)\n"]
|
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s003266981', 's270215355', 's313246048', 's314376008', 's326755990', 's507853451', 's857914341', 's318916176']
|
[9464.0, 9440.0, 9440.0, 9464.0, 9476.0, 9444.0, 9472.0, 9208.0]
|
[1871.0, 1965.0, 26.0, 1901.0, 1913.0, 1839.0, 1912.0, 1379.0]
|
[247, 256, 230, 242, 251, 244, 259, 330]
|
p02714
|
u135346354
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['N = int(input())\ns = input()\n\n\n\n# for j in range(i+1, N-1):\n# if s[i] == s[j]:\n# continue\n# for k in range(j+1, N):\n\n# continue\n# if s[i] == s[k] or s[j] == s[k]:\n# continue\n# cnt += 1\n\nr = 0\ng = 0\nb = 0\n\nfor t in s:\n if t == "R":\n r += 1\n elif t == "G":\n g += 1\n\nb = N - r - g\ncnt = r * g * b\nprint(r,g,b,cnt)\n\nfor i in range(1, N-1):\n j = 1\n while 0 <= i-j and i+j <= N-1:\n if s[i] != s[i-j] and s[i] != s[i+j] and s[i-j] != s[i+j]:\n cnt -= 1\n j += 1\n\nprint(cnt)\n', 'N = int(input())\ns = input()\n\n\n\n# for j in range(i+1, N-1):\n# if s[i] == s[j]:\n# continue\n# for k in range(j+1, N):\n\n# continue\n# if s[i] == s[k] or s[j] == s[k]:\n# continue\n# cnt += 1\n\nr = 0\ng = 0\nb = 0\n\nfor t in s:\n if t == "R":\n r += 1\n elif t == "G":\n g += 1\n\nb = N - r - g\ncnt = r * g * b\n\nfor i in range(1, N-1):\n j = 1\n while 0 <= i-j and i+j <= N-1:\n if s[i] != s[i-j] and s[i] != s[i+j] and s[i-j] != s[i+j]:\n cnt -= 1\n j += 1\n\nprint(cnt)\n']
|
['Wrong Answer', 'Accepted']
|
['s469243010', 's990620595']
|
[9172.0, 9168.0]
|
[1929.0, 1917.0]
|
[654, 637]
|
p02714
|
u135847648
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['# n = int(input())\n\n\n\n\n\n# st = s[i]\n# if st == "R":\n# r_pos.append(i)\n\n# if st == "G":\n# g_pos.append(i)\n\n# if st == "B":\n# b_pos.append(i)\n\n\n\n\n\n# ans = r_num * g_num * b_num\n\n# for r in r_pos:\n# for g in g_pos:\n# for b in b_pos:\n\n# color.sort()\n# x = color[0]\n\n\n\n# ans -= 1\n# print(ans)\n\n# -----------------------------------------------------\nn = int(input())\ns = list(input())\nr_pos = []\ng_pos = []\nb_pos = []\n\nfor i in range(n):\n st = s[i]\n if st == "R":\n r_pos.append(i)\n\n if st == "G":\n g_pos.append(i)\n\n if st == "B":\n b_pos.append(i)\n\nr_num = len(r_pos)\ng_num = len(g_pos)\nb_num = len(b_pos)\n\nprint(r_pos, g_pos, b_pos, r_num, g_num, b_num)\n\n\nans = r_num * g_num * b_num\nfor r in r_pos:\n for g in g_pos:\n x, y = min(r, g), max(r, g)\n\n dif = y - x\n left_pos = x - dif\n right_pos = y + dif\n mid_pos = 4000\n if dif % 2 == 0:\n mid_pos = x + dif // 2\n\n left = 0\n right = 0\n mid = 0\n if left_pos in b_pos:\n left = 1\n if right_pos in b_pos:\n right = 1\n if mid_pos in b_pos:\n mid = 1\n\n ans -= left + right + mid\n\nprint(ans)\n', 'n = int(input())\ns = list(input())\nr_pos = []\ng_pos = []\nb_pos = []\n\nfor i in range(n):\n st = s[i]\n if st == "R":\n r_pos.append(i)\n\n if st == "G":\n g_pos.append(i)\n\n if st == "B":\n b_pos.append(i)\n\ncolors = [r_pos, g_pos, b_pos]\nif len(colors[0]) > len(colors[1]):\n colors[0], colors[1] = colors[1], colors[0]\nif len(colors[0]) > len(colors[2]):\n colors[0], colors[2] = colors[2], colors[0]\nif len(colors[1]) > len(colors[2]):\n colors[1], colors[2] = colors[2], colors[1]\n\nx_num, y_num, z_num = len(colors[0]), len(colors[1]), len(colors[2])\n\nans = x_num * y_num * z_num\nc = set(colors[2])\nfor a in colors[0]:\n for b in colors[1]:\n x, y = min(a, b), max(a, b)\n\n dif = y - x\n left_pos = x - dif\n right_pos = y + dif\n mid_pos = 4000\n if dif % 2 == 0:\n mid_pos = x + dif // 2\n\n left = 0\n right = 0\n mid = 0\n if left_pos in c:\n left = 1\n if right_pos in c:\n right = 1\n if mid_pos in c:\n mid = 1\n\n ans -= left + right + mid\n\nprint(ans)\n']
|
['Wrong Answer', 'Accepted']
|
['s094385630', 's536751873']
|
[9252.0, 9272.0]
|
[2205.0, 1594.0]
|
[1566, 1111]
|
p02714
|
u135961419
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["n = int(input())\ns = input()\n\nanswer = s.count('R') * s.count('G') * s.count('B')\n\nfor i in range(n - 2):\n j = 0\n while((i + 1) + (j - i) * 2 <= n):\n if s[i] != s[j] and s[j] != s[(i + 1) + (j - i) * 2] and s[i] != s[(i + 1) + (j - i) * 2]:\n answer -= 1\n j += 1\n\nprint(answer)", "n = int(input())\ns = input()\n \nanswer = s.count('R') * s.count('G') * s.count('B')\n\nfor i in range(n - 2):\n j = i + 1\n while((i + 1) + (j - i) * 2 <= n):\n if s[i] != s[j] and s[j] != s[i + (j - i) * 2] and s[i] != s[i + (j - i) * 2]:\n answer -= 1\n j += 1\n \nprint(answer)"]
|
['Time Limit Exceeded', 'Accepted']
|
['s993813262', 's546312027']
|
[9120.0, 9200.0]
|
[2205.0, 1820.0]
|
[291, 283]
|
p02714
|
u143322814
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['\ndef main():\n n = int(input())\n s = input()\n r,g,b = 0,0,0\n for i in s:\n if i == \'r\': r += 1\n elif i == \'g\': g += 1\n elif i == \'b\': b += 1\n ans = r*g*b\n for j in range(n):\n for i in range(j):\n k = j+(j-i)\n if k < n:\n if s[i] == s[j] or s[i] == s[k] or s[k] == s[j]:\n continue\n ans -= 1\n print(ans)\nif __name__ == "__main__":\n main()', '\ndef main():\n n = int(input())\n s = input()\n r,g,b = 0,0,0\n for i in s:\n if i == \'R\': r += 1\n elif i == \'G\': g += 1\n elif i == \'B\': b += 1\n ans = r*g*b\n for j in range(n):\n sj = s[j]\n for i in range(j):\n k = j+(j-i)\n if k < n:\n si = s[i]\n sk = s[k]\n if si == sj or si == sk or sk == sj:\n continue\n ans -= 1\n print(ans)\nif __name__ == "__main__":\n main()']
|
['Wrong Answer', 'Accepted']
|
['s580668157', 's540205112']
|
[9196.0, 9204.0]
|
[1091.0, 923.0]
|
[455, 513]
|
p02714
|
u145582359
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['import collections\n\nN=int(input())\nS=input()\n\nlenR=S.count("R")\nlenG=S.count("G")\nlenB=S.count("B")\n\ncount=0\nfor i in range(N-2):\n for j in range(i,N-1):\n if 2*j-i>N:\n continue\n if (S[i] != S[j]) and (S[i]!=S[2*j-i]) and (S[j]!=S[2*j-i]):\n count+=1\n \nprint(lenR*lenG*lenB-count)', 'import collections\n\nN=int(input())\nS=input()\n\nlenR=S.count("R")\nlenG=S.count("G")\nlenB=S.count("B")\n\ncount=0\nfor i in range(N-2):\n for j in range(i,N-1):\n if 2*j-i>N:\n continue\n if (S[i] != S[j]) and (S[i]!=S[2*j-i]) and (S[j]!=S[2*j-i]):\n count+=1\n \nprint(lenR*lenG*lenB-count)', 'import collections\n\nN=int(input())\nS=input()\n\nlenR=S.count("R")\nlenG=S.count("G")\nlenB=S.count("B")\n\ncount=0\nfor i in range(N-2):\n for j in range(i,N-1):\n k=2*j-i\n if k>=N:\n continue\n else:\n if (S[i] != S[j]) and (S[i]!=S[k]) and (S[j]!=S[k]):\n count+=1\n \nprint(lenR*lenG*lenB-count)']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s012425772', 's546091307', 's043668247']
|
[9480.0, 9468.0, 9460.0]
|
[26.0, 25.0, 1899.0]
|
[320, 328, 347]
|
p02714
|
u145600939
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["n = int(input())\ns = input()\nR = set()\nG = set()\nB = set()\nfor i in range(s):\n if s[i] == 'R':\n R.add(i)\n elif s[i] == 'B':\n B.add(i)\n else:\n G.add(i)\nans = 0\nfor r in R:\n for g in G:\n ans += len(B)\n if 2*r - g in B:\n ans -= 1\n if 2*g - r in B:\n ans -= 1\n if not (r+g)&1 and (r+g)//2 in B:\n ans -= 1\nprint(ans)\n", "n = int(input())\ns = input()\nR = set()\nG = set()\nB = set()\nfor i in range(n):\n if s[i] == 'R':\n R.add(i)\n elif s[i] == 'B':\n B.add(i)\n else:\n G.add(i)\nans = 0\nfor r in R:\n for g in G:\n ans += len(B)\n if 2*r - g in B:\n ans -= 1\n if 2*g - r in B:\n ans -= 1\n if not (r+g)&1 and (r+g)//2 in B:\n ans -= 1\nprint(ans)\n"]
|
['Runtime Error', 'Accepted']
|
['s307107453', 's185662817']
|
[9212.0, 9540.0]
|
[24.0, 916.0]
|
[405, 405]
|
p02714
|
u151037808
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin.readline\n\n\ndef main():\n n = int(input())\n s = input()\n\n ans = s.count('R') * s.count('G') * s.count('B')\n # print(ans)\n for i in range(n - 2):\n for j in range(i + 1, n - 1):\n k = (j - i) + j\n if k > n:\n # print(i, j, k)\n break\n\n if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n ans -= 1\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin.readline\n\n\ndef main():\n n = int(input())\n s = input()\n\n ans = s.count('R') * s.count('G') * s.count('B')\n print(ans)\n for i in range(n - 2):\n for j in range(i + 1, n - 1):\n k = (j - i) + j\n if k > n:\n print(i, j, k)\n break\n\n if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n ans -= 1\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin.readline\n\n\ndef main():\n n = int(input())\n s = input()\n\n ans = s.count('R') * s.count('G') * s.count('B')\n # print(ans)\n for i in range(n - 2):\n for j in range(i + 1, n - 1):\n k = (j - i) + j\n if k >= n:\n # print(i, j, k)\n break\n\n if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n ans -= 1\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s145911663', 's919622734', 's343730761']
|
[9196.0, 9288.0, 9200.0]
|
[786.0, 791.0, 789.0]
|
[499, 495, 500]
|
p02714
|
u156591744
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['n=int(input())\ns=input()\ncompte=0\nr=[]\ng=[]\nb=[]\nfor i in range(n):\n if s[i]=="R":\n r.append(i)\n elif s[i]=="G":\n g.append(i)\n elif s[i]=="B":\n b.append(i)\n \nfor i in range(1,n-1):\n if n%2==0:\n if i<n//2:\n for j in range(1,i+1):\n if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:\n compte+=1\n else:\n for j in range(1,n-i):\n if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:\n compte+=1\n else:\n if i<(n-1)//2:\n for j in range(1,i+1):\n if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:\n compte+=1\n elif i==(n-1)//2:\n for j in range(1,n-i):\n if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:\n compte+=1\n elif i>(n-1)//2:\n for j in range(1,n-i):\n if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:\n compte+=1\n \nprint(len(r)*len(g)*len(b)-count)', 'N = int(input())\nS = input()\nif N>3 :\n total = S.count("R")*S.count("G")*S.count("B")\n for i in range(0,N-2):\n for j in range(i+1,N-1):\n if 2*j-i<N:\n if S[i]!=S[j] and S[j]!=S[2*j-i] and S[2*j-i]!=S[i]:\n total-=1\n print(total)\nelse:\n print(0)']
|
['Runtime Error', 'Accepted']
|
['s042869404', 's130082804']
|
[9312.0, 9144.0]
|
[1167.0, 1899.0]
|
[1096, 270]
|
p02714
|
u161712560
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["N = int(input())\nS = input()\n\nrList = []\ngList = []\nbList = []\n\nfor indx in range(N):\n if S[indx] == 'R':\n rList.append(indx)\n elif S[indx] == 'G':\n gList.append(indx)\n elif S[indx] == 'B':\n bList.append(indx)\n\nNoSum = 0\nfList = rList\nsList = gList\nremain = 'B'\n\nfor fItem in fList:\n for sItem in sList:\n NoSum += 1\n prsMax = max(fItem, sItem)\n prsMin = min(fItem, sItem)\n if ((2 * prsMax - prsMin) <= N-1):\n if (S[(2 * prsMax - prsMin)] == remain):\n NoSum += 1\n \n if ((prsMax - prsMin) % 2 == 0):\n if (S[int((prsMax + prsMin)/2)] == remain):\n NoSum += 1\n \n if ((2 * prsMin - prsMax) >= 0):\n if (S[(2 * prsMin - prsMax)] == remain):\n NoSum += 1\n\nprint(len(rList) * len(gList) * len(bList) - NoSum)", "N = int(input())\nS = input()\n\nrList = []\ngList = []\nbList = []\n\nfor indx in range(N):\n if S[indx] == 'R':\n rList.append(indx)\n elif S[indx] == 'G':\n gList.append(indx)\n elif S[indx] == 'B':\n bList.append(indx)\n\nNoSum = 0\nfList = rList\nsList = gList\nremain = 'B'\n\nfor fItem in fList:\n for sItem in sList:\n NoSum += 1\n # if ((2 * max(fItem, sItem) - min(fItem, sItem)) <= N-1):\n # if (S[(2 * max(fItem, sItem) - min(fItem, sItem))] == remain):\n \n \n # if ((max(fItem, sItem) - min(fItem, sItem)) % 2 == 0):\n # if (S[int((max(fItem, sItem) + min(fItem, sItem))/2)] == remain):\n \n \n # if ((2 * min(fItem, sItem) - max(fItem, sItem)) >= 0):\n # if (S[(2 * min(fItem, sItem) - max(fItem, sItem))] == remain):\n \n\nprint(len(rList) * len(gList) * len(bList) - NoSum)", "N = int(input())\nS = input()\n\nrList = []\ngList = []\nbList = []\n\nfor indx in range(N):\n if S[indx] == 'R':\n rList.append(indx)\n elif S[indx] == 'G':\n gList.append(indx)\n elif S[indx] == 'B':\n bList.append(indx)\n\nNoSum = 0\nfList = rList\nsList = gList\nremain = 'B'\n\nfor fItem in fList:\n for sItem in sList:\n prsMax = max(fItem, sItem)\n prsMin = min(fItem, sItem)\n if ((2 * prsMax - prsMin) <= N-1):\n if (S[(2 * prsMax - prsMin)] == remain):\n NoSum += 1\n \n if ((prsMax - prsMin) % 2 == 0):\n if (S[int((prsMax + prsMin)/2)] == remain):\n NoSum += 1\n \n if ((2 * prsMin - prsMax) >= 0):\n if (S[(2 * prsMin - prsMax)] == remain):\n NoSum += 1\n\nprint(len(rList) * len(gList) * len(bList) - NoSum)"]
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s061783523', 's286395616', 's884291217']
|
[9220.0, 9320.0, 9212.0]
|
[1733.0, 145.0, 1638.0]
|
[865, 945, 846]
|
p02714
|
u163320134
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["n=int(input())\ns=list(input())\nfor i in range(n):\n if s[i]=='R':\n s[i]=1\n elif s[i]=='G':\n s[i]=2\n elif s[i]=='B':\n s[i]=4\nans=s.count('R')*s.count('G')*s.count('B')\nfor i in range(n):\n for j in range(i+1,n):\n k=2*j-i\n if k>=n:\n continue\n if s[i]+s[j]+s[k]==7:\n ans-=1\nprint(ans)", "def calc():\n n=int(input())\n s=list(input())\n cnt1=0\n cnt2=0\n cnt3=0\n for i in range(n):\n if s[i]=='R':\n cnt1+=1\n s[i]=1\n elif s[i]=='G':\n cnt2+=1\n s[i]=2\n elif s[i]=='B':\n cnt3+=1\n s[i]=4\n ans=cnt1*cnt2*cnt3\n for i in range(n):\n for j in range(i+1,n):\n k=1*j-i\n if k>=n:\n continue\n if s[i]+s[j]+s[k]==7:\n ans-=1\n print(ans)\ncalc()", "def calc():\n n=int(input())\n s=input()\n cnt1=0\n cnt2=0\n cnt3=0\n for i in range(n):\n if s[i]=='R':\n cnt1+=1\n elif s[i]=='G':\n cnt2+=1\n elif s[i]=='B':\n cnt3+=1\n ans=cnt1*cnt1*cnt3\n for i in range(n):\n for j in range(i+1,n):\n if 2*j-i>=n:\n continue\n if len(set([s[i],s[j],s[2*j-i]]))==3:\n ans-=1\n print(ans)\ncalc()", "n=int(input())\ns=list(input())\nans=s.count('R')*s.count('G')*s.count('B')\nfor i in range(n):\n if s[i]=='R':\n s[i]=1\n elif s[i]=='G':\n s[i]=2\n elif s[i]=='B':\n s[i]=4\nfor i in range(n):\n for j in range(i+1,n):\n k=2*j-i\n if k>=n:\n continue\n if s[i]+s[j]+s[k]==7:\n ans-=1\nprint(ans)"]
|
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
|
['s556195486', 's678520056', 's705334157', 's739901992']
|
[9200.0, 9000.0, 9216.0, 9120.0]
|
[1652.0, 23.0, 2063.0, 1633.0]
|
[343, 461, 408, 343]
|
p02714
|
u167360450
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['import collections\n\nn = int(input())\ns = input()\nres = 0\n\n# for j in range(i+1,n):\n# if s[i] != s[j]:\n# for k in range(j+1,n):\n# if j-i!=k-j and s[i] != s[k] and s[j] != s[k]:\n# res += 1\n#\n# print(res)\nnum = collections.Counter(s)\n# print(num)\nnum_r = num["R"]\nnum_g = num["G"]\nnum_b = n - num_r - num_g\ncount_2 = 0\nfor x in range(1,int(n/2)+1):\n for i in range(n-2*x-i):\n # print(x)\n # print(i)\n # print()\n if (i + 2 * x < n and s[i] != s[i + x] and s[i + x] != s[i + 2 * x] and s[i] != s[i + 2 * x] ):\n count_2 += 1\n # print(x)\n # print(i)\n # print()\n\nres = num_r * num_g * num_b - count_2\n# print(num_r)\n# print(num_g)\n# print(num_b)\nprint(res)', 'import collections\n\nn = int(input())\ns = input()\nres = 0\n\n# for j in range(i+1,n):\n# if s[i] != s[j]:\n# for k in range(j+1,n):\n# if j-i!=k-j and s[i] != s[k] and s[j] != s[k]:\n# res += 1\n#\n# print(res)\nnum = collections.Counter(s)\n# print(num)\nnum_r = num["R"]\nnum_g = num["G"]\nnum_b = n - num_r - num_g\ncount_2 = 0\nfor x in range(1,int(n/2)+1):\n for i in range(n-2*x):\n # print(x)\n # print(i)\n # print()\n if (i + 2 * x < n and s[i] != s[i + x] and s[i + x] != s[i + 2 * x] and s[i] != s[i + 2 * x] ):\n count_2 += 1\n # print(x)\n # print(i)\n # print()\n\nres = num_r * num_g * num_b - count_2\n# print(num_r)\n# print(num_g)\n# print(num_b)\nprint(res)']
|
['Runtime Error', 'Accepted']
|
['s538125072', 's484134654']
|
[9400.0, 9404.0]
|
[28.0, 1719.0]
|
[805, 803]
|
p02714
|
u168832623
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["N = int(input())\ns = input()\n \nr_cnt = s.count('R')\ng_cnt = s.count('G')\nb_cnt = s.count('B')\n\nans = r_cnt * g_cnt * b_cnt\n \nfor i in range(N):\n for j in range(i,N):\n k = 2*j - i\n if k >= N:\n break\n elif S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:\n ans -= 1\n\nprint(ans)", "N = int(input())\nS = input()\n \nr_cnt = S.count('R')\ng_cnt = S.count('G')\nb_cnt = S.count('B')\n\nans = r_cnt * g_cnt * b_cnt\n \nfor i in range(N):\n for j in range(i,N):\n k = 2*j - i\n if k >= N:\n break\n if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:\n ans -= 1\n print(i,j,k)\nprint(ans)", "N = int(input())\ns = input()\n \nr_cnt = s.count('R')\ng_cnt = s.count('G')\nb_cnt = s.count('B')\n\nans = r_cnt * g_cnt * b_cnt\n \nfor i in range(N):\n for j in range(i,N):\n k = 2*j - i\n if k > N:\n break\n elif S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:\n ans -= 1\n\nprint(ans)", "N = int(input())\nS = input()\n \nr_cnt = S.count('R')\ng_cnt = S.count('G')\nb_cnt = S.count('B')\n\nans = r_cnt * g_cnt * b_cnt\n \nfor i in range(N):\n for j in range(i,N):\n k = 2*j - i\n if k >= N:\n break\n if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:\n ans -= 1\n# print(i,j,k)\n\nprint(ans)"]
|
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
|
['s288967903', 's642292888', 's759055650', 's940097759']
|
[9136.0, 31036.0, 9204.0, 9184.0]
|
[25.0, 2281.0, 22.0, 1313.0]
|
[313, 331, 312, 334]
|
p02714
|
u185405877
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['n=int(input())\ns=input()\ncnt=0\na=["R","G","B"]\nfor i in range(n):\n x=a.remove(s[i])\n for j in range(i+1,n):\n if s[i]!=s[j]:\n qw=s\n x.remove(s[j])\n k=j-1\n if j+k<n:\n qw[j+k]="P"\n q=x.pop(0)\n cnt+=qw.count(q)\nprint(cnt)', 'n=int(input())\ns=input()\nB=s.count("B")\nR=s.count("R")\nG=s.count("G")\nans=R*G*B\nfor i in range(n-2):\n for j in range(i+1,n-1):\n k=j-i+j\n if k<n:\n if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:\n ans-=1\nprint(ans)\n']
|
['Runtime Error', 'Accepted']
|
['s641389940', 's911753241']
|
[9208.0, 9128.0]
|
[22.0, 1814.0]
|
[310, 253]
|
p02714
|
u189056821
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["n = int(input())\ns = str(input())\ncount = {'R': 0, 'G': 0, 'B': 0}\nfor c in s:\n count[c] += 1\nR, G, B = count.values()\nans = R * G * B\n\nfor i in range(n - 1):\n for j in range(i + 1, n): \n k = j + j - i\n\n print(i,j,k)\n if k >= n:\n continue\n\n if (s[i] != s[j]) & (s[i] != s[k]) & (s[j] != s[k]):\n ans -= 1\n \nprint(ans)", "n = int(input())\ns = str(input())\nans = s.count('R') * s.count('G') * s.count('B')\n\nfor i in range(n - 1):\n for j in range(i + 1, n):\n k = j + j - i\n\n if k >= n:\n break\n\n if (s[i] != s[j]) & (s[i] != s[k]) & (s[j] != s[k]):\n ans -= 1\n \nprint(ans)"]
|
['Wrong Answer', 'Accepted']
|
['s601379787', 's512151829']
|
[33868.0, 9208.0]
|
[2254.0, 1846.0]
|
[383, 303]
|
p02714
|
u197457087
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['n = int(input())\ns = str(input())\n\nR = []\nG = []\nB = []\nfor i in range(n):\n if s[i] == "R":\n R.append(i+1)\n elif s[i] == "G":\n G.append(i+1)\n else:\n B.append(i+1)\n\n \nans = 0\n\nfor i in range(len(R)):\n for j in range(len(G)):\n test += len(B)\n temp = 0\n if 2*R[i] - G[j] in B:\n temp += 1\n if 2*G[j] - R[i] in B:\n temp += 1\n if (R[i]+G[j])/2 in B:\n temp += 1\n ans += len(B)- temp\n\nprint(ans)\n', 'n = int(input())\ns = str(input())\n\nR = []\nG = []\nB = []\nfor i in range(n):\n if s[i] == "R":\n R.append(i+1)\n elif s[i] == "G":\n G.append(i+1)\n else:\n B.append(i+1)\n\n \nans = 0\n\nfor i in range(len(R)):\n for j in range(len(G)):\n test += len(B)\n temp = 0\n if 2*R[i] - G[j] >0 and 2*R[i] - G[j] <= n:\n if s[2*R[i] - G[j] -1] == "B":\n temp += 1\n if 2*G[j] - R[i] >0 and 2*G[j] - R[i] <= n:\n if s[2*G[j] - R[i]-1] == "B":\n temp += 1\n if (R[i]+G[j])%2 == 0:\n if s[(R[i]+G[j])//2-1] == "B":\n temp += 1\n ans += len(B)- temp\n\nprint(ans)', 'n = int(input())\ns = str(input())\n\nR = []\nG = []\nB = []\nfor i in range(n):\n if s[i] == "R":\n R.append(i+1)\n elif s[i] == "G":\n G.append(i+1)\n else:\n B.append(i+1)\n\n \nans = 0\n\nfor i in range(len(R)):\n for j in range(len(G)):\n temp = 0\n if 2*R[i] - G[j] >0 and 2*R[i] - G[j] <= n:\n if s[2*R[i] - G[j] -1] == "B":\n temp += 1\n if 2*G[j] - R[i] >0 and 2*G[j] - R[i] <= n:\n if s[2*G[j] - R[i]-1] == "B":\n temp += 1\n if (R[i]+G[j])%2 == 0:\n if s[(R[i]+G[j])//2-1] == "B":\n temp += 1\n ans += len(B)- temp\n\nprint(ans)\n']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s030374281', 's264569988', 's255944824']
|
[9228.0, 9276.0, 9296.0]
|
[21.0, 24.0, 1854.0]
|
[435, 592, 574]
|
p02714
|
u199830845
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['import sys\nsys.setrecursionlimit(10 ** 6) \nto_index = lambda x: int(x) - 1 \nprint_list_in_2D = lambda x: print(*x, sep="\\n") \n\n\ndef input_int():\n return int(input())\n\ndef map_int_input():\n return map(int, input())\n\nMII = map_int_input\n\ndef MII_split():\n return map(int, input().split())\n\ndef MII_to_index():\n return map(to_index, input())\n\ndef MII_split_to_index():\n return map(to_index, input().split())\n\n\ndef list_int_inputs():\n return list(map(int, input()))\n\nLII = list_int_inputs\n\ndef LII_split():\n return list(map(int, input().split()))\n\n\ndef LII_2D(rows_number):\n return [LII() for _ in range(rows_number)]\n\ndef LII_split_2D(rows_number):\n return [LII_split() for _ in range(rows_number)]\n\nN = input_int()\nS = input()\n\nif N < 3:\n print(0)\n return\ncount = 0\nfor i in range(N - 2):\n for j in range(i + 1, N - 1):\n\n for k in range(j + 1, N):\n if S[i] == S[j] or S[j] == S[k] or S[i] == S[k] or j - i == k - j:\n continue\n else:\n count += 1\nprint(count)', 'import sys\nsys.setrecursionlimit(10 ** 6) \nto_index = lambda x: int(x) - 1 \nprint_list_in_2D = lambda x: print(*x, sep="\\n") \n\n\ndef input_int():\n return int(input())\n\ndef map_int_input():\n return map(int, input())\n\nMII = map_int_input\n\ndef MII_split():\n return map(int, input().split())\n\ndef MII_to_index():\n return map(to_index, input())\n\ndef MII_split_to_index():\n return map(to_index, input().split())\n\n\ndef list_int_inputs():\n return list(map(int, input()))\n\nLII = list_int_inputs\n\ndef LII_split():\n return list(map(int, input().split()))\n\n\ndef LII_2D(rows_number):\n return [LII() for _ in range(rows_number)]\n\ndef LII_split_2D(rows_number):\n return [LII_split() for _ in range(rows_number)]\n\nN = input_int()\nS = input()\n\nif N < 3:\n print(0)\n exit()\nrs = []\ngs = []\nbs = []\nfor i in range(len(S)):\n if S[i] == \'R\':\n rs.append(i)\n elif S[i] == \'G\':\n gs.append(i)\n else:\n bs.append(i)\ncount = len(rs) * len(gs) * len(bs)\n# for r in rs:\n# for g in gs:\n# for b in bs:\n# rgb = [r, g, b]\n# rgb.sort()\n# if rgb[1]-rgb[0] != rgb[2]-rgb[1]:\n# count += 1\n\nfor skip in range(1, N // 2 + 1):\n for i in range(N - 2):\n if i + 2 * skip > N - 1:\n break\n elif S[i] == S[i + skip] or S[i + skip] == S[i + 2 * skip] or S[i] == S[i + 2 * skip]:\n continue\n else:\n count -= 1\n\nprint(count)']
|
['Runtime Error', 'Accepted']
|
['s612936782', 's585034748']
|
[9140.0, 9308.0]
|
[25.0, 1742.0]
|
[1337, 1742]
|
p02714
|
u202634017
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
['from math import gcd\nk = int(input())\ngcdl = [[0 for i in range(k + 1)] for i in range(k + 1)]\nfor i in range(1, k + 1):\n for j in range(1, k + 1):\n gcdl[i][j] = gcd(i, j)\ns = 0\nfor i in range(1, k + 1):\n for j in range(1, k + 1):\n for l in range(1, k + 1):\n s += gcdl[i][gcdl[j][l]]\n\nprint(s)\n', 'n = int(input())\ns = list(input())\ncnt = {\n "R": 0,\n "G": 0,\n "B": 0\n}\n\nfor i, c in enumerate(s):\n cnt[c] += 1\n\nans = cnt["R"] * cnt["G"] * cnt["B"]\nd = 0\nfor i in range(n-2):\n for j in range(i + 1, n - 1):\n k = j + (j - i)\n if (k < n):\n if (s[i] != s[j])and(s[j] != s[k]) and (s[k] != s[i]):\n d += 1\n\nprint(ans-d)\n']
|
['Wrong Answer', 'Accepted']
|
['s648120782', 's815881876']
|
[142216.0, 9208.0]
|
[2209.0, 1878.0]
|
[325, 370]
|
p02714
|
u209418188
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["n = int(input())\ns = input()\nans = s.count('B') + s.count('G') + s.count('R')\nfor i in range(n):\n for j in range(i, n-1):\n k = 2*j - i\n if k >= n:\n continue\n if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:\n ans -= 1\n\nprint(ans)", "n = int(input())\ns = input()\nans = s.count('B') * s.coufnt('G') * s.count('R')\nfor i in range(n):\n for j in range(i, n-1):\n k = 2*j - i\n if k >= n:\n continue\n if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:\n ans -= 1\n\nprint(ans)\n", "n = int(input())\ns = input()\nans = s.count('R') * s.count('G') * s.count('B')\nfor i in range(n):\n for j in range(i, n-1):\n k = 2*j - i\n if k >= n:\n continue\n if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:\n ans -= 1\n\nprint(ans)\n"]
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s654882483', 's833768258', 's325728866']
|
[9204.0, 9180.0, 9048.0]
|
[1861.0, 22.0, 1893.0]
|
[250, 252, 251]
|
p02714
|
u211236379
| 2,000
| 1,048,576
|
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
|
["#from operator import itemgetter\n#from collections import Counter\n#import heapq\nN = int(input())\nS = input()\n#N, M = map(int, input().split())\n#A = list(map(lambda x: int(x)*(-1), input().split()))\n\n\nR =[]\nG =[]\nB =[]\n\nSTART_TIME = time.time()\nfor i, s in enumerate(S):\n if s == 'R':\n R.append(i)\n elif s == 'G':\n G.append(i)\n else:\n B.append(i)\nanswer = len(R)*len(G)*len(B)\nhiku = 0\nfor r in R:\n for g in G:\n for b in B:\n if b > max(r,g)+abs(r-g):\n break\n if abs(r-g) == abs(g-b) or abs(r-b) == abs(b-g) or abs(b-r) == abs(r-g):\n hiku += 1\nanswer -= hiku\nprint(answer)\n\n", "N = int(input())\nS = input()\n#N, M = map(int, input().split())\n#A = list(map(lambda x: int(x)*(-1), input().split()))\n\n\nR =[]\nG =[]\nB =[]\nfor i, s in enumerate(S):\n if s == 'R':\n R.append(i)\n elif s == 'G':\n G.append(i)\n else:\n B.append(i)\nanswer = len(R)*len(G)*len(B)\nhiku = 0\n\nfor i in range(1, (N-1)//2+1):\n #for j in range(N-i-i-2):\n j = 0\n while j + i*2 < N:\n if S[j] != S[j+i] and S[j+i] != S[j+i+i] and S[j] != S[j+i+i]:\n hiku += 1\n j+= 1\nanswer -= hiku\nprint(answer)\n"]
|
['Runtime Error', 'Accepted']
|
['s747518242', 's957688765']
|
[9220.0, 9208.0]
|
[22.0, 1860.0]
|
[759, 635]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.