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
p02714
u213498391
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 quest_d():\n N = int(input())\n S = input()\n\n index_dict = {\n 'R':0,\n 'G':0,\n 'B':0\n }\n for index in range(len(S)):\n index_dict[S[index]] = index_dict[S[index]] + 1\n\n if index_dict['R'] * index_dict['G'] * index_dict['B'] == 0:\n print(0)\n return\n\n rrr = combi_three(index_dict['R'])\n ggg = combi_three(index_dict['G'])\n bbb = combi_three(index_dict['B'])\n rrg = combi_three(index_dict['R'] + index_dict['G'])\n ggb = combi_three(index_dict['G'] + index_dict['B'])\n bbr = combi_three(index_dict['B'] + index_dict['R'])\n\n i = 0\n sum = 0\n while i < len(S):\n a = S[i]\n j = i\n while j < len(S) - 1:\n j += 1\n if S[j] == a:\n continue\n\n k = 2 * j - i\n if k < len(S):\n b = S[j]\n if S[k] != a and S[k] != b:\n sum += 1\n i += 1\n print(combi_three(N) - sum - rrg - bbr - ggb + rrr + ggg + bbb)\n\nif __name__ == '__main__':\n quest_d()", "def quest_d():\n N = int(input())\n S = input()\n\n r_index = []\n g_index = []\n b_index = []\n for index in range(len(S)):\n if S[index] == 'R':\n r_index.append(index)\n elif S[index] == 'G':\n g_index.append(index)\n else:\n b_index.append(index)\n if len(r_index) * len(g_index) * len(b_index) == 0:\n print(0)\n return\n\n i = 0\n sum = 0\n while i < len(S):\n a = S[i]\n j = i\n while j < len(S) - 1:\n j += 1\n if S[j] == a:\n continue\n\n l = 2 * j - i\n b = S[j]\n k = l\n while k < len(S)- 1:\n k += 1\n if S[k] == a or S[k] == b or l == k:\n continue\n sum += 1\n i += 1\n print(sum)\n\nif __name__ == '__main__':\n quest_d()\n", "def combi_three(n):\n if n < 3:\n return 0\n else:\n return int((n * (n - 1) * (n - 2)) / 6)\n\ndef quest_d():\n N = int(input())\n S = input()\n\n index_dict = {'R':0, 'G':0, 'B':0 }\n for index in range(N):\n index_dict[S[index]] = index_dict[S[index]] + 1\n\n if index_dict['R'] * index_dict['G'] * index_dict['B'] == 0:\n print(0)\n return\n\n rrr = combi_three(index_dict['R'])\n ggg = combi_three(index_dict['G'])\n bbb = combi_three(index_dict['B'])\n rrg = combi_three(index_dict['R'] + index_dict['G'])\n ggb = combi_three(index_dict['G'] + index_dict['B'])\n bbr = combi_three(index_dict['B'] + index_dict['R'])\n\n i = 0\n sum = 0\n while i < N:\n a = S[i]\n j = i\n while j < N - 1:\n j += 1\n if S[j] == a:\n continue\n\n k = 2 * j - i\n if k < N:\n b = S[j]\n if S[k] != a and S[k] != b:\n sum += 1\n i += 1\n print(combi_three(N) - sum - rrg - bbr - ggb + rrr + ggg + bbb)\n\nif __name__ == '__main__':\n quest_d()\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s000885537', 's803642906', 's379267647']
[9288.0, 8964.0, 9284.0]
[25.0, 2206.0, 1279.0]
[1049, 875, 1111]
p02714
u222668979
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 itertools import product as pro\n\nn = int(input())\ns = str(input())\n\nr = [i for i in range(n) if s[i] == 'R']\ng = [i for i in range(n) if s[i] == 'G']\nb = [i for i in range(n) if s[i] == 'B']\ncnt = len(r)*len(g)*len(b)\n\nlen = max(len(r), len(g), len(b))\nif len == len(r):\n max1 = set(r)\n min1 = g\n min2 = b\n\nif len == len(g):\n max1 = set(g)\n min1 = r\n min2 = b\n\nif len == len(b):\n max1 = set(b)\n min1 = g\n min2 = r\n\nfor i, j in pro(min1, min2):\n if 2*j-i in max1:\n cnt -= 1\n if 2*i-j in max1:\n cnt -= 1\n if (i+j)/2 in max1:\n cnt -= 1\n\nprint(cnt)\n", "from itertools import product as pro\n\nn = int(input())\ns = str(input())\n\nr = [i for i in range(n) if s[i] == 'R']\ng = [i for i in range(n) if s[i] == 'G']\nb = [i for i in range(n) if s[i] == 'B']\ncnt = len(r) * len(g) * len(b)\n\nlength = max(len(r), len(g), len(b))\nfor i, j, k in [(r, g, b), (g, b, r), (b, r, g)]:\n if length == len(i):\n max1 = set(i)\n min1, min2 = j, k\n\nfor i, j in pro(min1, min2):\n if ((2*j-i) or (2*i-j) or ((i+j)/2)) in max1:\n cnt -= 1\n\nprint(cnt)", "from itertools import product as pro\n\nn = int(input())\ns = str(input())\n\nr = [i for i in range(n) if s[i] == 'R']\ng = [i for i in range(n) if s[i] == 'G']\nb = [i for i in range(n) if s[i] == 'B']\ncnt = len(r) * len(g) * len(b)\n\nlength = max(len(r), len(g), len(b))\nfor i, j, k in [(r, g, b), (g, b, r), (b, r, g)]:\n if length == len(i):\n max1 = set(i)\n min1, min2 = j, k\n\nfor i, j in pro(min1, min2):\n if 2*j-i in max1:\n cnt -= 1\n if 2*i-j in max1:\n cnt -= 1\n if (i+j)/2 in max1:\n cnt -= 1\n\nprint(cnt)"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s072274460', 's940958036', 's296089746']
[9288.0, 9444.0, 9380.0]
[22.0, 314.0, 652.0]
[607, 496, 548]
p02714
u227082700
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(map(ord,input().split()))\nR=[0]\nG=[0]\nB=[0]\nfor i in s:\n R.append(R[-1])\n G.append(G[-1])\n B.append(B[-1])\n if i==82:R[-1]+=1\n elif i=="71":G[-1]+=1\n else:B[-1]+=1\nans=0\nfor i in range(n-2):\n for j in range(i+1,n-1):\n if s[i]==s[j]:continue\n if 82 not in [s[i],s[j]]:\n ans+=R[-1]-R[j]\n if j+(j-i)<n:\n if s[j+(j-i)]==82:ans-=1\n elif 71 not in [s[i],s[j]]:\n ans+=G[-1]-G[j]\n if j+(j-i)<n:\n if s[j+(j-i)]==71:ans-=1\n else:\n ans+=B[-1]-B[j]\n if j+(j-i)<n:\n if s[j+(j-i)]==66:ans-=1\nprint(ans)\n', 'n=int(input())\ns=list(map(ord,input().split()))\nR=[0]\nG=[0]\nB=[0]\nfor i in s:\n R.append(R[-1])\n G.append(G[-1])\n B.append(B[-1])\n if i==82:R[-1]+=1\n elif i==71:G[-1]+=1\n else:B[-1]+=1\nans=0\nfor i in range(n-2):\n for j in range(i+1,n-1):\n if s[i]==s[j]:continue\n if 82 not in [s[i],s[j]]:\n ans+=R[-1]-R[j]\n if j+(j-i)<n:\n if s[j+(j-i)]==82:ans-=1\n elif 71 not in [s[i],s[j]]:\n ans+=G[-1]-G[j]\n if j+(j-i)<n:\n if s[j+(j-i)]==71:ans-=1\n else:\n ans+=B[-1]-B[j]\n if j+(j-i)<n:\n if s[j+(j-i)]==66:ans-=1\nprint(ans)', 'n=int(input())\ns=input()\nr=g=b=0\nfor i in s:\n if i=="R":r+=1\n elif i=="G":g+=1\n else:b+=1\nans=r*g*b\nfor i in range(n-2):\n for j in range(i+1,n-1):\n k=j+(j-i)\n if k>=n:break\n if not(s[i]==s[j] or s[j]==s[k] or s[i]==s[k]):ans-=1\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s065253161', 's306763747', 's151702624']
[9204.0, 9300.0, 9156.0]
[23.0, 21.0, 1453.0]
[581, 578, 251]
p02714
u227550284
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\ninput = sys.stdin.readline\n\ndef main():\n n = int(input())\n s_li = list(input().rstrip())\n\n r_li = []\n g_li = []\n b_li = []\n\n for i in range(n):\n if s_li[i] == 'R':\n r.append(i)\n elif s_li[i] == 'G':\n g.append(i)\n elif s_li[i] == 'B':\n b.append(i)\n\n if (len(r_li) < 1 or len(g_li) < 1) or len(b_li) < 1:\n print(0)\n else:\n all_c = len(r_li) * len(g_li) * len(b_li)\n\n for i in range(n):\n for j in range(i+1,n):\n k = 2*j-i\n if k >= n:\n continue\n\n if (s_li[i] != s_li[j] and s_li[j] != s_li[k]) and s_li[i] != s_li[k]:\n all_c -= 1\n\n print(all_c)\n\nif __name__ == '__main__':\n main()\n", "import sys\ninput = sys.stdin.readline\n\ndef main():\n n = int(input())\n s_li = list(input().rstrip())\n\n r_li = []\n g_li = []\n b_li = []\n\n for i in range(n):\n if s_li[i] == 'R':\n r_li.append(i)\n elif s_li[i] == 'G':\n g_li.append(i)\n elif s_li[i] == 'B':\n b_li.append(i)\n\n if (len(r_li) < 1 or len(g_li) < 1) or len(b_li) < 1:\n print(0)\n else:\n all_c = len(r_li) * len(g_li) * len(b_li)\n\n for i in range(n):\n for j in range(i+1,n):\n k = 2*j-i\n if k >= n:\n continue\n\n if (s_li[i] != s_li[j] and s_li[j] != s_li[k]) and s_li[i] != s_li[k]:\n all_c -= 1\n\n print(all_c)\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s461272016', 's973726270']
[9256.0, 9336.0]
[22.0, 1012.0]
[791, 800]
p02714
u228303592
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')\n\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\n \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\n\nprint(ans)\n", "n = int(input())\ns = list(input())\nans = s.count('R')*s.count('G')*s.count('B')\n\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] = 4\n \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\n\nprint(ans)", "n = int(input())\ns = list(input())\nans = s.count('R')*s.count('G')*s.count('B')\n\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\n \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\n\nprint(ans)\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s240322272', 's777341254', 's587285619']
[9204.0, 9032.0, 9232.0]
[24.0, 22.0, 1669.0]
[338, 320, 342]
p02714
u237513745
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')\ng = s.count('G')\nb = s.count('B')\nc = 0\nfor i in range(n-1):\n for j in range(i+1, (n+1)//2):\n k = j*2-i\n if k >= n:\n continue\n if len(set([s[i], s[j], s[k]]))==3:\n c += 1\nprint(r*g*b-c)", "N = int(input())\nS = input()\nr = S.count('R')\ng = S.count('G')\nb = S.count('B')\nc = 0\nfor i in range(N-2):\n for j in range(i+1,(i+N+1)//2):\n k = j*2-i\n if len(set([S[i], S[j], S[k]]))==3:\n c += 1\nprint(r*g*b-c)"]
['Wrong Answer', 'Accepted']
['s111778604', 's267983116']
[9212.0, 9184.0]
[1018.0, 1963.0]
[253, 222]
p02714
u241159583
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 bisect\nN = int(input())\nS = list(input())\nR_i = []\nG_i = []\nB_i = []\nfor i in range(N):\n if S[i] == "R": R_i.append(i)\n elif S[i] == "G": G_i.append(i)\n else: B_i.append(i)\n\nr = len(R_i)\ng = len(G_i)\nb = len(B_i)\n\nans = 0\nfor i in range(N):\n for j in range(1, N-i):\n if S[i] == "R":\n print(i+j in G_i , b - bisect.bisect_right(B_i,i + j) > 0)\n if i+j in G_i and b - bisect.bisect_right(B_i,i + 2 * j) > 0:\n ans += b - bisect.bisect_right(B_i,i + 2 * j)\n if i + j + j in b: ans -= 1\n elif i+ j in B_i and g - bisect.bisect_right(G_i,i + 2 * j) > 0:\n ans += g - bisect.bisect_right(G_i,i + 2 * j)\n if i + j + j in g: ans -= 1\n elif S[i] == "G":\n if i+j in R_i and b - bisect.bisect_right(B_i,i + 2 * j) > 0:\n ans += b - bisect.bisect_right(B_i,i + 2 * j)\n if i + j + j in b: ans -= 1\n elif i+j in B_i and r - bisect.bisect_right(R_i,i + 2 * j) > 0:\n ans += r - bisect.bisect_right(R_i,i + 2 * j)\n if i + j + j in r: ans -= 1\n else:\n if i+j in R_i and g - bisect.bisect_right(G_i,i + 2 * j) > 0:\n ans += g - bisect.bisect_right(G_i,i + 2 * j)\n if i + j + j in g: ans -= 1\n elif i+j in G_i and r - bisect.bisect_right(R_i,i + 2 * j) > 0:\n ans += r - bisect.bisect_right(R_i,i + 2 * j)\n if i + j + j in r: ans -= 1\nprint(ans)', 'N = int(input())\nS = input()\nR = S.count("R")\nG = S.count("G")\nB = S.count("B")\n\ndef f(S):\n N = len(S)\n ret = 0\n for i in range(N):\n for j in range(i+1, N):\n k = j + j - i\n if k >= N: break\n if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n ret += 1\n return ret\n\nans = R * G * B - f(S)\nprint(ans)']
['Runtime Error', 'Accepted']
['s252077368', 's871229925']
[9356.0, 9204.0]
[72.0, 749.0]
[1359, 365]
p02714
u247680229
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\nS=list(input())\nm=0\n\na=S.count("R")\nb=S.count("G")\nc=S.count("B")\n\nnum=a*b*c\n\nfor i in range(N-2):\n for j in range(i+1,N):\n k=2*j-i\n if k>=n-1:\n break\n elif S[i]!=S[j]!=S[k]:\n m+=1\n \nprint(num-m)', 'ースコード \n\nCopy\nCopy\nN=int(input())\n \nS=list(input())\nm=0\n \na=S.count("R")\nb=S.count("G")\nc=S.count("B")\n \nnum=a*b*c\n \nfor i in range(N-2):\n for j in range(i+1,N-1):\n k=2*j-i \n if k>N-1:\n break\n elif S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:\n m+=1\n \nprint(num-m)', 'N=int(input())\n \nS=list(input())\nm=0\n \na=S.count("R")\nb=S.count("G")\nc=S.count("B")\n \nnum=a*b*c\n \nfor i in range(N-2):\n for j in range(i+1,N-1):\n k=2*j-i \n if k>N-1:\n break\n elif S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:\n m+=1\n \nprint(num-m)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s329319203', 's901180727', 's566387098']
[9172.0, 9216.0, 9232.0]
[23.0, 22.0, 1328.0]
[236, 307, 279]
p02714
u248670337
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=g=b=0\nR=[0 for _ in range(n)]\nG=[0 for _ in range(n)]\nB=[0 for _ in range(n)]\nfor i in range(i):\n if s[i]='R':r+=1\n elif s[i]='G':g+=1\n else:b+=1\n R[i]=r\n G[i]=g\n B[i]=b\nfor i in range(n):\n if s[i]='R':ans+=G[i]*(B[-1]-B[i])+B[i]*(G[-1]-G[i])\n elif s[i]='G':ans+=R[i]*(B[-1]-B[i])+B[i]*(R[-1]-R[i])\n else:ans+=R[i]*(G[-1]-G[i])+G[i]*(R[-1]-R[i])\nprint(ans)", 'from collections import Counter as C\nn=int(input())\nS=list(input())\na=1\nL=C(S).most_common(3)\nfor l in L:\n a*=l[1]\nfor i in range(1,n):\n for j in range(n-2*i):\n if len(set((S[j],S[j+i],S[j+2*i])))==3:\n a-=1\nprint(a if len(L)>2 else 0)']
['Runtime Error', 'Accepted']
['s312997459', 's362813371']
[8980.0, 9260.0]
[22.0, 1782.0]
[416, 244]
p02714
u249218427
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 -*-\nN = int(input())\nS = input()\n\nR = []\nG = []\nB = []\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 else:\n B.append(i)\n \ncount = 0\n\nfor r in R:\n for g in G:\n for b in B:\n S = sorted([r,g,b])\n if S[0]+S[2]!=2*S[1]:\n count += 1", "# -*- coding: utf-8 -*-\nN = int(input())\nS = input()\n\nR = 0\nG = 0\nB = 0\n\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\n\ncount = 0\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 a,b,c = S[i],S[j],S[k]\n if a!=b and b!=c and c!=a:\n count += 1\n\nprint(R*G*B-count)"]
['Wrong Answer', 'Accepted']
['s608786470', 's130880468']
[9120.0, 9248.0]
[2205.0, 1603.0]
[319, 363]
p02714
u250734103
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\nr , g, b = S.count("R"), S.count("G"), S.count("B")\nans = r * g * b\n\nfor i in range(N-2):\n for d in range(N//2+1):\n j = i + d\n k = j + d\n if k < N:\n \tif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n \tans -= 1\nprint(ans)', 'N = int(input())\nS = list(input())\n\nr , g, b = S.count("R"), S.count("G"), S.count("B")\nans = r * g * b\n\nfor i in range(N-2):\n for j in range(i+1, N-1):\n k = 2*(j+1) - (i+1)\n if k >= N: break\n if S[i] != S[j] and S[j] != S[k-1] and S[k-1] != S[i]:\n ans -= 1\nprint(ans)', "n = int(input())\ns = input()\n\nr = s.count('R')\ng = s.count('G')\nb = s.count('B')\n\nans = r*g*b\n\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 if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n ans -= 1\nprint(ans)\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s353817580', 's653220583', 's251082555']
[9048.0, 9236.0, 9056.0]
[20.0, 1607.0, 1919.0]
[300, 303, 283]
p02714
u252828980
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")\ng = s.count("G")\nb = s.count("B")\nnum = r*g*b\nfor i in range(n):\n for d in range(n):\n j = i + d\n k = j + d\n if k >=n:\n break\n if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n n', 'n = int(input())\ns = input()\nr = s.count("R")\ng = s.count("G")\nb = s.count("B")\nnum = r*g*b\nfor i in range(n):\n for d in range(n):\n j = i + d\n k = j + d\n if k >=n:\n break\n if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n num -=1\nprint(num)']
['Wrong Answer', 'Accepted']
['s322576491', 's610724472']
[9204.0, 9216.0]
[1634.0, 1464.0]
[278, 295]
p02714
u266014018
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\nans = 0\nfor i in range(n-2):\n\ts1 = s[i]\n\tfor j in range(i+1,n-1):\n \ts2 = s[j]\n if s1 == s2:\n \tpass\n else:\n \ts[2*j-i] != s1 and s[2*j-i] != s2:\n ans += 1\nprint(ans)', "n = int(input())\ns = input()\nans = s.count('R')*s.count('G')*s.count('B')\nfor i in range(n-2):\n for j in range(i+1,n-1):\n if 2*j - i > n-1:\n break\n if s[i] != s[j] and s[j] != s[2*j-i] and s[2*j-i] != s[i]:\n ans -=1\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s577600592', 's524603962']
[9008.0, 9188.0]
[25.0, 1628.0]
[280, 245]
p02714
u268792407
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,g,b=0,0,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\nchohuku=0\ndouble=0\nfor i in range(1,n-1):\n for j in range(1,min(i+1,n-1-i)):\n chohuku+=1\n k=j+i\n l=i-j\n if s[i]==s[k] or s[i]==s[l] or s[l]==s[k]:\n double+=1\nans=r*g*b-chohuku+double\nprint(ans)', 'n=int(input())\ns=input()\nR,G,B=[],[],[]\nans,r,g,b=0,0,0,0\nfor i in range(n):\n if s[i]=="R":\n R.append(i)\n r+=1\n if G!=[] and B!=[]:\n for gg in G:\n if (gg+i)/2 in B:\n ans+=b-1\n else:\n ans+=b\n for bb in B:\n if (bb+i)/2 in G:\n ans+=g-1\n else:\n ans+=g\n elif s[i]=="G":\n G.append(i)\n g+=1\n if R!=[] and B!=[]:\n for rr in R:\n if (rr+i)/2 in B:\n ans+=b-1\n else:\n ans+=b\n for bb in B:\n if (bb+i)/2 in R:\n ans+=r-1\n else:\n ans+=r\n else:\n B.append(i)\n b+=1\n if G!=[] and R!=[]:\n for gg in G:\n if (gg+i)/2 in R:\n ans+=r-1\n else:\n ans+=r\n for rr in R:\n if (rr+i)/2 in G:\n ans+=g-1\n else:\n ans+=g\nprint(ans)', 'n=int(input())\ns=input()\nr,g,b=0,0,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\nchohuku=0\ndouble=0\nfor i in range(1,n-1):\n for j in range(1,min(i+1,n-i)):\n chohuku+=1\n k=j+i\n l=i-j\n if s[i]!=s[k] and s[i]!=s[l] and s[l]!=s[k]:\n double+=1\nans=r*g*b-double\nprint(r,g,b,ans)', 'n=int(input())\ns=input()\nr,g,b=0,0,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\nchohuku=0\ndouble=0\nfor i in range(1,n-1):\n for j in range(1,min(i+1,n-i)):\n chohuku+=1\n k=j+i\n l=i-j\n if s[i]!=s[k] and s[i]!=s[l] and s[l]!=s[k]:\n double+=1\nans=r*g*b-double\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s168702276', 's240140698', 's870939763', 's986082746']
[9224.0, 9308.0, 9148.0, 9160.0]
[1598.0, 2205.0, 1394.0, 1529.0]
[378, 846, 376, 370]
p02714
u274635633
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=[]\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 else:\n b.append(i)\nans=len(r)*len(g)*len(b)\nfor i in g:\n for j in b:\n i+j=a\n if a%2==0 and (a//2 in r):\n ans-=1\nfor i in r:\n for j in b:\n i+j=a\n if a%2==0 and (a//2 in g):\n ans-=1\nfor i in g:\n for j in r:\n i+j=a\n if a%2==0 and (a//2 in b):\n ans-=1\nprint(ans)\n", "import bisect\nn=int(input())\ns=input()\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 else:\n b.append(i)\nans=len(r)*len(g)*len(b)\nr.append(n*4)\ng.append(n*4)\nb.append(n*4)\nfor i in g:\n for j in b:\n a=i+j\n if a%2==0 and r[bisect.bisect_left(r, a//2)]==a//2:\n ans-=1\nfor i in r:\n for j in b:\n a=i+j\n if a%2==0 and g[bisect.bisect_left(g, a//2)]==a//2:\n ans-=1\nfor i in g:\n for j in r:\n a=i+j\n if a%2==0 and b[bisect.bisect_left(b, a//2)]==a//2:\n ans-=1\nprint(ans+3)"]
['Runtime Error', 'Accepted']
['s264786511', 's191289648']
[9092.0, 9336.0]
[21.0, 1712.0]
[425, 557]
p02714
u274841648
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\ndef im(l, x):\n return [i for i, _x in enumerate(l) if _x == x]\nR = im(s, "R")\nG = im(s, "G")\nB = im(s, "B")\n\next = 0\nif n >= 3:\n for i in range((n-3)//2):\n for j in range(n-(3+2*i)+1):\n if s[j] != s[j+i+1] and s[j] != s[j+2*(i+1)] and s[j+i+1] != s[j+2*(i+1)]:\n ext += 1\n\nans = len(R)*len(G)*len(B) - ext\nprint(ans)\n', 'n = int(input())\ns = input()\n\ndef im(l, x):\n return [i for i, _x in enumerate(l) if _x == x]\nR = im(s, "R")\nG = im(s, "G")\nB = im(s, "B")\n\next = 0\nif n >= 3:\n for i in range((n-3)//2+1):\n for j in range(n-(3+2*i)+1):\n if s[j] != s[j+i+1] and s[j] != s[j+2*(i+1)] and s[j+i+1] != s[j+2*(i+1)]:\n ext += 1\n\nans = len(R)*len(G)*len(B) - ext\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s143501093', 's436429488']
[9320.0, 9240.0]
[1525.0, 1596.0]
[385, 387]
p02714
u277641173
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\ncount = 0\nr=0\ng=0\nb=0\nfor i in range(0,n):\n if s[i] == 'R':\n r = r + 1\n if s[i]=='G':\n g = g+1\n if s[i]=='B':\n b = b+1\n \nfor i in range(0,n-3):\n ii = s[i]\n for j in range(i+1, n-1):\n jj = s[j]\n if ii==jj:\n continue\n if (2*j-i)<=(n-1):\n if ii!=s[2*j-i] and jj!=s[2*j-i]:\n count = count + 1\nprint(r*g*b-count)\n", "n = int(input())\ns = input()\n\ncount = 0\nr=0\ng=0\nb=0\nfor i in range(0,n):\n if s[i] == 'R':\n r = r + 1\n if s[i]=='G':\n g = g+1\n if s[i]=='B':\n b = b+1\n \nfor i in range(0,n):\n ii = s[i]\n for j in range(i+1, n):\n jj = s[j]\n if ii==jj:\n continue\n if (2*j-i)<=(n-1):\n if ii!=s[2*j-i] and jj!=s[2*j-i]:\n count = count + 1\nprint(r*g*b-count)\n"]
['Wrong Answer', 'Accepted']
['s979865157', 's154629319']
[9136.0, 9184.0]
[2002.0, 1977.0]
[381, 377]
p02714
u289162337
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\nfor i in range(n-2):\n for j in range(i+1, n-1):\n if s[i] != s[j]:\n for k in range(j+1, n):\n if s[j] != s[k] and s[k]!= s[i]:\n if j-i != k-j:\n ans +=1\nprint(ans)', 'import statistics as st\nn = int(input())\ns = input()\nNGs = 0\nr = set()\ng = set()\nb = set()\nfor i in range(n):\n if s[i] == "R":\n r.add(i)\n elif s[i] == "G":\n g.add(i)\n else:\n b.add(i)\nfor i in range(n-2):\n for d in range((n-i-1)//2+1):\n j = i+d\n k = j+d\n if i in r and j in g and k in b:\n NGs += 1\n elif i in r and j in b and k in g:\n NGs += 1\n elif i in g and j in r and k in b:\n NGs += 1\n elif i in g and j in b and k in r:\n NGs += 1\n elif i in b and j in r and k in g:\n NGs += 1\n elif i in b and j in g and k in r:\n NGs += 1\nprint(len(r)*len(g)*len(b)-NGs)']
['Runtime Error', 'Accepted']
['s723043862', 's843113053']
[8968.0, 11176.0]
[23.0, 1946.0]
[225, 625]
p02714
u289288647
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\nnum = len(s)\nans = 0\nfor i in range(num):\n a = set(s[i])\n for j in range(i+1, num):\n if s[j] in a:\n continue\n a.add(s[j])\n for k in range(j+1, num):\n if s[k] in a or j-i == k-j:\n continue\n ans += 1\n a.remove()\n\nprint(ans)\n', "n = int(input())\ns = input()\n\nnum = len(s)\nans = s.count('R')*s.count('G')*s.count('B')\n\nfor i in range(num):\n for j in range(i+1, num):\n if 0 <= 2*j-i < num:\n if s[i] != s[j] and s[j] != s[2*j-i] and s[2*j-i] != s[i]:\n ans -= 1\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s946868456', 's324385531']
[9188.0, 9124.0]
[27.0, 1955.0]
[334, 276]
p02714
u297046168
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 = str(input())\ncount = S.count('R') * S.count('G') * S.count('B')\nfor i in range(N-1):\n for j in range(i,(N+i)//2):\n k = 2*j - i\n if S[i] == S[j] or S[i] == S[k] or S[j] == S[k]:\n pass\n else:\n count -= 1\nprint(count)", "N = int(input())\nN -= 1\nS = str(input())\ncount = 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 pass\n elif S[i] == S[j] or S[i] == S[k] or S[j] == S[k]:\n pass\n else:\n count -= 1\nprint(count)"]
['Wrong Answer', 'Accepted']
['s991801034', 's568860043']
[9448.0, 9204.0]
[1260.0, 1948.0]
[300, 318]
p02714
u300579805
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\nn = int(input())\ns = str(input())\nr = {}\nb = {}\ng = {}\nfor i in range(len(s)):\n if s[i] == 'R':\n r[i+1] = s[i]\n elif s[i] == 'B':\n b[i+1] = s[i]\n else:\n g[i+1] = s[i]\nans = len(r) * len(b) * len(g)\nprint(ans)\nfor i in r.keys():\n for j in b.keys():\n diff = abs(j-i)\n minb = min(i,j)-diff\n maxb = max(i,j)+diff\n if maxb in g.keys():\n ans -= 1\n if minb in g.keys():\n ans -= 1\n if((i+j)%2==0):\n if((i+j)//2 in g.keys()):\n ans -=1\nprint(ans)", "import itertools\nn = int(input())\ns = str(input())\nr = {}\nb = {}\ng = {}\nfor i in range(len(s)):\n if s[i] == 'R':\n r[i+1] = s[i]\n elif s[i] == 'B':\n b[i+1] = s[i]\n else:\n g[i+1] = s[i]\nans = len(r) * len(b) * len(g)\nfor i in r.keys():\n for j in b.keys():\n diff = abs(j-i)\n minb = min(i,j)-diff\n maxb = max(i,j)+diff\n if maxb in g.keys():\n ans -= 1\n if minb in g.keys():\n ans -= 1\n if((i+j)%2==0):\n if((i+j)//2 in g.keys()):\n ans -=1\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s346883878', 's500813571']
[9400.0, 9236.0]
[1696.0, 1670.0]
[576, 565]
p02714
u308684517
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 = 4000\ns = "RGB" * 1333 + "R"\nrgb = s.count("R") * s.count("G") * s.count("B")\nfor i in range(n-2):\n for j in range(i+1, n-1):\n d = j - i\n k = j + d\n if n <= k: break\n if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:\n rgb -= 1\nprint(rgb) \n', 'n = int(input())\ns = input()\nrgb = s.count("R") * s.count("G") * s.count("B")\nfor i in range(n-2):\n for j in range(i+1, n-1):\n d = j - i\n k = j + d\n if n <= k: break\n if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:\n rgb -= 1\nprint(rgb) \n']
['Wrong Answer', 'Accepted']
['s556038562', 's762266156']
[9040.0, 9076.0]
[1637.0, 1448.0]
[266, 263]
p02714
u319589470
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\nli_r = []\nli_g = []\nli_b = []\nfor i in range(n):\n if li[i] == "R":\n li_r.append(i+1)\n elif li[i] == "G":\n li_g.append(i+1)\n elif li[i] == "B":\n li_b.append(i+1)\nfor i in li_r:\n for j in li_g:\n if 2*j - i in li_b:\n ans += len(li_b) -1\n else:\n ans += len(li_b)\nprint(ans)', '#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**7)\nimport bisect\nimport heapq\nimport itertools\nimport math\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom math import gcd\nfrom operator import add, itemgetter, mul, xor\ndef cmb(n,r,mod):\n bunshi=1\n bunbo=1\n for i in range(r):\n bunbo = bunbo*(i+1)%mod\n bunshi = bunshi*(n-i)%mod\n return (bunshi*pow(bunbo,mod-2,mod))%mod\nmod = 10**9+7\ndef I(): return int(input())\ndef LI(): return list(map(int,input().split()))\ndef MI(): return map(int,input().split())\ndef LLI(n): return [list(map(int, input().split())) for _ in range(n)]\n\n\n\n\n\n\n\n\n\nn = I()\ns = input()\nc = Counter(s)\nans = 0\nfor i in range(n):\n for k in range(i+1,n):\n if (i+k)%2 == 0:\n j = (i+k)//2\n if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n ans+=1\nans_2 = c["R"]*c["G"]*c["B"]\nprint(ans_2-ans)']
['Runtime Error', 'Accepted']
['s823718437', 's791999781']
[9204.0, 9972.0]
[22.0, 1874.0]
[334, 1552]
p02714
u329709276
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()) # 1 <= N <= 4000\nS = input() # [RGB]{N}\nL = {\n 'R': tuple(i for i, v in enumerate(S) if v == 'R'),\n 'G': tuple(i for i, v in enumerate(S) if v == 'G'),\n 'B': tuple(i for i, v in enumerate(S) if v == 'B')\n}\nprint(type(L['R']))\n\nans = 0\nfor i in range(N):\n for j in range(i+1, N):\n if S[i] != S[j]:\n other = list({'R', 'G', 'B'} - {S[i], S[j]})[0]\n tmp = j + j - i\n ans += len([k for k in L[other] if (k > j) and (tmp != k)])\nprint(ans)\n\n\n\n", "N = int(input()) # 1 <= N <= 4000\nS = input() # [RGB]{N}\nL = {\n 'R': tuple(i for i, v in enumerate(S) if v == 'R'),\n 'G': tuple(i for i, v in enumerate(S) if v == 'G'),\n 'B': tuple(i for i, v in enumerate(S) if v == 'B')\n}\nR_length = len(L['R'])\nG_length = len(L['G'])\nB_length = len(L['B'])\n\nans = R_length * G_length * B_length\nfor i in range(N):\n for j in range(i+1, N):\n k = j + 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\nprint(ans)\n\n\n\n"]
['Wrong Answer', 'Accepted']
['s906785257', 's756860474']
[9036.0, 9096.0]
[2206.0, 1412.0]
[509, 541]
p02714
u345483150
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()\ns=list(s)\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 else:\n b.append(i)\nprint(r) \nprint(g) \nprint(b) \ncnt=0 \nfor j in r:\n for l in g:\n if (2*l-j) or (2*j-l) in b:\n cnt+=1\nprint(len(r)*len(g)*len(b)-cnt+1)', "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+1,n):\n k=2*j-i\n if k>=n:\n break\n if s[i]!= s[j] and s[i]!=s[k] and s[i+j]!= s[k] :\n ans-=1\nprint(ans)", '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):\n if 2*j-i>=n:\n break\n else:\n if s[i]!=s[j]!=s[2*j-i]!=s[i]:\n ans-=1\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s730702210', 's862233658', 's391876729']
[9160.0, 9200.0, 9188.0]
[273.0, 808.0, 1265.0]
[349, 256, 211]
p02714
u347452770
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 \nstr = input()\nsum = 0\npointer = n\nfor i in range(n-2):\n if i == poitner:\n break\n for j in range(i+1, n-1):\n for k in range(j+1, n):\n if str[i] == str[j]:\n pointer = j\n break\n elif str[i] != str[k] and str[j] != str[k] and j - i != k - j:\n sum += 1\nprint(sum)', 'n = int(input())\n \nstr = input()\nsum = 0\nfor i in range(n-2):\n for j in range(i+1, n-1):\n if str[i] == str[j]:\n break\n for k in range(j+1, n):\n if str[i] != str[k] and str[j] != str[k] and j - i != k - j:\n sum += 1\n\nprint(sum)', "n = int(input())\n \nstr = input()\n\nr = str.count('R')\ng = str.count('G')\nb = str.count('B')\nsum = r * g * 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 if str[i] != str[j] and str[i] != str[k] and str[j] != str[k] :\n sum -= 1\n \nprint(sum)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s035881461', 's381159787', 's899063276']
[9196.0, 8964.0, 9076.0]
[21.0, 23.0, 1883.0]
[316, 253, 290]
p02714
u352402050
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())\nA = S.count("R") * S.count("G") * S.count("B")\n\nfor i in range(N-3):\n for j in range(i+1, N-1):\n k = j-i+j\n if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:\n A -= 1\n\nprint(A)\n', 'N = int(input())\nS = list(input())\nA = S.count("R") * S.count("G") * S.count("B")\n\nfor i in range(N):\n for j in range(N):\n k = j-i+j\n if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:\n A -= 1 \n\nprint(A)\n\n\n \n\n\n', 'N = int(input())\nS = list(input())\nA = S.count("R") * S.count("G") * S.count("B")\n\nfor i in range(N):\n for j in range(i+1, N):\n k = j-i+j\n if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:\n A -= 1 \n\nprint(A)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s098779934', 's771321681', 's962570399']
[9096.0, 9120.0, 9112.0]
[1918.0, 2206.0, 1846.0]
[231, 235, 231]
p02714
u371132735
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")\ng = s.count("G")\nb = s.count("B")\ncnt= 0\nfor i in range(n):\n for j in range(i,n):\n if s[i] != s[j] and s[i] != s[2*j-i] and s[j] != s[2*j-i] and 2*j-i<n:\n cnt += 1\nprint(r*g*b-cnt)', '# abc162_d.py\nn = int(input())\ns = input()\nr = s.count("R")\ng = s.count("G")\nb = s.count("B")\ncnt= 0\nfor i in range(n):\n for j in range(i,n):\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 cnt += 1\nprint(r*g*b-cnt)']
['Runtime Error', 'Accepted']
['s369345620', 's649723077']
[9200.0, 9200.0]
[21.0, 1956.0]
[247, 277]
p02714
u374018235
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 = len(S.replace("G", "").replace("B", ""))\ng = len(S.replace("R", "").replace("B", ""))\nb = N - r - g\n\nans = r * g\nans = ans * b\n\nfor i in range( N ):\n for j in range(i, int((N+i)/2 + 1)):\n k = 2 * j - i\n if k < N:\n s = S[i] + S[j] + S[k]\n if ("R" in s) & ("G" in s) & ("B" in s):\n ans -= 1\n\nprint(ans)', 'N=int(input())\nS=input()\nr = len(S.replace("G", "").replace("B", ""))\ng = len(S.replace("R", "").replace("B", ""))\nb = N - r - g\n\nans = r * g\nans = ans * b\n\nfor i in range( N ):\n for j in range(i+1, int((N+i)/2 )):\n k = 2 * j - i\n if k < N:\n s = S[i] + S[j] + S[k]\n if ("R" in s) & ("G" in s) & ("B" in s):\n ans -= 1\n\nprint(ans)', 'N=int(input())\nS=input()\nr = len(S.replace("G", "").replace("B", ""))\ng = len(S.replace("R", "").replace("B", ""))\nb = N - r - g\n\nans = r * g\nans = ans * b\n\nfor i in range( N ):\n for j in range(i+1, int((N+i)/2 +1 )):\n k = 2 * j - i\n if k < N:\n s = S[i] + S[j] + S[k]\n if ("R" in s) & ("G" in s) & ("B" in s):\n ans -= 1\n\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s341561008', 's790353160', 's029292578']
[9048.0, 9236.0, 9188.0]
[22.0, 1685.0, 1710.0]
[399, 382, 385]
p02714
u379720557
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 = s.count('R')\nG = s.count('G')\nB = s.count('B')\nans = R*G*B\n\nfor i in range(n):\n for d in range(1, n):\n print(i, i+d, i+2*d)\n if i+2*d > n-1: break\n if s[i] != s[i+d] and s[i+d] != s[i+2*d] and s[i] != s[i+2*d]:\n ans -= 1\n\nprint(ans)", "n = int(input())\ns = input()\n\nR = s.count('R')\nG = s.count('G')\nB = s.count('B')\nans = R*G*B\n\nfor i in range(n):\n for d in range(n):\n if i+(2*d) >= n: break\n if s[i] != s[i+d] and s[i] != s[i+(2*d)] and s[i+d] != s[i+(2*d)]:\n ans -= 1\n \nprint(ans)"]
['Wrong Answer', 'Accepted']
['s345492424', 's921688048']
[27616.0, 9080.0]
[2236.0, 1653.0]
[301, 286]
p02714
u391725895
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.
["l = [input() for _ in range(2)]\nS = l[1]\nN = int(l[0])\ncount = 0\n\nindexR = []\nindexG = []\nindexB = []\n\ni = 0\nj = 0\nk = 0\n\nfor a in range(N):\n character = S[a:a+1]\n\n if character == 'R':\n indexR.append(a+1)\n elif character == 'G':\n indexG.append(a+1)\n elif character == 'B':\n indexB.append(a+1)\n\nfor r in indexR:\n for g in indexG:\n for b in indexB:\n mean = (max[r, g, b] + min[r, g, b])/2\n if mean != r and mean != g and mean != b:\n count = count + 1\nprint(count)", "l = [input() for _ in range(2)]\nS = l[1]\nN = int(l[0])\ncount = 0\n\nindexR = []\nindexG = []\nindexB = []\n\ni = 0\nj = 0\nk = 0\n\nfor a in range(N):\n character = S[a:a+1]\n\n if character == 'R':\n indexR.append(a+1)\n elif character == 'G':\n indexG.append(a+1)\n elif character == 'B':\n indexB.append(a+1)\n\nmaxi = 0\nmini = 0\n\nfor r in indexR:\n maxi = r\n mini = r\n for g in indexG:\n if g < mini:\n mini = g\n if g > maxi:\n maxi = g\n for b in indexB:\n if b < mini:\n mini = b\n if b > maxi:\n maxi = b\n mean = (maxi - mini)/2\n if mean != r and mean != g and mean != b:\n count = count + 1\nprint(count)", "l = [input() for _ in range(2)]\nS = l[1]\nN = int(l[0])\ncount = 0\n\nindexR = []\nindexG = []\nindexB = []\n\ni = 0\nj = 0\nk = 0\n\nfor a in range(N):\n character = S[a:a+1]\n\n if character == 'R':\n indexR.append(a+1)\n elif character == 'G':\n indexG.append(a+1)\n elif character == 'B':\n indexB.append(a+1)\n\nfor r in indexR:\n for g in indexG:\n for b in indexB:\n mean = (max[r, g, b] + min[r, g, b]/2)\n if mean != r and mean != g and mean != b:\n count = count + 1\nprint(count)", "from collections import Counter\n\nN = int(input())\nS = input()\ncnt = Counter(S)\n\nans = cnt['R']*cnt['G']*cnt['B']\n\n\nfor i in range(N-2):\n for j in range(i+1, N-1):\n k = j + (j - i)\n \n if k < N:\n if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:\n ans -= 1\n\nprint(ans)"]
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s197146720', 's657696946', 's818350234', 's146941709']
[9236.0, 9248.0, 9236.0, 9360.0]
[24.0, 2205.0, 22.0, 1907.0]
[542, 755, 542, 577]
p02714
u409306788
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 clipboard\n\n\n\n\n\nif sys.platform == 'ios':\n\tsample = clipboard.get()\n\tfile = open('input_file.txt', 'w')\n\tfile.write(sample)\n\tfile.close()\n\tsys.stdin = open('input_file.txt')\n# -----------------------------\n\t\t\t\t\t\t\n\n# D - RGB Triplets\n\nN = int(input())\nS = input()\n\nr, g, b = 0, 0, 0\n\nfor s in S:\n\tif s == 'R':\n\t\tr += 1\n\telif s == 'G':\n\t\tg += 1\n\telse:\n\t\tb += 1\n\nans = r * g * b\n\nfor i in range(N - 2):\n\tfor j in range(i + 1, N - 1):\n\t\tfor k in range(j + 1, N):\n\t\t\tif S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n\t\t\t\tif j -i == k -j:\n\t\t\t\t\tans -= 1\n\nprint(ans) ", "# D - RGB Triplets\n\t\nN = int(input())\nS = input()\n\t\nr, g, b = 0, 0, 0\n\t\nfor s in S:\n\tif s == 'R':\n\t\tr += 1\n\telif s == 'G':\n\t\tg += 1\n\telse:\n\t\tb += 1\n\t\nans = r * g * b\n\t\nfor i in range(N - 2):\n\tfor j in range(i + 1, N - 1):\n\t\tk = j * 2 - i\n\t\t\t\n\t\tif k < N:\n\t\t\tif S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n\t\t\t\tif j -i == k -j:\n\t\t\t\t\tans -= 1\n\t\nprint(ans)"]
['Runtime Error', 'Accepted']
['s823839224', 's380503354']
[9096.0, 9148.0]
[18.0, 1833.0]
[849, 355]
p02714
u411353821
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 = int(input())\n S = input()\n \'\'\'\n r_inds = []\n g_inds = []\n b_inds = []\n for i in range(len(S)):\n if S[i] == "R":\n r_inds.append(i)\n elif S[i] == "G":\n g_inds.append(i)\n else:\n b_inds.append(i)\n\n total_comb = len(r_inds)*len(g_inds)*len(b_inds)\n ded = 0\n for i in r_inds:\n for j in g_inds:\n s_ind = min(i, j)\n b_ind = max(i, j)\n diff = b_ind - s_ind\n bigger_ind = b_ind + diff\n smaller_ind = s_ind - diff\n if bigger_ind < len(S) and bigger_ind in b_inds:\n ded += 1\n if smaller_ind >= 0 and smaller_ind in b_inds:\n ded += 1\n if diff % 2 == 0:\n mid_diff = diff // 2\n mid_ind = s_ind + mid_diff\n if mid_ind in b_inds:\n ded += 1\n print(total_comb - ded)\n \'\'\'\n color_num = defaultdict(int)\n num_subst = 0\n\n for i in range(len(S) - 1):\n color_num[S[i]] += 1 \n for j in range(i + 1, len(S)):\n if S[i] != S[j]:\n diff = j - i\n idx = j + diff\n if idx < len(S) and S[idx] != S[i] and S[idx] != S[j]:\n num_subst += 1\n color_num[S[len(S) - 1]] += 1 \n total_num_comb = color_num["R"] * color_num["G"] * color_num["B"]\n print(total_num_comb - num_subst)\n\nif __name__ == "__main__":\n main()\n', 'from collections import defaultdict\n\n\ndef main():\n n = int(input())\n S = input()\n \'\'\'\n r_inds = []\n g_inds = []\n b_inds = []\n for i in range(len(S)):\n if S[i] == "R":\n r_inds.append(i)\n elif S[i] == "G":\n g_inds.append(i)\n else:\n b_inds.append(i)\n\n total_comb = len(r_inds)*len(g_inds)*len(b_inds)\n ded = 0\n for i in r_inds:\n for j in g_inds:\n s_ind = min(i, j)\n b_ind = max(i, j)\n diff = b_ind - s_ind\n bigger_ind = b_ind + diff\n smaller_ind = s_ind - diff\n if bigger_ind < len(S) and bigger_ind in b_inds:\n ded += 1\n if smaller_ind >= 0 and smaller_ind in b_inds:\n ded += 1\n if diff % 2 == 0:\n mid_diff = diff // 2\n mid_ind = s_ind + mid_diff\n if mid_ind in b_inds:\n ded += 1\n print(total_comb - ded)\n \'\'\'\n color_num = defaultdict(int)\n num_subst = 0\n\n for i in range(len(S) - 1):\n color_num[S[i]] += 1 \n for j in range(i + 1, len(S)):\n if S[i] != S[j]:\n diff = j - i\n idx = j + diff\n if idx < len(S) and S[idx] != S[i] and S[idx] != S[j]:\n num_subst += 1\n color_num[S[len(S) - 1]] += 1 \n total_num_comb = color_num["R"] * color_num["G"] * color_num["B"]\n print(total_num_comb - num_subst)\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s200401114', 's332976017']
[9232.0, 9448.0]
[20.0, 1393.0]
[1479, 1517]
p02714
u414430923
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 numpy as np\n\nin_list = []\nfor i in range(2):\n in_list.append(input())\nN,S = in_list\nN = int(N)\nres = 0\nfind_ind = []\nfor i in ['R','G','B']:\n find = (np.array(list(S)) == i)\n find_ind.append(find.argsort()[::-1][:sum(find)])\n # print(len(find_ind[-1]))\n\nfind_ind = np.array(find_ind)\nrg_diff = find_ind[0] - find_ind[1].reshape(len(find_ind[1]),1)\nrg_diff = np.abs(rg_diff)\n# print(rg_diff)\ngb_diff = find_ind[1] - find_ind[2].reshape(len(find_ind[2]),1)\ngb_diff = np.abs(gb_diff)\ngb_diff = gb_diff.T\n# print(gb_diff)\nbr_diff = find_ind[2] - find_ind[0].reshape(len(find_ind[0]),1)\nbr_diff = np.abs(br_diff)\n\n# print(br_diff)\n\nres = 0\n\nfor i in range(len(find_ind[1])):\n res += np.sum((rg_diff[i] - gb_diff[i].reshape(len(gb_diff[i]),1)) == 0)\nfor i in range(len(find_ind[0])):\n res += np.sum((rg_diff[:,i] - br_diff[i].reshape(len(br_diff[i]),1)) == 0)\nbr_diff = br_diff.T\nfor i in range(len(find_ind[2])):\n res += np.sum((gb_diff[:,i] - br_diff[i].reshape(len(br_diff[i]),1)) == 0)\n\n\nprint(len(find_ind[0])*len(find_ind[1])*len(find_ind[2])-res)\n\n", 'N = int(input())\nS = input()\n\nres = 0\nfor i in range(N-2):\n n = 1\n while True:\n j = i+n\n k = j+n\n if k > N-1: break\n res += (S[i] != S[j] and S[j] != S[k] and S[k] != S[i])\n n += 1\n \n \nrgb = S.count("R") * S.count("G") * S.count("B")\nprint(rgb - res)\n']
['Time Limit Exceeded', 'Accepted']
['s264269958', 's693071513']
[84028.0, 9116.0]
[2207.0, 1786.0]
[1112, 298]
p02714
u426764965
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, G, B = [], [], []\nfor i, c in enumerate(s):\n if c == 'R': R.append(i)\n elif c == 'G': G.append(i)\n else: B.append(i)\n\nans = 0\nfor r in R:\n for g in G:\n if r < g: x, y = r, g\n else: x, y = g, r\n\n ans += len(X3)\n if x*2 - y >= 0:\n if s[x*2 - y] == 'B': ans -= 1\n if (x + y) % 2 == 0:\n if s[(x+y)//2] == 'B': ans -= 1\n if y*2 - x < len(s):\n if s[y*2 - x] == 'B': ans -= 1\n\nprint(ans)", "n = int(input())\ns = str(input())\n\nR, G, B = [], [], []\nfor i, c in enumerate(s):\n if c == 'R': R.append(i)\n elif c == 'G': G.append(i)\n else: B.append(i)\n\nans = 0\nfor r in R:\n for g in G:\n if r < g: x, y = r, g\n else: x, y = g, r\n\n ans += len(B)\n if x*2 - y >= 0:\n if s[x*2 - y] == 'B': ans -= 1\n if (x + y) % 2 == 0:\n if s[(x+y)//2] == 'B': ans -= 1\n if y*2 - x < len(s):\n if s[y*2 - x] == 'B': ans -= 1\n\nprint(ans)"]
['Runtime Error', 'Accepted']
['s943396246', 's137076051']
[9232.0, 9284.0]
[24.0, 1308.0]
[455, 454]
p02714
u429029348
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 d in range(n):\n j=i+d\n k=j+d\n if 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 d in range(n):\n j=i+d\n k=j+d\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\nprint(ans) ']
['Runtime Error', 'Accepted']
['s568387691', 's026915457']
[9196.0, 9152.0]
[24.0, 1406.0]
[260, 298]
p02714
u431484963
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.
["mport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\nfrom numba import njit\n \nMOD = 10**9 + 7\n \nN = int(readline())\nS = np.array(list(read().rstrip()), np.int8)\n \nR = np.sum(S == ord('R'))\nB = np.sum(S == ord('B'))\nG = np.sum(S == ord('G'))\n \n@njit\ndef f(S):\n N = len(S)\n ret = 0\n for i in range(N):\n for j in range(i + 1, N):\n k = j + 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 ret += 1\n return ret\n \nanswer = R * B * G - f(S)\nprint(answer)", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\nfrom numba import njit\n \nMOD = 10**9 + 7\n \nN = int(readline())\nS = np.array(list(read().rstrip()), np.int8)\n \nR = np.sum(S == ord('R'))\nB = np.sum(S == ord('B'))\nG = np.sum(S == ord('G'))\n \n@njit\ndef f(S):\n N = len(S)\n ret = 0\n for i in range(N):\n for j in range(i + 1, N):\n k = j + 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 ret += 1\n return ret\n \nanswer = R * B * G - f(S)\nprint(answer)"]
['Runtime Error', 'Accepted']
['s758128880', 's988378519']
[9012.0, 109668.0]
[24.0, 639.0]
[639, 640]
p02714
u437727817
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\ncount = 0\nfor i in range(n-2):\n\tlis = []\n\tlis.append(s[i])\n\tfor j in range(i+1,n-1):\n\t\tif not s[j] in lis :\n\t\t\tlis.append(s[j])\n\t\t\tfor k in range(j+1,n):\n\t\t\t\tif not s[k] in lis :\n\t\t\t\t\tcount += 1\n\nprint(count)', 'n = int(input())\ns = input()\n\nr = s.count("R")\ng = s.count("G")\nb = s.count("B")\n\n\ncount = 0\n\nfor i in range(n):\n\tfor j in range(i+1,n):\n\t\tk = j*2-i\n\t\tif 0 <= k < n:\n\t\t\tif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n\t\t\t\tcount += 1\nprint(r*g*b - count)\n\n\n']
['Wrong Answer', 'Accepted']
['s091275178', 's329117153']
[9056.0, 9140.0]
[2206.0, 1922.0]
[238, 258]
p02714
u439176910
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 = []\nRD = {}\nGD = {}\nBD = {}\n\nS = input().rstrip()\nS = "".join([S for i in range(100)])\nfor i, s in enumerate(S):\n if s == "R":\n R.append(i)\n RD[i*2] = 1\n if s == "G":\n G. append(i)\n GD[i*2] = 1\n if s == "B":\n B.append(i)\n BD[i*2] = 1\n\nans = len(R) * len(G) * len(B)\nfor r in R:\n for b in B:\n if r + b in GD:\n ans -= 1\nfor b in B:\n for g in G:\n if b + g in RD:\n ans -= 1\nfor r in R:\n for g in G:\n if r + g in BD:\n ans -= 1\nprint(ans)\n', 'N = int(input())\nR = []\nG = []\nB = []\nRD = {}\nGD = {}\nBD = {}\n\nS = input().rstrip()\n\nfor i, s in enumerate(S):\n if s == "R":\n R.append(i)\n RD[i*2] = 1\n if s == "G":\n G. append(i)\n GD[i*2] = 1\n if s == "B":\n B.append(i)\n BD[i*2] = 1\n\nans = len(R) * len(G) * len(B)\nfor r in R:\n for b in B:\n if r + b in GD:\n ans -= 1\nfor b in B:\n for g in G:\n if b + g in RD:\n ans -= 1\nfor r in R:\n for g in G:\n if r + g in BD:\n ans -= 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s289703022', 's387055697']
[56088.0, 9412.0]
[2207.0, 564.0]
[581, 545]
p02714
u440161695
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 itertools import accumlate\nN=int(input())\ns=input()\nR=[]\nG=[]\nB=[]\nans=0\n\nfor i in range(N):\n if s[i]=="R":\n R.append(s[i])\n elif s[i]=="G":\n G.append(s[i])\n else:\n B.append(s[i])\nR.accumlate()\nG.accumlate()\nB.accumlate()\n\n\n\nfor i in range(N):\n a=s[i]\n for j in range(i+1,N):\n if a==s[j]:\n continue\n b=s[j]\n k=2*j-i\n if "R" not in a+b:\n ans+=R[N]-R[j+1]\n if s[k]=="R":\n ans-=1\n if "G" not in a+b:\n ans+=G[N]-G[j+1]\n if s[k]=="G":\n ans-=1\n if "B" not in a+b:\n ans+=B[N]-B[j+1]\n if s[k]=="B":\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\n \n\nfor i in range(N-2):\n a=s[i]\n for j in range(i+1,N-1):\n if a==s[j]:\n continue\n b=s[j]\n k=2*j-i\n if k>=N:\n continue\n if s[k]!=a and s[k]!=b:\n ans-=1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s156750912', 's760687789']
[9032.0, 9136.0]
[21.0, 1834.0]
[653, 290]
p02714
u443872523
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())\ncnt = 0\n\ncnt = s.count("R") * s.count("B") * s.count("G")\nprint(cnt)\n\nsub = 0 \nfor i in range(n):\n for j in range(i, n):\n k = 2 * j - i\n if k <= n - 1:\n if (s[i] != s[j]) and (s[j] != s[k]) and (s[i] != s[k]):\n sub += 1\n\nprint(cnt-sub)', 'n = int(input())\ns = list(input())\ncnt = 0\n\ncnt = s.count("R") * s.count("B") * s.count("G")\n\nsub = 0 \nfor i in range(n):\n for j in range(i, n):\n k = 2 * j - i\n if k <= n - 1:\n if (s[i] != s[j]) and (s[j] != s[k]) and (s[i] != s[k]):\n sub += 1\n\nprint(cnt-sub)\n']
['Wrong Answer', 'Accepted']
['s967817155', 's599547643']
[9204.0, 9200.0]
[1864.0, 1851.0]
[343, 333]
p02714
u449473917
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=s.count('R')\ng=s.count('G')\nb=s.count('B')\n\nans=r*g*b\n\nfor i in range(n):\n for d in range(n):\n j=i+d\n k=j+d\n if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i] and k<n:\n ans-=1\n\nprint(ans)", "n=int(input())\ns=input()\n\nr=s.count('R')\ng=s.count('G')\nb=s.count('B')\n\nans=r*g*b\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)\n"]
['Runtime Error', 'Accepted']
['s807475426', 's571217478']
[9216.0, 9128.0]
[21.0, 1471.0]
[244, 260]
p02714
u454524105
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("R") * s.count("G") * s.count("B")\ncnt = 0\nfor i in range(n-3):\n i_ = s[i]\n for j in range(i+1, n-1):\n if s[j] == i_: continue\n k = 2 * j - i\n j_ = s[j]\n if k >= n or s[k] == i_ or s[k] == j_: continue\n cnt += 1\nprint(ans - cnt)', 'n = int(input())\ns = input()\nans = s.count("R") * s.count("G") * s.count("B")\ncnt = 0\nfor i in range(n):\n i_ = s[i]\n for j in range(i+1, n):\n if s[j] == i_: continue\n k = 2 * j - i\n j_ = s[j]\n if k >= n or s[k] == i_ or s[k] == j_: continue\n cnt += 1\nprint(ans - cnt)']
['Wrong Answer', 'Accepted']
['s006482352', 's554382077']
[9168.0, 9132.0]
[1989.0, 1998.0]
[312, 308]
p02714
u455957070
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\nkumikazu = s.count('R')*s.count('B')*s.count('G')\n\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 if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):\n kumikazu -= 1", "n = int(input())\ns = input()\n\nkumikazu = s.count('R')*s.count('B')*s.count('G')\n\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 kumikazu -= 1\nprint(kumikazu)\n\n\n"]
['Runtime Error', 'Accepted']
['s814845103', 's154359600']
[9116.0, 9088.0]
[22.0, 1291.0]
[261, 298]
p02714
u461454424
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.
['#input\nN = int(input())\nS = str(input())\n\n#output\nfrom collections import Counter\nanswer = 0\nif N <= 3:\n continue\nelse:\n for i in range(N-2):\n for j in range(i+1, N-1):\n k = 2*j-i\n if S[i] == "R":\n if S[j] == "G":\n answer += Counter(S[j+1:])["B"]\n if k < N:\n if S[k] == "B":\n answer -= 1\n elif S[j] == "B":\n answer += Counter(S[j+1:])["G"]\n if k < N:\n if S[k] == "G":\n answer -= 1\n elif S[i] == "G":\n if S[j] == "R":\n answer += Counter(S[j+1:])["B"]\n if k < N:\n if S[k] == "B":\n answer -= 1\n elif S[j] == "B":\n answer += Counter(S[j+1:])["R"]\n if k < N:\n if S[k] == "R":\n answer -= 1\n elif S[i] == "B":\n if S[j] == "R":\n answer += Counter(S[j+1:])["G"]\n if k < N:\n if S[k] == "G":\n answer -= 1\n elif S[j] == "G":\n answer += Counter(S[j+1:])["R"]\n if k < N:\n if S[k] == "R":\n answer -= 1\n \nprint(answer)', '#input\nN = int(input())\nS = str(input())\n\n#output\nimport numpy as np\nanswer = 0\nR = np.zeros(N, int)\nG = np.zeros(N, int)\nB = np.zeros(N, int)\nfor i in range(N):\n if S[i] == "R":\n R[i] = 1\n elif S[i] == "G":\n G[i] = 1\n elif S[i] == "B":\n B[i] = 1\nR = np.cumsum(R)\nG = np.cumsum(G)\nB = np.cumsum(B)\nRR = R[-1]\nGG = G[-1]\nBB = B[-1]\n\nif N > 3:\n for i in range(1, N-1):\n if S[i] == "R":\n a = G[i]\n b = BB - B[i]\n c = B[i]\n d = GG - G[i]\n answer += a*b + c*d\n for j in range(1, min(i+1, N-i)):\n if S[i-j] != "R" and S[i+j] != "R" and S[i-j] != S[i+j]:\n answer -= 1\n elif S[i] == "G":\n a = B[i]\n b = RR - R[i]\n c = R[i]\n d = BB - B[i]\n answer += a*b + c*d\n for j in range(1, min(i+1, N-i)):\n if S[i-j] != "G" and S[i+j] != "G" and S[i-j] != S[i+j]:\n answer -= 1\n elif S[i] == "B":\n a = R[i]\n b = GG - G[i]\n c = G[i]\n d = RR - R[i]\n answer += a*b + c*d\n for j in range(1, min(i+1, N-i)):\n if S[i-j] != "B" and S[i+j] != "B" and S[i-j] != S[i+j]:\n answer -= 1\n \nprint(answer)']
['Runtime Error', 'Accepted']
['s746881100', 's526323974']
[9132.0, 27136.0]
[20.0, 1220.0]
[1492, 1329]
p02714
u461833298
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 numba import njit\nN = int(input())\nS = input()\n\nR = S.count('R')\nG = S.count('G')\nB = S.count('B')\n\n@njit\ndef f(S, N):\n tmp = 0\n for i in range(N):\n for j in range(i+1, N):\n k = j + (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 tmp-=1\n return tmp\n \nprint(f(S,N) + R*G*B)", "N = int(input())\nS = input()\n\nR = S.count('R')\nG = S.count('G')\nB = S.count('B')\ntmp = 0\nfor i in range(N):\n for j in range(i+1, N):\n k = j + (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 tmp-=1\nprint(tmp + R*G*B)"]
['Time Limit Exceeded', 'Accepted']
['s188719222', 's818294106']
[114104.0, 9144.0]
[2208.0, 1269.0]
[397, 287]
p02714
u469254913
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 numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n\n\n\ndef main():\n N = int(input())\n S = input().rstrip()\n\n R = set([])\n G = set([])\n B = set([])\n\n for i in range(N):\n temp = S[i]\n if temp == 'R':\n R.add(i)\n elif temp == 'G':\n G.add(i)\n else:\n B.add(i)\n\n all = [R,G,B]\n\n M = [len(R),len(G),len(B)]\n res = M[0] * M[1] * M[2]\n index = M.index(max(M))\n\n most = all.pop(index)\n first = all[0]\n second = all[1]\n\n count = 0\n\n for f in first:\n for s in second:\n temp1 = s * 2 - f\n temp2 = f * 2 - s\n temp3 = (f + s) // 2\n if (True) & (temp1 in most):\n count += 1\n if (True) & (temp2 in most):\n count += 1\n if (s + f) % 2 == 0:\n if temp3 in most:\n count += 1\n\n print(res)\n res -= count\n print(res)\n\n\n\n\nmain()\n", "# import numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n\n\n\ndef main():\n N = int(input())\n S = input().rstrip()\n\n R = set([])\n G = set([])\n B = set([])\n\n for i in range(N):\n temp = S[i]\n if temp == 'R':\n R.add(i)\n elif temp == 'G':\n G.add(i)\n else:\n B.add(i)\n\n all = [R,G,B]\n\n M = [len(R),len(G),len(B)]\n res = M[0] * M[1] * M[2]\n index = M.index(max(M))\n\n most = all.pop(index)\n first = all[0]\n second = all[1]\n\n count = 0\n\n for f in first:\n for s in second:\n temp1 = s * 2 - f\n temp2 = f * 2 - s\n temp3 = (f + s) // 2\n if (True) & (temp1 in most):\n count += 1\n if (True) & (temp2 in most):\n count += 1\n if (s + f) % 2 == 0:\n if temp3 in most:\n count += 1\n\n res -= count\n print(res)\n\n\n\n\nmain()\n"]
['Wrong Answer', 'Accepted']
['s469800860', 's387839507']
[9344.0, 9496.0]
[564.0, 604.0]
[1051, 1036]
p02714
u478646901
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\nrs = []\ngs = []\nbs = []\nfor i, e in enumerate(s):\n if e == 'R':\n rs.append(i)\n if e == 'G':\n gs.append(i)\n if e == 'B':\n bs.append(i)\n \nsaidai = len(rs) * len(gs) * len(bs)\nif saidai == 0:\n print('0')\nelse:\n if len(rs) <= len(bs) and len(gs) <= len(bs):\n for i in rs:\n for j in gs:\n mi = i if i < j else j\n ma = j if i < j else i\n p = [mi - (ma - mi), mi + (ma - mi)/2, ma + (ma - mi)]\n for e in p:\n if e in bs:\n saidai -= 1\n print(int(saidai))\n elif len(rs) <= len(gs) and len(bs) <= len(gs):\n for i in rs:\n for j in bs:\n mi = i if i < j else j\n ma = j if i < j else i\n p = [mi - (ma - mi), mi + (ma - mi)/2, ma + (ma - mi)]\n for e in p:\n if e in bs:\n saidai -= 1\n elif len(gs) <= len(rs) and len(bs) <= len(rs):\n for i in gs:\n for j in bs:\n mi = i if i < j else j\n ma = j if i < j else i\n p = [mi - (ma - mi), mi + (ma - mi)/2, ma + (ma - mi)]\n for e in p:\n if e in bs:\n saidai -= 1\n print(int(saidai))", "n = int(input())\ns = input()\n\nrs = {}\ngs = {}\nbs = {}\n\nfor i, e in enumerate(s):\n if e == 'R':\n rs[i] = ''\n if e == 'G':\n gs[i] = ''\n if e == 'B':\n bs[i] = ''\n \nsaidai = len(rs) * len(gs) * len(bs)\nif saidai == 0:\n print('0')\nelse:\n a = max(bs.keys())\n b = min(bs.keys())\n for i in rs.keys():\n for j in gs.keys():\n mi = i if i < j else j\n ma = j if i < j else i\n p = [mi - (ma - mi), mi + (ma - mi)/2, ma + (ma - mi)]\n for e in p:\n if e%1 != 0 or e < b or e > a:\n continue\n if e in bs:\n saidai -= 1\n print(int(saidai))\n"]
['Wrong Answer', 'Accepted']
['s433330055', 's339285553']
[9340.0, 9304.0]
[2205.0, 1803.0]
[1129, 594]
p02714
u479674982
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 functools import lru_cache\n\n@lru_cache(maxsize=1000)\nN = int(input())\nS =input()\na = 0\nfor i in range(N-2):\n for j in range(i,N-1):\n for k in range(j,N):\n if S[i] != S[j] and S[i] != S[k] and S[k] != S[j] and j -i != k-j:\n a+= 1\n print(a)', 'n = int(input())\ns = input()\n\nr = 0\ng = 0\nb = 0\n\n\nfor ss in s:\n if ss == "R":\n r += 1\n elif ss == "G":\n g += 1\n elif ss == "B":\n b += 1\nng = 0\ni = 0\nwhile i < n:\n j = 1\n while i+2*j < n:\n if s[i] != s[i+j] and s[i+j] != s[i+2*j] and s[i] != s[i+2*j]:\n ng += 1\n j += 1\n i += 1\nprint(r*g*b-ng)']
['Runtime Error', 'Accepted']
['s863192461', 's954619036']
[8956.0, 9200.0]
[19.0, 1719.0]
[266, 355]
p02714
u479719434
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 collections import Counter\n\n\ndef main(N=None, S=None):\n if not N or not S:\n N = int(input())\n S = int(input())\n c = Counter(S)\n ans = c["R"]*c["G"]*c["B"]\n for hop in range(1, N//2):\n for start in range(N):\n i = start\n j = start + hop\n k = start + hop*2\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 # print(i, j, k, ans)\n print(ans)\n return ans\n\n\nif __name__ == "__main__":\n \n \n main()\n', 'from collections import Counter\n\n\ndef main(N=None, S=None):\n if not N or not S:\n N = int(input())\n S = input()\n c = Counter(S)\n ans = c["R"]*c["G"]*c["B"]\n for hop in range(1, N):\n for start in range(N):\n i = start\n j = start + hop\n k = start + hop*2\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 # print(i, j, k, ans)\n print(ans)\n return ans\n\n\nif __name__ == "__main__":\n \n \n main()\n']
['Runtime Error', 'Accepted']
['s330675350', 's855383248']
[9472.0, 9472.0]
[21.0, 903.0]
[669, 661]
p02714
u482743994
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(0)', '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-2):\n for j in range(i+1,n):\n k=2*j-i\n if k>(n-1):\n break\n if s[i]!=s[j]!=s[k]!=s[i]:\n ans-=1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s003705911', 's718290965']
[9076.0, 9196.0]
[22.0, 1277.0]
[8, 220]
p02714
u485319545
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\nfrom collections import Counter\n\nc=Counter(s)\n\nans = 1\nfor i in list(c.values()):\n ans*=i\n\nfor i in range(n):\n for j in range(i+1,n):\n if i+2*j<n:\n if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i]!=s[i+2*j]:\n ans-=1\n else:\n break\n\n\nprint(ans)', "n=int(input())\ns=input()\n\nfrom collections import Counter\n\nc=Counter(s)\n\n# ans = 1\n\n# ans*=i\n\nr=s.count('R')\ng=s.count('G')\nb=s.count('B')\n\ncnt=0\nfor i in range(n):\n for j in range(i+1,n):\n k = j+(j-i)\n if k>=n:\n break\n else:\n if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:\n cnt+=1\n\nprint((r*g*b)-cnt)"]
['Wrong Answer', 'Accepted']
['s379561511', 's510951799']
[9440.0, 9412.0]
[638.0, 1302.0]
[322, 392]
p02714
u489762173
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 = [i for i, x in enumerate(S) if x == 'R']\nG = [j for j, y in enumerate(S) if y == 'G']\nB = [k for k, z in enumerate(S) if z == 'B']\nprint(R, G, B)\n\ncnt=0\nfor r in R:\n for g in G:\n for b in B:\n if abs(g-r) != abs(b-g) and \\\n abs(b-r) != abs(g-b) and \\\n abs(r-b) != abs(g-r):\n cnt+=1\n\nprint(cnt)\n", "N = int(input())\nS = input()\n\nR = [X for X, x in enumerate(S) if x == 'R']\nG = [Y for Y, y in enumerate(S) if y == 'G']\nB = [Z for Z, z in enumerate(S) if z == 'B']\n\nmae = len(R)*len(G)*len(B)\n\ncnt=0\nfor i in range(0,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 cnt+=1\n\nprint(mae-cnt)"]
['Wrong Answer', 'Accepted']
['s591652809', 's088993151']
[9216.0, 9300.0]
[2205.0, 1352.0]
[393, 399]
p02714
u496009935
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')\ng=s.count('G')\nb=s.count('B')\ncnt=0\nfor i in range(n-2):\n for j in range(1, min(i+1, n-i)):\n if (s[i] != s[i-j]) and (s[i] != s[i+j]) and (s[i-j] != s[i+j]):\n cnt += 1\nprint(r*g*b-cnt)", "n=int(input())\ns=input()\nr=s.count('R')\ng=s.count('G')\nb=s.count('B')\ncnt=0\nfor i in range(n-1):\n for j in range(1, min(i+1, n-i)):\n if (s[i] != s[i-j]) and (s[i] != s[i+j]) and (s[i-j] != s[i+j]):\n cnt += 1\nprint(r*g*b-cnt)"]
['Wrong Answer', 'Accepted']
['s726399496', 's161866861']
[9088.0, 9132.0]
[1294.0, 1170.0]
[253, 253]
p02714
u496687522
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(1,N+1):\n for d in range(1, N+1):\n j = i+d\n k = j+d\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\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 d in range(N):\n j = i+d\n k = j+d\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\nprint(ans)"]
['Runtime Error', 'Accepted']
['s546312347', 's280296756']
[9208.0, 9160.0]
[21.0, 1477.0]
[332, 324]
p02714
u496821919
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"""\nCreated on Wed May 6 02:13:01 2020\n\n@author: shinba\n"""\n\nN = int(input())\nS = input()\n\nR = []\nG = []\nB = []\n\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\nans = len(R)*len(G)*len(B)\nprint(R)\nprint(G)\nprint(B)\n\nfor i in R:\n for j in G:\n if 2*j - i in B:\n ans -= 1\n if (i+j)%2 == 0:\n if (i+j)//2 in B:\n ans -= 1\n if 2*i - j in B:\n ans -= 1\n\nprint(ans)\n \n', '# -*- coding: utf-8 -*-\n"""\nCreated on Wed May 6 02:13:01 2020\n\n@author: shinba\n"""\nimport sys\n\nN = int(input())\nS = input()\n\nR = []\nG = []\nB = []\n\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\nif R==[] or G==[] or B==[]:\n print(0)\n sys.exit()\n \nans = len(R)*len(G)*len(B)\n\nm = min(B)\nM = max(B)\n\nfor i in R:\n for j in G:\n a = 2*j - i \n b = (i+j)//2 if (i+j)%2 == 0 else 0\n c = 2*i - j\n if m <= a <= M:\n if S[a-1] == "B":\n ans -= 1\n if b != 0 and S[b-1] == "B":\n ans -= 1\n if m <= c <= M:\n if S[c-1] == "B":\n ans -= 1\n \nprint(ans)\n \n']
['Wrong Answer', 'Accepted']
['s214896419', 's168581368']
[9108.0, 9176.0]
[2206.0, 1100.0]
[552, 761]
p02714
u506910932
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\nans = s.count('R') * s.count('G') * s.count('B')\nprint(ans)\nfor i in range(n):\n for j in range(i + 1, n):\n k = 2 * j - i\n \n if k < n and (s[i] != s[j] and s[j] != s[k]\n and s[i] != s[k]) and j - i == k - j:\n ans -= 1\n\nprint(ans)\n", "n = int(input())\ns = input()\n\nans = s.count('R') * s.count('G') * s.count('B')\n\nfor i in range(n):\n for j in range(i + 1, n):\n k = 2 * j - i\n \n if k < n and (s[i] != s[j] and s[j] != s[k]\n and s[i] != s[k]) and j - i == k - j:\n ans -= 1\n\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s256886667', 's770337242']
[9220.0, 9136.0]
[1851.0, 1862.0]
[393, 383]
p02714
u509739538
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 math\nimport queue\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef fact(n):\n\tans = 1\n\tm=n\n\tfor _i in range(n-1):\n\t\tans*=m\n\t\tm-=1\n\treturn ans\ndef comb(n,r):\n\tl = min(r,n-r)\n\tm=n\n\tu=1\n\tfor _i in range(l):\n\t\tu*=m\n\t\tm-=1\n\treturn u//fact(l)\ndef printQueue(q):\n\tr=q\n\tans=[0]*r.qsize()\n\tfor i in range(r.qsize()-1,-1,-1):\n\t\tans[i] = r.get()\n\tprint(ans)\ndef binary_search(li,item):\n\tleft,right = 0, len(li)\n\twhile left<=right:\n\t\tmid = (left+right)//2\n\t\tif li[mid]==item:\n\t\t\treturn mid\n\t\telif li[mid]<item:\n\t\t\tleft = mid+1\n\t\telse:\n\t\t\tright = mid-1\n\treturn -1\n\nN = readInt()\nS = readChar()\nrgb = {"R":[],"G":[],"B":[]}\nfor i in range(N):\n\trgb[S[i]].append(i)\n\nc=s=0\nc=len(rgb["R"])*len(rgb["G"])*len(rgb["B"])\nfor i in range(1,N):\n\tfor j in range(i+1,N):\n\t\tk = 2*j-i\n\t\tif S[i]==s[j] and s[i]==s[k]:\n\t\t\ts+=1\n\nans=c-s\nprint(ans)\n', 'import math\nimport queue\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef fact(n):\n\tans = 1\n\tm=n\n\tfor _i in range(n-1):\n\t\tans*=m\n\t\tm-=1\n\treturn ans\ndef comb(n,r):\n\tl = min(r,n-r)\n\tm=n\n\tu=1\n\tfor _i in range(l):\n\t\tu*=m\n\t\tm-=1\n\treturn u//fact(l)\ndef printQueue(q):\n\tr=q\n\tans=[0]*r.qsize()\n\tfor i in range(r.qsize()-1,-1,-1):\n\t\tans[i] = r.get()\n\tprint(ans)\ndef binary_search(li,item):\n\tleft,right = 0, len(li)\n\twhile left<=right:\n\t\tmid = (left+right)//2\n\t\tif li[mid]==item:\n\t\t\treturn mid\n\t\telif li[mid]<item:\n\t\t\tleft = mid+1\n\t\telse:\n\t\t\tright = mid-1\n\treturn -1\n\nN = readInt()\nS = readChar()\nrgb = {"R":[],"G":[],"B":[]}\nfor i in range(N):\n\trgb[S[i]].append(i)\n\nc=s=0\nc=len(rgb["R"])*len(rgb["G"])*len(rgb["B"])\nfor i in range(1,N):\n\tfor j in range(i+1,N):\n\t\tk = 2*j-i\n\t\tif k<=N-1:\n\t\t\tcontinue\n\t\tif S[i]==S[j] and S[i]==S[k]:\n\t\t\ts+=1\n\nans=c-s\nprint(ans)\n', 'import math\nimport queue\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef fact(n):\n\tans = 1\n\tm=n\n\tfor _i in range(n-1):\n\t\tans*=m\n\t\tm-=1\n\treturn ans\ndef comb(n,r):\n\tl = min(r,n-r)\n\tm=n\n\tu=1\n\tfor _i in range(l):\n\t\tu*=m\n\t\tm-=1\n\treturn u//fact(l)\ndef printQueue(q):\n\tr=q\n\tans=[0]*r.qsize()\n\tfor i in range(r.qsize()-1,-1,-1):\n\t\tans[i] = r.get()\n\tprint(ans)\ndef binary_search(li,item):\n\tleft,right = 0, len(li)\n\twhile left<=right:\n\t\tmid = (left+right)//2\n\t\tif li[mid]==item:\n\t\t\treturn mid\n\t\telif li[mid]<item:\n\t\t\tleft = mid+1\n\t\telse:\n\t\t\tright = mid-1\n\treturn -1\n\nN = readInt()\nS = readChar()\nrgb = {"R":[],"G":[],"B":[]}\nfor i in range(N):\n\trgb[S[i]].append(i)\n\nc=s=0\nc=len(rgb["R"])*len(rgb["G"])*len(rgb["B"])\nfor i in range(N):\n\tfor j in range(i+1,N):\n\t\tk = 2*j-i\n\t\tif k>=N:\n\t\t\tcontinue\n\t\tif S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:\n\t\t\ts+=1\n\nans=c-s\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s459134611', 's834435882', 's704695756']
[9828.0, 9932.0, 9836.0]
[29.0, 1534.0, 1917.0]
[1398, 1423, 1434]
p02714
u510722570
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())\nrn = s.count("R")\ngn = s.count("G")\nbn = s.count("B")\n\nct=0\nfor i in range(n):\n for j in range(i+1,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[i]!=s[k]:\n ct += 1\n \nprint(rn*gn*bn-ct)', 'n = int(input())\ns = str(input())\nrn = s.count("R")\ngn = s.count("G")\nbn = s.count("B")\n \nct=0\nfor i in range(n):\n for j in range(i+1,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[i]!=s[k]:\n ct += 1\n \nprint(rn*gn*bn-ct)']
['Runtime Error', 'Accepted']
['s020475764', 's600090344']
[9032.0, 9208.0]
[24.0, 1346.0]
[264, 266]
p02714
u512212329
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 = int(input())\n s = input()\n # Positions for each character.\n r = []\n g = []\n b = []\n for ind, c in enumerate(s):\n if c == 'R':\n r.append(ind)\n elif c == 'G':\n g.append(ind)\n else:\n b.append(ind)\n ans = 0\n print(r, g, b)\n\n for i in r:\n for j in g:\n for k in b:\n o, p, q = sorted((i, j, k))\n if p - o != q - p:\n ans += 1\n return ans\n\n\nif __name__ == '__main__':\n print(main())\n", "def main():\n n = int(input())\n s = input()\n # Positions for each character.\n rs = s.count('R')\n gs = s.count('G')\n bs = s.count('B')\n ans = rs * gs * bs\n\n \n for j in range(n):\n for i in range(j): \n k = j + (j - i)\n if k >= n:\n continue\n if s[i] == s[j]:\n continue\n if s[i] == s[k]:\n continue\n if s[j] == s[k]:\n continue\n\n \n ans -= 1\n\n return ans\n\n\nif __name__ == '__main__':\n print(main())\n"]
['Wrong Answer', 'Accepted']
['s656802002', 's938339538']
[9244.0, 9156.0]
[2205.0, 1037.0]
[548, 687]
p02714
u514894322
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')\ng=s.count('G')\nb=s.count('B')\nans=r*g*b\nfor i in range(1,(n+1)//2):\n for j in range(n-2*i):\n print(s[j],s[j+i],s[j+2*i])\n if len(set([s[j],s[j+i],s[j+2*i]]))==3:\n print(j,j+i,j+2*i)\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(1,(n+1)//2):\n for j in range(n-2*i):\n if len(set([s[j],s[j+i],s[j+2*i]]))==3:\n ans-=1\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s502623680', 's910710794']
[17424.0, 9028.0]
[2221.0, 1863.0]
[257, 200]
p02714
u515674295
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\nRN = S.count('R')\nGN = S.sount('G')\nBN = S.count('B')\n\nans = RN * GN * BN\n\nfor i in range(N):\n for d in range(N):\n j = i + d\n k = i + 2 * d\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\nprint(ans)", "N = int(input())\nS = input()\n\nRN = S.count('R')\nGN = S.count('G')\nBN = S.count('B')\n\nans = RN * GN * BN\n\nfor i in range(N):\n for d in range(N):\n j = i + d\n k = i + 2 * d\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\nprint(ans)"]
['Runtime Error', 'Accepted']
['s486885865', 's971020469']
[9216.0, 9176.0]
[24.0, 1546.0]
[315, 315]
p02714
u519939795
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.
['Npt', "n = int(input())\ns = list(input())\n\nnum_r = s.count('R')\nnum_g = s.count('G')\nnum_b = s.count('B')\n\nans = num_r*num_g*num_b\n\nfor i in range(n):\n for j in range(i, n):\n k = j+(j-i)\n if (k < n) and (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):\n ans -= 1\nprint(ans)"]
['Runtime Error', 'Accepted']
['s571517054', 's896472216']
[9116.0, 9172.0]
[25.0, 1921.0]
[3, 298]
p02714
u529106146
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#sys.exit()\n\nN = int(input())\n#S,T = map(int, input().split())\n#A = list(map(int, input().split()))\n#print(N)\n#print(S,T)\n#print(A)\nS = str(input())\nr = S.count("R")\ng = S.count("G")\nb = S.count("B")\nans = (r*g*b)\n#r2 = [i for i, x in enumerate(S) if x == \'R\']\n#g2 = [i for i, x in enumerate(S) if x == \'G\']\n#b2 = [i for i, x in enumerate(S) if x == \'B\']\nans = (len(r2)*len(g2)*len(b2))\nfor i in range (N-2):\n for j in range (i+1,N-1):\n k = 2*j-i\n if k < N and S[i]!=S[j] and S[j] != S[k] and S[k] != S[i]:\n ans -=1\n #print(r2[i],g2[j],b2[k])\nprint(ans)\n', 'import sys\n#sys.exit()\n\nN = int(input())\n#S,T = map(int, input().split())\n#A = list(map(int, input().split()))\n#print(N)\n#print(S,T)\n#print(A)\nS = str(input())\nr = S.count("R")\ng = S.count("G")\nb = S.count("B")\nans = (r*g*b)\n#r2 = [i for i, x in enumerate(S) if x == \'R\']\n#g2 = [i for i, x in enumerate(S) if x == \'G\']\n#b2 = [i for i, x in enumerate(S) if x == \'B\']\nans = (len(r2)*len(g2)*len(b2))\nfor i in range (N-2):\n for j in range (i+1,N-1):\n k = 2*j-i\n if k < N and S[i]!=S[j] and S[j] != S[k] and S[k] != S[i]:\n ans -=1\n #print(r2[i],g2[j],b2[k])\nprint(ans)\n', 'import sys\n#sys.exit()\n\nN = int(input())\nS = str(input())\nr = S.count("R")\ng = S.count("G")\nb = S.count("B")\nans = (r*g*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 and S[i]!=S[j] and S[j] != S[k] and S[k] != S[i]:\n ans -=1\n #print(r2[i],g2[j],b2[k])\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s610325482', 's800898576', 's450259161']
[9208.0, 9204.0, 9168.0]
[25.0, 22.0, 1864.0]
[635, 635, 360]
p02714
u536034761
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 = int(input())\n S = input()\n R = set()\n G = set()\n B = set()\n for i,s in enumerate():\n if s == "R":\n R.add(i)\n elif s == "B":\n B.add(i)\n else:\n G.add(i)\n ans = 0\n for r in R:\n for b in B:\n for g in G:\n k = max(r, b, g)\n i = min(r, b, g)\n j = r + b + g - k - i\n if j - i != k - j:\n ans += 1\n print(ans)\n\nif __name__ == "__main__":\n main()', 'def main():\n N = int(input())\n S = input()\n cnt = 0\n for 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[j] != S[i] and S[i] != S[k] and S[k] != S[j]:\n cnt += 1\n print(S.count("R") * S.count("B") * S.count("G") - cnt)\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s227560164', 's414369178']
[9156.0, 9124.0]
[25.0, 1060.0]
[533, 379]
p02714
u558717347
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.
['total = 0\nfor i in range(0,n-2):\n for j in range(i+1,n-1):\n for k in range(j+1,n):\n if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:\n if j!= (k+i)/2:\n # if j<3:\n # print(i,j,k)\n total += 1\nprint(total)', "n = int(input())\ns = input()\na = []\nfor i in range(n):\n if s[i] == 'R' :\n a.append(0)\n if s[i] == 'G' :\n a.append(1)\n if s[i] == 'B' :\n a.append(2)\ncnt = [0,0,0]\nfor i in range(n):\n cnt[a[i]] +=1\nans = 1\n\nfor i in range(3):\n ans *= cnt[i]\n# print(a)\nfor i in range(n):\n for j in range(i+1,n):\n k = j+(j-i)\n if k<n:\n if a[i] != a[j] and a[i] != a[k]and a[k] != a[j]:\n # print(i,j,k,a[i],a[j],a[k])\n ans -=1\n\n\n\n# print(cnt)\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s389667401', 's396421502']
[9116.0, 9192.0]
[22.0, 1795.0]
[301, 531]
p02714
u585348179
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 numpy as np\nN=int(input())\nS = input()\n\nr = S.count('R')\ng = S.count('G')\nb = S.count('B')\n\n\nans = r*g*b\n\nfor i in range(N):\n for d in range(N):\n j = i+d\n k = j+d\n if k >= N:\n break\n if S[i] != S[j] and S[j] != S[k] and S[i] != S[i]:\n ans -= 1\n \nprint(ans)", "import numpy as np\nN=int(input())\nS = input()\n\nc=S.count\nr,g,b=c('R'),c('G'),c('B')\n\nans = r*g*b\n\nfor i in range(N):\n for d in range(N):\n j = i+d\n k = j*d\n if k >= N:\n break\n if S[i] != S[j] and S[j] != S[k] and S[i] != S[i]:\n ans -= 1\n \nprint(ans)\n", "import numpy as np\nN=int(input())\nS = input()\n\nc=S.count\nr,g,b=c('R'),c('G'),c('B')\n\nans = r*g*b\n\nfor i in range(n):\n for d in range(n):\n j = i+d\n k = j*d\n if k >= n:\n break\n if s[i] != s[j] and s[j] != s[k] and s[i] != s[i]:\n ans -= 1\n \nprint(ans)\n", "import numpy as np\nN=int(input())\nS = input()\n\nc=S.count\nr,g,b=c('R'),c('G'),c('B')\n\nans = r*g*b\n\nfor i in range(N):\n for d in range(N):\n j = i+d\n k = j*d\n if k >= n:\n break\n if S[i] != S[j] and S[j] != S[k] and S[i] != S[i]:\n ans -= 1\n \nprint(ans)\n", "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:\n break\n if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n ans -= 1\nprint(ans)"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s429360429', 's513567602', 's556386536', 's982383573', 's138933001']
[27024.0, 27132.0, 27040.0, 27104.0, 9204.0]
[1479.0, 110.0, 103.0, 106.0, 1468.0]
[289, 275, 275, 275, 331]
p02714
u585963734
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())\na=[0]*4\n\nfor i in range(N):\n if S[i]=='R':a[0]+=1\n if S[i]=='G':a[1]+=1\n if S[i]=='B':a[2]+=1\n \nfor i in range(N):\n for j in range(i+1,N):\n k=j+(j-i)\n if k>=N:\n break\n else:\n if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i] and j-i==k-j:\n a[3]+=1\n\nprint(a)\nprint(a[0]*a[1]*a[2]-a[3])", "N=int(input())\nS=list(input())\na=[0]*4\n\nfor i in range(N):\n if S[i]=='R':a[0]+=1\n if S[i]=='G':a[1]+=1\n if S[i]=='B':a[2]+=1\n \nfor i in range(N):\n for j in range(i+1,N):\n k=j+(j-i)\n if k>=N:\n break\n else:\n if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i] and j-i==k-j:\n a[3]+=1\n\nprint(a[0]*a[1]*a[2]-a[3])"]
['Wrong Answer', 'Accepted']
['s278760072', 's982778415']
[9252.0, 9188.0]
[1462.0, 1327.0]
[342, 333]
p02714
u614628638
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.
["S = list(input())\nS_len = len(S)\nans = 0\ni = 0\nfor _ in range(S_len):\n if S[0] == 'R':\n ans += S[1:].count('B') * S[1:].count('G')\n for j in range(int(len(S)/2+1)):\n try:\n if S[j+1] != S[j*2+2] and S[j*2+2] !='R' and S[j+1] !='R':\n ans-=1\n except:\n pass\n if S[0] == 'B':\n ans += S[1:].count('R') * S[1:].count('G')\n for j in range(int(len(S)/2+1)):\n try:\n if S[j+1] != S[j*2+2] and S[j*2+2] !='B' and S[j+1] !='B':\n ans-=1\n except:\n pass\n if S[0] == 'G':\n ans += S[1:].count('B') * S[1:].count('R')\n for j in range(int(len(S)/2+1)):\n try:\n if S[j+1] != S[j*2+2] and S[j*2+2] !='G' and S[j+1] !='G':\n ans-=1\n except:\n pass\n S = S[1:]\nprint(ans)", "S = input()\nS = list(input())\nS_len = len(S)\nans = 0\ni = 0\nfor _ in range(S_len):\n if S[0] == 'R':\n ans += S[1:].count('B') * S[1:].count('G')\n for j in range(int(len(S)/2+1)):\n try:\n if S[j+1] != S[j*2+2] and S[j*2+2] !='R' and S[j+1] !='R':\n ans-=1\n except:\n pass\n if S[0] == 'B':\n ans += S[1:].count('R') * S[1:].count('G')\n for j in range(int(len(S)/2+1)):\n try:\n if S[j+1] != S[j*2+2] and S[j*2+2] !='B' and S[j+1] !='B':\n ans-=1\n except:\n pass\n if S[0] == 'G':\n ans += S[1:].count('B') * S[1:].count('R')\n for j in range(int(len(S)/2+1)):\n try:\n if S[j+1] != S[j*2+2] and S[j*2+2] !='G' and S[j+1] !='G':\n ans-=1\n except:\n pass\n S = S[1:]\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s278312547', 's231614538']
[9224.0, 9236.0]
[20.0, 1454.0]
[765, 777]
p02714
u619084943
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())\t\ns=input()\n\nc = collections.Counter(s)\n\nans_count = c['R'] * c['G'] * c['B']\n\nfor i in range(1, (n-1)//2):\n for j in range(n):\n if j+(2*i) >= n:\n break\n\n if s[j] != s[j+i] and s[j+i] != s[j+(2*i)] and s[j] != s[j+(2*i)]:\n ans_count -= 1\n\n\nprint(ans_count)\n", "import collections\n\nn=int(input())\t\ns=input()\n\nc = collections.Counter(s)\n\nans_count = c['R'] * c['G'] * c['B']\n\nfor i in range((n-1)//2):\n for j in range(n):\n if j+(2*i) >= n:\n break\n\n if s[j] != s[j+i] and s[j+i] != s[j+(2*i)] and s[j] != s[j+(2*i)]:\n ans_count -= 1\n\n\nprint(ans_count)\n", "import collections\n\nn=int(input())\t\ns=input()\n\nc = collections.Counter(s)\n\nans_count = c['R'] * c['G'] * c['B']\n\nfor i in range(1, (n+1)//2):\n for j in range(n):\n if j+(2*i) >= n:\n break\n\n if s[j] != s[j+i] and s[j+i] != s[j+(2*i)] and s[j] != s[j+(2*i)]:\n ans_count -= 1\n\n\nprint(ans_count)\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s843807696', 's865993005', 's122272236']
[9460.0, 9468.0, 9412.0]
[1730.0, 1669.0, 1761.0]
[330, 327, 330]
p02714
u619398783
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\nfor i in range(n-2):\n for j in range(i+1,n-1):\n if s[i] == s[j]:\n break\n for k in range(j+1,n):\n if s[k] in (s[i],s[j]):\n break\n if j-i != k-j:\n cnt +=1\nprint(cnt)\n', "n = int(input())\ns = input()\ncnt = 0\nfor i in range(n-2):\n for j in range(i+1,n-1):\n if s[i] != s[j]:\n if (s[i]+s[j]).count('R') == 0:\n cnt += s[j+1:n].count('R')\n if s[j+i] == 'R' and j-i > n-j:\n cnt -= 1\n elif (s[i]+s[j]).count('G') == 0:\n cnt += s[j+1:n].count('G')\n if s[j+i] == 'G' and j-i > n-j:\n cnt -= 1\n else:\n cnt += s[j+1:n].count('B')\n if s[j+i] == 'B' and j-i > n-j:\n cnt -= 1\nprint(cnt)", "n = int(input())\ns = input()\ncnt = s.count('R')*s.count('G')*s.count('B')\nfor i in range(n-2):\n for j in range(i+1,n-1):\n if s[i] != s[j]:\n if 2*j-i > n-1:\n break\n if s[2*j-i] not in(s[i],s[j]):\n cnt -= 1\nprint(cnt)"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s616464200', 's759324565', 's169545645']
[9176.0, 9244.0, 9200.0]
[27.0, 105.0, 1381.0]
[281, 590, 277]
p02714
u629454253
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 = 0\n\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 else:\n b.append(i)\nmcount = 0\nfor i in range((n-1)/2-1):\n for j in range(i+1, n-1-1-i):\n if s[j] != s[j-i-1] and s[j] != s[j+i+1] and s[j-i-1] != s[j+i+1]:\n mcount += 1\n \n\nfor i in range(n):\n if i in r:\n for j in g:\n for k in b:\n if k < j:\n continue\n count += 1\n for j in b:\n for k in g:\n if k < j:\n continue\n count += 1 \n if i in g:\n for j in r:\n for k in b:\n if k < j:\n continue\n count += 1\n for j in b:\n for k in r:\n if k < j:\n continue\n count += 1\n if i in b:\n for j in g:\n for k in r:\n if k < j:\n continue\n count += 1\n for j in r:\n for k in g:\n if k < j:\n continue\n count += 1\n if i in r:\n r = r[1:]\n elif i in g:\n g = g[1:]\n else:\n b = b[1:]\n\nprint(count-mcount)", 'n = int(input())\ns = input()\nr = []\ng = []\nb = []\n\nans = s.count("R")*s.count("G")*s.count("B")\n\nfor i in range(n):\n for j in range(i+1,n):\n k = 2*j-i\n if k>=n:\n break\n ans -= s[k] != s[i] != s[j] != s[k]\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s565532377', 's563310296']
[9308.0, 9188.0]
[25.0, 1308.0]
[1039, 250]
p02714
u630554891
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\n\nfor i in range(n):\n for j in range(n):\n for k in range(n):\n if s[i] != s[j] and s[i] != s[k] and s[j] != s[k] and i < j and j < k and j-i != k-j:\n print(i,j,k)\n ans = ans + 1\n\nprint(ans)', "n=int(input())\ns=input()\n\nr = s.count('R')\ng = s.count('G')\nb = s.count('B')\n\nans = r * g * b\n\nfor i in range(0,n-2):\n for j in range(1,int((n-i)/2)+1):\n if i + j + j <= n-1:\n if s[i] != s[i+j] and s[i] != s[i+j+j] and s[i+j] != s[i+j+j] :\n ans = ans - 1\n\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s288422979', 's267419419']
[14680.0, 9208.0]
[2238.0, 1861.0]
[271, 302]
p02714
u631755487
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())\nstring = input()\n\nresult = string.count('R')*string.count('G')*string.count('B')\n\nfor i in range(N-2):\n for j in range(i+1, N):\n k = 2*j-1\n if k>=N:\n break\n if string[i] != string[j] != string[k]:\n result -= 1\nprint(result)", "N = int(input())\nstring = input()\n \nresult = string.count('R')*string.count('G')*string.count('B')\n \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 string[i] != string[j] and string[j] != string[k] and string[i] != string[k]:\n result -= 1\nprint(result)"]
['Wrong Answer', 'Accepted']
['s339459989', 's416200387']
[9192.0, 9172.0]
[587.0, 1325.0]
[260, 305]
p02714
u634934338
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_count = s.count('R')\ng_count = s.count('G')\nb_count = s.count('B')\n\ndiscount = 0\nfor i in range(n-2):\n for j in range(i+1, n-1):\n k = i + 2*(j-i)\n if k > n-1:\n break\n if s[i] == s[j] and s[i] == s[k]:\n discount += 1\n\nprint(r_count*g_count*b_count-discount)", 'n = int(input())\ns = input()\n\ncount = 0\nif(n < 3):\n print(0)\nelse:\n r_indexs = []\n g_indexs = []\n b_indexs = []\n for index, char in enumerate(s):\n if char == "R":\n r_indexs.append(index)\n elif char == "G":\n g_indexs.append(index)\n else:\n b_indexs.append(index)\n\n color_indexs = [r_indexs, g_indexs, b_indexs]\n\n for col_index in range(3):\n i_indexs_list = color_indexs[col_index]\n tmp_index1 = (col_index+1) % 3\n tmp_index2 = (col_index+2) % 3\n \n j_indexs_list = color_indexs[tmp_index1]\n k_indexs_list = color_indexs[tmp_index2]\n for i in i_indexs_list:\n for j in j_indexs_list:\n for k in k_indexs_list:\n if j-i != k-j:\n count += 1\n \n j_indexs_list = color_indexs[tmp_index2]\n k_indexs_list = color_indexs[tmp_index1]\n for i in i_indexs_list:\n for j in j_indexs_list:\n for k in k_indexs_list:\n if j-i != k-j:\n count += 1\n \n\nprint(count)\n', "n = int(input())\ns = input()\n\nr_count = s.count('R')\ng_count = s.count('G')\nb_count = s.count('B')\n\ndiscount = 0\nfor i in range(n-2):\n for j in range(i+1, n-1):\n k = i + 2*(j-i)\n if k > n-1:\n break\n if s[i] == s[j] and s[i] == s[k]:\n print(str(i)+str(j)+str(k)+s[i] + s[j] + s[k])\n discount += 1\n\nprint(r_count*g_count*b_count-discount)", "n = int(input())\ns = input()\n\nr_count = s.count('R')\ng_count = s.count('G')\nb_count = s.count('B')\n\ndiscount = 0\nfor i in range(n-2):\n for j in range(i+1, n-1):\n k = i + 2*(j-i)\n if k > n-1:\n break\n if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:\n discount += 1\n\nprint(r_count*g_count*b_count-discount)"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s153766805', 's603113949', 's864534888', 's197279314']
[9100.0, 9240.0, 18616.0, 9212.0]
[1223.0, 2205.0, 2225.0, 1455.0]
[334, 1132, 393, 351]
p02714
u644126199
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\nN = int(input())\nS = input()\n#Rc1,Gc1,Bc1\nout = S.count('R') * S.count('G') * S.count('B')\nprint(out)\n\nRGBs = list(itertools.permutations(['R', 'G', 'B'], 3))\n\nfor i in range(1, N):\n for j in range(N-i*2):\n \n if (S[j], S[j+i], S[j+i*2]) in RGBs:\n out -= 1\nprint(out)", "import itertools\nN = int(input())\nS = input()\n#Rc1,Gc1,Bc1\nout = S.count('R') * S.count('G') * S.count('B')\n\nRGBs = list(itertools.permutations(['R', 'G', 'B'], 3))\n\nfor i in range(1, N):\n for j in range(N-i*2):\n \n if (S[j], S[j+i], S[j+i*2]) in RGBs:\n out -= 1\nprint(out)"]
['Wrong Answer', 'Accepted']
['s686185890', 's314739267']
[9204.0, 9200.0]
[1666.0, 1628.0]
[347, 336]
p02714
u645436608
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\nN = int(input())\nS = input()\nC = np.array(list(itertools.combinations_with_replacement(range(1, N + 1), 3)))\ncount = 0\nfor i, j, k in C:\n if (i != 2 * j - k) and (S[i - 1] != S[j - 1] and S[i - 1] != S[k - 1] and S[j - 1] != S[k - 1]):\n count += 1\nprint(count)\n', 'N = int(input())\nS = input()\ncount = S.count("R") * S.count("G") * S.count("B")\n\n\nfor j in range(N):\n for i in range(j):\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 count -= 1\nprint(count)']
['Runtime Error', 'Accepted']
['s208274313', 's509458201']
[9200.0, 9156.0]
[22.0, 1935.0]
[288, 286]
p02714
u658915215
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()\ns=collections.Counter(S)\nprint(s)\nans=s['R']*s['G']*s['B']\nfor i in range(n):\n for d in range(n):\n j=i+d\n k=j+d\n if k>n-1:\n break\n if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:\n ans-=1\nprint(ans)", "#162D\n#RGB Triplets\n\nimport collections\n\nn=int(input())\nS=input()\ns=collections.Counter(S)\nans=s['R']*s['G']*s['B']\nfor i in range(n):\n for d in range(n):\n j=i+d\n k=j+d\n if k>n-1:\n break\n if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:\n ans-=1\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s226023565', 's029430246']
[9452.0, 9316.0]
[1446.0, 1489.0]
[292, 304]
p02714
u666351996
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\nRs = 0\nGs = 0\nBs = 0\nfor i, il in enumerate(S):\n if il == 'R':\n Rs += 1\n if il == 'G':\n Gs += 1\n if il == 'B':\n Bs += 1\nnum = 0\nfor i in range(N):\n for step in range(1, N):\n j = i + step\n k = i + 2*step\n if k > N - 1:\n continue\n print(i, j, k)\n if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:\n num += 1\nprint(Rs*Gs*Bs - num)\n", "N = int(input())\nS = input()\n\nRs = 0\nGs = 0\nBs = 0\nfor il in S:\n if il == 'R':\n Rs += 1\n if il == 'G':\n Gs += 1\n if il == 'B':\n Bs += 1\nnum = 0\nfor i in range(N):\n for step in range(1, N):\n j = i + step\n k = i + 2*step\n if k > N - 1:\n break\n if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:\n num += 1\nprint(Rs*Gs*Bs - num)\n"]
['Wrong Answer', 'Accepted']
['s720300370', 's783421230']
[23688.0, 9176.0]
[2262.0, 1600.0]
[448, 408]
p02714
u667084803
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\nans = S.count('R') * S.count('G') * S.count('B')\nfor i in range(N):\n a = S[i]\n for j in range(i+1,N):\n b = S[j]\n if (i+j)%2 :\n continue\n k = (i+j)//2\n if [a,S[k],b].sort() == ['B','G','R']\n ans -= 1\n \nprint(ans)", "N = int(input())\nS = input()\n\nans = S.count('R') * S.count('G') * S.count('B')\nfor i in range(N):\n a = S[i]\n for j in range(i+2,N,2):\n b = S[j]\n k = (i+j)//2\n if sorted([a,S[k],b]) == ['B','G','R']:\n ans -= 1\n \nprint(ans)"]
['Runtime Error', 'Accepted']
['s346731961', 's206665708']
[9056.0, 9168.0]
[23.0, 1815.0]
[270, 242]
p02714
u668642853
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.
['x1 = input()\nx2 = input()\nRGB = {"R", "G", "B"}\n_sum = 0\nfor i, rgb in zip(itertools.combinations(range(x1), 3), itertools.combinations(x2, 3)):\n if set(rgb) == RGB and (i[1] - i[0]) != (i[2] - i[1]):\n _sum += 1\nprint(_sum)', 'from itertools import product\n\nx1 = int(input())\nx2 = input()\n\nR_i = [i for i, x in enumerate(x2) if x == "R"]\nG_i = [i for i, x in enumerate(x2) if x == "G"]\nB_i = {i for i, x in enumerate(x2) if x == "B"}\n\nR = len(R_i)\nG = len(G_i)\n# B = len(B_i)\n\nxs = map(sorted, product(R_i, G_i))\n\ns = 0\nfor a in xs:\n k = a[1]*2 - a[0] # 2j-i\n if k in B_i:\n s +=1\n i = a[0]*2 - a[1] # 2j-k\n if i in B_i:\n s +=1\n j = (a[0] + a[1]) / 2\n if j.is_integer():\n j = int(j)\n if j in B_i:\n s +=1\nprint(R*G*B - s)', 'import itertools\n\nx1 = input()\nx2 = input()\nRGB = {"R", "G", "B"}\n_sum = 0\nfor i, rgb in zip(itertools.combinations(range(x1), 3), itertools.combinations(x2, 3)):\n if set(rgb) == RGB and (i[1] - i[0]) != (i[2] - i[1]):\n _sum += 1\nprint(_sum)', 'from itertools import product\n\nx1 = int(input())\nx2 = input()\n\nR_i = [i for i, x in enumerate(x2) if x == "R"]\nG_i = [i for i, x in enumerate(x2) if x == "G"]\nB_i = {i for i, x in enumerate(x2) if x == "B"}\n\nR = len(R_i)\nG = len(G_i)\n# B = len(B_i)\n\nxs = map(sorted, product(R_i, G_i))\n\ns = 0\nfor a in xs:\n k = a[1]*2 - a[0] # 2j-i\n if k in B_i:\n s +=1\n i = a[0]*2 - a[1] # 2j-k\n if i in B_i:\n s +=1\n j = (a[0] + a[1]) / 2\n if j.is_integer():\n j = int(j)\n if j in B_i:\n s +=1\nprint(R*G*B - s)', 'x1 = int(input())\nx2 = input()\n\nR_i = [i for i, x in enumerate(x2) if x == "R"]\nG_i = [i for i, x in enumerate(x2) if x == "G"]\nB_i = [i for i, x in enumerate(x2) if x == "B"]\n\nR = len(R_i)\nG = len(G_i)\nB = len(B_i)\n\nxs = map(sorted, product(R_i, G_i))\n\ns = 0\nfor a in xs:\n k = a[1]*2 - a[0] # 2j-i\n if k in B_i:\n s +=1\n i = a[0]*2 - a[1] # 2j-k\n if i in B_i:\n s +=1\n j = (a[0] + a[1]) / 2\n if j.is_integer():\n j = int(j)\n if j in B_i:\n s +=1\nprint(R*G*B - s)', 'import itertools\n\nx1 = 39\nx2 = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"\nRGB = {"R", "G", "B"}\n_sum = 0\nfor i, rgb in zip(itertools.combinations(range(x1), 3), itertools.combinations(x2, 3)):\n if set(rgb) == RGB and (i[1] - i[0]) != (i[2] - i[1]):\n _sum += 1\nprint(_sum)', 'from itertools import product \n\n\nN = int(input()) \nS = input() \n\nR_i = [i for i, s in enumerate(S) if s == "R"] \nG_i = [i for i, s in enumerate(S) if s == "G"] \nB_i = {i for i, s in enumerate(S) if s == "B"} \n\nR = len(R_i) \nG = len(G_i) \nB = len(B_i) \n\nxs = map(sorted, product(R_i, G_i)) \n\ns = 0 \nfor x in xs: \n k = 2 * x[1] - x[0] # 2j-i \n if k in B_i: \n s += 1 \n i = 2 * x[0] - x[1] # 2j-k \n if i in B_i: \n s += 1 \n j = (x[0] + x[1]) / 2 # (i+k)/2 \n if j in B_i: \n s += 1 \n\nprint(R * G * B - s) ']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s515660578', 's517904236', 's653004100', 's670607404', 's725033687', 's916518187', 's322996535']
[9132.0, 9268.0, 9128.0, 9420.0, 9284.0, 9120.0, 9272.0]
[23.0, 1233.0, 25.0, 1183.0, 24.0, 26.0, 1079.0]
[233, 551, 251, 551, 518, 280, 562]
p02714
u673338219
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\ninput = sys.stdin.readline\nn = int(input())\ns = str(input())\nr = 0\ng = 0\nfor i in range(n):\n if s[i] == "R":\n r += 1\n elif s[i] == "G":\n g += 1\nc = r*g*(n-r-g)\nfor j in range(1,n-1):\n for i in range(1,min(n-j-1,j)+1):\n if (s[j-i] != s[j]) and (s[j] != s[j+i]) and (s[j+i] != s[j-i]):\n c -= 1\nprint(c)\n \n \nprint(c)', 'import sys\ninput = sys.stdin.readline\nn = int(input())\ns = str(input())\nr = 0\ng = 0\nfor i in range(n):\n if s[i] == "R":\n r += 1\n elif s[i] == "G":\n g += 1\nc = r*g*(n-r-g)\nfor j in range(1,n-1):\n for i in range(1,min(n-j-1,j)+1):\n if (s[j-i] != s[j]) and (s[j] != s[j+i]) and (s[j+i] != s[j-i]):\n c -= 1\nprint(c)']
['Wrong Answer', 'Accepted']
['s569984629', 's310325733']
[9196.0, 9216.0]
[1212.0, 1257.0]
[347, 328]
p02714
u685684561
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())\nt=N*(N-1)*(N-2)//6\nprint (t)\nfor i in range(N):\n for j in range(i+1,N):\n if S[i]==S[j]:\n t=t-(N-j-1)\n else:\n for k in range(j+1,N):\n if S[j]!=S[k] and S[i]!=S[k] and (i-j)!=(j-k):\n continue\n else:\n t=t-1\nprint (t)', "N=int(input())\nS=str(input())\nt=0\nr=0\nb=0\ng=0\nfor i in range(N):\n if S[i]=='R':\n r+=1\n elif S[i]=='B':\n b+=1\n else:\n g+=1\nfor i in range(N):\n for j in range(i+1,N):\n if S[i]==S[j]:\n continue\n else:\n try:\n if S[2*j-i]!=S[j] and S[2*j-i]!=S[i]:\n t+=1\n else:\n continue\n except IndexError:\n break\nprint (r*b*g-t)"]
['Wrong Answer', 'Accepted']
['s896377315', 's549533970']
[9076.0, 9248.0]
[2205.0, 1148.0]
[350, 471]
p02714
u686390526
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\nR=[]\nG=[]\nB=[]\n\n\nfor i in range(0,N):\n if S[i]=="R":\n R += [i]\n elif S[i]=="G":\n G += [i]\n else:\n B += [i]\n\ndef search(ind, col):\n n=0\n useable_col = ["R","G","B"]\n useable_col.remove(col)\n for i,j in [[0,1],[1,0]]:\n l_col=useable_col[i]\n r_col=useable_col[j]\n if l_col=="R":\n l_col=R\n elif l_col=="G":\n l_col=G\n else:\n l_col=B\n if r_col=="R":\n r_col=R\n elif r_col=="G":\n r_col=G\n else:\n r_col=B\n \n l_useable = [ii for ii in l_col if ii<ind]\n r_useable = [ii for ii in r_col if ii>ind]\n\n if l_useable == [] or r_useable == []:\n return 0\n \n # print(l_useable)\n # print(r_useable)\n l = min(ind, N-1-ind)\n for m in range(1,l+1):\n if ind-m in l_useable and ind+m in r_useable:\n n -= 1\n n += len(l_useable) * len(r_useable)\n return n\n\nn=0\nfor pivot in range(1,N-1):\n if S[pivot] =="R":\n n += search(pivot, "R")\n elif S[pivot] =="G":\n n += search(pivot, "G")\n else:\n n += search(pivot, "B")\n\nprint(n)\n', 'N=int(input())\nS=list(input())\n\nR=[]\nG=[]\nB=[]\n\n\nfor i in range(0,N):\n if S[i]=="R":\n R += [i]\n elif S[i]=="G":\n G += [i]\n else:\n B += [i]\n\ndef search(ind, col):\n n=0\n useable_col = ["R","G","B"]\n useable_col.remove(col)\n for i,j in [[0,1],[1,0]]:\n l_col=useable_col[i]\n r_col=useable_col[j]\n if l_col=="R":\n l_col=R\n elif l_col=="G":\n l_col=G\n else:\n l_col=B\n if r_col=="R":\n r_col=R\n elif r_col=="G":\n r_col=G\n else:\n r_col=B\n \n l_useable = [ii for ii in l_col if ii<ind]\n r_useable = [ii for ii in r_col if ii>ind]\n # print(l_useable)\n if (l_useable == []) or (r_useable == []):\n return 0\n\n # print(l_useable)\n # print(r_useable)\n l = min(ind, N-1-ind)\n for m in range(1,l+1):\n if ind-m in l_useable and ind+m in r_useable:\n n -= 1\n n += len(l_useable) * len(r_useable)\n return n\n\nn=0\nfor pivot in range(1,N-1):\n if S[pivot] =="R":\n n += search(pivot, "R")\n elif S[pivot] =="G":\n n += search(pivot, "G")\n else:\n n += search(pivot, "B")\n\nprint(n)\n', 'N=int(input())\nS=list(input())\n\nR=[]\nG=[]\nB=[]\n\n\nfor i in range(0,N):\n if S[i]=="R":\n R += [i]\n elif S[i]=="G":\n G += [i]\n else:\n B += [i]\n\ndef search(ind, col):\n n=0\n useable_col = ["R","G","B"]\n useable_col.remove(col)\n for i,j in [[0,1],[1,0]]:\n l_col=useable_col[i]\n r_col=useable_col[j]\n if l_col=="R":\n l_col=R\n elif l_col=="G":\n l_col=G\n else:\n l_col=B\n if r_col=="R":\n r_col=R\n elif r_col=="G":\n r_col=G\n else:\n r_col=B\n \n l_useable = [ii for ii in l_col if ii<ind]\n r_useable = [ii for ii in r_col if ii>ind]\n print(l_useable)\n if not l_useable or not r_useable:\n return 0\n\n # print(l_useable)\n # print(r_useable)\n l = min(ind, N-1-ind)\n for m in range(1,l+1):\n if ind-m in l_useable and ind+m in r_useable:\n n -= 1\n n += len(l_useable) * len(r_useable)\n return n\n\nn=0\nfor pivot in range(1,N-1):\n if S[pivot] =="R":\n n += search(pivot, "R")\n elif S[pivot] =="G":\n n += search(pivot, "G")\n else:\n n += search(pivot, "B")\n\nprint(n)\n', 'N=int(input())\nS=list(input())\n\nR=[]\nG=[]\nB=[]\n\n\nfor i in range(0,N):\n if S[i]=="R":\n R += [i]\n elif S[i]=="G":\n G += [i]\n else:\n B += [i]\n\ndef search(ind, col):\n n=0\n useable_col = ["R","G","B"]\n useable_col.remove(col)\n for i,j in [[0,1],[1,0]]:\n l_col=useable_col[i]\n r_col=useable_col[j]\n if l_col=="R":\n l_col=R\n elif l_col=="G":\n l_col=G\n else:\n l_col=B\n if r_col=="R":\n r_col=R\n elif r_col=="G":\n r_col=G\n else:\n r_col=B\n \n l_useable = [] \n r_useable = [] \n for ii in range(len(l_col)):\n if ii<ind:\n l_useable += [ii]\n else:\n break\n if l_useable == []:\n continue\n for ii in range(len(r_col)):\n if ii>ind:\n r_useable += [ii]\n else:\n break\n if r_useable == []:\n continue\n\n # print(l_useable)\n # print(r_useable)\n l = min(ind, N-1-ind)\n for m in range(1,l+1):\n if ind-m in l_useable and ind+m in r_useable:\n n -= 1\n n += len(l_useable) * len(r_useable)\n # print(len(l_useable))\n # print(len(r_useable))\n return n\n\nn=0\nfor pivot in range(1,N-1):\n if S[pivot] =="R":\n n += search(pivot, "R")\n elif S[pivot] =="G":\n n += search(pivot, "G")\n else:\n n += search(pivot, "B")\n\nprint(n)\n', 'N=int(input())\nS=list(input())\n\nR=[]\nG=[]\nB=[]\n\n\nfor i in range(0,N):\n if S[i]=="R":\n R += [i]\n elif S[i]=="G":\n G += [i]\n else:\n B += [i]\n\ndef search(ind, col):\n n=0\n useable_col = ["R","G","B"]\n useable_col.remove(col)\n for i,j in [[0,1],[1,0]]:\n l_col=useable_col[i]\n r_col=useable_col[j]\n if l_col=="R":\n l_col=R\n elif l_col=="G":\n l_col=G\n else:\n l_col=B\n if r_col=="R":\n r_col=R\n elif r_col=="G":\n r_col=G\n else:\n r_col=B\n \n l_useable = [ii for ii in l_col if ii<ind]\n r_useable = [ii for ii in r_col if ii>ind]\n print(l_useable)\n if (l_useable == []) or (r_useable == []):\n return 0\n\n # print(l_useable)\n # print(r_useable)\n l = min(ind, N-1-ind)\n for m in range(1,l+1):\n if ind-m in l_useable and ind+m in r_useable:\n n -= 1\n n += len(l_useable) * len(r_useable)\n return n\n\nn=0\nfor pivot in range(1,N-1):\n if S[pivot] =="R":\n n += search(pivot, "R")\n elif S[pivot] =="G":\n n += search(pivot, "G")\n else:\n n += search(pivot, "B")\n\nprint(n)\n', 'N=int(input())\nS=list(input())\n\nr=0\ng=0\nb=0\n\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\n \nn=r*g*b\n\nfor i in range(N):\n for j in range(i+1,N):\n if S[i]==S[j]:\n continue\n k = 2*j-i\n if k >= N:\n break\n if S[i]==S[k] or S[j]==S[k]:\n continue\n n -= 1\n \nprint(n)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s221978253', 's536343135', 's539624120', 's706481144', 's825361777', 's255918309']
[9304.0, 9308.0, 9544.0, 9260.0, 9536.0, 9192.0]
[2205.0, 2206.0, 2206.0, 652.0, 2206.0, 1114.0]
[1083, 1103, 1093, 1298, 1101, 340]
p02714
u693173434
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\nrcount=0\ngcount=0\nbcount=0\nfor i in range(n):\n if s[i]=="R":\n rcount+=1\n elif s[i]=="G":\n gcount+=1\n else:\n bcount+=1\n\nal=rcount*bcount*gcount\n\nfor i in range(n-2):\n for k in range(i+1,n):\n dis=k-i\n l=k+dis\n if k+dis>n:\n continue\n if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:\n al-=1\n\nprint(al)\n', 'n = int(input())\ns = input()\n\nal=s.count("R")*s.count("G")*s.count("B")\n\nfor i in range(n-2):\n for k in range(i+1,n-1):\n l=k+(k-i)\n if l>=n:\n continue\n if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:\n al-=1\n\nprint(al)\n']
['Runtime Error', 'Accepted']
['s049998125', 's327405349']
[9148.0, 9152.0]
[32.0, 1949.0]
[407, 261]
p02714
u698849142
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=[]\ng=[]\nb=[]\nfor i,c in enumerate(s):\n if 'R' == c:\n r.append(i+1)\n elif 'G' == c:\n g.append(i+1)\n elif 'B' == c:\n b.append(i+1)\nprint(r,g,b)\ncount=0\nfor i in r:\n for j in g:\n for k in b:\n if j*2-i-k != 0:\n count+=1\nprint(count)", 'import collections\nn = int(input())\ns=input()\nl=list(collections.Counter(s).values())\nif len(l) == 3:\n ans=l[0]*l[1]*l[2]\n for i in range(n):\n for j in range(i+1,n):\n k = 2*j-i\n if n <= k:\n break\n if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:\n ans-=1\n print(ans)\nelse:\n print(0)\n']
['Wrong Answer', 'Accepted']
['s635311586', 's744896000']
[9208.0, 9468.0]
[2205.0, 1349.0]
[323, 366]
p02714
u698868214
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\nI = []\nJ = []\nK = []\n\nfor n in range(1,N+1):\n if S[n-1] == "R":\n I.append(n)\n elif S[n-1] == "G":\n J.append(n)\n else:\n K.append(n)\n \ncnt = 0\nfor a in I:\n for b in J:\n for c in K:\n ls = [a,b,c]\n ls.sort()a\n if ls[1] - ls[0] != ls[2] - ls[1]:\n cnt += 1\n \nprint(cnt)', 'N = int(input())\nS = input()\n\nans = S.count("R") * S.count("G") * S.count("B")\n\nfor i in range(1,N-1):\n for j in range(i+1,N):\n k = 2 * j - i\n if k > N:\n break\n if S[i-1] != S[j-1] and S[j-1] != S[k-1] and S[k-1] != S[i-1]:\n ans -= 1\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s966365719', 's892691001']
[8768.0, 9192.0]
[28.0, 1781.0]
[337, 271]
p02714
u699296734
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.
['\na=int(input())\nmoji=input()\nr=[]\ng=[]\nb=[]\nfor i in range(a):\n if moji[i]=="R":\n r.append(i)\n elif moji[i]=="G":\n g.append(i)\n elif moji[i]=="B":\n b.append(i)\nres=len(r)*len(g)*len(b)\nif len(r)==0 or len(g)==0 or len(b)==0:\n print(0)\nelse:\n min_len={len(r):r,len(g):g,len(b):b}\n tmp=sorted(min_len.keys())\n r=min_len[tmp[0]]\n g=min_len[tmp[1]]\n b=min_len[tmp[2]]\n for i in r:\n for j in g:\n if -abs(i-j)+min(i,j) in b:\n res-=1\n if abs(i-j)+max(i,j) in b:\n res-=1\n if abs(i-j)%2==0 and int(abs(i-j)/2)+min(i,j) in b:\n res-=1\n print(res)', 'a=int(input())\nmoji=input()\nr=[]\ng=[]\nb=[]\nfor i in range(a):\n if moji[i]=="R":\n r.append(i)\n elif moji[i]=="G":\n g.append(i)\n elif moji[i]=="B":\n b.append(i)\nres=len(r)*len(g)*len(b)\nif len(r)==0 or len(g)==0 or len(b)==0:\n print(0)\nelse:\n min_len={r:0,g:1,b:2}\n if len(r)>len(g):\n tmp=min_len[r]\n min_len[r]=min_len[g]\n min_len[g]=tmp\n if len(g)>len(b):\n tmp=min_len[g]\n min_len[g]=min_len[b]\n min_len[b]=tmp\n if len(b)>len(r):\n tmp=min_len[b]\n min_len[b]=min_len[r]\n min_len[r]=tmp\n \n for key,value in min_len.items():\n if value==0:\n a1=key\n elif value==1:\n a2=key\n elif value==2:\n a3=key\n \n for i in a1:\n for j in a2:\n if -abs(i-j)+min(i,j) in a3:\n res-=1\n if abs(i-j)+max(i,j) in a3:\n res-=1\n if abs(i-j)%2==0 and int(abs(i-j)/2)+min(i,j) in a3:\n res-=1\n print(res)', 'a=int(input())\nmoji=input()\nr=[]\ng=[]\nb=[]\nfor i in range(a):\n if moji[i]=="R":\n r.append(i)\n elif moji[i]=="G":\n g.append(i)\n elif moji[i]=="B":\n b.append(i)\nres=len(r)*len(g)*len(b)\nif len(r)==0 or len(g)==0 or len(b)==0:\n print(0)\nelse:\n min_len={len(r):r,len(g):g,len(b):b}\n tmp=list(min_len.keys()).sort()\n r=min_len[tmp[0]]\n g=min_len[tmp[1]]\n b=min_len[tmp[2]]\n for i in r:\n for j in g:\n if -abs(i-j)+min(i,j) in b:\n res-=1\n if abs(i-j)+max(i,j) in b:\n res-=1\n if abs(i-j)%2==0 and int(abs(i-j)/2)+min(i,j) in b:\n res-=1\n print(res)', 'a=int(input())\nmoji=input()\nr=[]\ng=[]\nb=[]\nfor i in range(a):\n if moji[i]=="R":\n r.append(i)\n elif moji[i]=="G":\n g.append(i)\n else:\n b.append(i)\nres=len(r)*len(g)*len(b)\nif len(r)==0 or len(g)==0 or len(b)==0:\n print(0)\nelse:\n min_len={0:r,1:g,2:b}\n if len(min_len[0])>len(min_len[1]):\n tmp=min_len[0]\n min_len[0]=min_len[1]\n min_len[1]=tmp\n if len(min_len[1])>len(min_len[2]):\n tmp=min_len[1]\n min_len[1]=min_len[2]\n min_len[2]=tmp\n if len(min_len[0])>len(min_len[1]):\n tmp=min_len[0]\n min_len[0]=min_len[1]\n min_len[1]=tmp\n a1=[]\n for i in range(3):\n a1.append(min_len[i])\n A=set(a1[0])\n B=set(a1[1])\n C=set(a1[2])\n for i in A:\n for j in B:\n if -abs(i-j)+min(i,j) in C:\n res-=1\n if abs(i-j)+max(i,j) in C:\n res-=1\n if abs(i-j)%2==0 and int(abs(i-j)/2)+min(i,j) in C:\n res-=1\n print(res)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s454903628', 's781053337', 's847438840', 's449781866']
[9188.0, 9104.0, 9284.0, 9492.0]
[2205.0, 23.0, 21.0, 1785.0]
[675, 1033, 679, 1012]
p02714
u699944218
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()\nls = list(S)\ncount = 0\nfor k in range(2,N):\n for j in range(1,k):\n for i in range(0,j):\n if ls[i] != ls[j] and ls[j] != ls[k] and ls[k] != ls[i]:\n count += 1\nprint(count)', "N = int(input())\nS = input()\nls = list(S)\n\nnr = len([r for r in S if r == 'R'])\nnb = len([b for b in S if b == 'B'])\nng = len([g for g in S if g == 'G'])\n\nALL = nr * nb * ng\ncount = 0\n\nfor i in range(N-2):\n for k in range(2,N):\n j = (i + k) // 2\n if 1 <= j and j <= N:\n count += 1\n \nprint(ALL - count)", "import itertools\nN = int(input())\nS = input()\nls = list(S)\n\nnr = len([r for r in S if r == 'R'])\nnb = len([b for b in S if b == 'B'])\nng = len([g for g in S if g == 'G'])\n\nALL = nr * nb * ng\ncount = 0\n\nRGBs = list(itertools.permutations(['R', 'G', 'B'], 3))\n\nfor i in range(N):\n for j in range(N-i*2):\n if (S[j], S[j+i], S[j+i*2]) in RGBs:\n count += 1\n \nprint(ALL - count)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s713651130', 's841473655', 's754949479']
[9116.0, 9212.0, 9200.0]
[2206.0, 2206.0, 1617.0]
[215, 318, 386]
p02714
u704563784
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())\nstring = input()\n\nr=g=b=0\n\nfor idx, s in enumerate(string):\n if s == 'R':\n r+=1\n elif s == 'B':\n b+=1\n elif s == 'G':\n g+=1\n\nans = r*g*b\n\nfor i in range(n):\n for k in range(i+1, n):\n if string[i] != string[k]:\n if (k+i)%2 == 0 and len(set(string[i], string[k], string[(k+i)//2]) ==3:\n ans -= 1\n\nprint(ans)", "n = int(input())\nstring = input()\n\nr=g=b=0\n\nfor idx, s in enumerate(string):\n if s == 'R':\n r+=1\n elif s == 'B':\n b+=1\n elif s == 'G':\n g+=1\n\nans = r*g*b\n\nfor i in range(n):\n for k in range(i+1, n):\n if string[i] != string[k]:\n if (k+i)%2 == 0 and len(set(string[i], string[k], string[(k+i)//2])) ==3:\n ans -= 1\n\nprint(ans)\n \n\n", "n = int(input())\nstring = input()\nr = 0\ng = 0\nb = 0\nfor c in string:\n if c == 'R':\n r += 1\n elif c == 'G':\n g += 1\n else:\n b += 1\nans = r*g*b\nfor i in range(n):\n for j in range(i+1, n):\n if 2*j - i >= n:\n break\n \n if string[i] != string[j] and string[i] != string[2*j-i] and string[j] != string[2*j-i]:\n ans -= 1\nprint(ans)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s552587178', 's752209523', 's198995237']
[8932.0, 9168.0, 9152.0]
[23.0, 23.0, 1553.0]
[388, 404, 399]
p02714
u706786134
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 numba import njit\nimport numpy as np\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\n\nN = int(input())\nS = np.array(list(read().rstrip()), np.int8)\n\nR = np.sum(S == ord('R'))\nB = np.sum(S == ord('B'))\nG = np.sum(S == ord('G'))\n\n\n@njit\ndef f(S):\n N = len(S)\n ret = 0\n for i in range(N):\n for j in range(i + 1, N):\n k = j + 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 ret += 1\n return ret\n\n\nanswer = R * B * G - f(S)\nprint(answer)\n", "from numba import njit\nimport numpy as np\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\nN = int(input())\nS = np.array(list(read().rstrip()), np.int8)\n\nR = np.sum(S == ord('R'))\nB = np.sum(S == ord('B'))\nG = np.sum(S == ord('G'))\n\n\n@njit\ndef f(S):\n N = len(S)\n ret = 0\n for i in range(N):\n for j in range(i + 1, N):\n k = j + 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 ret += 1\n return ret\n\n\nanswer = R * B * G - f(S)\nprint(answer)\n", "from numba import njit\nimport numpy as np\nimport sys\nreadline = sys.stdin.buffer.readline\n\nN = int(input())\nS = np.array(list(readline().rstrip()), np.int8)\n\nR = np.sum(S == ord('R'))\nB = np.sum(S == ord('B'))\nG = np.sum(S == ord('G'))\n\n\n@njit\ndef f(S):\n N = len(S)\n ret = 0\n for i in range(N):\n for j in range(i + 1, N):\n k = j + 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 ret += 1\n return ret\n\n\nanswer = R * B * G - f(S)\nprint(answer)\n", "from numba import njit\nimport numpy as np\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN = int(readline())\nS = np.array(list(readline().rstrip()), np.int8)\n\nR = np.sum(S == ord('R'))\nB = np.sum(S == ord('B'))\nG = np.sum(S == ord('G'))\n\n\n@njit\ndef f(S):\n N = len(S)\n ret = 0\n for i in range(N):\n for j in range(i + 1, N):\n k = j + 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 ret += 1\n return ret\n\n\nanswer = R * B * G - f(S)\nprint(answer)\n"]
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s539563647', 's566181402', 's648129240', 's569873830']
[91532.0, 109532.0, 109628.0, 109668.0]
[391.0, 714.0, 695.0, 752.0]
[565, 579, 554, 625]
p02714
u709304134
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 collections import Counter\nN = int(input())\nS = input()\n#c = Counter(S)\n#print (c.most_common())\n#ls = list(c.values())\nans = S.count('R') * S.count('G') * S.count('B')\n\n\nfor i in range(N):\n for j in range(1,N):\n a = i + j\n b = i + j + j\n if (b >= N):\n break\n else:\n l = S[i]\n m = S[a]\n r = S[b]\n if l!=m and m!=r and r!=l:\n ans -= 1\n # if (i-j<0 or i+j>=N):\n # break\n # l = S[i-j]\n # m = S[i]\n # r = S[i+j]\n # if l!=m and m!=r and r!=l:\n # ans -= 1\nprint (ans)\n", "from collections import Counter\nN = int(input())\nS = input()\nans = S.count('R') * S.count('G') * S.count('B')\n\nfor i in range(N):\n for j in range(1,N):\n if (i-j<0 or i+j>=N):\n break\n l = S[i-j]\n m = S[i]\n r = S[i+j]\n if l!=m and m!=r and r!=l:\n ans -= 1\nprint (ans)\n"]
['Runtime Error', 'Accepted']
['s965515036', 's456946050']
[8876.0, 9468.0]
[21.0, 1631.0]
[626, 326]
p02714
u720636500
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("R")*s.count("G")*s.count("B")\nfor i in range(1,n//2+10):\n j = 0\n while j+2*i <= n-1:\n print([j, j+i, j+2*i])\n if s[j] != s[j+i] and s[j] != s[j+2*i] and s[j+i] != s[j+2*i]:\n ans -= 1\n j += 1\nprint(ans)', 'n = int(input())\ns = input()\nans = s.count("R")*s.count("G")*s.count("B")\nfor i in range(1,n//2+10):\n j = 0\n while j+2*i <= n-1:\n if s[j] != s[j+i] and s[j] != s[j+2*i] and s[j+i] != s[j+2*i]:\n ans -= 1\n j += 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s203033875', 's245680286']
[39564.0, 9192.0]
[2302.0, 1707.0]
[261, 235]
p02714
u725993280
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,s = input().split()\ns = list(s)\n\ncount = 0\n\nfor i in range(0,len(s)):\n for j in range(i,len(s)):\n for k in range(j,len(s)):\n if(j-i != k-j) and (s[i] != s[j] and s[i] != s[k] and s[j] != s[k]):\n count += 1\n\n\nprint(count)\n', 'n = int(input())\ns = input()\n\ns = list(s)\n\nk = r = b = g = count = 0\n\nfor i in range(len(s)):\n for j in range(i+1,len(s)):\n k = 2*j-i\n if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:\n count += 1 \n\nrbg = s.count("R")*s.count("B")*s.count("G")\n\nprint(rbg-count)\n']
['Runtime Error', 'Accepted']
['s279621932', 's504976416']
[9036.0, 9220.0]
[24.0, 1869.0]
[259, 304]
p02714
u726285999
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\nsum = 0\nfor i in range(N):\n for j in range(i+1, N):\n if S[i] == S[j]:\n continue\n\n RGB = ['R','G','B']\n RGB.remove(S[j])\n RGB.remove(S[i])\n sum += S[(j+1):].count(RGB[0])\n\n # S[k]\n k = 2 * j - i\n if k < len(S):\n if S[k] == RGB[0]:\n sum -= 1\nprint(sum)", "from collections import Counter\n\nN = int(input())\nS = input()\n\nr = S.count('R')\ng = S.count('G')\nb = S.count('B')\n\nsum = r*g*b\n\nfor i in range(N):\n for j in range(i+1, N):\n k = 2 * j - i\n if not S[i] == S[j] and not S[j] == S[k] and not S[k] == S[i]:\n sum -= 1\nprint(sum)", "from collections import Counter\n\nN = int(input())\nS = input()\n\nr = S.count('R')\ng = S.count('G')\nb = S.count('B')\n\nsum = r*g*b\n\nfor i in range(N):\n for j in range(i+1, N):\n k = 2 * j - i\n if k > N - 1:\n break\n if not S[i] == S[j] and not S[j] == S[k] and not S[k] == S[i]:\n sum -= 1\nprint(sum)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s259691570', 's789369892', 's086424037']
[8912.0, 9348.0, 9472.0]
[22.0, 22.0, 1347.0]
[408, 299, 339]
p02714
u727057618
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 math\nfrom itertools import combinations\n\ndef main():\n k = int(input())\n res = 0\n memo = [[0 for _ in range(k+1)] for _ in range(k+1)]\n for i ian range(1, k+1):\n for j in range(i, k+1):\n tmp = math.gcd(i,j)\n memo[i][j] = tmp\n memo[j][i] = tmp\n\n for i in range(1, k+1):\n res += i \n\n for c in combinations(range(1,k+1),2):\n ab = memo[c[0], c[1]]\n res += ab * 6\n\n for c in combinations(range(1,k+1), 3):\n ab = memo[c[0], c[1]]\n abc = memo[ab, c[2]]\n res += abc * 6\n print(res)\n\n\nif __name__ == '__main__':\n main()\n", "from itertools import permutations\n\ndef main():\n n = int(input())\n s = input()\n res = 0\n r = 0\n g = 0\n b = 0\n for i, c in enumerate(s):\n if c == 'R':\n r += 1\n elif c == 'G':\n g += 1\n else:\n b += 1\n \n rgb = []\n for t in permutations('RGB'):\n rgb.append(''.join(t))\n\n cnt = 0\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] + s[k]) in rgb:\n cnt += 1\n print(r*g*b - cnt)\n\n\nif __name__ == '__main__':\n main()\n\n"]
['Runtime Error', 'Accepted']
['s398222453', 's665677322']
[9024.0, 9228.0]
[24.0, 1170.0]
[626, 630]
p02714
u729008627
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()\nnR = 0\nnG = 0\nnB = 0\ncnt = 0\nfor i in range(N-1):\n if S[i] == 'R':\n nR += 1\n elif S[i] == 'G':\n nG += 1\n else:\n nB += 1\n for j in range(i+1, N):\n k = j - i + j\n if k < N:\n L = [S[i], S[j], S[k]]\n if 'R' in L and 'G' in L and 'B' in L:\n cnt += 1\n else:\n break\nprint(nR*nG*nB-cnt)\n", "N = int(input())\nS = input()\nnR = 0\nnG = 0\nnB = 0\ncnt = 0\nfor i in range(N):\n if S[i] == 'R':\n nR += 1\n elif S[i] == 'G':\n nG += 1\n else:\n nB += 1\n for j in range(i+1, N):\n k = j - i + j\n if k < N:\n L = [S[i], S[j], S[k]]\n if 'R' in L and 'G' in L and 'B' in L:\n cnt += 1\n else:\n break\nprint(nR*nG*nB-cnt)\n"]
['Wrong Answer', 'Accepted']
['s297657606', 's685979650']
[9208.0, 9208.0]
[1793.0, 1558.0]
[352, 350]
p02714
u732061897
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()\nresult = 0\n'''\nfor i in range(N):\n print(result)\n for j in range(i+1,N):\n if S[i] != S[j]:\n for k in range(j ,N):\n if k- j == j - i:\n continue\n if S[j] != S[k] and S[i] != S[k]:\n result +=1\nprint(result)\n'''\nr = S.count('R')\ng = S.count('G')\nb = S.count('B')\ntarget = set('RGB')\nresult = r * g * b\nfor i in range(N):\n for j in range(1, min(i, (N - i + 1)) + 1):\n if target == set(S[i] + S[i-j] + S[j + i]):\n result -= 1\nprint(result)", "N = int(input())\nS = input()\nresult = 0\n'''\nfor i in range(N):\n print(result)\n for j in range(i+1,N):\n if S[i] != S[j]:\n for k in range(j ,N):\n if k- j == j - i:\n continue\n if S[j] != S[k] and S[i] != S[k]:\n result +=1\nprint(result)\n'''\nr = S.count('R')\ng = S.count('G')\nb = S.count('B')\ntarget = set('RGB')\nresult = r * g * b\nfor i in range(N):\n for j in range(1, min(i, (N - i - 1)) + 1):\n if target == set(S[i] + S[i-j] + S[j + i]):\n result -= 1\nprint(result)"]
['Runtime Error', 'Accepted']
['s804524983', 's763159065']
[9192.0, 9152.0]
[994.0, 1943.0]
[575, 575]
p02714
u744695362
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]\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') \n \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 \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\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') \n \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 \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', 'Runtime Error', 'Runtime Error', 'Accepted']
['s155741589', 's274450706', 's298093806', 's657441472', 's701690294', 's721333055']
[9208.0, 9192.0, 9216.0, 9204.0, 9176.0, 9120.0]
[23.0, 22.0, 23.0, 24.0, 22.0, 1696.0]
[346, 765, 347, 349, 765, 351]
p02714
u745687363
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()\na = s.count("R")\nb = s.count("G")\nc = s.count("B")\nz = a*b*c\nif z ==0:\n print(0)\nelse:\n R=[]\n G=[]\n B=[]\n for 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)\n x = 0\n for i in R:\n for j in G:\n if (0<= 2*j-i <=n-1 and s[2*j-i] in B) or (0<= 2*i-j <=n-1 and s[2*i-j] in B):\n x += 1\nprint(z-x)', 'n = int(input())\ns = input()\na = s.count("R")\nb = s.count("G")\nc = s.count("B")\nz = a*b*c\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 else:\n B.append(i)\nx = 0\nfor i in R:\n for j in G:\n if 0 <= 2*j-i <= n-1 and s[2*j-i]=="B":\n x+=1\n if 0 <= 2*i-j <= n-1 and s[2*i-j]=="B":\n x+=1\n if (i+j)%2==0 and s[(i+j)//2]=="B":\n x+=1\nprint(z-x)\n']
['Runtime Error', 'Accepted']
['s553319516', 's611147871']
[9236.0, 9236.0]
[2205.0, 1041.0]
[411, 418]