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
u747391638
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\nn = int(input())\ns = list(input())\n\nupper = s.count("R")*s.count("G")*s.count("B")\n\ndef counting(x):\n count = 0\n for i in range(math.ceil(x/2)):\n if s[x-1]!=s[x-1-i] and s[x-1-i]!=s[x-1-2*i] and s[x-1-2*i]!=s[x-1]:\n count += 1\n else:\n count += 0\n return count\n\nif n>=3:\n...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s326951113', 's814951030', 's300180729']
[9240.0, 9248.0, 9268.0]
[1324.0, 1310.0, 1310.0]
[526, 481, 529]
p02714
u748241164
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())\nRGB = [0] * 3\nfor i in range(N):\n if S[i] == "R":\n RGB[0] += 1\n elif S[i] == "G":\n RGB[1] += 1:\n else:\n RGB[2] += 1\n \nans = RGB[0] * RGB[1] * RGB[2]\n\nfor i in range(1, 2000):\n for j in range(1, N + 1):\n if (j + 2 * i) <= N:\n if S[j - 1] != S[j ...
['Runtime Error', 'Accepted']
['s197808528', 's656392901']
[8984.0, 9208.0]
[24.0, 1731.0]
[455, 405]
p02714
u749742659
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 = []\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)\n\nsamu = len(R) * len(G) * len(B)\n\nfor i in R:\n for j in G:\n k = int(2 * j - i)\n if(0 <= k < n):\n ...
['Wrong Answer', 'Accepted']
['s382020445', 's946212441']
[15708.0, 9232.0]
[1981.0, 1291.0]
[673, 586]
p02714
u750651325
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 math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef s(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): return list(...
['Runtime Error', 'Accepted']
['s913874883', 's914441259']
[10156.0, 10128.0]
[32.0, 1341.0]
[745, 749]
p02714
u751717561
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\na = S[0]\nres= 0\n\nfor i in range(1, N-2):\n if a == S[i]:\n b = S[i]\n for j in range(j, N-1):\n if i == j:\n continue\n c = S[j]\n if a!=b and b!= c and a!=c:\n res +=1\n\nprint(res)', "N = int(in...
['Runtime Error', 'Accepted']
['s445930902', 's759196193']
[9192.0, 9192.0]
[22.0, 1991.0]
[288, 305]
p02714
u767664985
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")\n\nres = 0\nfor i in range(N-2):\n for d in range(1, (N-i)//2+1):\n if set(S[i], S[i+d], S[i+2*d]) == {"R", "G", "B"}:\n res += 1\nans -= res\nprint(ans)\n', 'from bisect import bisect_right\n\ndef runLength(string)...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s261657087', 's703977825', 's311551607']
[9192.0, 9352.0, 9080.0]
[21.0, 2206.0, 1846.0]
[246, 1609, 259]
p02714
u768256617
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()\ns=Counter(s_)\nrgb = s['R'] * s['G'] * s['B']\ncnt=0\nfor i in range(len(s_)):\n for j in range(i+1,len(s_)):\n h=j-i+j\n if h<len(s_)-1:\n if s_[i]!=s_[j] and s_[h]!=s_[j] and s_[i]!=s_[h]:\n cnt+=1\n\nprint(rgb-cnt)", "from collections ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s228232611', 's849016207', 's196864200']
[9328.0, 9464.0, 9492.0]
[2206.0, 24.0, 1882.0]
[284, 280, 281]
p02714
u784022244
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 jit\n\n@jit\ndef main():\n\n N=int(input())\n S=input()\n R=0\n G=0\n B=0\n for i in range(N):\n s=S[i]\n if s=="R":\n R+=1\n elif s=="G":\n G+=1\n else:\n B+=1\n ans=R*G*B\n for i in range(N-2):\n for j in r...
['Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s113244646', 's443289134', 's465215838', 's859343237', 's862759769']
[117480.0, 113928.0, 91528.0, 113984.0, 9372.0]
[2208.0, 2108.0, 390.0, 2129.0, 1975.0]
[552, 474, 473, 472, 286]
p02714
u785573018
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())\nList = list(input())\ncount = 0\nprint(List)\nfor k in range(n - 2):\n for l in range(k + 1, n - 1):\n if List[k] != List[l]:\n for m in range(l + 1, min(2 * l - k, n)):\n if List[k] != List[m] and List[l] != List[m]:\n count += 1\n f...
['Wrong Answer', 'Accepted']
['s726931512', 's627029650']
[9128.0, 9208.0]
[2206.0, 1268.0]
[454, 299]
p02714
u788608806
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\nN = int(input())\nS = input()\nS = S[::-1]\n\ncnt = 0\n\n# for j in range(i+1,N):\n# if S[i-1] != S[j-1]:\n# for k in range(j+1,N+1):\n# if S[i-1]!=S[k-1] and S[j-1]!=S[k-1] and j-i!=k-j:\n# cnt += 1\nfor i in range(1,N-1):\n for j in range(i+1,N):\n ...
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s117573119', 's139234908', 's298215632', 's339925741', 's396292952', 's462926745', 's023627562']
[9136.0, 9100.0, 9188.0, 9220.0, 9188.0, 9200.0, 9200.0]
[2205.0, 21.0, 20.0, 23.0, 24.0, 23.0, 1882.0]
[476, 220, 428, 513, 497, 425, 271]
p02714
u802234211
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(str, input()))\nf=0\ni_c = j_c = k_c =1\nijk = list()\nfor i in range(N):\n for j in range(N):\n for k in range(N):\n if(k_c>j_c and j_c>i_c):\n if(j_c-i_c!=k_c-j_c):\n ijk.append([i,j,k])\n k_c+=1\n j_c+=1\n ...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s027097893', 's153526918', 's211742241', 's314292008', 's548554802', 's744807421', 's826607149', 's890866636', 's947502226', 's258806529']
[403140.0, 9208.0, 9156.0, 317128.0, 9172.0, 305008.0, 8984.0, 406416.0, 9076.0, 9204.0]
[2217.0, 1737.0, 1800.0, 2216.0, 1868.0, 2213.0, 21.0, 2218.0, 22.0, 1783.0]
[547, 268, 270, 302, 262, 309, 342, 500, 525, 269]
p02714
u813387707
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\n\nk = int(input())\ns = input()\n\ntemp_dict = {\n "R": [],\n "G": [],\n "B": [],\n}\nfor i, c in enumerate(s):\n temp_dict[c].append(i)\n\nans = 0\ntemp_list = list(product(temp_dict["R"], temp_dict["G"], temp_dict["B"]))\nfor temp in temp_list:\n temp.sort()\n if tem...
['Runtime Error', 'Runtime Error', 'Accepted']
['s760090437', 's984700097', 's815741672']
[1947000.0, 9124.0, 9104.0]
[2261.0, 20.0, 990.0]
[367, 319, 237]
p02714
u815304751
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')\n\ncount = R*G*B\nprint(count)\ncnt = 0\nfor i in range(len(s)):\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 ...
['Wrong Answer', 'Accepted']
['s168953188', 's371544299']
[9204.0, 9192.0]
[1508.0, 1559.0]
[330, 317]
p02714
u819593641
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\narr = []\nR = len(list(filter(lambda x:x == 'R', s)))\nG = len(list(filter(lambda x:x == 'G', s)))\nB = len(list(filter(lambda x:x == 'B', s)))\ntot = R*G*B\nprint(tot)\n\nfor i in range(n):\n for j in range(i+1, n):\n k = 2*j-i\n if k < n:\n if (s[i] != s[j]) & (s[i...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s041345207', 's742757255', 's297378929']
[9228.0, 9208.0, 9128.0]
[2088.0, 24.0, 1787.0]
[361, 355, 361]
p02714
u821775079
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")\n\ntmp=0\n\nfor i in range(N):\n for j in range(i,N):\n if j-i+j < N:\n if S[i]==S[j] and S[j]==S[j-i+j] and S[i]==S[j-i+j]:\n tmp += 1\n\nans = ans - tmp\nprint(ans)', 'N=int(input())\nS=input()\n\nans = S.count("R")*S.count("G...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s361491818', 's690605456', 's995935246']
[9192.0, 9044.0, 9192.0]
[1852.0, 19.0, 1923.0]
[242, 241, 242]
p02714
u823885866
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\nn = int(sys.stdin.readline())\ns = sys.stdin.readline()\nr = []\ng = []\nb = []\ncnt = 0\ni = 0\nwhile i < 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)\nfor j in r:\n for k in g:\n for l in b:\n if l - k != k - j:\n cnt += 1\nprint(...
['Time Limit Exceeded', 'Accepted']
['s324348759', 's568300998']
[142968.0, 9208.0]
[2209.0, 1919.0]
[302, 511]
p02714
u824295380
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)\nprint(r)\nprint(g)\nprint(b)\nt=0\nfor i in range(len(r)):\n for j in range(len(g)):\n p=0\n for k in range(len(b)):\n ...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s163755372', 's732340758', 's829112562', 's572250654']
[9244.0, 15504.0, 9232.0, 9236.0]
[2205.0, 2225.0, 2205.0, 1934.0]
[561, 436, 408, 399]
p02714
u830881690
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(input().split()))\n\nr_i = [i for i, x in enumerate(s) if x=='R']\ng_i = [i for i, x in enumerate(s) if x=='G']\nb_i = [i for i, x in enumerate(s) if x=='B']\n\nans = 0\n\nfor i in len(r_i):\n for j in len(g_i):\n for k in len(b_i):\n if r_i[i]!=g_i[j] and g_i[j]!=b...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s036307837', 's623719020', 's670448907', 's848392688']
[9224.0, 9216.0, 9124.0, 9204.0]
[21.0, 20.0, 21.0, 1621.0]
[368, 361, 368, 390]
p02714
u833738197
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=[]\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\nans = len(R)*len(G)*len(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 ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s049209914', 's194957248', 's893834218']
[9044.0, 9196.0, 9124.0]
[22.0, 1809.0, 1878.0]
[383, 386, 386]
p02714
u841599623
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()\nc = 0\nRGB = 'RGB'\nfor i in range(N-2):\n a = S[i]\n for j in range(i+1,N-1):\n if S[j] != a:\n S_ = S[j+1:]\n d = j - i\n S_ = S_[d: d+1]\n RGB = RGB.strip(a).strip(S[j])\n c += S_.count(RGB)\nprint(c)", "N=int(input())\nS=input()\nA=S.count('R')*S.count('G')...
['Wrong Answer', 'Accepted']
['s613982443', 's253347257']
[9144.0, 9100.0]
[2205.0, 1975.0]
[247, 238]
p02714
u843318346
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_num = s.count('R')\ng_num = s.count('G')\nb_num = s.count('B')\ntot = r_num*g_num*b_num\nprint(tot)\nfor i in range(n):\n for j in range(i+1,n):\n k = j+(j-i)\n\n if k<n:\n if s[i]!=s[j] and s[i]!=s[k] and s[j] != s[k]:\n tot -= 1\n\nprint(to...
['Wrong Answer', 'Accepted']
['s004971878', 's420725774']
[9204.0, 9184.0]
[1994.0, 1922.0]
[306, 295]
p02714
u844895214
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 S(): return stdin.readline().rstrip()\ndef I(): return int(stdin.readline().rstrip())\n\n\nn = I()\ns = S()\n\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[k] != s[i] and s[k] != s[j]:\n if j-i !=...
['Runtime Error', 'Runtime Error', 'Accepted']
['s068211977', 's126821712', 's745976053']
[9112.0, 106756.0, 9092.0]
[23.0, 486.0, 1538.0]
[355, 589, 407]
p02714
u851125702
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=input()\nlis=list(S)\nC= collections.Counter(lis)\ncount=list(C.values())\nc=0\nfor i in range(N):\n print(i)\n for j in range(i,(N+i-1) // 2+1):\n if(lis[i]!=lis[j]):\n if(lis[j]!=lis[2*j-i]):\n if(lis[i]!=lis[2*j-i]):\n ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s177252459', 's953128885', 's727224096']
[9644.0, 9648.0, 9468.0]
[1054.0, 1168.0, 1014.0]
[388, 346, 375]
p02714
u852124489
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 = 0\ng = 0\nb = 0\nk = 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\n\nsum = r * g * b\nfor i in range(0, N-2):\n for j in range(i+1,N-1):\n if 2*j - i < N:\n k = 2*j - i\n if S...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s176303514', 's243060832', 's256445327', 's582244033', 's622150314', 's042088247']
[9192.0, 9208.0, 9168.0, 9224.0, 9220.0, 9200.0]
[2205.0, 2080.0, 22.0, 21.0, 2206.0, 1871.0]
[362, 409, 1278, 1278, 401, 390]
p02714
u857293613
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)\ndef func(a,b,c):\n ans = 0\n for i in a:\n for k in [num1 for num1 in b if num1 > i+...
['Runtime Error', 'Accepted']
['s859863489', 's593678082']
[9240.0, 9176.0]
[21.0, 1496.0]
[478, 276]
p02714
u864069774
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")\n\nRGB = [R,G,B]\nRGB.sort()\nans = min(RGB) * (max(RGB)+1) * (RGB[1]-1)\nprint(ans)\n', "N = int(input())\nS = input()\nR = set()\nG = set()\nB = set()\nfor i in range(N):\n if S[i] == 'R':\n R.add(i)\n elif S[i] == 'G':\n G....
['Wrong Answer', 'Accepted']
['s679051672', 's229843220']
[9052.0, 9380.0]
[21.0, 708.0]
[174, 401]
p02714
u864273141
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.
['ans=0\nn=int(input())\nk=str(input())\nr=k.count("R")\nb=k.count("B")\ng=k.count("G")\nans+=r*b*g\n \nfor i in range(n-2):\n ii=k[i]\n for j in range(i+1,(n-i)//2):\n jj=k[j]\n l=j+(j-i)\n #print(l)\n if jj!=ii and l<n:\n #print(i,j)\n ll=k[l]\n if ii!=ll and jj!=ll:\n ans-=1\n ...
['Wrong Answer', 'Accepted']
['s543622958', 's580107319']
[9208.0, 9212.0]
[476.0, 1269.0]
[332, 336]
p02714
u868339437
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\n\nfor i in range(n-3):\n for j in range(i+1, n-2):\n if s[i] == s[j]:\n continue\n for k in range(j+1, n-1):\n if s[i] == s[k] or s[j] == s[k]:\n continue\n else:\n if j - i == k - j:\n ...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s312008262', 's776034904', 's993002780', 's700510354']
[9124.0, 9200.0, 9152.0, 9196.0]
[2205.0, 1117.0, 2108.0, 1117.0]
[391, 363, 390, 363]
p02714
u871934301
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=[]\nans=0\nx=0\na=0\nb=0\nc=0\nfor i in S:\n if i=="R":\n R.append(x)\n if i=="G":\n G.append(x)\n if i=="B":\n B.append(x)\n x+=1\nfor j in R:\n for k in G:\n if 2*k-j in B:\n B.pop(B.index(2*k-j))\n a+=1\n ...
['Runtime Error', 'Accepted']
['s843381089', 's088330833']
[9260.0, 9208.0]
[20.0, 1895.0]
[662, 533]
p02714
u875541136
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\n\nN = int(input())\nS = input()\nout = S.count('R') * S.count('G') * S.count('B')\nfor i in range(1, N):\n for j in range(N-i*2):\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()\nout = S.count('R') * S.count('G') * S.count('B'...
['Runtime Error', 'Accepted']
['s561575215', 's379679828']
[9200.0, 9092.0]
[22.0, 1619.0]
[209, 266]
p02714
u891489344
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 = input\n#\'\'\'\nallinputs = iter(input().splitlines())\ninput = lambda : next(allinputs)\n#\'\'\'\n\n\n\n\nN=int(input())\nS=input()\n\nRGB_num=[0]*3\n\nfor c in S:\n\tif c==\'R\':\n\t\tRGB_num[0] += 1\n\telif c==\'G\':\n\t\tRGB_num[1] += 1\n\telse:\n\t\tRGB_num[2] += 1\n\n#print(RGB_num)\njoken2=0\n\nprint(...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s056903345', 's528488658', 's909553968', 's588832895']
[9236.0, 9112.0, 9124.0, 9212.0]
[26.0, 1481.0, 1534.0, 1468.0]
[671, 671, 670, 658]
p02714
u902430070
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 = 0\ng = 0 \nfor i in range(s):\n if i == 'R':\n r += 1\n elif i == 'G':\n g += 1\n \nc = r*g*(n-r-g)\nfor j in range(1, n):\n for i in range(1, min(j, n - j -1) + 1):\n if s[j] != s[j + i] and s[j] != s[j - i] and s[j - i] != s[j + 1]:\n c -= 1\nprint(c)\n ", "n = ...
['Runtime Error', 'Accepted']
['s947633470', 's674826308']
[9144.0, 9104.0]
[21.0, 1142.0]
[294, 293]
p02714
u909991537
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 = input()\n\nR = []\nG = []\nB = []\nans = 0\n\nfor i, x in enumerate(S):\n if x == 'R':\n R.append(i)\n elif x == 'G':\n G.append(i)\n else:\n B.append(i)\n\ndef calc(a, b, c):\n lis = sorted([a, b, c])\n if lis[1] * 2 != lis[0] + lis[2]:\n ...
['Wrong Answer', 'Accepted']
['s363764557', 's046317109']
[61504.0, 9208.0]
[2207.0, 1398.0]
[407, 320]
p02714
u919017918
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-2):\n for j in range(i+1,n-1):\n k = j+1\n if k < n and S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:\n ans -= 1\nprint(ans)", "N = int(input())\nS = input()\n\nans = S.count('R')*S.count('G')*S.count('B')\n\...
['Runtime Error', 'Accepted']
['s721817247', 's025812933']
[9188.0, 9204.0]
[22.0, 1975.0]
[225, 247]
p02714
u919235786
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=len(s)\n\nr=set()\ng=set()\nb=set()\na=0\nfor i in range(n):\n if s[i]=='R':\n r.add(i)\n if s[i]=='G':\n g.add(i)\n if s[i]=='B':\n b.add(i)\nd=len(r)*len(g)*len(b)\nfor ri in r:\n for gi in g:\n if 2ri-gi in b:\n d-=1\n if 2...
['Runtime Error', 'Accepted']
['s123299331', 's723172234']
[8984.0, 9320.0]
[23.0, 759.0]
[414, 416]
p02714
u935016954
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 = 0\n\n\ndef main():\n for i in range(N):\n first_s = S[i]\n for j in range(i+1, N):\n if S[j] != first_s:\n second_s = S[j]\n for k in range(j+1, N):\n if (S[k] != first_s) and (S[k] != second_s):\n ...
['Runtime Error', 'Accepted']
['s375261976', 's296809620']
[9208.0, 9216.0]
[22.0, 1966.0]
[468, 376]
p02714
u945181840
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 idx, i in enumerate(S, 1):\n if i == 'R':\n r.append(idx)\n elif i == 'G':\n g.append(idx)\n else:\n b.append(idx)\n\nb = set(b)\ncnt = len(b) * len(r) * len(g)\nprint(r)\nprint(g)\nfor i in r:\n original = i\n for j in g:\...
['Wrong Answer', 'Accepted']
['s551502837', 's181643645']
[9240.0, 9316.0]
[771.0, 745.0]
[545, 527]
p02714
u954415195
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())\nstr=input()\ncount=str.count("R")*str.count("G")*str.count("B")\ncount0=0\nfor i in range(0,n-2):\n for j in range(i+1,(n+i)/2):\n k=2*j-i\n if str[k]!=str[i] and str[k]!=str[j] and str[i]!=str[j]:\n count0=count0+1\nprint(count-count0)', 'n=int(input())\nstr=input()\ncount...
['Runtime Error', 'Accepted']
['s582266384', 's830646987']
[9104.0, 9188.0]
[22.0, 1187.0]
[271, 280]
p02714
u958820283
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= list(input())\ncount=0\nrr,bb,gg=0,0,0\nfor i in range(0,n):\n if s_list[i]=="R":\n rr=rr+1\n elif s_list[i]=="G":\n gg=gg+1\n else:\n bb=bb+1\nsum=rr*gg*bb\n\nfor p in range(0,n-2):\n for q in range(p+1,n-1):\n if s_list[p] == s_list[q]:\n b...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s695283963', 's842266568', 's614554033']
[9224.0, 9224.0, 9124.0]
[29.0, 2205.0, 1961.0]
[564, 530, 434]
p02714
u964904181
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\nidxs = [i for i in range(N)]\n\nris = [i for i, s in enumerate(S) if s == "R"]\ngis = [i for i, s in enumerate(S) if s == "G"]\nbis = [i for i, s in enumerate(S) if s == "B"]\n\nans = 0\nfor ri in ris:\n for gi in gis:\n for bi in bis:\n i, j, k = sorted([ri, gi...
['Wrong Answer', 'Accepted']
['s749022322', 's038637276']
[9216.0, 9176.0]
[2206.0, 1872.0]
[367, 427]
p02714
u970267139
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(1, n):\n j = i + d\n k = j + d\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\npri...
['Runtime Error', 'Accepted']
['s236970270', 's009428418']
[8988.0, 9224.0]
[27.0, 1378.0]
[307, 308]
p02714
u970809473
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)\nres = 0\nfor i in range(len(r)):\n for j in range(len(b)):\n if (i + j) / 2 in g:\n res += len(g) - 1\n else:\n res += len(g)\...
['Wrong Answer', 'Accepted']
['s364301315', 's088078626']
[9204.0, 9164.0]
[2205.0, 1959.0]
[310, 389]
p02714
u972591645
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\nc = Counter(list(s))\nans = 1\nfor i in list(c.values):\n ans *= i\nfor i in range(n-2):\n for j in range(i+1, n-1):\n k = j + (j-i)\n if k >= n:\n break\n if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n ...
['Runtime Error', 'Accepted']
['s237416104', 's363250420']
[9480.0, 9080.0]
[29.0, 1260.0]
[329, 297]
p02714
u977193988
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\nfrom collections import Counter\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nsys.setrecursionlimit(20000000)\n\nMOD = 10 ** 9 + 7\nINF = float("inf")\n\n\ndef main():\n N = int(input())\n S = input()\n C = Counter(S)\n r = C.get("R")\n g = C.get("G")\n b = C.get("B")\n...
['Runtime Error', 'Accepted']
['s361137134', 's897155679']
[9264.0, 9400.0]
[1083.0, 1109.0]
[621, 627]
p02714
u979823197
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 jit\n\nn=int(input())\ns=input()\nR=[]\nG=[]\nB=[]\n\n@jit\ndef f():\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 r=len(R)\n g=len(G)\n b=len(B)\n if r==0 or g==0 or b==0:\n return 0\n else:\n ans=r*g*b...
['Time Limit Exceeded', 'Accepted']
['s273928622', 's599157476']
[120140.0, 9192.0]
[2209.0, 701.0]
[506, 477]
p02714
u984276646
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()\nD = {"R": [], "G": [], "B": []}\nfor i in range(N):\n D[S[i]].append(i)\nprint(D)\np = 1\nfor i in D:\n p *= len(D[i])\ncnt = 0\nfor i in range(N):\n for j in range(i+1, N):\n if 2 * j - i < N:\n if S[i] != S[j] and S[j] != S[2*j-i] and S[2*j-i] != S[i]:\n cnt += 1\npr...
['Wrong Answer', 'Accepted']
['s699289652', 's612969745']
[9260.0, 9260.0]
[1958.0, 1963.0]
[313, 305]
p02714
u999750647
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 functools import reduce\n\nn = int(input())\nans = 0\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\nfor a in range(1,n+1):\n for b in range(1,n+1):\n for c in range(1,n+1):\n ans += gcd(a,b,c)\nprint(ans)', "n = int(input())\ns = input()\ncount = 0\n\nfullcount= ...
['Wrong Answer', 'Accepted']
['s795871057', 's762866801']
[9476.0, 9200.0]
[2206.0, 1371.0]
[246, 313]
p02715
u034128150
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['N, K = map(int, input().split())\nmod = 10 ** 9 + 7\n\ns = 0\ntmp = 1\nfor _ in range(N):\n tmp *= K\n tmp %= mod\ns = tmp\nfor i in range(K+1):\n baisuu = K % i\n tmp = 1\n for _ in range(N):\n tmp *= baisuu\n tmp %= mod\n s += tmp * (i - 1)\n\nprint(s)', 'N, K = map(int, input().spli...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s265307634', 's424234972', 's734824585', 's851885030']
[9192.0, 9028.0, 9180.0, 9548.0]
[40.0, 22.0, 2205.0, 1829.0]
[269, 267, 272, 356]
p02715
u059210959
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['# encoding:utf-8\nimport copy\nimport random\nimport bisect \nimport fractions \nimport math\nimport sys\nimport collections\n\nmod = 10**9+7\nsys.setrecursionlimit(mod) \n\nd = collections.deque()\ndef LI(): return list(map(int, sys.stdin.readline().split()))\n\nN, K = LI()\n\n\n\n\nx_cnt = [0 for i in range(K + 1)]...
['Runtime Error', 'Accepted']
['s112016325', 's313754713']
[13152.0, 13144.0]
[344.0, 346.0]
[811, 789]
p02715
u067983636
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['import bisect\nimport copy\nimport heapq\nimport sys\nimport itertools\nimport queue\ninput = sys.stdin.readline\nsys.setrecursionlimit(100000)\nmod = 10 ** 9 + 7\n\ndef read_values(): return map(int, input().split())\ndef read_index(): return map(lambda x: int(x) - 1, input().split())\ndef read_list(): return list(r...
['Wrong Answer', 'Accepted']
['s693825740', 's986266612']
[11916.0, 11832.0]
[349.0, 325.0]
[1004, 1067]
p02715
u078932560
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n, k = map(int, input().split())\nmod = MOD = 10**9 + 7\n\nG = [0] + [pow(k//i, n, mod) for i in range(1,k+1)]\nfor i in range(k, 0, -1):\n for j in range(2, k//i+1):\n G[i] -= G[j*i]\nprint(G)\nprint(sum([i*f for i,f in enumerate(G)]) % mod)', 'n, k = map(int, input().split())\nmod = MOD = 10**9 + 7\n\nG = [0] +...
['Wrong Answer', 'Accepted']
['s808438686', 's729396645']
[16044.0, 15172.0]
[381.0, 350.0]
[238, 230]
p02715
u102461423
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n\nMOD = 10**9 + 7\nN, K = map(int, read().split())\n\nis_prime = np.zeros(K + 1, np.bool)\nis_prime[2] = 1\nis_prime[3::2] = 1\nfor p in range(3, K + 1, 2):\n if p * p >= K:\n...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s482697725', 's790067233', 's828525022', 's429011212']
[29800.0, 29668.0, 29604.0, 9460.0]
[296.0, 298.0, 291.0, 25.0]
[632, 634, 632, 1140]
p02715
u149844264
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['\n\n\nN, K = [int(x) for x in input().split()]\ncountBcd = [0]*(K+1)\nmod=10**9+7\nsumTotal=0\nfor i in range(K,0,-1):\n countBcd[i] = pow(K//i,N,mod)\n\n for j in range(i*2,K+1,i):\n countBcd[i] - countBcd[j]\n\n sumTotal += i*countBcd[i]%mod\n\nprint(sumTotal%mod)\n', '\n\n\nN, K = [int(x) for x in ...
['Wrong Answer', 'Accepted']
['s290780078', 's790784637']
[11252.0, 11220.0]
[333.0, 360.0]
[435, 436]
p02715
u250664216
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n, k = map(int, input().split())\nmod = 10**9+7\n\nnum_gcd_k = [0]*(k+1)\nnum_gcd_k[k] = 1\nans = 0\nfor i in range(k-1,0,-1):\n \n total = pow(k//i,n,mod)\n m = 2\n while i*m <= k:\n total -= num_gcd_k[i*m]\n m += 1\n num_gcd_k[i] = total\n ans += i*total\n ans %= mod\n\nprint(ans)...
['Wrong Answer', 'Accepted']
['s981641124', 's973577533']
[11300.0, 11308.0]
[456.0, 439.0]
[377, 375]
p02715
u347600233
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n, k = map(int, input().split())\np = 10**9 + 7\nsg = [0] * (k + 1)\nfor i in range(k, 0, -1):\n sg[i] += i * pow(k // i, n, p)\n m = 2\n while m*i <= k:\n sg[i] = (sg[i] - sg[m*i]) % p\n m += 1\nprint(sum(sg) % MOD)', 'n, k = map(int, input().split())\np = 10**9 + 7\nsg = [0] * (k + 1)\nfor i ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s617284692', 's850504617', 's793039264']
[12820.0, 12840.0, 12100.0]
[562.0, 547.0, 434.0]
[230, 224, 265]
p02715
u347640436
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['N, K = map(int, input().split())\n\nMOD = 10 ** 9 + 7\n\ncache = {}\ndef f(k, n):\n if k == 1:\n return 1\n if k in cache:\n return cache[k]\n result = pow(k, n, MOD)\n for i in range(2, k + 1):\n result -= f(k // i, n)\n result %= MOD\n cache[k] = result\n return result\...
['Runtime Error', 'Accepted']
['s269000507', 's254729294']
[9204.0, 11300.0]
[24.0, 396.0]
[402, 305]
p02715
u375616706
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['N,K = map(int,input().split())\n\nans=0\nMOD=10**9+7\n\ncnt=[0]*(K+1)\nfor x in reversed(range(1,K+1)):\n cnt_tmp = pow(K//x,N,MOD)\n t=1\n while (t+1)*x<=K:\n t+=1\n cnt_tmp -= cnt[x*t] \n\n cnt[x]=cnt_tmp\n ans = x*cnt_tmp %MOD\nprint(ans)\n', 'N,K = map(int,input().split())\n\nans=0\nM...
['Wrong Answer', 'Accepted']
['s627430057', 's965284817']
[11224.0, 11108.0]
[454.0, 449.0]
[362, 381]
p02715
u391540332
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n, k = (int(x) for x in input().split())\n\nc = {} \nt = 0\nfor x in range(k, 0, -1):\n q = k // x\n c[x] = q ** n # - sum(c[x * y] for y in range(2, q + 1))\n t += c[x] * x\n t = t % 1000000007\n\nprint(t)', 'n, k = (int(x) for x in input().split())\nc = {} \nt = 0\nMOD = 1000000007\nfor x in range(k, 0,...
['Wrong Answer', 'Accepted']
['s572145284', 's647783169']
[137020.0, 20656.0]
[2209.0, 354.0]
[208, 222]
p02715
u399298563
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['N, K = map(int, input().split())\nMOD = 10 ** 9 + 7\ncnt = [0] * (K + 1)\nfor x in range(1, K + 1):\n cnt[x] = pow(K // x , N , MOD)\n\nfor x in range(K, 0, -1):\n for i in range(2, (K // x) + 1):\n cnt[x] -= cnt[x * i]\n \nprint(cnt)\nans = 0\nfor x in range(1, K + 1):\n ans += cnt[x] * x\nprint(ans % MOD)', ...
['Wrong Answer', 'Accepted']
['s605815047', 's858211467']
[12692.0, 11364.0]
[377.0, 355.0]
[338, 330]
p02715
u414050834
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n,k=map(int,input().split())\nl=[0]*(k+1)\na=0\nmod=10**9+7\nfor i in range(1,k+1):\n l[i]=i\n for j in range(i*2,k+1,i):\n l[j]-=l[i]\n a+=l[i]*pow(k//i,n,mod)\nprint(a%mod)', 'n,k=map(int,input().split())\nl=[0]*(k+1)\na=0\nmod=10**9+7\nfor i in range(1,k+1):\n l[i]+=i\n for j in range(i*2,k+1,i):\n l[j]...
['Wrong Answer', 'Accepted']
['s720501854', 's493457195']
[12756.0, 12840.0]
[374.0, 357.0]
[171, 173]
p02715
u460229551
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['N,K=list(map(int,input().split()))\nl=[0]*(K+1)\nans=0\nmod=10**9+7\n\nfor x in range(K,0,-1):\n l[x]=pow((K//x),N,mod)\n for y in range(2*x,K+1,x):\n l[x]-=l[y]\n l[x]=pow(l[i],1,mod)\n ans+=l[x]*x\n ans=pow(ans,1,mod)\nprint(ans)', 'N,K=list(map(int,input().split()))\nl=[0]*(K+1)\nans=0\nm...
['Runtime Error', 'Accepted']
['s018026300', 's169788007']
[9660.0, 11296.0]
[114.0, 1187.0]
[245, 245]
p02715
u479719434
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['M = 1000000007\n\n\ndef main(N=None, K=None):\n if not N or not K:\n N = int(input())\n K = int(input())\n ans = 0\n gcds = {}\n for X in range(K, 0, -1):\n gcds[X] = int(pow(K//X, N, M))\n n = 1\n while True:\n n += 1\n if n*X > K:\n ...
['Runtime Error', 'Accepted']
['s011059379', 's014374870']
[9232.0, 20576.0]
[21.0, 416.0]
[565, 556]
p02715
u481550011
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['mod=10**9+7\nN,K=map(int,input().split())\ngcd=[0]*(K+1)\nans=0\nmultipleNumber=0\nfor i in reversed(range(1,K+1)):\n multipleNumber=K//i\n totalNumber=multipleNumber**N%mod\n minus=range(2*i,K+1,i)\n for j in minus:\n totalNumber-=gcd[j]\n totalNumber%=mod\n gcd[i]=totalNumber\n ans+=...
['Runtime Error', 'Runtime Error', 'Accepted']
['s351254741', 's531526617', 's299721681']
[11300.0, 9660.0, 11304.0]
[2206.0, 23.0, 472.0]
[326, 369, 238]
p02715
u486065927
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n, k = map(int, input().split())\nc = 10**9+7\ntm = [0] + [1]*k\na = k//2\nans = k*(k+1)//2 - a*(a+1)//2\nfor i in range(k//2, 0, -1):\n a = k//i\n t = (left_bin(a, n, c) - sum([tm[j*i] for j in range(2, a+1)])) % c\n ans = (ans + t*i) % c\n tm[i] = t\nprint(ans)\n', 'def left_bin(a, n, c):\n ns = [int...
['Runtime Error', 'Accepted']
['s203648203', 's952699285']
[10456.0, 11992.0]
[27.0, 384.0]
[266, 432]
p02715
u512212329
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['\nMOD = 1000000007\nn, k = [int(x) for x in input().split()]\nd = [pow(k, n, MOD) for i in range(1, k+1)]\n\nfor i in range(k, 0, -1): \n for j in range(i * 2, k + 1, i): \n \n d[i] -= d[j]\n d[i] %= MOD\nans = 0\nfor i, item in enumerate(d):\n ans += i * item\n ans %= MOD\nprint(ans)\...
['Runtime Error', 'Accepted']
['s359850045', 's278791337']
[12936.0, 11172.0]
[467.0, 433.0]
[388, 420]
p02715
u515740713
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['import sys \nimport numpy as np\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nMOD = 10 ** 9 + 7 \nN, K = map(int, readline().split())\nd = [0] * (K+1)\nfor i in range(K,0,-1):\n t = K // i\n cnt = pow(t,N,MOD)\n for j in range(2,t+1):\n ...
['Runtime Error', 'Accepted']
['s722446836', 's219911550']
[27088.0, 29048.0]
[165.0, 526.0]
[439, 439]
p02715
u523545435
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['import math\n\nN,K=map(int,input().split())\nP=10**9+7\n\nL=[0]*K\nfor i in range(N):\n L[i]=pow(K//(i+1),N-1,P)\n\ndef culc(x):\n f=K//i\n r=K-f\n if r==1:\n return (f*(N-1))%P\n else:\n y=pow(r,N-1)-1\n return ((f*y)//(r-1))%P\n\nfor j in range(1,K):\n L[0]+=culc(j+1)\n\nans=0...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s802592466', 's894778341', 's809026133']
[12232.0, 12220.0, 11220.0]
[2206.0, 2206.0, 498.0]
[354, 354, 358]
p02715
u535236942
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['def make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n \n return divisors\n\nn, k = map(int, input().split())\nmod = 1000000007\nl = [1 for i in range(k...
['Wrong Answer', 'Accepted']
['s570755269', 's405435936']
[11948.0, 11368.0]
[2206.0, 392.0]
[482, 289]
p02715
u535803878
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['def factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr=...
['Runtime Error', 'Accepted']
['s309228961', 's864426651']
[8988.0, 28632.0]
[20.0, 503.0]
[685, 684]
p02715
u545368057
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['import math\nK = int(input())\nans = 0\nfor i in range(1,K+1):\n for j in range(1,K+1):\n for k in range(1,K+1):\n ans+=math.gcd(i,math.gcd(j,k)) \nprint(ans) \n\n', 'N,K = map(int, input().split())\nmod = 10**9+7\nans = 0\ndp = [0] * (K+10)\n\nfor i in range(K,0,-1):\n x = K//i\n ...
['Runtime Error', 'Accepted']
['s506527963', 's185096944']
[9196.0, 11172.0]
[19.0, 459.0]
[185, 274]
p02715
u571199625
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n=int(input())\ns=input()\n\nremain = [[0,0,0]]\nfor i in range(n):\n r, g, b = remain[-1]\n if s[-i-1] == "R":\n r = r+1\n elif s[-i-1] == "G":\n g = g + 1\n elif s[-i-1] == "B":\n b = b + 1\n\n remain.append([r,g,b])\n\ntotal = 0\nfor i in range(n-2):\n if s[i] == "R":\n ...
['Runtime Error', 'Accepted']
['s459636689', 's957119193']
[9352.0, 11348.0]
[22.0, 594.0]
[1557, 508]
p02715
u572142121
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['N,K=map(int, input().split())\nimport math\ncnt=(K**N)%(10**9+7)\n\nprint(cnt)\nfor i in range(2,K+1):\n a=K//i\n cnt+=((a**N-2)*(i-1))%(10**9+7)\nprint(cnt)', 'N,K=map(int,input().split())\nD=[0]*(K+1)\nans=0\nmod=10**9+7\nfor i in range(K,0,-1):\n D[i]=(pow(K//i,N,mod)-sum(D[i::i]))%mod\n ans+=(D[i]*i)%mod\n a...
['Wrong Answer', 'Accepted']
['s648897303', 's816586478']
[9780.0, 12048.0]
[2205.0, 214.0]
[151, 166]
p02715
u624696727
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\nprintV = lambda x: print(*x, sep="\\n")\nprintH = lambda x: print(" ".join(map(str,x)))\ndef IS(): return sys.stdin.readline()[:-1]\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI():...
['Wrong Answer', 'Accepted']
['s950037103', 's519313740']
[11172.0, 11180.0]
[616.0, 613.0]
[1017, 1031]
p02715
u627600101
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['mod=10**9+7\nN,K=map(int,input().split())\nAns=[1 for k in range(K)]\nc=K\nfor j in range(N):\n Ans[0]=Ans[0]*(K)%mod\nfor k in range(2,(K+1)//2+1):\n d=K//k\n if c==d:\n Ans[k-1]=Ans[k-2]\n else:\n for j in range(N):\n Ans[k-1]=Ans[k-1]*d%mod\n c=d\nprint(Ans)\nfor j in ra...
['Wrong Answer', 'Accepted']
['s346846999', 's564737784']
[11112.0, 12240.0]
[2206.0, 389.0]
[451, 959]
p02715
u703442202
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n = input()\nk = int(input())\ndp = [[[0 for i in range(len(n)+1)] for i in range(2)] for i in range(len(n)+1)]\ndp[0][0][0] = 1\nfor a in range(len(n)):\n for b in range(2):\n for c in range(len(n)):\n for i in range(10):\n if b ==1:\n if i != 0:\n dp[a+1][1][c+1] += dp[a][1][c]\n...
['Runtime Error', 'Accepted']
['s554863740', 's946786653']
[9240.0, 11344.0]
[23.0, 376.0]
[777, 466]
p02715
u714269187
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['#include <bits/stdc++.h>\nusing namespace std;\n\ntypedef long long ll;\n\n\n\nll n,k,mod=1e9+7,ans=0;\n\nll fastMod(ll a,ll b){\n ll res=1;\n while(b>0){\n if(b&1)res=(res*a)%mod;\n b/=2;\n a=(a*a)%mod;\n }\n return res;\n}\n\nvoid solve(){ \n cin>>n>>k;\n vector<ll> v(k+1);...
['Runtime Error', 'Accepted']
['s159465215', 's015125074']
[9012.0, 11296.0]
[22.0, 515.0]
[754, 252]
p02715
u723583932
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['#include <bits/stdc++.h>\nusing namespace std;\ntypedef long long ll;\n\n\n\n\n#define INF 2e9\n#define ALL(v) v.begin(), v.end()\n\nint k;\nint memo[200+1][200+1];\nll N=1000000000+7;\n\nint gcd(int x,int y){\n if(y==0){\n return x;\n }\n return gcd(y,x%y);\n}\n\nint main(){\n cin>>k;\n int ans...
['Runtime Error', 'Accepted']
['s765586366', 's922475975']
[9012.0, 61644.0]
[22.0, 507.0]
[588, 402]
p02715
u760642788
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n, k = list(map(int, input().split()))\nl = [0 for i in range(k)]\nans = 0\nM = 10**9 + 7\n\ndef dev(n):\n dl = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n dl.append(i)\n if i != n // i:\n dl.append(n//i)\n dl.sort()\n return dl\n\nfor i in range(k...
['Wrong Answer', 'Accepted']
['s025592965', 's729142140']
[129224.0, 11364.0]
[2463.0, 364.0]
[501, 508]
p02715
u831651889
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['Big=10**9+7\n_=list(map(int,input().split(" ")))\nN=_[0]\nK=_[1]\ngcd_list=[0 for _ in range(K)]\nfor i in range(K):\n s=K-i-1\n gcd_list[s]=(pow(K//K-i, N, Big)-(sum(gcd_list[2*s+1::s+1]))%Big)%Big\nanswer=[(x+1)*gcd_list[x]%Big for x in range(K)]\nprint(sum(answer)%Big)', 'Big=10**9+7\n_=list(map(int,input().spli...
['Wrong Answer', 'Accepted']
['s200332376', 's767730450']
[16816.0, 15664.0]
[299.0, 243.0]
[265, 267]
p02715
u858742833
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['def main():\n N = int(input())\n A = list(map(int, input().split()))\n a0, a1, a2, b0, b1, b2 = A[0], 0, 0, A[1], 0, 0\n for a in A[2:]:\n a0, a1, a2, b0, b1, b2 = (\n b0,\n max(b1, a0),\n max(b2, a1),\n a0 + a,\n a1 + a,\n ...
['Runtime Error', 'Accepted']
['s236174859', 's120380480']
[9204.0, 12048.0]
[22.0, 173.0]
[425, 258]
p02715
u898967808
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['MOD = 10**9+7\nn,k = map(int,input().split())\n\nL = [0]*(k+1)\n\nfor i in range(k,0,-1): \n L[i] = pow(k//i,n,mod)\n for j in range(2,k//i+1): \n L[i] -= L[i*j]\n \nans = 0\nfor i in range(1,k+1): \n ans = (ans + i*L[i]) % MOD\n \nprint(ans) ', 'MOD = 10**9+7\nn,k = map(int,input().split())\n\nL ...
['Runtime Error', 'Accepted']
['s629505516', 's462924150']
[9508.0, 11148.0]
[25.0, 391.0]
[249, 249]
p02715
u934868410
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n,k = map(int,input().split())\nmod = 10**9 + 7\n\n\ndef pow_mod(x, n, mod):\n if n > 1:\n return pow_mod(pow(x,2) % mod, n//2, mod) * pow(x, n%2) % mod\n else:\n return x\n\n\npow_n = [-1] * (k+1)\nfor i in range(1,k+1):\n if pow_n[k//i] == -1:\n pow_n[k//i] = pow_mod(k//i, n, mod)\n\na...
['Wrong Answer', 'Accepted']
['s281125142', 's145860801']
[11952.0, 11948.0]
[348.0, 336.0]
[552, 515]
p02715
u944390835
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['import math\nN, K = map(int,input().split())\na = 0\nfor i in range(1, K):\n p = (K-i+1)**N - (K-i)**N\n q = (math.floor(K/i))**N - ((math.floor(K/i))-1)**N\n a += (i-1)*q + p\nprint(a%1000000007)\n', 'N, K = map(int, input().split())\nP = 10 ** 9 + 7\nX = [0] * (K + 1)\nans = 0\nfor i in range(1, K + 1):\n ...
['Wrong Answer', 'Accepted']
['s713218393', 's429209805']
[10732.0, 12800.0]
[2206.0, 367.0]
[199, 219]
p02715
u983154415
2,000
1,048,576
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
['n,k=map(int,input().split())\ndp=[0]*(k+1)\nmod=int(1e9+7)\nfor i in range(k,0,-1):\n sm=0\n for j in range(2*i,k+1,i):\n sm=(sm+dp[j])%mod\n dp[i]=pow(k//i,n,mod)-sm\n\nans=0\nfor i in range(1,n+1):\n ans+=(dp[i]%mod*i%mod)%mod\nprint(ans%mod)\n', 'n,k=map(int,input().split())\ndp=[0]*(k+1)\nmod=i...
['Runtime Error', 'Accepted']
['s533310313', 's122797752']
[11180.0, 11080.0]
[383.0, 384.0]
[252, 258]
p02716
u023540496
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['n = int(input())\na = [int(num) for num in input().split()]\ndp = [[0,0,0] for _ in range(n//2+1)]\n\n#dp[0] = [a[0],a[1],a[2]]\n\nfor i in range(n//2):\n dp[i+1][0] = dp[i][0] + a[i*2]\n dp[i+1][1] = max(dp[i][1],dp[i][0]) + a[i*2+1]\n if n % 2 == 1:\n dp[i+1][2] = max(dp[i][2],dp[i][1],dp[i][0]) + a...
['Wrong Answer', 'Accepted']
['s669385787', 's482351059']
[54492.0, 42192.0]
[293.0, 233.0]
[346, 396]
p02716
u034128150
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['N = int(input())\nAs = list(map(int, input().split()))\n\nINF = 10 ** 15\ndp = [[-INF] * N for _ in range(3)]\ndp[0][0] = As[0]\ndp[1][0] = As[0]\ndp[0][1] = As[0]\ndp[1][1] = As[1]\n\nif N % 2 == 0:\n for i in range(2, N):\n dp[0][i] = dp[0][i-2] + As[i]\n dp[1][i] = max(dp[0][i-1], dp[1][i-2] + As[...
['Wrong Answer', 'Accepted']
['s041974890', 's569548477']
[77044.0, 33744.0]
[397.0, 203.0]
[548, 486]
p02716
u064963667
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
["\nn = int(input())\na_list = list(map(int,input().split()))\n\nif n % 2 == 0: \n dp = [[-float('inf') for _ in range(n)] for __ in range(2)]\n dp[1][-1] = a_list[-1]\n\n for j in reversed(range(2)):\n for i in reversed(range(n)):\n if j == 2 and i >= n-2:\n pass\n ...
['Runtime Error', 'Accepted']
['s381955315', 's671545972']
[47704.0, 48024.0]
[511.0, 510.0]
[1145, 1192]
p02716
u069125420
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['import sys\n\nsys.setrecursionlimit(2*1000000)\n\nN = int(input())\nA = list(map(int, input().split(" ")))\n\n\n\ndef dp(i, j):\n if i >= N:\n return (-1*1000000000)\n if (N//2)-j < (i-1)//2:\n return (-1*1000000000)\n if j == 1:\n return A[i]\n\telse:\n temp = max([dp(i+2, j-1)+A...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s132211468', 's474986711', 's484904429', 's283577302']
[9044.0, 31560.0, 120036.0, 98292.0]
[21.0, 72.0, 399.0, 478.0]
[449, 372, 557, 549]
p02716
u114954806
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
["from functools import lru_cache\n\n@lru_cache(None)\ndef dp(N,A,i,k):\n if k<=0:\n return 0\n tmp=N-i\n if k>(tmp//2)+(tmp%2):\n return -float('inf')\n return max(A[i]+dp(N,A,i+2,k-1),dp(N,A,i+1,k))\n\ndef main():\n N=int(input())\n A=[int(_) for _ in input().split()]\n print(dp(N,A...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s289876859', 's411471104', 's813407989', 's894254261', 's753765828']
[33416.0, 32864.0, 33092.0, 42236.0, 42160.0]
[77.0, 78.0, 79.0, 282.0, 199.0]
[322, 329, 321, 425, 391]
p02716
u139112865
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['n = int(input())\na = list(map(int, input().split()))\n\nle, lo, re, ro = [0], [0], [0], [0]\n\nfor i in range(n):\n if i % 2 == 0:\n le.append(le[-1] + a[i])\n else:\n lo.append(lo[-1] + a[i])\n\nfor i in range(n-1, -1, -1):\n if i % 2 == 0:\n re.append(re[-1] + a[i])\n else:\n ...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s210825145', 's463265493', 's871074206', 's315057409']
[48964.0, 49084.0, 51032.0, 45760.0]
[376.0, 391.0, 459.0, 322.0]
[823, 823, 869, 763]
p02716
u163320134
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['n=int(input())\narr=list(map(int,input().split()))\nlim=n%2+2\ndp=[[0]*lim for _ in range(n+100)]\nfor i in range(n):\n dp[i+1][0]=dp[i-1][0]+arr[i]\n dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])\n if lim==3:\n dp[i+1][2]=max(dp[i-1][2]+arr[i],dp[i-2][1]+arr[i],dp[i-3][0]+arr[i])\nprint(max(dp[-1][:lim])...
['Wrong Answer', 'Accepted']
['s182882969', 's136981222']
[66060.0, 45220.0]
[418.0, 463.0]
[310, 1312]
p02716
u227082700
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['n,*l=open(0);n=int(n);l=list(map(int,l.split()))\np=[0]*n;d=[0]*n\nfor i in range(n):p[i]=l[i]+p[i-2];d[i]=max(p[i-1]if(i&1)else d[i-1],l[i]+d[i-2])\nprint(d[-1])', 'n,*l=open(0);n=int(n);l=list(map(int,l))\np=[0]*n;d=[0]*n\nfor i in range(n):p[i]=l[i]+p[i-2];d[i]=max(p[i-1]if(i&1)else d[i-1],l[i]+d[i-2])\nprint(d[-1...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s192243126', 's601627978', 's998357540', 's188496920']
[12924.0, 13376.0, 39000.0, 39404.0]
[25.0, 38.0, 235.0, 208.0]
[159, 151, 159, 157]
p02716
u268554510
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
["N = int(input())\nA = list(map(int,input().split()))\ndp = [{} for _ in range(N+1)]\nINF = -float('inf')\nfor i in range(1,N+1):\n mid = i//2\n dp[i][mid-2],dp[i][mid-1],dp[i][mid],dp[i][mid+1],dp[i][mid+2]=INF,INF,INF,INF,INF\ndp[1][1] = A[0]\ndp[2][1] = max(A[1],dp[1][1])\ndp[1][0],dp[2][0]=0,0\n\nfor i in ra...
['Wrong Answer', 'Accepted']
['s052516738', 's898269375']
[164352.0, 116416.0]
[743.0, 517.0]
[480, 470]
p02716
u294375415
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
["\n\nn = 0\na = []\n\ndef format_input(filename = None):\n\tglobal n\n\tglobal a\n\tif filename == None:\n\t\tn = int(input())\n\t\ta = list(map(int, input().split()))\n\n\telif filename == '__random__':\n\t\tfrom random import randint as rng\n\t\tn = rng(2, 2 * 10**5)\n\t\ta = [rng(-1 * 10**9, 10**9) for i in range(n...
['Wrong Answer', 'Accepted']
['s255651065', 's606853797']
[32444.0, 33760.0]
[2210.0, 154.0]
[1007, 946]
p02716
u303739137
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['input()\naa = map(int, input().split())\n\nbb = [0] * len(aa)\nbb[0] = aa[0]\nbb[1] = aa[1]\nfor i in range(2,len(aa)):\n bb[i] = bb[i-2] + aa[i]\n\nsum0 = bb[len(aa)-2]\nsum1 = bb[len(aa)-1]\nret = sum1\nif len(aa)%2 == 0:\n ret = max(ret, sum0)\nif len(aa)%2:\n sum0 = bb[len(aa)-1]\n sum1 = bb[len(aa)-2...
['Runtime Error', 'Runtime Error', 'Accepted']
['s548118920', 's563228121', 's215239376']
[25032.0, 9200.0, 33088.0]
[44.0, 20.0, 710.0]
[768, 728, 772]
p02716
u391540332
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['import collections\nimport math\n\nN, *A = map(int, open(0).read().split())\na = dict(enumerate(A, 1))\ndp = collections.defaultdict(int)\ndp[1, 1] = a[1]\n\nfor i in range(2, N + 1):\n jj = range(math.floor(i // 2 - 1), math.ceil((i + 1) // 2) + 1)\n debug(jj)\n for j in jj:\n x = dp[i - 2, j - 1] + ...
['Runtime Error', 'Accepted']
['s718724963', 's231804797']
[41532.0, 155584.0]
[91.0, 646.0]
[386, 652]
p02716
u391731808
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['N = int(input())\n*A, = map(int,input().split())\n\nif N%2==0:\n 1/0\n ans = max(sum(A[::2]),sum(A[1::2]))\n print(ans)\nelse:\n INF = 2* 10**9\n dp = [[-INF]*N for _ in [0]*3]\n dp[0][0] = A[0]\n dp[1][1] = A[1]\n dp[2][2] = A[2]\n for i in range(2,N,2):\n a = A[i]\n dp[0][i]...
['Runtime Error', 'Accepted']
['s338397064', 's180746595']
[41024.0, 41036.0]
[250.0, 253.0]
[538, 800]
p02716
u392319141
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['N = int(input())\nA = list(map(int, input().split()))\nINF = 10**18\n\ndp0 = [-INF] * (N + 2)\ndp1 = [-INF] * (N + 2)\ndp2 = [-INF] * (N + 2)\ndp0[0] = 0\ndp0[1] = 0\n\nfor i, a in enumerate(A, start=2):\n dp0[i] = dp0[i - 2] + a\n dp1[i] = max(dp1[i - 2] + a, dp0[i - 1])\n dp2[i] = max(dp2[i - 2] + a, dp1[i...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s525835257', 's682936791', 's478783629']
[50260.0, 50160.0, 31684.0]
[269.0, 276.0, 152.0]
[398, 398, 332]
p02716
u446774692
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['N = int(input())\nA = list(map(int,input().split()))\n\nDP = [0,0,0]\nm = N//2*2\nif N%2 == 0:\n for i in range(0,m,2):\n DP[0] += A[i]\n DP[1] += A[i+1]\n DP[1] += max(DP[0],DP[1])\n\n print(DP[1])\n\nelse:\n for i in range(0,m,2):\n DP[0] += A[i]\n DP[1] += A[i+1]\n ...
['Wrong Answer', 'Accepted']
['s212082048', 's076503237']
[31232.0, 31540.0]
[426.0, 158.0]
[404, 403]
p02716
u543954314
2,000
1,048,576
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x.
['#![allow(unused_imports, non_snake_case)]\nuse proconio::{\n input, fastout,\n marker::{Chars, Bytes, Usize1}\n};\n\nmacro_rules! max {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr $ (, ) * ) => {{std :: cmp :: max ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cm...
['Runtime Error', 'Accepted']
['s439363569', 's001427685']
[8920.0, 66404.0]
[28.0, 382.0]
[884, 556]