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
p03200
u054471580
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['t = input()\ns = input()\ns = s.split()\nlist=[]\nfor i in range(len(s)):\n list.append(int(s[i]))\n\nkind = 1\ncounter=0\n\nfor i in range(len(list)-1):\n if(list[i]>=list[i+1]):\n if(kind==1):\n kind = kind + 1\n else:\n if(counter==kind-1):\n kind = kind + 1\n counter=0 \n else:\n counter = counter + 1\n \nprint(kind)\n ', 's = input()\nlist = list(s)\ncount=0\nb=0\n\nfor i in range(len(list)-1):\n if(list[i] == "W"):\n count+=b\n continue\n else:\n if(i == len(list)-1):\n break\n b += 1\n \nprint(count)\n', 'list = list(s)\ncount=0\nb=0\n\nfor i in range(len(list)):\n if(list[i] == "W"):\n count+=b\n continue\n else:\n if(i == len(list)-1):\n break\n b += 1\n \nprint(count)', 's=input()\nt=input()\nlist=[]\nlist = t.split()\nprint(list)\nans=0\n\ndef even(i,k):\n for j in range(k+1,len(list)):\n if(int(list[j])%2==0):\n s = i + int(list[j])\n if(power(s)):\n return 1\n else:\n continue\n \n return 0\n \ndef odd(i,k):\n for j in range(k+1,len(list)):\n if(int(list[j])%2==0):\n continue\n else:\n s = i + int(list[j])\n if(power(s)):\n return 1\n \n return 0\n \n\ndef power(s):\n while(True):\n s = int(s / 2)\n if(s==1):\n return 1\n\n if(s % 2 != 0):\n break \n return 0\n\nfor i in range(len(list)-1):\n if(int(list[i]) % 2 == 0):\n if(even(int(list[i]),i)):\n ans = ans+1\n else:\n if(odd(int(list[i]),i)):\n ans = ans+1\n\nprint(ans)', 's=input()\nt=input()\nlist=[]\nlist = t.split()\nprint(list)\nans=0\n\ndef even(i,k):\n for j in range(k+1,len(list)):\n if(int(list[j])%2==0):\n s = i + int(list[j])\n if(power(s)):\n return 1\n else:\n continue\n \n return 0\n \ndef odd(i,k):\n for j in range(k+1,len(list)):\n if(int(list[j])%2==0):\n continue\n else:\n s = i + int(list[j])\n if(power(s)):\n return 1\n \n return 0\n \n\ndef power(s):\n while(True):\n s = int(s / 2)\n if(s==1):\n return 1\n\n if(s % 2 != 0):\n break \n return 0\n\nfor i in range(len(list)-1):\n if(int(list[i]) % 2 == 0):\n if(even(int(list[i]),i)):\n ans = ans+1\n else:\n if(odd(int(list[i]),i)):\n ans = ans+1\n\nprint(ans)', 's = input()\nlist = list(s)\ncount=0\nb=0\n\nfor i in range(len(list)):\n if(list[i] == "W"):\n count+=b\n continue\n else:\n if(i == len(list)-1):\n break\n b += 1\n \nprint(count)\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s238978262', 's509729483', 's718819403', 's847945686', 's877853956', 's048250540']
[3500.0, 4968.0, 2940.0, 3628.0, 3628.0, 4840.0]
[19.0, 76.0, 17.0, 18.0, 17.0, 83.0]
[358, 194, 179, 743, 743, 192]
p03200
u086127549
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['def integration(s):\n itg = [0]\n counter = 0\n for x in s:\n if x == "B":\n counter += 1\n itg.append(counter)\n return itg\n\ndef solve(s, itg):\n print(s,itg)\n n = len(s)\n if n <= 1:\n return 0\n a = solve(s[0:n//2], itg[0:n//2+1])\n b = solve(s[n//2:n], itg[n//2:n+1])\n res = a + b + \\\n (itg[n//2]-itg[0])*(n-n//2-(itg[n]-itg[n//2]))\n return res\n\ns = input()\nprint(solve(s,integration(s)))\n', 'def integration(s):\n itg = [0]\n counter = 0\n for x in s:\n if x == "B":\n counter += 1\n itg.append(counter)\n return itg\n\ndef solve(itg, left, right):\n n = right-left\n if n <= 1:\n return 0\n mid = (left+right)//2\n a = solve(itg, left, mid)\n b = solve(itg, mid, right)\n res = a + b + (itg[mid]-itg[left])* \\\n (right-mid-(itg[right]-itg[mid]))\n return res\n\ns = input()\nprint(solve(integration(s), 0, len(s)))\n']
['Wrong Answer', 'Accepted']
['s379404231', 's303330622']
[48868.0, 11136.0]
[1332.0, 158.0]
[409, 431]
p03200
u112317104
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["A = list(input())\nn = len(A)\n\ncount = 0\nfor _ in range(n):\n for i in reversed(range(1, n)):\n if A[i-1] == 'B' and A[i] == 'W':\n A[i] = 'B'\n A[i-1] = 'W'\n count += 1\n\nprint(A)\nprint(count)\n", "A = list(input())\nn = len(A)\n\ncount = 0\nfor i in reversed(range(1, n)):\n if A[i-1] == 'B' and A[i] == 'W':\n A[i-1] = 'W'\n A[i] = 'B'\n count += 1\n a += 1\n\nprint(count * 2)\n", "A = list(input())\nn = len(A)\n\ncount = 0\nfor i in reversed(range(1, n)):\n if A[i-1] == 'B' and A[i] == 'W':\n A[i-1] = 'W'\n A[i] = 'B'\n count += 1\n\nprint(count * 2)\n", "A = list(input())\n\ncount = 0\nans = 0\nfor a in A:\n if a == 'B':\n count += 1\n else:\n ans += count\n\nprint(ans)\n"]
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s000813546', 's617756650', 's766222845', 's037714599']
[4840.0, 4840.0, 4840.0, 4840.0]
[2104.0, 56.0, 76.0, 49.0]
[232, 203, 188, 128]
p03200
u116702662
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = input('')\nbc = 0\nc = 0\n\nfor i in range(0,len(s)):\n\tif s[i] == 'B':\n \tbc += 1\n elif s[i] == 'W':\n \tc += bc\n \nprint(c)\n\t\n", "s = input('')\nbc = 0\nc = 0\n\nfor i in range(0,len(s)):\n if s[i] == 'B':\n bc += 1\n elif s[i] == 'W':\n c += bc\n \nprint(c)"]
['Runtime Error', 'Accepted']
['s334626385', 's744273563']
[2940.0, 3500.0]
[18.0, 66.0]
[139, 129]
p03200
u121161758
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['if __name__ == "__main__":\n S = input()\n ans = 0\n bcount = 0\n for i in range(len(S)):\n if S[i] == \'B\':\n bcount += 1\n else:\n ans += bcount\n\u200b\n print(ans)', 'S = input()\nbcount = 0\nans = 0\nfor i in range(len(S)):\n if S[i] == "B":# countup B(= empty space)\n bcount += 1\n else: # countup W shift value\n ans += bcount\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s913156079', 's813854841']
[2940.0, 3500.0]
[17.0, 60.0]
[204, 197]
p03200
u131638468
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["count=0\nosero=input()\ns=[]\nfor i in osero:\n s.append(i)\nfor i in range(len(s)-1):\n for j in range(i,len(s)-1):\n if s[j]=='B' and s[j+1]=='W':\n s[j]='W'\n s[j+1]='B'\n count+=1\nprint(count)", "s=input()\nans=0\nw=0\nfor i in range(1,len(s)+1):\n if s[i-1]=='W':\n ans += i-w-1\n w+=1\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s478545796', 's701209674']
[5096.0, 3500.0]
[2104.0, 79.0]
[206, 102]
p03200
u135116520
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import collections\nS=list(input())\nc=collections.Counter(S)\nn=c["W"]\ns=0\ni=0\nwhile "B" in S[0:n]:\n if S[i]=="B" and S[i+1]=="W":\n S[i]="W" and S[i+1]="B"\n s+=1\n i=i\n else:\n i+=1\nprint(s)\n', 'import collections\nS=list(input())\nN=len(S)\nn=S.count("W")\ns=0\ni=0\nwhile "B" in S[:n] and i<=N-1:\n if S[i]=="B" and S[i+1]=="W":\n S[i]="W" \n S[i+1]="B"\n s+=1\n i=i\n else:\n i+=1\n if i>=N-1:\n break\nprint(s)', 'S=list(input())\nN=len(S)\nn=S.count("W")\ns=0\ni=0\nwhile "B" in S[:n]:\n if S[i]=="B" and S[i+1]=="W":\n S[i]="W" \n S[i+1]="B"\n s+=1\n i=i\n else:\n i+=1\n if i>=N-1:\n break\nprint(s)', 'S=list(input())\nN=len(S)\ns=0\nans=0\nfor i in range(N):\n if S[i]=="B":\n s+=1\n elif S[i]=="W":\n ans+=s\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s402365982', 's725433656', 's881424950', 's903033870']
[3056.0, 6552.0, 6308.0, 4840.0]
[17.0, 2104.0, 2104.0, 64.0]
[201, 228, 198, 119]
p03200
u143492911
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s=list(input())\nn=len(s)\ntotal_b=0\ncnt=0\ntotal=0\nfor i in range(n):\n if s[i]=="B":\n total_b+=i\n cnt+=1\nfor i in range(n-cnt,n):\n total+=i\nprint(total-total_b)\nprint(total,total_b)\n', 's=list(input())\nn=len(s)\ntotal_b=0\ncnt=0\ntotal=0\nfor i in range(n):\n if s[i]=="B":\n total_b+=i\n cnt+=1\nfor i in range(n-cnt+1,n):\n total+=i\nprint(total-total_b)\n', 's=list(input())\nn=len(s)\ntotal_b=0\ncnt=0\ntotal=0\nfor i in range(n):\n if s[i]=="B":\n total_b+=i\n cnt+=1\nfor i in range(n-cnt,n):\n total+=i\nprint(total-total_b)\n#print(total,total_b)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s562064696', 's998434984', 's244454688']
[4840.0, 4840.0, 4840.0]
[98.0, 97.0, 96.0]
[200, 181, 201]
p03200
u176208232
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['S = input()\nwhite = 0\ntotal = 0\nfor i in range len(S):\n if S[i] == "W":\n total += (i - white)\n white ++\n \nprint(total)', 'from sys import stdin\n\nS = stdin.readline().rstrip()\n#S = input()\nwhite = 0\ntotal = 0\nfor i in range len(S):\n if S[i] == "W":\n total += (i - white)\n white += 1\n \nprint(total)\n', 'S = input()\nwhite = 0\ntotal = 0\nfor i in range len(S):\n if S[i] == "W":\n total += (i - white)\n white += 1\n \nprint(total)\n', 'from sys import stdin\n\nS = stdin.readline().rstrip()\n#S = input()\nwhite = 0\ntotal = 0\nfor i in range(len(S)):\n if S[i] == "W":\n total += (i - white)\n white += 1\n \nprint(total)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s147437853', 's314308137', 's588572225', 's060568147']
[2940.0, 2940.0, 2940.0, 3500.0]
[17.0, 17.0, 17.0, 69.0]
[142, 199, 145, 200]
p03200
u177132624
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s=input()\nanswer-0\ncounter=0\nfor i in range(len(s)-1,-1,-1):\n if s[i]=="B":\n answer += len(s)-i-1-counter\n counter += 1\nprint(answer)\n \n \n ', 's=input()\ncounter=0\nwhile s.find("BW"):\n s.replace("BW","WB")\n counter+=1\nprint(counter)\n ', 's=input()\nanswer-0\ncounter=0\nfor i in range(len(s)-1,-1,-1):\n if s[i]=="B":\n answer += len(s)-i-1-counter\n counter += 1\nprint(answer)\n \n ', 's=input()\ncounter=0\nwhile "BW" in s:\n s.replace("BW","WB")\n counter+=1\nprint(counter)\n ', '\ns=input()\nanswer=0\ncounter=0\nfor i in range(len(s)-1,-1,-1):\n if s[i]=="B":\n answer += len(s)-i-1-counter\n counter += 1\nprint(answer)\n \n ']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s045025051', 's156079104', 's236048760', 's569493294', 's894168014']
[3500.0, 3500.0, 3500.0, 3500.0, 3500.0]
[19.0, 2104.0, 18.0, 2104.0, 95.0]
[153, 97, 158, 94, 159]
p03200
u181083204
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['# -*- coding: utf-8 -*-\n\n\ns = input()\n\ncount=0\nanswer=0\nprint(s)\nstr_list = list(s)\n\nfor i in range(len(s)):\n if str_list[i]=="W":\n answer=answer+i-count\n count=count+1\n \nprint(answer)\n', 's = input()\ncount=0\nanswer=0\nfor i in range(len(s)):\n if s[i]=="W":\n answer=answer+i-count\n count=count+1\n \nprint(answer)\n']
['Wrong Answer', 'Accepted']
['s097209287', 's555816968']
[5096.0, 3500.0]
[75.0, 71.0]
[240, 132]
p03200
u197300260
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['# _*_ coding:utf-8 _*_\n\n\nfrom collections import Counter\n\ndef maxCountPair(n_ballCount,a_ballDatas):\n\ta_ballDatas.sort(reverse=True)\n\tballDictBox = Counter(a_ballDatas)\n\tballCountRange = range(0,n_ballCount)\n\tpairCount = 0\n\tfor i in ballCountRange:\n\t\tgetBallNumber = a_ballDatas[i]\n\t\tgetBallNumberBin = getBallNumber.bit_length()\n\t\tnextTwoPower = 2**getBallNumberBin\n\t\tdiffNumber = nextTwoPower - getBallNumber\n\t\tif 1 <= ballDictBox[diffNumber] :\n\t\t\tif getBallNumber != diffNumber:\n\t\t\t\tpairCount = pairCount + 1\n\t\t\t\tballDictBox[getBallNumber]=ballDictBox[getBallNumber]-1\n\t\t\t\tballDictBox[diffNumber] = ballDictBox[diffNumber]-1\n\t\t\telse:\n\t\t\t\tif 2 <= ballDictBox[diffNumber]:\n\t\t\t\t\tpairCount = pairCount + 1\n\t\t\t\t\tballDictBox[diffNumber]=ballDictBox[diffNumber]-2\n\tanswer = pairCount\n\treturn answer\n\n\nif __name__ == \'__main__\':\n\tn_ballCount=int(input())\n\ta_ballDatas=list((map(int,input().split(" "))))\n\tsolution=maxCountPair(n_ballCount,a_ballDatas)\n\tprint(solution)', "# _*_ coding:utf-8 _*_\n\n\n\ndef irr_operation(givenString):\n\n\tallLength = len(givenString)\n\tallRange = range(0,allLength)\n\tbCounter =0\n\tbPosition = []\n\tfor i in allRange:\n\t\tif givenString[i] == 'B':\n\t\t\tbPosition.append(i)\n\t\t\tbCounter=bCounter+1\n\n\tcollectPosition =[]\n\tbLength = len(bPosition)\n\tbRange = range(allLength-bLength,allLength)\n\tfor i in bRange:\n\t\tcollectPosition.append(i)\n\n\tbLengthRange = range(0,bLength)\n\tdiffPosition = 0\n\tfor i in bLengthRange:\n\t\tdiffPosition = diffPosition+(collectPosition[i]-bPosition[i])\n\n\tanswer = diffPosition\n\treturn answer\n\n\nif __name__ == '__main__':\n\tbwstring = input()\n\tsolution=irr_operation(bwstring)\n\tprint(solution)"]
['Runtime Error', 'Accepted']
['s162666387', 's307005997']
[3880.0, 19304.0]
[22.0, 81.0]
[1044, 741]
p03200
u200516156
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["txt = input()\ntxt_list = list(txt)\n\nnum = 0\ncount = 0\nfor i in range(len(txt)):\n if txt_list[i] == 'W':\n count += i-num \n num += 1\n\nprint(txt_list, count)", "txt = input()\ntxt_list = list(txt)\n\ncount = 0\n\nwhile True:\n pre_count = count\n for i in range(len(txt)-1):\n if txt_list[i] == 'B' and txt_list[i+1] == 'W':\n tmp = txt_list[i]\n txt_list[i] = txt_list[i+1]\n txt_list[i+1] = tmp\n count += 1\n if pre_count == count:\n break\n\nprint(txt_list, count)", "txt = input()\ntxt_list = list(txt)\n\nnum = 0\ncount = 0\nfor i in range(len(txt)):\n if txt_list[i] == 'W':\n count += i-num \n num += 1\n\nprint(count)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s068556898', 's784911101', 's681592163']
[7908.0, 7780.0, 4840.0]
[87.0, 2104.0, 73.0]
[171, 358, 161]
p03200
u206570055
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S = input()\nlength = len(S)\nfor c in S:\n if c == 'B':\n countB += 1\nsoko = 1\nans = 0\nfor i in range(length):\n if S[-i-1] == 'B':\n ans += i + 1 - soko\n soko += 1\nprint(ans)", "S = input()\nlength = len(S)\nsoko = 1\nans = 0\nfor i in range(length):\n if S[-i-1] == 'B':\n ans += i + 1 - soko\n soko += 1\nprint(ans)"]
['Runtime Error', 'Accepted']
['s526445053', 's268272095']
[3500.0, 3500.0]
[57.0, 82.0]
[198, 149]
p03200
u219607170
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["import numpy as np\n# S = input()\nS = 'BWBWBW'\nS_mask = np.array([True if s=='W' else False for s in S])\n# print(S_mask.sum())\nW_indices = np.where(S_mask)[0]\n# print(idx.sum())\nW_num = S_mask.sum()\n# print(idx)\nprint(W_indices.sum() - (W_num-1)*W_num//2)", "import numpy as np\nS = input()\n# S = 'BWBWBW'\nS_mask = np.array([True if s=='W' else False for s in S])\n# print(S_mask.sum())\nW_indices = np.where(S_mask)[0]\n# print(idx.sum())\nW_num = S_mask.sum()\n# print(idx)\nprint(W_indices.sum() - (W_num-1)*W_num//2)"]
['Wrong Answer', 'Accepted']
['s759749162', 's145223867']
[21528.0, 14560.0]
[795.0, 177.0]
[254, 254]
p03200
u227082700
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['a,s,b=0,input(),0\nfor i in range(len(s)):a+=i*(s[i]=="W");b+=1\nprint(a-((b*(b-1))//2))', 'a,b,s=0,input(),0\nfor i in range(len(s)):a+=i*(s[i]=="W");b+=1\nprint(a-((b*(b-1))//2))', 'a,s,b=0,input(),0\nfor i in range(len(s)):\n if s[i]=="W":a+=i;b+=1\nprint(a-((b*(b-1))//2))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s731624325', 's760907692', 's301994495']
[3500.0, 3500.0, 3500.0]
[80.0, 18.0, 70.0]
[86, 86, 90]
p03200
u228232845
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import sys\n\n\ndef input(): return sys.stdin.readline().strip()\ndef I(): return int(input())\ndef LI(): return list(map(int, input().split()))\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef S(): return input()\ndef LS(): return input().split()\n\n\nINF = float(\'inf\')\n\n\ndef calc_rle(s):\n tmp, count, ans = s[0], 1, ""\n for i in range(1, len(s)):\n if tmp == s[i]:\n count += 1\n else:\n ans += tmp + str(count)\n tmp = s[i]\n count = 1\n ans += tmp + str(count)\n return ans\n\n\ns = S()\nrle = calc_rle(s)\nprint(rle)\nif rle[0] == \'W\':\n rle = rle[2:]\nif rle[-2] == \'B\':\n rle = rle[:-2]\n# print(rle)\nrle = [[rle[i], eval(rle[i+1])] for i in range(0, len(rle), 2)]\n# print(rle)\nans = 0\nfor i in range(0, len(rle), 2):\n # print(rle[i], rle[i+1])\n ans += rle[i][1] * rle[i + 1][1]\n if i + 2 < len(rle):\n rle[i + 2][1] += rle[i][1]\n # print(f\'{ans=}\')\nprint(ans)\n', 'import sys\n\n\ndef input(): return sys.stdin.readline().strip()\ndef I(): return int(input())\ndef LI(): return list(map(int, input().split()))\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef S(): return input()\ndef LS(): return input().split()\n\n\nINF = float(\'inf\')\n\n\ns = S()\nans = 0\nw_cnt = 0\nfor i in range(len(s)):\n if s[i] == "W":\n ans += i - w_cnt \n w_cnt += 1\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s974338094', 's800594194']
[9336.0, 9380.0]
[70.0, 66.0]
[1019, 523]
p03200
u239342230
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['S = list(str(input()))\n\nans = 0\ncnt = 0\nfor i in range(len(S)-1):\n if S[i] == "B" and S[i+1] == "W":\n S[i+1] = "B"\n ans = ans + i + 1\n cnt = cnt + 1 \n\nprint(ans - cnt)', 's = input()\nans = 0\ncount = 0\nfor i in range(len(s)):\n if s[i] == "W":\n ans += i - count\n count += 1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s207383430', 's424101863']
[4840.0, 3500.0]
[92.0, 69.0]
[191, 128]
p03200
u239725287
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S = list(input())\nn = len(S)\ncnt_b = 0\ncnt = 0\nfor i in range(n):\n if S[i] == 'B':\n cnt_b += 1\n cnt += i\nans = (2*n - cnt_b -1)*cnt_b*0.5 -cnt\nprint(ans)", "S = list(input())\nn = len(S)\ncnt_b = 0\ncnt = 0\nfor i in range(n):\n if S[i] == 'B':\n cnt_b += 1\n cnt += i\nans = int((2*n - cnt_b -1)*cnt_b*0.5 - cnt)\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s426750539', 's271432048']
[4840.0, 4840.0]
[69.0, 70.0]
[170, 176]
p03200
u240630407
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['S = input()\nnum = 0\nwhile(True):\n num += S.count("BW")\n S = S.replace("BW", "WB")\n print(S)\n if not "BW" in S:\n break\nprint(num)', 'S = input()\nindexes = [i for i, x in enumerate(S) if x == "W"]\nprint(sum([x-i for i, x in enumerate(indexes)]))']
['Runtime Error', 'Accepted']
['s658106687', 's485608483']
[134588.0, 13032.0]
[1583.0, 51.0]
[147, 111]
p03200
u244459371
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = input()\ncnt = 0\nfor i in s:\n if i == 'W':\n cnt += 1\nprint(cnt)", "s = input()\nret = 0\nst = 0\nfor i in range(len(s)):\n if (s[i] == 'W'):\n ret += (i-st)\n st += 1\nprint(ret)"]
['Wrong Answer', 'Accepted']
['s709858601', 's029192441']
[3500.0, 3500.0]
[41.0, 70.0]
[76, 121]
p03200
u253479302
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['# -*- coding:utf-8 -*-\nS = list(input())\n\nloop_idx = 0\nloop_len = -(-len(S)//2)\ncnt = 0\n\nif len(S) == 1:\n pass\nelse:\n while loop_idx < loop_len:\n while True:\n if S[0] == "W":\n S.pop(0)\n else:\n break\n while True:\n if S[-1] == "B":\n S.pop(-1)\n else:\n break\n for i in range(len(S)-1,0,-1):\n if S[i]=="W" and S[i-1] == "B":\n cnt += 1\n S[i],S[i-1] = "B","W"\n loop_idx += 1\n #print(S)\nprint(cnt)', '# -*- coding:utf-8 -*-\nS = list(input())\n\ncnt_b = 0 \nans = 0\n\nfor i in range(len(S)):\n if S[i] == "B":\n cnt_b += 1\n if S[i] == "W":\n ans += cnt_b\nprint(ans) ']
['Runtime Error', 'Accepted']
['s850019358', 's581130377']
[10560.0, 10480.0]
[2206.0, 71.0]
[575, 184]
p03200
u268516119
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['#AGC030 B - Powers of two\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\ndef tasitekesu(data,n):\n result=[]\n kosu=0\n for i in range(len(data)):\n if i in result:\n continue\n for j in range(i):\n if j in result:\n continue\n if data[i]+data[j]==n:\n result.append(i)\n result.append(j)\n kosu=kosu+1\n break\n result.sort(reverse=True)\n for i in result:\n del data[i]\n return [data,kosu]\n\nN=int(input())\nA=input().split()\nans=0\nfor i in range(N):\n A[i]=int(A[i])\nfor i in (reversed(beki)):\n R=tasitekesu(A,i)\n A=R[0]\n ans=ans+R[1]\nprint(ans)', '#AGC030 B - Powers of two\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\nN=int(input())\nfor i in range(N):\n A[i]=int(A[i])\nsorted(A)\nfor i in (reversed(beki)):\n inverseA=[]\n for j in range(len(A)):\n inverseA.append(i-A[j])#inverseA\n for j in range(len(A)):\n if inverseA[j] in A:\n A.remove(inverseA[j])\nprint((N-len(A))%2)', '#AGC030 B - Powers of two\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\nN=int(input())\nA=input().split()\nfor i in range(N):\n A[i]=int(A[i])\nsorted(A)\nfor i in (reversed(beki)):\n inverseA=[]\n for j in range(len(A)):\n inverseA.append(i-A[j])#inverseA\n for j in range(len(A)):\n if inverseA[j] in A:\n A.remove(inverseA[j])\nprint((N-len(A))//2)', '#AGC030 B - Powers of two\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\nN=int(input())\nfor i in range(N):\n A[i]=int(A[i])\nsorted(A)\nfor i in (reversed(beki)):\n inverseA=[]\n for j in range(len(A)):\n inverseA.append(i-A[j])#inverseA\n for j in range(len(A)):\n A.remove(inverseA[j])\nprint((N-len(A))%2)', '#AGC029 A - Irreversible operation\ndef countB(data):\n sum=0\n kosu=0\n for i in range(len(data)):\n if data[i]=="B":\n kosu=kosu+1\n sum=sum+i\n return[sum,kosu]\n\ntext=input()\nS=[]\nN=len(text)\nfor i in range(N):\n S.append(text[i])\nresult=countB(S)\nx=result[1]\nAns=(2*N-x-1)*x/2-result[0]\nprint(Ans)', '#AGC029 A - Irreversible operation\ndef countB(data):\n sum=0\n kosu=0\n for i in range(len(data)):\n if data[i]=="B":\n kosu=kosu+1\n sum=sum+i\n return[sum,kosu]\n\ntext=input()\nS=[]\nN=len(text)\nfor i in range(N):\n S.append(text[i])\nresult=countB(S)\nx=result[1]\nAns=int((2*N-x-1)*x/2-result[0])\nprint(Ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s083719193', 's224652746', 's266307754', 's268690876', 's388504041', 's465592945']
[3500.0, 3500.0, 3500.0, 3500.0, 5096.0, 5096.0]
[19.0, 19.0, 19.0, 19.0, 77.0, 81.0]
[821, 418, 437, 385, 383, 388]
p03200
u282347497
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = input()\nn = len(s)\nsum = [0] * (n + 1)\nsum[0] = (s[0] == 'B')\nfor i in range(1 , n):\n\tsum[i] = sum[i-1] + (s[i] == 'B')\nans = 0\nfor i in range(n, -1 ,-1):\n\tprint(i)\n\tif s[i] == 'W':\n\t\tans += sum[i]\nprint(ans)\n\t", "s = input()\nn = len(s)\nsum = [0] * (n + 1)\nsum[0] = (s[0] == 'B')\nfor i in range(1 , n):\n\tsum[i] = sum[i-1] + (s[i] == 'B')\nans = 0\nfor i in range(n, -1 ,-1):\n\tif s[i] == 'W':\n\t\tans += sum[i]\nprint(ans)\n\t", "s = input()\nn = len(s)\nsum = [0] * (n + 1)\nsum[0] = (s[0] == 'B')\nfor i in range(1 , n):\n\tsum[i] = sum[i-1] + (s[i] == 'B')\nans = 0\nfor i in range(n - 1, 0 ,-1):\n\tprint(i)\n\tif s[i] == 'W':\n\t\tans += sum[i]\nprint(ans)\n\t", "s = input()\nn = len(s)\nsum = [0] * (n + 1)\nsum[0] = (s[0] == 'B')\nfor i in range(1 , n):\n\tsum[i] = sum[i-1] + (s[i] == 'B')\nans = 0\nfor i in range(n - 1, -1 ,-1):\n\tif s[i] == 'W':\n\t\tans += sum[i]\nprint(ans)\n\t"]
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s088902936', 's329599092', 's428752782', 's316000722']
[16876.0, 16804.0, 17088.0, 16748.0]
[73.0, 71.0, 149.0, 108.0]
[214, 204, 217, 208]
p03200
u289288647
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['from itertools import permutations\nN = int(input())\n\nval = []\nfor _ in range(N):\n val.append(int(input()))\nans = 10**10\nfor i in permutations(val):\n for j in range(1, N):\n ans = min(max(sum(i[:j]), sum(i[j:])), ans)\nif N == 1:\n print(val[0])\nelse:\n print(ans)\n \n\n \n', "S = input()\nans = 0\ncount = 0\nfor i in S:\n print(i)\n if i == 'B':\n count += 1\n elif i == 'W':\n ans += count\nprint(ans)\n", "S = input()\nans = 0\ncount = 0\nfor i in S:\n if i == 'B':\n count += 1\n elif i == 'W':\n ans += count\nprint(ans)\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s883598198', 's886790223', 's371772261']
[9376.0, 9232.0, 9148.0]
[28.0, 98.0, 56.0]
[290, 142, 129]
p03200
u297651868
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["/*test*/\n#include<bits/stdc++.h>\n\nusing namespace std;\n\nint main() {\n int i = 0,b = 0, bko = 0, sum = 0;\n string s;\n cin >> s;\n for (i = 0; i < s.size(); i++) {\n if (s[i] == 'B') {\n b += bko;\n bko += 1;\n sum += s.size() - 1 - i;\n }\n }\n cout << sum - b << endl;\n return 0;\n}", 's=list(input())\nn=len(s)\nans=0\nw=0\nfor index,value in enumerate(s):\n if value=="W":\n ans+=index-w\n w+=1\nprint(ans)']
['Runtime Error', 'Accepted']
['s900164618', 's877563049']
[2940.0, 4840.0]
[17.0, 76.0]
[341, 131]
p03200
u303037478
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s=list(input())\n\nima=0\nwNum=0\nfor i in range(len(s)):\n if s[i]=="W":\n ima += i\n wNum += 1\n\ndef kasan(n):\n if n==0:\n return 0\n else:\n return kasan(n-1) + n\n\nprint(0)\n#if wNum==0:\n# print(0)\n#else:\n\n# print(ima-saigo)', 's=list(input())\n\nima=0\nwNum=0\nfor i in range(len(s)):\n if s[i]=="W":\n ima += i\n wNum += 1\n\ndef kasan(n):\n if n==0:\n return 0\n else:\n return kasan(n-1) + n\n\nsaigo = ((wNum-1)+0)*wNum//2\nprint(ima-saigo)']
['Wrong Answer', 'Accepted']
['s247362017', 's856848958']
[4840.0, 4840.0]
[74.0, 73.0]
[256, 216]
p03200
u303059352
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s,t,a=input(),0,0\nfor c in s:\n t+=1 if c is 'B' else a+=t\nprint(a)", "cnt = ans = 0\nfor c in input():\n if c is 'W':\n ans += cnt\n else:\n cnt += 1\nprint(ans)"]
['Runtime Error', 'Accepted']
['s473352511', 's836622132']
[2940.0, 3500.0]
[18.0, 48.0]
[67, 93]
p03200
u308684517
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["# -*- coding: utf-8 -*-\nS = input()\nN = len(S)\nS = list(S)\n\ncount = 0\ncount2 = 0\nkekka = 0\nfor i in range(len(S)):\n\tif(S[i] == 'W'):\n\t\tcount = count + 1\n\t\tcount2 = count2 + i\nfor j in range(count):\n\tkekka = kekka + N - j\n\nprint(kekka-count2)", "# -*- coding: utf-8 -*-\nS = input()\nN = len(S)\nS = list(S)\n\ncount = 0\ncount2 = 0\nkekka = 0\nfor i in range(len(S)):\n\tif(S[i] == 'B'):\n\t\tcount = count + 1\n\t\tcount2 = count2 + i\nfor j in range(count):\n\tkekka = kekka + N - j-1\n\nprint(kekka-count2)"]
['Wrong Answer', 'Accepted']
['s699609606', 's149012558']
[4840.0, 4840.0]
[99.0, 109.0]
[241, 243]
p03200
u309039873
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['S = array(input())\nprint(S)', "S = list(input().strip())\nis_irrversible = 0\nanswer = 0\nposition_key_sum = 0\nnumber_of_white = 0\nfor i in range(len(S)):\n if S[i] == 'W':\n position_key_sum += i\n number_of_white += 1\nanswer = position_key_sum - number_of_white\nprint(answer)", "S = list(input().strip())\nis_irrversible = 0\nanswer = 0\nposition_key_sum = 0\nnumber_of_white = 0\nsigma = 0\nfor i in range(len(S)):\n if S[i] == 'W':\n position_key_sum += (i+1)\n number_of_white += 1\n sigma += number_of_white\nanswer = position_key_sum - sigma\nprint(answer)"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s079904265', 's524044597', 's345953510']
[2940.0, 4840.0, 4840.0]
[19.0, 69.0, 91.0]
[27, 257, 294]
p03200
u336721073
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['S = input()\n\narr = [0 if s == "W" else 1 for s in S]\n\nstate = [arr[i] * i for i in range(len(S))]\nfinal_state = [sorted(arr)[i] * i for i in range(len(S))]\n\nprint(final_state - state)', 'S = input()\n \narr = [0 if s == "W" else 1 for s in S]\nsorted_arr = sorted(arr)\n \nstate = [arr[i] * i for i in range(len(S))]\nfinal_state = [sorted_arr[i] * i for i in range(len(S))]\n \nprint(final_state - state)\nS = input()\n\narr = [0 if s == "W" else 1 for s in S]\n\nstate = sum([arr[i] * i for i in range(len(S))])\nfinal_state = sum([sorted(arr)[i] * i for i in range(len(S))])\n\nprint(final_state - state)', 'S = input()\n \narr = [0 if s == "W" else 1 for s in S]\n \nstate = [arr[i] * i for i in range(len(S))]\nfinal_state = [sorted(arr)[i] * i for i in range(len(S))]\n \nprint(final_state - state)\nS = input()\n\narr = [0 if s == "W" else 1 for s in S]\n\nstate = sum([arr[i] * i for i in range(len(S))])\nfinal_state = sum([sorted(arr)[i] * i for i in range(len(S))])\n\nprint(final_state - state)', 'S = input()\n \narr = [0 if s == "W" else 1 for s in S]\nsorted_arr = sorted(arr)\n \nstate = sum([arr[i] * i for i in range(len(S))])\nfinal_state = sum([sorted_arr[i] * i for i in range(len(S))])\n \nprint(final_state - state)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s250347862', 's750685682', 's825670810', 's875721686']
[14568.0, 22504.0, 14568.0, 14568.0]
[2104.0, 85.0, 2104.0, 90.0]
[183, 404, 380, 221]
p03200
u363074342
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S = list(input())\nans = 0\nb = 0\nprint(S)\nfor i in range(len(S)):\n if S[i] == 'B':\n b += 1\n else:\n ans += b\n \nprint(ans)", "S = list(input())\nans = 0\nb = 0\nfor i in range(len(S)):\n if S[i] == 'B':\n b += 1\n else:\n ans += b\n \nprint(ans)"]
['Wrong Answer', 'Accepted']
['s081160146', 's699543156']
[7584.0, 4840.0]
[73.0, 56.0]
[146, 137]
p03200
u364386647
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = """BBW"""\n output = """2"""\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = """BWBWBW"""\n output = """6"""\n self.assertIO(input, output)\n\n\ndef resolve():\n s = str(input())\n ans = 0\n while True:\n origin = s\n s = s.replace(\'BW\', \'WB\', 1)\n if origin == s:\n break\n ans += 1\n print(ans)\n\n return\n\n\nif __name__ == "__main__":\n unittest.main()\n', "def resolve():\n s = str(input())\n ans = 0\n ind = []\n for i, char in enumerate(s):\n if char == 'W':\n ind.append(i)\n lst = 0\n # print(ind)\n for i in ind:\n ans += (i - lst)\n lst += 1\n\n # idx = s.index('W')\n print(ans)\n return\n\n\nresolve()"]
['Wrong Answer', 'Accepted']
['s858514402', 's046950021']
[16652.0, 16932.0]
[76.0, 62.0]
[902, 296]
p03200
u369402805
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s = list(input())\nret, counter = 0, 0\nfor a in s:\n if a == "B":\n counter += 1\n else:\n ret += counter\n', 's = list("BWBWBW" * 10000)\n\ns = list(input())\nret, counter = 0, 0\nfor a in s:\n if a == "B":\n counter += 1\n else:\n ret += counter\nprint(str(ret))']
['Wrong Answer', 'Accepted']
['s679337438', 's568336946']
[4840.0, 5352.0]
[48.0, 46.0]
[121, 164]
p03200
u373047809
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s = input()\nprint(sum(s[:i].count("B") for i in range(len(s)) if s[i]=="W")', 'c = b = 0\nfor s in input():\n c += b*(s=="W")\n b += s=="B"\nprint(c)']
['Runtime Error', 'Accepted']
['s756812636', 's515341303']
[2940.0, 3500.0]
[17.0, 73.0]
[75, 68]
p03200
u377834804
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S = input()\nW = []\n\nfor i, s enumerate(S):\n if s == 'W':\n W.append(i)\n\nidx = 0\nans = 0\nfor w in W:\n ans += w-idx\n idx += 1\n\nprint(ans)", "S = input()\nW = []\n \nfor i, s in enumerate(S):\n if s == 'W':\n W.append(i)\n\nidx = 0\nans = 0\nfor w in W:\n ans += w-idx\n idx += 1\n\nprint(ans)"]
['Runtime Error', 'Accepted']
['s075713009', 's470837495']
[8804.0, 17048.0]
[27.0, 87.0]
[140, 144]
p03200
u377989038
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s = sorted(list(input()), reverse=True)\nans = []\ntmp = 0\nfor i in s:\n if i == "W":\n tmp += 1\n ans.append(tmp)\nprint(sum(ans))', 's = input()[::-1]\nans = []\ntmp = 0\nfor i in s:\n if i == "W":\n tmp += 1\n elif i == "B":\n ans.append(tmp)\nprint(sum(ans))']
['Wrong Answer', 'Accepted']
['s131683673', 's443927202']
[12424.0, 5924.0]
[70.0, 54.0]
[142, 139]
p03200
u384261199
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import numpy as np\nS = input()\n\nidx = []\ni = 0\nfor s in S:\n if s == "W":\n idx.append(i)\n i+=1\nprint(int(np.sum(idx) - (len(idx))))', 'import numpy as np\nS = input()\n\nidx = []\ni = 0\nW_flag = False\nfor s in S:\n if not W_flag:\n if s == "W":\n continue\n elif s == "B":\n W_flag = True\n \n if s == "W" and W_flag:\n idx.append(i)\n i+=1\nprint(int(np.sum(idx) - ((0+len(idx)-1)*len(idx)/2)))\n ']
['Wrong Answer', 'Accepted']
['s875914904', 's532648387']
[26360.0, 26256.0]
[1224.0, 1147.0]
[143, 310]
p03200
u387914114
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["def main():\n s = np.array(list(input()))\n \n ind = np.array(np.where(s=='B'))\n \n len_ind=ind.shape[1]\n \n len=s.shape[0]\n \n dist=np.arange(len-len_ind,len)\n \n ans=np.sum(dist-ind)\n return ans", "import numpy as np\ndef main():\n s = np.array(list(input()))\n \n ind = np.array(np.where(s=='B'))\n \n len_ind=ind.shape[1]\n \n len=s.shape[0]\n \n dist=np.arange(len-len_ind,len)\n \n ans=np.sum(dist-ind)\n return ans", "def main(s1):\n s = np.array(list(s1))\n \n ind = np.array(np.where(s=='B'))\n \n len_ind=ind.shape[1]\n \n len=s.shape[0]\n \n dist=np.arange(len-len_ind,len)\n \n ans=np.sum(dist-ind)\n return ans", "#import numpy as np\ns = np.array(list(input()))\n\nind = np.array(np.where(s=='B'))\n\nlen_ind=ind.shape[1]\n\nlen=s.shape[0]\n\ndist=np.arange(len-len_ind,len)\n\nans=np.sum(dist-ind)\nprint(ans)", "import numpy as np\ns = np.array(list(input()))\n\nind = np.array(np.where(s=='B'))\n\nlen_ind=ind.shape[1]\n\nlen=s.shape[0]\n\ndist=np.arange(len-len_ind,len)\n\nans=np.sum(dist-ind)\nprint(ans)"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s081503424', 's537950006', 's628671643', 's920724451', 's382798202']
[2940.0, 12504.0, 2940.0, 3064.0, 18064.0]
[17.0, 161.0, 17.0, 28.0, 191.0]
[287, 306, 284, 247, 246]
p03200
u394731058
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["ans = 0\nans2 = 0\ns = input()\nl = len(s)\nt = 1\nfor i in range(l):\n print(f'a={t}')\n same = True\n while same:\n if s[i] != s[t]:\n i = t\n print(f'b={t}')\n same = False\n else:\n ans += 1\nprint(max(ans, ans2))\n", "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n ans = 0\n S = input().rstrip('\\n')\n w = 0\n for s in S[::-1]:\n if s == 'W':\n w += 1\n else:\n ans += w\n print(ans)\n\nif __name__ == '__main__':\n main()"]
['Time Limit Exceeded', 'Accepted']
['s156214940', 's334783388']
[9288.0, 9140.0]
[2206.0, 41.0]
[232, 253]
p03200
u395381395
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["txt = input()\ntxt_list = list(txt)\n\ncount = 0\nn_b = 0\nn_w = 0\ni = 0\nfor i in range(len(txt_list)):\n print(txt_list[i])\n if txt_list[i] == 'W':\n n_w += 1\n if (i>=1 and txt_list[i-1] == 'W' and txt_list[i] == 'B') or (i==len(txt_list)-1 and txt_list[i] == 'W'):\n count += n_b * n_w\n # print(n_b)\n # print(n_w)\n n_w = 0\n if txt_list[i] == 'B':\n n_b += 1\n\nprint(count)", "txt = input()\ntxt_list = list(txt)\n\ncount = 0\nn_b = 0\nn_w = 0\ni = 0\nfor i in range(len(txt_list)):\n if txt_list[i] == 'W':\n n_w += 1\n if (i>=1 and txt_list[i-1] == 'W' and txt_list[i] == 'B') or (i==len(txt_list)-1 and txt_list[i] == 'W'):\n count += n_b * n_w\n n_w = 0\n if txt_list[i] == 'B':\n n_b += 1\n\nprint(count)"]
['Wrong Answer', 'Accepted']
['s653900718', 's396182355']
[5860.0, 4840.0]
[269.0, 159.0]
[418, 353]
p03200
u397531548
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import math\nN=int(input())\nA=list(map(int,input().split()))\nA.sort()\ns=0\ni=1\nwhile i<=len(A)-1:\n a=int(math.log2(A[-i]))\n if 2**(a+1)-A[-i] in A[:-i]:\n s+=1\n A.remove(2**(a+1)-A[-i])\n i+=1\n else:\n i+=1\nprint(s)', 'import math\nN=int(input())\nA=list(map(int,input().split()))\nAe1=[]\nAo1=[]\nfor i in range(N):\n if A[i]%2==0:\n Ae1.append(A[i])\n else:\n Ao1.append(A[i])\nif Ao1!=[]:\n s=0\n Ao=sorted(Ao1,reverse=True)\n i=0\n while i<=len(Ao)-1:\n a=int(math.log2(Ao[i]))\n if 2**(a+1)-Ao[i] in Ao[i:]:\n s+=1\n Ao.remove(2**(a+1)-Ao[i])\n i+=1\n else:\n i+=1\nelse:\n s=0\nif Ae1!=[]:\n t=0\n Ae=sorted(Ae1,reverse=True)\n j=0\n while j<=len(Ae):\n b=int(math.log2(Ae[j]))\n if 2**(a+1)-Ae[j] in Ae[j:]:\n s+=1\n Ae.remove(2**(a+1)-Ae[j])\n j+=1\n else:\n j+=1\nelse:\n t=0\nprint(s+t)\n ', 'S=input()\na=0\nb=0\nfor i in range(len(S)):\n if S[-i-1]=="B":\n a+=i-b\n b+=1\nprint(a)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s151597203', 's888521824', 's570820846']
[3500.0, 3628.0, 3500.0]
[19.0, 19.0, 79.0]
[247, 728, 100]
p03200
u405256066
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['ans=0\nfor i in range(1000000):\n cnt=N.count("BW")\n ans=ans+cnt\n N=N.replace("BW","WB")\n N=N.lstrip("W")\n N=N.rstrip("B")\n if cnt==0:\n break\nprint(ans)', 'from sys import stdin\nN=(stdin.readline().rstrip())\nans=0\nfor i in range(10000):\n index=N.find("W")\n if index==-1:\n break\n ans=ans+index\n N=str_del(N,index)\nprint(ans)', 'from sys import stdin\nN=(stdin.readline().rstrip())\nN=list(N)\ncnt=0\nans=0\nfor i in N:\n if i=="B":\n cnt+=1\n else:\n ans+=cnt\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s306902741', 's830794207', 's635984980']
[2940.0, 3500.0, 4840.0]
[17.0, 17.0, 46.0]
[175, 186, 153]
p03200
u419354839
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['#S = input().strip()\nSb = [c == "B" for c in S]\n\ndef reverse(Sb,i):\n _list = Sb.copy()\n _list[i] = not _list[i]\n return _list\n\ndef operate_onestep(Sb):\n _list = Sb.copy()\n cnt = 0\n flg = True\n while flg:\n flg = False\n for i in range(len(_list)-1):\n if _list[i] and not _list[i+1]:\n cnt += 1\n _list = reverse(_list,i)\n _list = reverse(_list,i+1)\n flg = True\n return cnt\n\nprint(operate_onestep(Sb))', 'S = input().strip()\nSb = [c == "B" for c in S]\n \ndef reverse(Sb,i):\n _list = Sb.copy()\n _list[i] = not _list[i]\n return _list\n\ndef operate(Sb):\n _list = Sb.copy()\n cnt = 0\n flg = True\n t_start = 0\n t_end = len(Sb)\n while flg:\n flg = False\n try:\n t_start = _list[t_start:].index(True) + t_start\n except:\n break\n try:\n t_end = t_end - list(reversed(_list[:t_end])).index(False)\n except:\n break\n \n for i in range(t_start,t_end-1):\n if _list[i] and not _list[i+1]:\n cnt += 1\n _list = reverse(_list,i)\n _list = reverse(_list,i+1)\n flg = True\n return cnt, _list, t_start, t_end\n \nprint(operate(Sb))', 'S = input().strip()\n\nw_total = 0\nnum_op = 0\nfor i,c in enumerate(S):\n if c == "W":\n w_total += 1\n num_op += i + 1 - w_total\n \nprint(num_op)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s214772105', 's559870295', 's516571910']
[3064.0, 10440.0, 3500.0]
[17.0, 2104.0, 71.0]
[505, 787, 163]
p03200
u427344224
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['N = int(input())\nA_list = list(map(int, input().split()))\ntwo_list = [2 ** i for i in range(32)]\n \ncount = 0\nitems = {}\nfor a in A_list:\n if a in items:\n items[a] += 1\n \n else:\n items[a] = 1\nA_list.sort(reverse=True)\n \nfor a in A_list:\n if items[a] >= 1:\n \n for t in two_list:\n m = t -a\n if m in items:\n if m == a and items[a] >= 2:\n count += 1\n items[a] -= 1\n items[m] -= 1\n break\n \n elif m != a and items[m] >= 1 and items[a] >=1:\n count += 1\n items[a] -= 1\n items[m] -= 1\n break\nprint(count)', 'S = input()\nS_list = []\nfor i in S:\n S_list.append(i)\n\nw_count = S.count("W")\nb_count = S.count("B")\nc = 0\n\nfor i in range(len(S)):\n\n if S[i] == "B":\n c += w_count\n else:\n w_count -= 1\n\nprint(c)\n\n']
['Runtime Error', 'Accepted']
['s563384464', 's265814314']
[3500.0, 5096.0]
[19.0, 86.0]
[728, 219]
p03200
u428132025
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = input()\nans = 0\nnumB = 0\nfor i in reversed(range(len(s))):\n if s[i] == 'B':\n ans += len(s) - 1 - i - numB\n numB += 1\n print(ans)", "s = input()\nans = 0\nnumB = 0\nfor i in reversed(range(len(s))):\n if s[i] == 'B':\n ans += len(s) - 1 - i - numB\n numB += 1\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s826457459', 's983712546']
[4456.0, 3500.0]
[217.0, 89.0]
[156, 148]
p03200
u434208140
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import collections\n \nn=int(input())\na=list(map(int,input().split()))\na.sort(reverse=True)\nc=collections.Counter(a)\nans=0\nfor i in a:\n for j in range(31):\n if(2**j>i):\n k=2**j-i\n break\n if k in c.keys():\n if i==k and c[i]>1:\n c[i]-=2\n ans+=1\n elif i!=k and c[i]>0 and c[k]>0:\n c[i]-=1\n c[k]-=1\n ans+=1\nprint(ans)\n', "s=input()\nn=0\nc=0\nfor i in range(len(s)):\n if s[i]=='W':\n n+=i-c\n c+=1\nprint(n)"]
['Runtime Error', 'Accepted']
['s811085053', 's855270287']
[3756.0, 3500.0]
[22.0, 72.0]
[358, 86]
p03200
u445511055
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['# -*- coding: utf-8 -*-\n\n\ndef main():\n """Function."""\n s = str(input())\n num = len(s)\n\n total = 0\n for _ in range(num//2+1):\n print(_)\n count = s.count("BW")\n if count == 0:\n break\n else:\n total += count\n s_list = list(s)\n\n for i in range(num):\n if s_list[i:i+2] == ["B", "W"]:\n s_list[i:i+2] = ["W", "B"]\n print(s_list)\n\n s = "".join(s_list)\n\n print(total)\n\n\nif __name__ == "__main__":\n main()\n', '# -*- coding: utf-8 -*-\n\n\ndef main():\n """Function."""\n s = str(input())\n\n total = 0\n b_count = 0\n for i in range(len(s)):\n if s[i] == "B":\n b_count += 1\n if s[i] == "W":\n total += b_count\n\n print(total)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s046066838', 's435120241']
[32556.0, 3500.0]
[2104.0, 53.0]
[545, 298]
p03200
u447528293
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["N = int(input().rstrip())\nA = [int(s) for s in input().rstrip().split()]\nA.sort()\n\nsquared = [2]\ntmp = 2\nwhile tmp < 2 * 10**9:\n tmp *= 2\n squared.append(tmp)\n\npairs = []\nfor i in range(N):\n for j in range(i+1, N):\n if A[i] + A[j] in squared:\n pairs.append([A[i], A[j]])\n\nadopt = [format(i, 'b').rjust(len(pairs), '0') for i in range(2**len(pairs))]\nmax_pair = 0\n\nfor i in range(len(adopt)):\n num = []\n for j in range(len(pairs)):\n if adopt[i][j] == '1':\n num.append(pairs[j][0])\n num.append(pairs[j][1])\n if len(num) == len(set(num)) and len(num) > max_pair:\n max_pair = len(num)\n\nprint(max_pair // 2)", "state = input().rstrip()\nans = 0\ncnt = 0\nfor i, s in enumerate(state):\n if s == 'B':\n cnt += 1\n else:\n ans += cnt\nprint(ans)"]
['Runtime Error', 'Accepted']
['s628149447', 's247142555']
[3628.0, 3500.0]
[19.0, 57.0]
[674, 144]
p03200
u464032595
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S = list(input())\ncnt = 0\nfor i, a in enumerate(S):\n if a == 'W':\n cnt += i-1\nprint(cnt)", "S = list(input())\ncnt = call = 0\nfor i, a in enumerate(S):\n if a == 'W':\n cnt += i-call\n call += 1\nprint(cnt)"]
['Wrong Answer', 'Accepted']
['s312621105', 's875069131']
[4840.0, 4840.0]
[60.0, 75.0]
[92, 116]
p03200
u465062650
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["osero = input();\nlen = len(osero);\ncon_b = 0;\ncon = 0;\nfor(i =0; i<len, i++) {\n\tif(osero[i]='B') {\n\t\tcon_b++;\n\t}\n\tif(osero[i] ='W') {\n\t\tcon = con + con_b;\n\t}\n}\nprint(con)", "osero = input();\nlen = len(osero);\ncon_b = 0;\ncon = 0;\nfor i in range(0,len):\n\tif osero[i]=='B':\n\t\tcon_b = con_b + 1;\n\tif osero[i] =='W':\n\t\tcon = con + con_b;\nprint(con)"]
['Runtime Error', 'Accepted']
['s243739167', 's042057676']
[2940.0, 3500.0]
[17.0, 68.0]
[170, 169]
p03200
u466335531
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S=list(input())\nn=len(S)\n\ndef search(t):\n for i in range(t,n-1):\n if S[i]=='B' and S[i+1]=='W':\n S[i],S[i+1]='W','B'\n if t>0:\n return 1+search(t-1)\n else:\n return 1+search(1)\n return 0\n\nprint(search(0))\n", "S=list(input())\nn=len(S)\nans=0\nb=0\n\nfor s in S:\n if s=='B':b+=1\n else:ans+=b\n \nprint(ans)"]
['Runtime Error', 'Accepted']
['s363643548', 's438035490']
[5564.0, 4840.0]
[2104.0, 53.0]
[279, 98]
p03200
u475503988
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = input()\nslist = list(s)\nl = len(s)\nn = 0\nj = 1\nstart = 0\nend = l-1\n\nwhile j != 0:\n j = 0\n for i in range(start, end):\n if slist[i:i+2] == ['B','W']:\n slist[i:i+2] = ['W','B']\n n += 1\n j = 1\n end = i\n start += 1\n# end -= 1\n\nprint(n)", "s = input()\nslist = list(s)\nl = len(s)\nn = 0\nj = 1\nstart = 0\nend = l-1\n\nwhile j != 0:\n j = 0\n for i in range(start, end):\n if slist[i:i+2] == ['B','W']:\n slist[i:i+2] = ['W','B']\n n += 1\n j = 1\n# end = i+1\n start += 1\n end -= 1\n\nprint(n)", "S = input()\ncnt = 0\nans = 0\nleft = 0\nfor i in range(len(S)):\n if S[i] == 'W':\n cnt += S[left:i].count('B')\n ans += cnt\n left = i\nprint(ans)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s417649797', 's884842183', 's166675188']
[4968.0, 4840.0, 3500.0]
[2104.0, 2104.0, 116.0]
[262, 264, 163]
p03200
u480472958
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['N, As = int(input()), list(map(int, input().split()))\nmaxA, ans = max(As), 1\nwhile True:\n if pow(ans, maxA) - 1 > N:\n break\n ans += 1\nprint(ans)', "ans, w_idx = 0, 0\nfor i, s in enumerate(input()):\n if s != 'W':\n continue\n ans += i - w_idx\n w_idx += 1\nprint(ans)"]
['Runtime Error', 'Accepted']
['s988334931', 's346455767']
[3500.0, 3500.0]
[21.0, 75.0]
[157, 130]
p03200
u500297289
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['"""AtCoder"""\n\nS = input()\n\nans = 1\ntmp = 1\n\nfor i in range(len(S)):\n if S[i] == \'W\':\n ans += i - tmp + 1\n tmp = i + 1\n\nprint(ans)\n', '"""AtCoder"""\n\nS = input()\n\nans = 0\ntmp = 0\n\nfor i in range(len(S)):\n if S[i] == \'W\':\n ans += i - tmp\n tmp += 1\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s167476016', 's382563190']
[3500.0, 3500.0]
[74.0, 69.0]
[148, 141]
p03200
u517152997
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["# -*- coding: utf-8 -*-\n# \nimport math\nimport sys\nimport itertools\nimport numpy as np\n\n\nm = list(input())\nprint(m)\nanswer = 0\n\nfor i in range(len(m)):\n if m[i] == 'W':\n for j in range(i):\n if m[j] == 'B':\n answer += 1\n\nprint(answer)\n", "# -*- coding: utf-8 -*-\n# \nimport math\nimport sys\nimport itertools\nimport numpy as np\n\n\nm = list(input())\nprint(m)\nanswer = 0\nnum_b = 0\nfor i in range(len(m)):\n if m[i] == 'W':\n answer += num_b\n else:\n num_b += 1\n\nprint(answer)\n", "# -*- coding: utf-8 -*-\n# \nimport math\nimport sys\nimport itertools\nimport numpy as np\n\n\nm = list(input())\n#print(m)\nanswer = 0\nnum_b = 0\nfor i in range(len(m)):\n if m[i] == 'W':\n answer += num_b\n else:\n num_b += 1\n\nprint(answer)\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s562543790', 's838446460', 's624513385']
[17168.0, 19012.0, 24352.0]
[2108.0, 220.0, 1084.0]
[269, 248, 249]
p03200
u517447467
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s = input()\nl = len(s)\nb_num = sum([1 for w in s if w == "B"])\nb_pos = sum([i for i,w in enumerate(s) if w == "B"])\nmax_num = sum([i for i in range(l-b_num, l)])\nprint(max_num - b_num)', 's = input()\nl = len(s)\nb_num = sum([1 for w in s if w == "B"])\nb_pos = sum([i for i,w in enumerate(s) if w == "B"])\nmax_num = sum([i for i in range(l-b_num, l)])\nprint(max_num - b_pos)']
['Wrong Answer', 'Accepted']
['s631800087', 's537625759']
[11084.0, 11080.0]
[58.0, 57.0]
[184, 184]
p03200
u522665179
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['def main(a):\n s=0\n t=0\n for i in range(0,len(a)):\n if a[i]=="B":\n s+=len(a)-i-1\n t+=1\n return s-t*(t-1)/2\n\na=input()\nprint(main(a))', 'def main(a):\n s=0\n t=0\n for i in range(0,len(a)):\n if a[i]=="B":\n s+=len(a)-i-1\n t+=1\n return s-t*(t-1)/2\n\na=input()\nprint(int(main(a)))']
['Wrong Answer', 'Accepted']
['s059625326', 's374069653']
[3500.0, 3500.0]
[67.0, 66.0]
[148, 153]
p03200
u532966492
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s=input()\nprint(sum([s[i+1]!=s[i] for i in range(len(s)-1)]))', 's=list(reversed(list(input())))\nans=0\ncnt=0\nfor i in range(len(s)):\n if s[i]=="W":\n cnt+=1\n else:\n ans+=cnt\nprint(ans)']
['Wrong Answer', 'Accepted']
['s734609977', 's110111171']
[5096.0, 6180.0]
[52.0, 60.0]
[61, 138]
p03200
u540572789
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['S = input()\ncount_B = 0\nright_W = 0\nfor i in S:\n if i == "B":\n count_B += 1\n else:\n right_W = i\nrb = len(S) - right_W - 1\nprint(count_B - rb)', 'S = input()\ncount_ans = 0\ncount_B = 0\nright_W = 0\nfor i, c in enumerate(S):\n\tif c == "W":\n\t\tcount_ans += count_B\n\telse:\n\t\tcount_B += 1\nprint(count_ans)']
['Runtime Error', 'Accepted']
['s843975651', 's482641465']
[3500.0, 3500.0]
[43.0, 56.0]
[149, 151]
p03200
u543954314
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s = input()\nans = 0\nwhile b:\n b = 0\n c = s.count("BW")\n if c:\n ans += c\n b = 1\n s = s.replace("BW", "WB")\nprint(ans)\n', 's = input()\nt = 0\nc = 0\nfor i in range(len(s)):\n if s[i] == "W":\n t += i\n c += 1\nprint(t-c*(c-1)//2)']
['Runtime Error', 'Accepted']
['s021371953', 's771281123']
[3500.0, 3500.0]
[18.0, 74.0]
[129, 107]
p03200
u547537397
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s = input()\n \nn = len(s)\n \nans = 0\n \ncunt = 0\n \nfor i in range(n):\n if s[i] == "B":\n cnt += 1\n else:\n ans += cunt\nprint(ans)', 's = input()\n \nn = len(s)\n \nans = 0\n \ncunt = 0\n \nfor i in range(n):\n if s[i] == "B":\n cunt += 1\n else:\n ans += cunt\nprint(ans)']
['Runtime Error', 'Accepted']
['s564241300', 's381240582']
[9336.0, 9264.0]
[50.0, 62.0]
[144, 145]
p03200
u548545174
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['S = input()\n \nans = 1\nfor i in range(len(S)):\n if S[i] == "B":\n ans += S[i:].count("W")\n\nprint(ans)', 'S = input()\n\nans = 1\nfor i in range(len(S)):\n if S[i] == "B":\n ans *= S[i:].count("W")\n\nprint(ans)\n', 'S = input()\nN = len(S)\n \nans = 1\nfor i in range(N):\n if S[i] == "B":\n ans += S[i:].count("W")\n\nprint(ans)', 'S = input()\n \nans = 0\nb_count = 0\n\nfor i in S:\n if i == "B":\n b_count += 1\n else:\n ans += b_count\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s085233829', 's089820453', 's981468103', 's863854785']
[3500.0, 3500.0, 3500.0, 3500.0]
[2107.0, 2104.0, 2104.0, 45.0]
[109, 109, 115, 129]
p03200
u564837886
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = input()\nans = 0\n\ndef reverse(s,i):\n if s[i] == 'B' and s[i+1] == 'B':\n\ts[i] = 'W'\n\ts[i+1] = 'B'\n ans += 1\n \nwhile True:\n s = ans\n for i in range(len(s) - 1):\n reverse(s,i)\n if s == ans:\n print(ans)\n break", "s = input()\nans = 0\n\ndef reverse(s,i):\n if s[i] == 'B' and s[i+1] == 'W':\n\ts[i] = 'W'\n\ts[i+1] = 'B'\n ans += 1\n \nwhile True:\n s = ans\n for i in range(len(s) - 1):\n reverse(s,i)\n if s == ans:\n print(ans)\n break\n", 'BWBWBW', "s = input()\nw = 0\nb = 0\nwa = 0\nba = 0\nl = len(s)\n \nfor i in range(l):\n if s[i] == 'W':\n wa += i - w\n w += 1\n if s[-1-i] == 'B':\n ba += i - b\n b += 1\n \nprint(min(ba, wa))"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s025165132', 's509267474', 's546746352', 's862682136']
[2940.0, 2940.0, 2940.0, 3500.0]
[17.0, 17.0, 17.0, 109.0]
[225, 226, 6, 186]
p03200
u575431498
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
[" = [i for i in input()]\nf = True\ni = 0\ncnt = 0\nwhile True:\n if s[i] == 'B' and s[i+1] == 'W':\n cnt += 1\n s[i] = 'W'\n s[i+1] = 'B'\n i += 1\n f = False\n else:\n i += 1\n if i >= len(s) - 1:\n if f:\n break\n i = 0\n f = True\nprint(cnt)", "s = [i for i in input()]\nB_pos_ls = []\nfor i, x in enumerate(s):\n if x == 'B':\n B_pos_ls.append(i)\nres = 0\nB_pos_ls.sort(reverse=True)\nlast_B_pos = len(s) - 1\nfor B_pos in B_pos_ls:\n res += last_B_pos - B_pos\n last_B_pos -= 1\nprint(res)"]
['Runtime Error', 'Accepted']
['s743506324', 's293292623']
[2940.0, 12708.0]
[17.0, 97.0]
[309, 252]
p03200
u575956662
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["import collections\ns = list(input())\nAns = 0\nc = collections.Counter(s)\nd = c['B']\nfor i in range(len(s)):\n if s[i] == 'B':\n for j in range(len(s)-i-1):\n if s[i+j+1]=='W':\n Ans += j+1\n s[i] = 'W'\n s[i+1] = 'B'\n s[i+j+1] = 'B'\n break\n if i = d:\n break\nprint(Ans)", "s = list(input())\nAns = 0\nW_put_place = 0\nfor i in range(len(s)):\n if s[i] == 'W':\n Ans += i - W_put_place\n W_put_place += 1\nprint(Ans)"]
['Runtime Error', 'Accepted']
['s442130937', 's310864550']
[8988.0, 10536.0]
[20.0, 67.0]
[367, 152]
p03200
u576335153
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = input()\nl = []\nfor i in range(len(s)-1, -1, -1):\n if s[i] == 'B':\n l.append(0)\n else:\n l.append(1)\ncnt = 0\n\nfor j in range(len(s)**0.5):\n for i in range(j, len(s) - 1, 2):\n if l[i] == 1 and l[i+1] == 0:\n l[i] = 0\n l[i+1] = 1\n cnt += 1\n\nprint(cnt)\n", "s = input()\n\nleft = 0\nans = 0\n\nfor x in s:\n if x == 'B':\n left += 1\n continue\n ans += left\n\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s436428824', 's054301591']
[11200.0, 9312.0]
[55.0, 52.0]
[314, 123]
p03200
u578694888
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["# -*- coding: utf-8 -*-\n\ns=input()\n\ncnt=0\ncum=0\n\nfor i in range(len(s)):\n if s[i]=='W':\n cnt+=1\n cum+=i\nprint(cum-int((cnt+1)*cnt/2))\n", "# -*- coding: utf-8 -*-\n\ns=input()\n\ncnt=0\ncum=0\n\nfor i in range(len(s)):\n if s[i]=='W':\n cnt+=1\n cum+=i\nprint(cum-int((cnt-1)*cnt/2))\n"]
['Wrong Answer', 'Accepted']
['s787393390', 's361639814']
[3500.0, 3500.0]
[66.0, 67.0]
[151, 151]
p03200
u580362735
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S = str(input())\ncount = 0;\nfor i in range(100000)\n count=count+S.count('BW');\n S = S.replace('BW','WB');\n if 'BW' not in S:break;\nprint(count)\n", "S = input()\nans = 0\ntmp = 0\nfor i in range(len(S)):\n if S[i] == 'W':\n ans+=i-tmp\n else:\n tmp+=1\nprint(ans)", "S = input()\nans = 0\ntmp = 0\nfor i in range(len(S)):\n if S[i] == 'W':\n ans+=i-tmp\n tmp+=1\nprint(ans)\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s619807575', 's621113641', 's560907911']
[2940.0, 3500.0, 3500.0]
[17.0, 68.0, 71.0]
[147, 114, 107]
p03200
u580697892
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['# coding: utf-8\ndef calc(state, print_state):\n times = 0\n while "BW" in print_state:\n for i in range(len(state)):\n if state[i] == "B":\n if i < len(state)-1 and state[i+1] == "W":\n state[i] = "W"\n state[i+1] = "B"\n times += 1\n print_state = "".join(state) \n print(times)\n \nif __name__ == "__main__":\n start = time.time()\n state = list(input())\n print_state = "".join(state)\n calc(state, print_state)', '#coding: utf-8\ns = list(input())\nans = 0\nb = 0\nfor i in range(len(s)):\n if s[i] == "W":\n ans += i - b\n b += 1\nprint(ans)']
['Runtime Error', 'Accepted']
['s867082227', 's895427281']
[3064.0, 4840.0]
[21.0, 74.0]
[514, 137]
p03200
u581403769
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = list(input())\n\ncount = 0\nwhite = 0\nfor i in range(len(s)):\n if s[i] == 'W':\n count += i\n white += 1\n \nprint(count - white)", "s = list(input())\n\ncount = 0\nwhite = 0\nfor i in range(len(s)):\n if s[i] == 'W':\n count += i - white\n white += 1\n\nprint(count)\n"]
['Wrong Answer', 'Accepted']
['s074874248', 's513024875']
[10568.0, 10556.0]
[67.0, 66.0]
[150, 143]
p03200
u584174687
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["data = list(input())[::-1]\n\ncount = 0\n\n# while 1:\ncount_b = 0\nfor i in range(len(data)):\n # print(i)\n if data[i] == 'W':\n count += count_b\n # count += 1\n # data[i], data[i+1] = 'B', 'W'\n # break\n else:\n count_b += 1\n # else:\n # break\nprint(count)\n", "\n\nball_num = int(input())\nnum_data = list(map(int, input().split()))\n\nans = 0\n\ndef check_beki(num1, num2):\n data = num1 + num2\n while 1:\n data1 = data % 2\n data = int(data / 2)\n if data1 == 1:\n return 0\n elif num1 + num2 >= 1 and data == 1:\n return 1\n\ndef check_ans(ans_list, tasu_flg):\n global ans\n ans_kari = 0\n for i in range(len(ans_list)):\n if check_beki(ans_list[i], 0) and tasu_flg[i] == 1:\n ans_kari += 1\n if ans_kari > ans:\n ans = ans_kari\n\ndef check(index, ans_list_ori, tasu_flg_ori):\n global ball_num, num_data\n ans_list = ans_list_ori.copy()\n tasu_flg = tasu_flg_ori.copy()\n\n # if len(ans_list) >= tree_num:\n # return\n\n \n\n if index < ball_num:\n for j in range(len(ans_list)):\n # print(ans_list[j], num_data[index])\n if check_beki(ans_list[j], num_data[index]) and tasu_flg[j] == 0:\n \n ans_list[j] += num_data[index]\n tasu_flg[j] = 1\n check(index+1, ans_list, tasu_flg)\n tasu_flg[j] = 0\n ans_list[j] -= num_data[index]\n \n ans_list.append(num_data[index])\n tasu_flg.append(0)\n check(index+1, ans_list, tasu_flg)\n tasu_flg.pop(-1)\n ans_list.pop(-1)\n else:\n \n check_ans(ans_list, tasu_flg)\n\n\ndef main():\n global num_data\n check(1, [num_data[0]], [0])\n\n print(ans)\n\n\n\nif __name__ == '__main__':\n main()", "data = list(input())\n\ncount = 0\n\n# while 1:\ncount_b = 0\nfor i in range(len(data)):\n # print(i)\n if data[i] == 'W':\n count += count_b\n # count += 1\n # data[i], data[i+1] = 'B', 'W'\n # break\n else:\n count_b += 1\n # else:\n # break\nprint(count)\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s749260039', 's921526563', 's644652541']
[6304.0, 3628.0, 4840.0]
[58.0, 19.0, 58.0]
[308, 1672, 302]
p03200
u593005350
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import collections\nN=int(input())\nx=list(map(int,input().split()))\nc=collections.Counter(x)\nt=[2**i for i in range(len(str(bin(max(x)*2))[2:])+1)[::-1]]\ncount=0\n#print(c)\n#print("x=",x)\n#print("t=",t)\nfor i in range(len(x))[::-1]:\n if x[i] != 0:\n for j in range(0,len(t)):\n if t[j] <= x[i]:\n break\n if t[j]-x[i] in c:\n if t[j]-x[i] == x[i]:\n if c.get(x[i],-1) >= 2:\n c[x[i]] -= 2\n count +=1\n break\n else:\n if c.get(t[j]-x[i],-1)>0 and c.get(x[i],-1)>0:\n c[t[j]-x[i]] -= 1\n c[x[i]] -= 1\n count+=1\n break\n#print(c) \nprint(count)', 'S=input()\ncount=S.count("BW")\nend=0\ndef sigma(i):\n a=[b for b in range(i+1)]\n return sum(a)\nplace=[]\ni=0\nwhile "BW" in S:\n i=S[i:].find("BW") + 1 + i\n place.append(i)\n S=S[:i-1]+S[i-1:].replace("BW","BB",1)\n print(S)\n\ncount=sum(place)-sigma(count-1)\nprint(count)', 'import collections\nN=int(input())\nx=list(map(int,input().split()))\nc=collections.Counter(x)\nt=[2**i for i in range(len(str(bin(max(x)*2))[2:])+1)[::-1]]\ncount=0\nstart=0\nx.sort()\nfor i in range(len(x))[::-1]:\n for j in range(start,len(t)):\n if t[j] > 2*x[i]:\n start = j\n if t[j] < x[i]:\n break\n if t[j]-x[i] in c.keys():\n if t[j]-x[i] == x[i]:\n if c[x[i]] >= 2:\n c[x[i]] -= 2\n count +=1\n else:\n if c[t[j]-x[i]]>0 and c[x[i]]>0:\n c[t[j]-x[i]] -= 1\n c[x[i]] -= 1\n count+=1\nprint(count)', 'import collections\nN=int(input())\nx=list(map(int,input().split()))\nc=collections.Counter(x)\nt=[2**i for i in range(len(str(bin(max(x)*2))[2:])+1)[::-1]]\ncount=0\nstart=0\nx.sort()\nfor i in range(len(x))[::-1]:\n for j in range(len(t)):\n if t[j] < x[i]:\n break\n if t[j]-x[i] in c.keys():\n if t[j]-x[i] == x[i] and c[x[i]] >= 2:\n c[x[i]] -= 2\n count +=1\n elif c[t[j]-x[i]]>0 and c[x[i]]>0:\n c[t[j]-x[i]] -= 1\n c[x[i]] -= 1\n count+=1\nprint(count)', 'S=input()\ncount=0\ndef sigma(i):\n a=[b for b in range(0,i+1)]\n return sum(a)\nplace=0\nflag=0\nstart=0\nfor i in range(len(S)):\n if S[i]=="B":\n flag=1\n elif S[i]=="W":\n if flag == 1:\n count += 1\n place += i - start\n else:\n start+=1\nans=place-sigma(count-1)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s197911011', 's576069435', 's826363979', 's916936941', 's519370152']
[3884.0, 134900.0, 3884.0, 3884.0, 7528.0]
[26.0, 457.0, 23.0, 22.0, 83.0]
[805, 280, 675, 565, 328]
p03200
u602715823
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import re\n\ns = input()\na = [m.start() for m in re.finditer("W", s)]\n\nans = 0\nfor i, e in enumerate(a):\n ans += e - (i + 1)\n\nprint(ans)\n', 'import re\n\ns = input()\na = [m.start() for m in re.finditer("W", s)]\n\nans = 0\nfor i, e in enumerate(a):\n ans += e - i\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s503000381', 's345352794']
[11624.0, 11624.0]
[95.0, 83.0]
[138, 132]
p03200
u617515020
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S=list(input())\na=[0]*len(S)\ncnt=0\nj=len(S)-1\nfor i in range(len(S)-1,-1,-1):\n if S[i]=='W':\n a[i]=a[j]+1\n j=i\n else:\n a[i]=0\nprint(sum(a))", "S=list(input())\ncnt=0\nans=0\nfor i in range(len(S)-1,-1,-1):\n if S[i]=='W':\n cnt+=1\n else:\n ans+=cnt\n\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s267352592', 's292653551']
[18244.0, 10500.0]
[72.0, 59.0]
[150, 119]
p03200
u675918663
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import re\nimport sys\n\nl = line = next(map(str.strip, sys.stdin))\n\ncount = 0\nprev = None\nwhile prev is None or prev != line:\n prev = line\n count += len(re.findall("BW", line))\n line = line.replace("BW", "WB")\n\nprint(count)\n\nline = l\n\ncount = 0\nnb_bs = 0\nfor i, c in enumerate(line):\n if c == \'W\' and nb_bs > 0:\n count += nb_bs\n elif c == \'B\':\n nb_bs += 1\n\nprint(count)\n', "import sys\n\ndef main(l):\n u = set()\n l = list(sorted(l))\n for i, a in enumerate(reversed(l)):\n searching = (1 << a.bit_length()) - a\n for j, b in enumerate(l[:-i-1]):\n if b == searching and not j in u:\n u.add(j)\n break\n\n return len(u)\n\n\nif __name__ == '__main__':\n input()\n main(map(int, input()))", 'import sys\n\nnbs = list(sorted(map(int, list(sys.stdin)[1].strip().split())))\nused = set()\ncount = 0\n\nfor k in reversed(range(1, 31)):\n p = 1 << k\n j = len(nbs) - 1\n for i, a in enumerate(nbs):\n if i not in used:\n while j > i and (nbs[j] > p - a or j in used):\n j -= 1\n if j <= i:\n break\n if nbs[j] == p - a:\n used.add(i)\n used.add(j)\n count += 1\n\nprint(count)', "import re\nimport sys\n\nline = next(map(str.strip, sys.stdin))\n\ncount = 0\nnb_bs = 0\nfor i, c in enumerate(line):\n if c == 'W' and nb_bs > 0:\n count += nb_bs\n elif c == 'B':\n nb_bs += 1\n\nprint(count)\n"]
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s223087007', 's809462843', 's886983441', 's988095295']
[10272.0, 3500.0, 3444.0, 3760.0]
[2104.0, 18.0, 19.0, 73.0]
[397, 370, 483, 217]
p03200
u681917640
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['from collections import Counter\n\nn = int(input())\nnums = sorted(list(map(int, input().split())), reverse=True)\n\nnum_map = Counter(nums)\n\nanswer = 0\nfor num in nums:\n pair = (1 << (num.bit_length())) - num\n\n if num_map[num] > 0 and num_map[pair]:\n if num == pair and num_map[num] > 1:\n answer += 1\n num_map[num] -= 2\n else:\n answer += 1\n num_map[num] -= 1\n num_map[pair] -= 1\n\nprint(answer)', 's = input()\n \nanswer = 0\nblack_count = 0\nfor i in range(len(s)):\n if s[i] == "B":\n black_count += 1\n else:\n answer += black_count\n \nprint(answer)']
['Runtime Error', 'Accepted']
['s951935162', 's120177445']
[3756.0, 3500.0]
[22.0, 56.0]
[464, 165]
p03200
u695644361
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s=list(input())\nc=i=0\nwhile i<len(s)-1:\n\tt,u=s[i],s[i+1]\n\tif t>=u:i+=1\n\telse:\n\t\tt,u=u,t\n\t\tc+=1\n\t\tif i>1:i-=1\nprint(c)', "s=input()\nr=w=0\nfor c,i in zip(s,range(len(s))):\n\tif c=='W':\n\t\tr+=i-w\n\t\tw+=1\nprint(r)"]
['Time Limit Exceeded', 'Accepted']
['s477447026', 's154719109']
[4840.0, 3500.0]
[2104.0, 77.0]
[117, 85]
p03200
u713914478
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s = input()\nans = 0\ntmp = 0\n#saving the number of black\n#counting the numbers\n\nfor c in s:\n\tif s == "B":\n\t\ttmp += ans\n\telse:\n\t\tans += tmp\n\nprint(ans)', 's = input()\nans = 0\ntmp = 0\n#saving the number of black\n#counting the numbers\n\nfor c in s:\n\tif s == "B":\n\t\ttmp += 1\n\telse:\n\t\tans += tmp\n\nprint(ans)', "\ns = input()\nans = 0\ntmp = 0\n#saving the number of black\nfor c in reversed(s):\n if c == 'W':\n tmp += 1\n else:\n ans += tmp\nprint(ans)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s212721738', 's883087336', 's877638583']
[3500.0, 3500.0, 3500.0]
[40.0, 41.0, 46.0]
[149, 147, 152]
p03200
u730476362
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S = input()\ncounter = 0\n# while True:\n# tmp=S.count('BW')\n# if tmp == 0:\n# print(counter)\n# break\n# else:\n# counter+=tmp\n# S=S.replace('BW','WB')\n\n# i=0\n# while True:\n# tmp = S[i:].find('W')\n# print(S[i:])\n# if tmp == -1:\n# print(counter)\n# break\n# else:\n# counter += tmp\n# i+=1\n\nsum=0\nfor i in range(len(S)):\n if S[i]=='W':\n sum+=i\n counter+=1\nprint(sum-counter)", "S = input()\ncounter = 0\n# while True:\n# tmp=S.count('BW')\n# if tmp == 0:\n# print(counter)\n# break\n# else:\n# counter+=tmp\n# S=S.replace('BW','WB')\n\n# i=0\n# while True:\n# tmp = S[i:].find('W')\n# print(S[i:])\n# if tmp == -1:\n# print(counter)\n# break\n# else:\n# counter += tmp\n# i+=1\n\nsum=0\nfor i in range(len(S)):\n if S[i]=='W':\n sum+=i\n counter+=1\n\nn=counter-1\nminus=n*(n+1)/2\nprint(int(sum-minus))"]
['Wrong Answer', 'Accepted']
['s852320838', 's466621836']
[3500.0, 3500.0]
[74.0, 70.0]
[472, 504]
p03200
u747703115
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['print(TODO)', "s = input()\nr = 0\nc = 0\nfor i in range(len(s)):\n if s[i]=='B':\n c += 1\n else:\n r += c\nprint(r)"]
['Runtime Error', 'Accepted']
['s650044572', 's721798599']
[2940.0, 3500.0]
[17.0, 55.0]
[11, 114]
p03200
u760171369
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["import numpy as np\nS = input()\nb_num = S.count('B')\nw_num = len(S) - b_num\nend = 2**(w_num + 1) - 1\nstart = 0\nfor i in range(len(S)):\n if S[i] == 'W':\n start += np.power(2, i)\nprint(np.log2(start / end))", "import numpy as np\nS = input()\nb_num = S.count('B')\nw_num = len(S) - b_num\nend = 2**(w_num + 1) - 1\nstart = 0\nfor i in range(len(S)):\n if S[i] = 'W':\n start += np.power(2, i)\nprint(np.log2(start / end))", "S = input()\nnum, cnt = 0, 0\nfor k in range(len(S)):\n if S[k] == 'B':\n num += 1\n else:\n cnt += num\nprint(cnt)"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s528722843', 's806449726', 's186152924']
[22788.0, 2940.0, 3500.0]
[1778.0, 17.0, 56.0]
[207, 206, 116]
p03200
u762488523
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["temp=input()\nS=list(temp)\ncounter1=0\ncounter2=0\ncounter3=0 \ni=len(S)-1\n\nwhile True:\n if S[i-1]=='B' and S[i]=='W':\n S[i-1]='W'\n S[i]='B'\n counter1 +=1\n i -=1\n if i ==0:\n if counter1==counter2:\n break\n counter2=counter1\n for j in range(len(S)):\n if S[j]=='W':\n counter3 =j\n j -=1\n i= counter3\n\nprint(counter1)\n", "temp=input()\nS=list(temp)\ncounter1=0\ncounter2=0\ncounter3=0 \ni=0\n\nwhile True:\n if S[i]=='B' and S[i+1]=='W':\n S[i]='W'\n S[i+1]='B'\n counter1 +=1\n i +=1\n if i ==len(S)-1:\n if counter1==counter2:\n break\n counter2=counter1\n counter3+=1\n i=counter3\n\nprint(counter1)\n", "S=input()\ncounter=0\nresult = 0\n\nfor i in range(len(S)):\n if S[i]=='B':\n counter+=1\n else:\n result +=counter\n\nprint(result)"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s109613848', 's836506428', 's561929859']
[4840.0, 4840.0, 3500.0]
[2104.0, 2104.0, 60.0]
[415, 330, 142]
p03200
u766684188
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["import sys\ninput=sys.stdin.readline\nS=input()\nl=len(S)\nw_idx=0\ncnt=0\nfor i in range(n):\n if S[l]=='W':\n cnt+=i-w_idx\n w_idx+=1\nprint(cnt)", "import sys\nS=sys.stdin.readline()\nl=len(S)\nw_idx=0\ncnt=0\nfor i in range(l):\n if S[i]=='W':\n cnt+=i-w_idx\n w_idx+=1\nprint(cnt)"]
['Runtime Error', 'Accepted']
['s807865689', 's434892745']
[3316.0, 3372.0]
[18.0, 71.0]
[154, 142]
p03200
u771532493
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S=input()[::-1]\nans,tmp=0,0\nfor i in S:\n if i=='W'\n tmp+=1\n else:\n ans+=tmp\nprint(ans)", "S=list(input())\na=0\nfor i in range(len(S):\n if S[i]=='W':\n a+=L[:i].count('B')\nprint(a)\n \n ", "S=input()[::-1]\nans,tmp=0,0\nfor i in S:\n if i=='W':\n tmp+=1\n else:\n ans+=tmp\nprint(ans)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s044857870', 's393172506', 's612956572']
[2940.0, 2940.0, 3500.0]
[18.0, 17.0, 44.0]
[94, 101, 95]
p03200
u777028980
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['hoge=input()\nans=0\ncount=0\nwhite=0\nfor i in hoge:\n \n if(i=="W"):\n ans+=count - white\n white+=1\n count+=1\n \nprint(count)', 'hoge=input()\nans=0\ncount=0\nwhite=0\nfor i in hoge:\n \n if(i=="W"):\n ans+=count - white\n white+=1\n \n count+=1\n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s400602953', 's405500135']
[3500.0, 3500.0]
[75.0, 78.0]
[129, 132]
p03200
u778814286
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['\n###template###\nimport sys\ndef input(): return sys.stdin.readline().rstrip()\nimport heapq\nINF = float("inf")\ndef mi(): return map(int, input().split())\ndef ii(): return int(input())\n###template###\n\n\nS = ii()\n\nprev = 0\nsum = 0\nfor c in S:\n if c == \'B\':\n prev += 1\n else:\n sum += prev\n \nprint(sum)', '###template###\nimport sys\ndef input(): return sys.stdin.readline().rstrip()\nimport heapq\nINF = float("inf")\ndef mi(): return map(int, input().split())\ndef ii(): return int(input())\n###template###\n\n\nS = input()\n\nprev = 0\nsum = 0\nfor c in S:\n if c == \'B\':\n prev += 1\n else:\n sum += prev\n \nprint(sum)\n']
['Runtime Error', 'Accepted']
['s941509041', 's200814216']
[3628.0, 3628.0]
[19.0, 46.0]
[306, 309]
p03200
u785578220
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s = input() + "lllllll"\nn = len(s)\ntt = 0\nts = 0\nfor i in range(n-3):\n if s[i] == "B" and s[i+1] == "W":\n tt+=1\n if s[i+2] == "B" and s[i+3] == "W":tt+=1\n for j in range(1,i):\n if i - j >= 0 and s[i-j] =="B":tt+=1\n else:break\n for j in range(1,n-i):\n if i + j <= n-2 and s[i+j+1] =="W":tt+=1\n else:break\n i = j-1\nprint(tt)', 'a = input()\nb = 0\nbt = 0\nw = 0\nwt = 0\nfor i in range(len(a)):\n if a[i] == "B":bt = 1\n if bt == 1 and a[i] == "B":b+=1\n if a[i] =="W":\n w+=b\n wt +=1\nprint(w)']
['Wrong Answer', 'Accepted']
['s455443110', 's267759425']
[3500.0, 3500.0]
[164.0, 111.0]
[404, 179]
p03200
u791110052
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['r = input().split()\n\ns = 0\n\nfor i in range(len(r)):\n if r[i] == "W":\n s += i\n\nprint(s)', 'r = input()\n\ns = 0\nc = 0\n\nfor i in range(len(r)):\n if r[i] == "W":\n s += i - c\n c += 1\n\nprint(s)']
['Wrong Answer', 'Accepted']
['s420603454', 's156968818']
[9020.0, 9268.0]
[32.0, 69.0]
[90, 103]
p03200
u798316285
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['s=input()\na=0\nc=0\nfor i in range(len(s)):\n if s[i]=="W":\n a+=i\n c+=1\nb=c*(c-1)//2\nprint(a-c)', 's=input()\na=0\nc=0\nfor i in range(len(s)):\n if s[i]=="W":\n a+=i\n c+=1\nb=c*(c-1)//2\nprint(a-b)']
['Wrong Answer', 'Accepted']
['s364280044', 's256319596']
[3500.0, 3500.0]
[69.0, 72.0]
[99, 99]
p03200
u802234211
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["othello = input()\nbef = 0\nsumall = 0\nsumelse = 0\n\nfor i in range(len(othello)):\n sumall += i\n if(othello[i] == 'B'):\n bef += i\n count += 1\n\ncount = 0\nfor i in range(len(othello)-count):\n sumelse += i\n\naft = sumall - sumelse\n\nprint(aft - bef)", "othello = input()\nbef = 0\nsumall = 0\ncount = 0\n\nfor i in range(len(othello)):\n sumall += i\n if(othello[i] == 'B'):\n bef += i\n count += 1\n\nsumelse = 0\nfor i in range(len(othello)-count):\n sumelse += i\n\naft = sumall - sumelse\n\nprint(aft - bef)"]
['Runtime Error', 'Accepted']
['s125390748', 's976619393']
[9232.0, 9092.0]
[67.0, 84.0]
[264, 264]
p03200
u805668940
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = list(input())\nl = len(s)\nn, psum = 0, 0\nfor i in range(l):\n if s[i] == 'W':\n n += 1\n psum += i\n\nnsum = n*(n + 1)/2\n\nprint(int(psum - nsum))", "s = list(input())\nl = len(s)\nn, psum = 0, 0\nfor i in range(l):\n if s[i] == 'W':\n n += 1\n psum += i\n\nnsum = (n*(n - 1))/2\n\nprint(int(psum - nsum))"]
['Wrong Answer', 'Accepted']
['s136413997', 's357682734']
[4840.0, 4840.0]
[76.0, 69.0]
[160, 162]
p03200
u807772568
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["a = list(input())\n\nsu = 0\ndd = 0\nco = 0\nfor i in range(len(a)-1,-1,-1):\n\tif a[i] == 'B':\n\t\tco += 1\n\tif co >= 1:\n\t\tif a[i] == 'W':\n\t\t\tsu += (len(a)-1 - i) - dd\n\t\t\tdd += 1\nif dd != 0:\n\tprint(su+dd-1)\nelse:\n\tprint(su+dd)\n\n", "a = list(input())\n\nsu = 0\ndd = 0\nco = 0\nfor i in range(len(a)-1,-1,-1):\n\tif a[i] == 'B':\n\t\tco += 1\n\tif co >= 1:\n\t\tif a[i] == 'W':\n\t\t\tsu += (len(a)-1 - i) - dd\n\tif a[i] == 'W':\n\t\tdd += 1\nif su == 0:\n\tprint(0)\nelse:\n\tprint(su+ (len(a) - dd))\n\n", "a = list(input())\n\nsu = 0\ndd = 0\nco = 0\nfor i in range(len(a)-1,-1,-1):\n\tif a[i] == 'W':\n\t\tco += 1\n\tif co >= 1:\n\t\tif a[i] == 'B':\n\t\t\tsu += (len(a)-1 - i) - dd\n\telse:\n\t\tif a[i] == 'B':\n\t\t\tdd += 1\nprint(su)\n", "a = list(input())\n\nsu = 0\ndd = 0\nco = 0\nfor i in range(len(a)):\n\n\t\tif a[i] == 'W':\n\t\t\tsu += i - dd\n\t\t\tdd += 1\n\nprint(su)\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s184845168', 's283260908', 's847147863', 's687209945']
[4840.0, 4840.0, 4840.0, 4840.0]
[106.0, 126.0, 104.0, 71.0]
[219, 241, 205, 121]
p03200
u813174766
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s=input()\nc=0\na=0\nfor i in s:\n if i=='B':\n c+=1\n else:\n a+=c\nprint(ans)", "s=input()\nc=0\na=0\nfor i in s:\n if i=='B':\n c+=1\n else:\n a+=c\nprint(a)"]
['Runtime Error', 'Accepted']
['s887372114', 's758597862']
[9200.0, 9228.0]
[51.0, 52.0]
[79, 77]
p03200
u818349438
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s = input()\nn =len(s)\nres = 0\nans = 0\nfor i in range(n):\n if s[i] == 'B':\n res+=1AC\n else:\n ans+=res\n\n\nprint(ans)", "s = input()\nn =len(s)\nres = 0\nans = 0\nfor i in range(n):\n if s[i] == 'B':\n res+=1\n else:\n ans+=res\n\n\nprint(ans)"]
['Runtime Error', 'Accepted']
['s298612615', 's633246469']
[2940.0, 3500.0]
[17.0, 59.0]
[134, 132]
p03200
u820351940
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['import re\nimport numpy as np\ns = input()\nwlen = list(map(len, re.findall(r"(W+)", s)))\nprint(np.cumsum(wlen[::-1]).sum())\n', 's = input()\n\ncnt = 0\nresult = 0\nfor v in reversed(s):\n if v == "W":\n cnt += 1\n else:\n result += cnt\nprint(result)\n\n']
['Wrong Answer', 'Accepted']
['s412363688', 's376559652']
[14668.0, 3500.0]
[166.0, 44.0]
[122, 135]
p03200
u831274245
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
['S = input().strip()\n\ncount = 0\nsuma = 0\nfor i in S:\n if i=="W":\n suma += count\n else:\n count += 1\n', 'S = input().strip()\n\ncount = 0\nsuma = 0\nfor i in S:\n if i=="W":\n suma += count\n else:\n count += 1\nprint(suma)']
['Wrong Answer', 'Accepted']
['s051858594', 's375611718']
[3500.0, 3500.0]
[46.0, 45.0]
[106, 117]
p03200
u840813237
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["s=input()\nn=len(s)\ncnt=0\nfor i in range(n):\n if s[i]=='W':\n cnt+=1\nans=0\nfor i in range(n):\n if s[i]=='W':\n cnt--\n else:\n ans+=cnt\nprint(ans)\n \n ", "s=input()\nn=len(s)\ncnt=0\nfor i in range(n):\n if s[i]=='W':\n cnt+=1\nans=0\nfor i in range(n):\n if s[i]=='W':\n cnt-=1\n else:\n ans+=cnt\nprint(ans)\n \n\n"]
['Runtime Error', 'Accepted']
['s616920133', 's495435314']
[2940.0, 3500.0]
[18.0, 84.0]
[158, 158]
p03200
u849433300
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["def main():\n s = input()\n start = forward = backward = 0\n intervals = []\n \n if len(s) > 3:\n for i in range(1, len(s)):\n if s[start] != s[i]:\n intervals.append((start, i-1, s[start]))\n if s[start] == 'B':\n forward += 1\n else:\n backward += 1\n start = i\n intervals.append((start, len(s)-1, s[start]))\n print(len(intervals))\n \n elif s =='WBW' or 'BWB' or 'BW':\n print(1)\n \n else:\n print(0)\nmain()", "def main():\n S=input()\n b_n = 0; ans = 0\n for s in S:\n if s=='B': b_n += 1\n else: ans += b_n\n print(ans)\nmain()"]
['Wrong Answer', 'Accepted']
['s324193239', 's817044549']
[17836.0, 3500.0]
[77.0, 32.0]
[651, 137]
p03200
u851469594
2,000
1,048,576
There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed.
["S = list(input())\ncnt = 0\n\nfor i in range(len(S)-1):\n if S[i] == 'B' and S[i+1] == 'W':\n S[i] = 'W'\n S[i+1] = 'B'\n cnt += 1\n # print(S)\n j = 1\n while True:\n if S[i-j] == 'B':\n S[i-j] = 'W'\n S[i-j+1] = 'B'\n cnt += 1\n j += 1\n # print(S)\n else :\n break\n \nprint(cnt)", "S = list(input())\ncnt = 0\nans = 0\n\nfor i in range(len(S)):\n if S[i] =='W':\n ans += i - cnt\n cnt += 1\n i += 1\nprint(ans)"]
['Runtime Error', 'Accepted']
['s422392576', 's308119778']
[4840.0, 4840.0]
[2104.0, 83.0]
[430, 139]