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
p02596
u955255448
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
['ans = -1\nif K in [2,5]:\n pass\nelse:\n num = 7\n ans = 0\n while True:\n ans += 1\n if num % K == 0:\n break\n else:\n num = (num * 10 + 7)%K\nprint(ans)', 'K = int(input())\nans = -1\nif K%2 == 0:\n pass\nelif K%5 == 0:\n pass\nelse:\n num = 7\n ans = 0\n while True:\n ans += 1\n if num % K == 0:\n break\n else:\n num = (num * 10 + 7)%K\nprint(ans)']
['Runtime Error', 'Accepted']
['s129594112', 's735640349']
[9004.0, 9116.0]
[26.0, 237.0]
[198, 237]
p02596
u956547804
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
['k=int(input())\nif k%2==0 k%5==0:\n print(-1)\n exit()\na=0\nfor i in range(k):\n a=(a*10+7)%k\n if a==0:\n print(i+1)\n exit()', 'k=int(input())\nif k%2==0 or k%5==0:\n print(-1)\n exit()\na=0\nfor i in range(k):\n a=(a*10+7)%k\n if a==0:\n print(i+1)\n exit()']
['Runtime Error', 'Accepted']
['s552794738', 's338806334']
[9008.0, 9180.0]
[24.0, 188.0]
[144, 147]
p02596
u957799665
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
['k = int(input())\ni = 0\ns = 0\nans = -1\n\nfor z in range(k):\n i += 1\n #s = (7 + 10*s) % k\n s = 7 + 10*s\n if s % k != 0:\n s = s % k\n else:\n ans = i\n\nprint(i)\n', 'b=7\nd=0\ne =-1\ni=1\na = int(input())\nwhile True:\n d = 7 + 10*d\n print(d)\n if a % 2 == 0:\n print(e)\n break\n elif d % a ==0:\n print(i)\n break\n i +=1', 'k = int(input())\ni = 0\ns = 0\nans = -1\n\nfor z in range(k):\n i += 1\n s = 7 + 10*s\n if s % k != 0:\n s = s % k\n else:\n ans = i\n break\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s442645837', 's770256332', 's875243061']
[9056.0, 33996.0, 9024.0]
[275.0, 2259.0, 276.0]
[183, 187, 174]
p02596
u958869885
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
['k = int(input())\nif k % 2 == 0 or k % 5 == 0:\n print(-1)\nelse:\n myconst = 7 % k\n cnt = 1\n while True:\n if not myconst:\n print(cnt)\n break\n\t else:\n myconst = ((10 * myconst) + 7) % k\n cnt += 1\n \n \n', "k = int(input())\nif k % 2 == 0 or k % 5 == 0:\n print(-1)\nelse:\n mystr = '7'\n while True:\n if int(mystr, 10) % k == 0:\n print(len(mystr))\n break\n\telse:\n mystr += '7'\n \n ", 'k = int(input())\nif k % 2 == 0 or k % 5 == 0:\n print(-1)\nelse:\n myconst = 7 % k\n cnt = 1\n while True:\n if not myconst:\n print(cnt)\n break\n else:\n myconst = ((10 * myconst) + 7) % k\n cnt += 1\n \n \n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s740875397', 's888591764', 's135537996']
[9028.0, 8856.0, 9036.0]
[29.0, 25.0, 191.0]
[227, 194, 228]
p02596
u966207392
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
["def make_divisors(n):\n lower_divisors , upper_divisors = [], []\n i = 1\n while i*i <= n:\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n i += 1\n return lower_divisors + upper_divisors[::-1]\n\nK = int(input())\nfor i in range(1, 14):\n if K % 2 == 0:\n print('-1')\n break\n lis=[]\n lis.append(make_divisors(int('7'*i)))\n if K in lis:\n print(i)\n break\nelse:\n print(K-1)", "def make_divisors(n):\n lower_divisors , upper_divisors = [], []\n i = 1\n while i*i <= n:\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n i += 1\n return lower_divisors + upper_divisors[::-1]\n\nK = int(input())\nfor i in range(1, 14):\n if K % 2 == 0:\n print('-1')\n break\n lis=make_divisors(int('7'*i))\n if K in lis:\n print(i)\n break\n print(K-1)", "def make_divisors(n):\n lower_divisors , upper_divisors = [], []\n i = 1\n while i*i <= n:\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n i += 1\n return lower_divisors + upper_divisors[::-1]\n\nK = int(input())\nfor i in range(1, 20):\n if K % 2 == 0:\n print('-1')\n break\n lis=[]\n lis.append(make_divisors(int('7'*i)))\n if K in lis:\n print(i)\n break\nelse:\n print(K-1)", "import sys\nK = int(input())\nif K % 2 == 0 or K % 5 == 0:\n print('-1')\n sys.exit()\n\nA = 0\nfor i in range(K):\n A = (10 * A + 7) % K\n if A == 0:\n print(i+1)\n break"]
['Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Accepted']
['s211588765', 's325925723', 's471977856', 's112147844']
[9064.0, 9184.0, 9092.0, 9036.0]
[600.0, 586.0, 2206.0, 186.0]
[508, 483, 508, 186]
p02596
u975997984
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
["K = int(input())\na = 0\nn = 0\nout = '-1'\nfor _ in range(K):\n a += 7 * (10 ** n)\n if a % K == 0:\n out = n + 1\n break\nprint(out)\n", "K = int(input())\nres = '-1'\na = 0\nfor n in range(K):\n a += 7*(10**n)\n if a%K==0:\n res = n+1\nprint(res)", 'K = int(input())\na = 0\nn = 0\nout = -1\nfor _ in range(K):\n a += 7 * (10 ** n)\n if a % K == 0:\n out = n + 1\n break\nreturn print(out)\n', 'K = int(input())\na = 0\nn = 0\nout = -1\nfor _ in range(K):\n a += 7 * (10 ** n)\n if a % K == 0:\n out = n + 1\n break\n\nprint(out)\n', 'def main():\n counts = 0\n target = 0\n while True:\n if k % 2 == 0:\n print(-1)\n break\n target += 7 * (10 ** count)\n if taget % k == 0:\n print(count+1)\n break\n count += 1', 'K = int(input())\na = 0\nn = 0\nout = -1\nwhile True:\n a += 7 * (10 ** n)\n if a % K == 0:\n out = n + 1\n print(out)\n break\n ', "K = int(input())\nans = '-1'\nmod = 7%K\npath = [mod]\nfor i in range(1,K+1):\n if mod == 0:\n ans = i\n break\n mod = (mod*10 + 7)%K\n path.append(mod)\n if mod == path[0]:\n ans = '-1'\n break\nprint(ans)\n"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s018296495', 's273333960', 's383876992', 's572474279', 's605129108', 's922419092', 's743283088']
[9184.0, 9176.0, 9016.0, 9096.0, 9000.0, 9068.0, 48640.0]
[194.0, 2206.0, 27.0, 213.0, 27.0, 172.0, 307.0]
[134, 107, 139, 133, 201, 131, 210]
p02596
u977104016
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
["k=input()\nif int(k)%2==0:\n print(-1)\nelse:\n s='7'\n flag=0\n for _ in range(12):\n if int(s)%int(k)==0:\n flag=1\n print(len(s))\n break\n s=s+'7'\n if flag==0 and k[-1]=='3':\n print(int(k)-1)\n else:\n print(-1)", 'k=input()\nif int(k)%2==0:\n print(-1)\nelse:\n s=7\n count=1\n flag=0\n while 1:\n if s%int(k)==0:\n print(count)\n break\n if count>int(k):\n print(-1)\n break\n s=(s%int(k))*10+7\n count+=1\n ']
['Wrong Answer', 'Accepted']
['s153331304', 's152372278']
[9120.0, 9152.0]
[34.0, 657.0]
[281, 269]
p02596
u987155832
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
['cnt = 1\nmod = 7\nk = int(input())\n\nfor i in range(k):\n if mod % k == 0:\n break\n cnt += 1\n mod = (mod * 10 * 7) % k\n\nif mod % k == 0:\n print(cnt)\nelse:\n print(-1)\n', 'cnt = 1\nmod = 7\nk = int(input())\n\nfor i in range(k):\n if mod % k == 0:\n break\n cnt += 1\n mod = (mod * 10 * 7) % k\n\nif mod % k == 0:\n print(cnt)\nelse:\n print(-1)\n', 'cnt = 1\nmod = 7\nk = int(input())\nfor i in range(k):\n if mod % k == 0:\n break\n cnt += 1\n mod = (mod * 10 + 7) % k\n\nif mod % k == 0:\n print(cnt)\nelse:\n print(-1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s357718308', 's388277751', 's507503064']
[9112.0, 9116.0, 9120.0]
[253.0, 256.0, 277.0]
[169, 183, 182]
p02596
u995163736
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
['k = int(input())\nif k % 2 == 0:\n print(-1)\nnana = 0\nans = 0\nprint(len(k))\nwhile True:\n nana += (10**ans) * 7\n #print(nana)\n if nana % k == 0:\n print(ans + 1)\n break\n ans += 1', 'k = int(input())\nif k % 2 == 0:\n print(-1)\nelif k in [1,7]:\n \tprint(1)\nelse:\n amari = [7]\n tmp = 7\n for i in range(k):\n tmp = (tmp * 10) % k\n if tmp != 7:\n amari.append(tmp%k)\n else:\n break\n amari = amari * ((k//len(amari)) +1)\n\n ans = amari[0]\n for i in range(1, k+1):\n ans += amari[i]\n if ans % k == 0:\n print(i+1)\n break\n else:\n print(-1)']
['Runtime Error', 'Accepted']
['s893885477', 's212326172']
[9140.0, 63884.0]
[27.0, 525.0]
[185, 416]
p02596
u999799597
2,000
1,048,576
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead.
['limit = pow(10, 7)\nK = int(input())\nnum = "7"\nif K % 2 == 0 or K % 5 == 0:\n print (-1)\nelse:\n total = 0\n flag = False\n for i in range(limit + 1):\n total = (total * 10 + 7) % K\n if total == 0:\n flag = True\n break\n if flag:\n print (i)\n else:\n print(-1)', 'limit = pow(10, 7)\nK = int(input())\nnum = "7"\nif K % 2 == 0 or K % 5 == 0:\n print (-1)\nelse:\n total = 0\n flag = False\n for i in range(1, limit + 1):\n total = (total * 10 + 7) % K\n if total == 0:\n flag = True\n break\n if flag:\n print (i)\n else:\n print(-1)']
['Wrong Answer', 'Accepted']
['s654211991', 's559311025']
[9008.0, 9108.0]
[180.0, 194.0]
[318, 321]
p02597
u021849254
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n=int(input())\na=list(input())\nc=a.count("W")\nb=a[:n-c]\nd=b.count("W")\nprint(d)\nprint(b)', 'n=int(input())\na=list(input())\nc=a.count("W")\nb=a[:n-c]\nd=b.count("W")\nprint(d)\n']
['Wrong Answer', 'Accepted']
['s527508144', 's492342537']
[13868.0, 11876.0]
[54.0, 40.0]
[88, 80]
p02597
u021916304
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\nfrom collections import Counter\n\nn = ii()\ns = input()\n\nd = Counter(s)\nnum = d['R']\nans = num\nwcnt = 0\nrcnt = 0\nfor i in s:\n print(i)\n if i == 'W':\n wcnt += 1\n else:\n if num - 1 > wcnt or wcnt == 0:\n ans -= 1\n num -= wcnt\n wcnt = 0\n else:\n break\nprint(ans)\n", "def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\nfrom collections import Counter\n\nn = ii()\ns = input()\n\nd = Counter(s)\nnum = d['R']\nans = num\nwcnt = 0\nrcnt = 0\nfor i in s:\n# print(i)\n if i == 'W':\n wcnt += 1\n else:\n if num - 1 >= wcnt or wcnt == 0:\n ans -= 1\n num -= wcnt+1\n wcnt = 0\n if num == 0:\n break\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s379981727', 's475691098']
[9696.0, 9776.0]
[133.0, 98.0]
[449, 459]
p02597
u026788530
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\ns = [_ for _ in input()]\n\nl, r = 0, n-1\nif not('R' in s):\n print(0)\n exit()\n\nif not('W' in s):\n print('0')\n exit()\n\nans = 0\nwhile 1:\n while s[l] == 'R':\n l += 1\n\n while s[r] == 'W' and l <= r:\n r -= 1\n\n s[l] = 'r'\n s[r] = 'w'\n l += 1\n r -= 1\n\n # print(s)\n if l > r:\n if l == r:\n ans += 1\n break\n # print(l, r)\n ans += 1\nprint(ans)\n# print(s)\n", "n = int(input())\ns = [_ for _ in input()]\n\nl, r = 0, n-1\nif not('R' in s):\n print(0)\n exit()\n\nif not('W' in s):\n print('0')\n exit()\n\nans = 0\nwhile 1:\n while s[l] == 'W':\n l += 1\n\n while s[r] == 'R' and l < r:\n r -= 1\n\n ans += 1\n\n if l >= r:\n break\n\n l += 1\n r -= 1\nprint(ans)\n", 'n = int(input())\ns = [_ for _ in input()]\n\nl, r = 0, n-1\nif not(\'R\' in s):\n print(0)\n exit()\n\nif not(\'W\' in s):\n print(\'0\')\n exit()\n\nans = 0\nwhile 1:\n while s[l] == "R":\n l += 1\n while s[r] == "W" and l != r:\n r -= 1\n\n if l != r:\n s[l], s[r] = s[r], s[l]\n ans += 1\n # print(s)\n if l == r:\n break\n\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s578625284', 's667817210', 's425851627']
[11024.0, 11012.0, 11000.0]
[72.0, 66.0, 96.0]
[440, 327, 374]
p02597
u032798323
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['import sys\nN = int(input())\nc = input()\nans = 0\nexchange = 0\nfor i in range(N):\n if c[i] == "W":\n exchange = i\n break\nelse:\n print(0)\n sys.exit()\n\nfor i in range(N):\n if N-1-i >exchange:\n if c[-(i+1)] =="R":\n c = c[:exchange]+"R"+c[exchange+1:]\n c = c[:-(i+1)]+"W"+c[(i+1)+1:]\n ans += 1\n for k in range(exchange+1,N):\n if c[i] == "W":\n exchange = k\n break\n else:\n break\n \nprint(ans)', 'import sys\nN = int(input())\nc = input()\nans = 0\nexchange = 0\nfor i in range(N):\n if c[i] == "W":\n exchange = i\n break\nelse:\n print(0)\n sys.exit()\n\nfor i in range(N):\n \n # print("exchange=",exchange)\n # print("c=",c)\n if N-i < exchange:\n if c[-(i+1)] =="R":\n # c = list(c)\n # c[exchange] = "R"\n # c[-(i+1)] = "W"\n # c = "".join(c)\n c = c[:exchange]+"R"+c[exchange+1:]\n print("newc=",c)\n c = c[:-(i+1)]+"W"+c[N-i:]\n # print("newc=",c)\n ans += 1\n for k in range(exchange+1,N):\n if c[k] == "W":\n exchange = k\n break\n else:\n break\n else:\n break\nprint(ans)', 'import sys\nN = int(input())\nc = input()\nans = 0\nexchange = 0\nfor i in range(N):\n if c[i] == "W":\n exchange = i\n break\nelse:\n print(0)\n sys.exit()\n\nfor i in range(N//2):\n \n # print("exchange=",exchange)\n # print("c=",c)\n if c[-(i+1)] =="R":\n # c = list(c)\n # c[exchange] = "R"\n # c[-(i+1)] = "W"\n # c = "".join(c)\n c = c[:exchange]+"R"+c[exchange+1:]\n print("newc=",c)\n c = c[:-(i+1)]+"W"+c[N-i:]\n # print("newc=",c)\n ans += 1\n for k in range(exchange+1,N):\n if c[k] == "W":\n exchange = k\n break\n else:\n break\n \nprint(ans)', 'import sys\nN = int(input())\nc = input()\nans = 0\nexchange = 0\nfor i in range(N):\n if c[i] == "W":\n exchange = i\n break\nelse:\n print(0)\n sys.exit()\n\nfor i in range(N):\n if N-i > exchange:\n if c[-(i+1)] =="R":\n # c = list(c)\n # c[exchange] = "R"\n # c[-(i+1)] = "W"\n # c = "".join(c)\n # c = c[:exchange]+"R"+c[exchange+1:]\n # print("newc=",c)\n # c = c[:-(i+1)]+"W"+c[N-i:]\n # print("newc=",c)\n ans += 1\n for k in range(exchange+1,N-(i+1)):\n if c[k] == "W":\n exchange = k\n break\n else:\n break\n else:\n break\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s005221030', 's167020004', 's762359814', 's406374169']
[1205808.0, 9512.0, 138524.0, 9480.0]
[2223.0, 41.0, 968.0, 97.0]
[541, 812, 709, 744]
p02597
u039860745
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nc = input()\nred_to_white = c.count("R")\nans = red_to_white\nwhile_to_red = 0\n\nfor i in c:\n if i == "W":\n while_to_red += 1 \n else:\n red_to_white -= 1\n ans = min(ans,max(while_to_red,red_to_white))\n print(while_to_red)\n print(red_to_white)\n\nprint(ans)', 'N = int(input())\nc = input()\nred_to_white = c.count("R")\nans = red_to_white\nwhile_to_red = 0\n\nfor i in c:\n if i == "W":\n while_to_red += 1 \n else:\n red_to_white -= 1\n ans = min(ans,max(while_to_red,red_to_white))\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s108184108', 's366933444']
[9480.0, 9400.0]
[229.0, 111.0]
[295, 247]
p02597
u043035376
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['\nif w_count >= r_count:\n print(w_count)\nelse:\n print(w_count - right_w_count)\n', 'n = int(input())\n\nc = list(input())\n\nw_count = c.count("W")\nr_count = c.count("R")\n\nright_center = c[r_count:]\nright_w_count = right_center.count("W")\n\nprint(w_count - right_w_count)\n']
['Runtime Error', 'Accepted']
['s025259358', 's291154743']
[9004.0, 12064.0]
[32.0, 42.0]
[84, 183]
p02597
u048238198
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
[' \n import sys\n import math\n \n sys.setrecursionlimit(10 ** 8)\n ini = lambda: int(sys.stdin.readline())\n inm = lambda: map(int, sys.stdin.readline().split())\n inl = lambda: list(inm())\n ins = lambda: sys.stdin.readline().rstrip()\n debug = lambda *a, **kw: print("\\033[33m", *a, "\\033[0m", **dict(file=sys.stderr, **kw))\n \n N = ini()\n c = input()\n \n R = c.count(\'R\')\n left = c[:R]\n ans = left.count(\'W\')\n \n print(ans)\n', '\nimport sys\nimport math\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninm = lambda: map(int, sys.stdin.readline().split())\ninl = lambda: list(inm())\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print("\\033[33m", *a, "\\033[0m", **dict(file=sys.stderr, **kw))\n\nN = ini()\nc = input()\n\nR = c.count(\'R\')\nleft = c[:R]\nans = left.count(\'W\')\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s120244397', 's900324630']
[9008.0, 9428.0]
[25.0, 28.0]
[471, 452]
p02597
u058259032
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = list(input())\ncnt = 0\n\nfor i in range(n):\n if c[i] == 'W':\n for j in range(n-1,0,-1 ):\n if c[j] == 'R':\n if i < j:\n c[i] = 'R'\n c[j] = 'W'\n cnt += 1\n print(i, j)\n print(c)\n break\nprint(cnt)", "n = int(input())\nc = input()\ncnt = 0\nans = 0\n\nfor i in range(n):\n if c[i] == 'R':\n cnt += 1\n \nfor j in range(cnt):\n if c[j] == 'W':\n ans += 1\n \nprint(ans)"]
['Runtime Error', 'Accepted']
['s750888135', 's251162017']
[141216.0, 9384.0]
[2206.0, 68.0]
[356, 184]
p02597
u060793972
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n=int(input())\ns=input()\nl=[0]\nfor i in range(n):\n l.append(l[i]+(s[i]=="R"))\nans=n\nprint(l)\nfor i in range(n+1):\n ans=min(ans,abs(l[i]-i)+abs(l[-1]-l[i]))\n #print(ans,i)\n if i==l[-1]:\n ans=min(ans,abs(l[i]-i))\n #print(ans)\nprint(ans)', 'n=int(input())\ns=input()\nl=[0]\nfor i in range(n):\n l.append(l[i]+(s[i]=="R"))\nans=n\n#print(l)\nfor i in range(n+1):\n ans=min(ans,abs(l[i]-i)+abs(l[-1]-l[i]))\n #print(ans,i)\n if i==l[-1]:\n ans=min(ans,abs(l[i]-i))\n #print(ans)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s191235200', 's156384660']
[19896.0, 17080.0]
[197.0, 173.0]
[260, 262]
p02597
u068844030
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nc = input()\nlists = list(c)\ncnt = 0\nwhile 1:\n if lists[cnt] == "W":\n cnt += 1\n if cnt == len(lists):\n break\n else:\n break\nnumber = 0\nfor i in range(len(lists) - cnt):\n if lists[i + cnt] == "W":\n number += 1\nprint(number)', 'n = int(input())\nc = input()\nlists = list(c)\ncnt = 0\nwhile 1:\n if lists[cnt] == "W":\n cnt += 1\n else:\n break\nnumber = 0\nfor i in range(len(lists) - cnt):\n if lists[i + cnt] == "W":\n number += 1\nprint(number)\n', 'n = int(input())\nc = input()\nlists = list(c)\ncnt = 0\nwhile 1:\n if lists[cnt] == "W":\n cnt += 1\n else:\n break\nnumber = 0\nfor i in range(len(lists) - cnt):\n if lists[i + cnt] == "W":\n number += 1\nprint(number)\n', 'n = int(input())\nc = input()\nlists = list(c)\ncnt = 0\n\nfor i in range(len(lists)):\n if lists[i] == "R":\n cnt += 1\nchange = 0\nfor i in range(cnt):\n if lists[i] == "W":\n change += 1\nprint(change)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s312324233', 's419331499', 's744024586', 's729785507']
[10772.0, 10764.0, 10628.0, 10676.0]
[68.0, 62.0, 64.0, 69.0]
[285, 238, 238, 212]
p02597
u072717685
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import sys\nsys.setrecursionlimit(10**6)\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ndef main():\n n = int(input())\n a = input()\n\n if not 'WR' in a:\n print(0)\n else:\n rightmostW = a.rfind('WR')\n wnum = a[rightmostW:].count('R')\n print(wnum + 1)\n\nif __name__ == '__main__':\n main()\n", "import sys\nsys.setrecursionlimit(10**6)\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ndef main():\n n = int(input())\n a = input()\n\n if not 'WR' in a:\n print(0)\n else:\n rightmostW = a.find('WR')\n wnum = a[rightmostW+2:].count('R')\n print(wnum)\n\nif __name__ == '__main__':\n main()", "import sys\nsys.setrecursionlimit(10**6)\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nfrom math import ceil\ndef main():\n n = int(input())\n a = list(input())\n\n if not 'WR' in a:\n print(0)\n sys.exit()\n r = 0\n rnum = a.count('R')\n while True:\n if 'W' in a[:rnum]:\n t1 = a[:rnum].index('W')\n t2 = a[rnum:].index('R')\n a[t1] = 'R'\n a[t2+rnum] = 'W'\n r += 1\n else:\n break\n print(r)\n\nif __name__ == '__main__':\n main()\n", "import sys\nsys.setrecursionlimit(10**6)\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nfrom math import ceil\ndef main():\n n = int(input())\n a = list(input())\n\n if not 'WR' in a:\n print(0)\n sys.exit()\n r = 0\n rnum = a.count('R')\n while True:\n if 'W' in a[:rnum]:\n t1 = a[:rnum].index('W')\n t2 = a[rnum:].index('R')\n a[t1] = 'R'\n a[t2+rnum] = 'W'\n r += 1\n else:\n break\n print(r)\n\nif __name__ == '__main__':\n main()", "read = sys.stdin.read\nfrom collections import deque\ndef main():\n n = int(input())\n a = input()\n if not 'WR' in a:\n print(0)\n sys.exit()\n a = list(a)\n rnum = a.count('R')\n r = 0\n for i1 in range(rnum):\n r += a[i1] == 'W'\n for j1 in range(n - rnum):\n r += a[rnum + j1] == 'R'\n\n r = r // 2\n print(r)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nsys.setrecursionlimit(10**6)\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ndef main():\n n = int(input())\n a = input()\n\n if not 'WR' in a:\n print(0)\n else:\n rightmostW = a.rfind('RW')\n wnum = a[:rightmostW+1].count('W')\n print(wnum)\n\nif __name__ == '__main__':\n main()\n", "import sys\nsys.setrecursionlimit(10**6)\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ndef main():\n n = int(input())\n a = input()\n\n if not 'WR' in a:\n print(0)\n else:\n rightmostW = a.find('WR')\n wnum = a[rightmostW+2:].count('R')\n leftmostR = a.rfind('R')\n wnum2 = a[:leftmostR].count('W')\n r = min(wnum, wnum2)\n print(r)\n\nif __name__ == '__main__':\n main()", "import sys\nsys.setrecursionlimit(10**6)\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ndef main():\n n = int(input())\n a = input()\n\n if not 'WR' in a:\n print(0)\n else:\n rightmostW = a.find('RW')\n wnum = a[rightmostW+1:].count('R')\n leftmostR = a.rfind('R')\n wnum2 = a[:leftmostR+1].count('W')\n ri = a.find('WR')\n wnum3 = a[ri+2:].count('R')\n r = min(wnum, wnum2,wnum3)\n print(r)\n\nif __name__ == '__main__':\n main()\n", "import sys\nread = sys.stdin.read\n\ndef main():\n n = int(input())\n rc = tuple(input())\n rc2 = [c == 'W' for c in rc]\n r1 = sum(rc2) \n r2 = n - r1 \n r3 = sum(rc2[:r2]) \n print(min(r1, r2, r3))\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s082177813', 's099472576', 's389613400', 's634115171', 's657453286', 's681648936', 's844691671', 's913171761', 's290414703']
[9268.0, 9432.0, 10728.0, 10588.0, 9040.0, 9472.0, 9488.0, 9436.0, 13540.0]
[32.0, 26.0, 38.0, 32.0, 25.0, 31.0, 36.0, 32.0, 48.0]
[332, 328, 538, 537, 395, 330, 428, 499, 409]
p02597
u078982327
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = str(input())\n\nr_m = c.count('R')\nw_m = c.count('W')\nwr_m = c.count('WR')\n\nprint(min(r_m, w_m) - wr_m //2)\ns = 0\nif r_m >= w_m:\n for i in range(len(c) - 1):\n if c[i] == 'W' and c[i + 1] == 'R':\n c[i + 1] = 'W'\n s += 1", "n = int(input())\nc = str(input())\n\nr_m = c.count('R')\nw_m = 0\nout = max(r_m, w_m)\nfor i in range(n):\n if c[i] == 'W':\n w_m += 1\n else:\n r_m -= 1\n out = min(out, max(w_m, r_m))\nprint(out)\n"]
['Runtime Error', 'Accepted']
['s903884475', 's365291896']
[8944.0, 9432.0]
[25.0, 116.0]
[257, 210]
p02597
u087470052
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['from collections import deque\n\nN = int,input()\nc = input()\n\nrd = deque([i for i, x in enumerate(c) if x == "R"])\nwd = deque([i for i, x in enumerate(c) if x == "W"])\nif(len(rd) == 0 or len(wd) == 0):\n print(0)\n exit()\ncount = 0\nfor i in range(len(c)):\n if(not(wd[0] < rd[-1])):\n break\n rd.pop()\n wd.popleft()\n count += 1\nprint(count)', 'from collections import deque\n\nN = int(input())\nc = input()\n\nrd = deque([i for i, x in enumerate(c) if x == "R"])\nwd = deque([i for i, x in enumerate(c) if x == "W"])\nif(len(rd) == 0 or len(wd) == 0):\n print(0)\n exit()\ncount = 0\nfor i in range(len(c)):\n if(not(wd[0] < rd[-1])):\n break\n rd.pop()\n wd.popleft()\n count += 1\n if(len(rd) == 0 or len(wd) == 0):\n break\nprint(count)']
['Runtime Error', 'Accepted']
['s613933144', 's368036770']
[18816.0, 18896.0]
[82.0, 99.0]
[342, 389]
p02597
u088553842
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\ns = input()\nred = []\nwhite = []\nfor i in range(n):\n if s[i] == 'W':\n white.append(i)\nfor i in range(n - 1, -1, -1):\n if s[i] == 'R':\n red.append(i)\n#print(white, red)\nif min(len(red), len(white)) == 0:\n print(0)\n exit()\n\nfor i in range(min(len(red), len(white))):\n if white[i] >= red[i]:\n print(i)\n exit()\n\n", "n = int(input())\ns = input()\nred = []\nwhite = []\nfor i in range(n):\n if s[i] == 'W':\n white.append(i)\nfor i in range(n - 1, -1, -1):\n if s[i] == 'R':\n red.append(i)\nprint(white, red)\nif min(len(red), len(white)) == 0:\n print(0)\n exit()\n\nfor i in range(min(len(red), len(white))):\n if white[i] >= red[i]:\n print(i)\n exit()", "n = int(input())\ns = input()\nred = []\nwhite = []\nfor i in range(n):\n if s[i] == 'W':\n white.append(i)\nfor i in range(n - 1, -1, -1):\n if s[i] == 'R':\n red.append(i)\n#print(white, red)\nif min(len(red), len(white)) == 0:\n print(0)\n exit()\n\nfor i in range(min(len(red), len(white))):\n if white[i] >= red[i]:\n print(i)\n exit()\nprint(min(len(red), len(white)))"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s180979069', 's489900012', 's380968906']
[17240.0, 20268.0, 17232.0]
[85.0, 105.0, 93.0]
[341, 338, 372]
p02597
u094213642
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = input()\n\nwcount = c.count('R')\ncount = 0\n\nfor i in range(n):\n if c[i] == 'W' and i >= wcount:\n count += 1\nprint(count)\n", "n = int(input())\nc = input()\n\ncount = c.count('R')\nans = 0\n\nfor i in range(n):\n if c[i] == 'R' and i >= count:\n ans += 1\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s765845930', 's986478641']
[9248.0, 9300.0]
[58.0, 53.0]
[150, 142]
p02597
u096128910
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nc = input()\nans = 0\nfs = 0\nls = N - 1\nfor _ in range(N):\n for i in c[fs:ls]:\n if i == 'W':\n break\n fs += 1\n for i in c[fs:ls:-1]:\n if i == 'R':\n break\n ls -= 1\n if fs >= ls:\n break\n ans += 1\n fs += 1\n ls -= 1\n #print(c[fs:ls] + 1)\n if (ls - fs) <= 1:\n break\nprint(ans)\n\n", "N = int(input())\nC = input()\na = b = ans = 0\nfor c in C:\n if c == 'R':\n a += 1\nans = max(a, b)\nfor c in C:\n if c == 'R':\n a -= 1\n else:\n b += 1\n ans = min(ans, max(a, b))\nprint(ans)\n\n"]
['Wrong Answer', 'Accepted']
['s183018930', 's694401133']
[9340.0, 9192.0]
[508.0, 123.0]
[376, 216]
p02597
u101350975
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['K = int(input())\nif K % 2 == 0 or K % 5 ==0:\n print(-1)\n exit()\nelse:\n n = 7\n n_before = 7\n count = 0\n while True:\n count += 1\n n = n % K\n if n == 0:\n print(count)\n exit()\n else:\n n_before = 10 * n_before % K\n n = n + n_before\nprint(count)\n', "N = int(input())\nl = list(input())\ncount = 0\nminus = 0\nfor i in l:\n if i == 'R':\n count += 1\nfor i in l[:count]:\n if i == 'R':\n minus += 1\nprint(count - minus)\n"]
['Wrong Answer', 'Accepted']
['s462143030', 's715604897']
[9112.0, 12068.0]
[57.0, 65.0]
[330, 180]
p02597
u119982001
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nC = input()\n\nans = 0\nw = C.count("W")\nr = C.count("R")\n\nprint(w, r)\n\nif w <= r:\n print(C[0:w].count("W"))\nelse:\n print(C[w:len(C)].count("R"))\n', 'N = int(input())\nC = input()\n\nans = 0\nw = C.count("W")\nr = C.count("R")\n\nCC = r*"R" + w*"W"\n\nfor i in range(N):\n if C[i] != CC[i] and CC[i] == "R":\n ans += 1\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s780519510', 's416187922']
[9416.0, 9404.0]
[33.0, 65.0]
[166, 180]
p02597
u123579949
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nS = input()\nn=0\nif S.find("W")==-1 or S.find("R")==-1:\n print(0)\nelse:\n while S.find("W")<=S.rfind("R"):\n S = S[S.find("W")+1:S.rfind("R")]\n n+=1\n print(n)', 'N = int(input())\nS = input()\nn=0\nif S.find("W")==-1 or S.find("R")==-1:\n print(0)\nelse:\n while S.find("W")<S.rfind("R") and S.find("W")>=0:\n S = S[S.find("W")+1:S.rfind("R")]\n n+=1\n print(n)']
['Time Limit Exceeded', 'Accepted']
['s514893499', 's139527573']
[9400.0, 9356.0]
[2205.0, 340.0]
[181, 199]
p02597
u129212218
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n=int(input())\ns=input()\nc=0\nfor i in range(len(s)-1):\n if(s[i]=='W' and s[i+1]=='R'):\n c+=1\nprint(c)", 'n=int(input())\ns=input()\nr=0\nfor i in s:\n if(i=="R"):\n r+=1\nans=0\nfor j in range(r):\n if(s[j]=="W"):\n ans+=1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s893085965', 's489449073']
[9360.0, 9468.0]
[57.0, 63.0]
[105, 127]
p02597
u141419468
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nc = list(map(str, input().split()))\n\na=0\nb=0\n\na = c.count("R")\n\nfor i in range(N):\n if S[i] == \'R\':\n a -= 1\n else:\n b += 1\n\n now = max(a,b)\n ans = min(ans, now)\n\nprint(ans)', 'N = int(input())\nc = list(map(str, input().split()))\n\na=0\nb=0\n\na = c.count("R")\nans = c.count("R")\nfor i in range(N):\n if c[i] == \'R\':\n a -= 1\n else:\n b += 1\n\n now = max(a,b)\n ans = min(ans, now)\n\nprint(ans)', 'N = int(input())\nc = list(map(str, input().split()))\n\na=0\nb=0\n\na = c.count("R")\n\nfor i in range(N):\n if c[i] == \'R\':\n a -= 1\n else:\n b += 1\n\n now = max(a,b)\n ans = min(ans, now)\n\nprint(ans)\n', 'N = int(input())\nc = list(input())\n\na=0\nb=0\n\na = c.count("R")\nans = c.count("R")\nfor i in range(N):\n print(i)\n if c[i] == "R":\n a -= 1\n else:\n b += 1\n\n now = max(a,b)\n ans = min(ans, now)\n\nprint(ans)', 'N = int(input())\nc = list(input())\n\na=0\nb=0\n\na = c.count("R")\nans = c.count("R")\nfor i in range(N):\n if c[i] == "R":\n a -= 1\n else:\n b += 1\n\n now = max(a,b)\n ans = min(ans, now)\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s358807879', 's617218390', 's707754215', 's876543465', 's819307501']
[9476.0, 9344.0, 9396.0, 10780.0, 10748.0]
[25.0, 26.0, 24.0, 189.0, 128.0]
[215, 233, 216, 228, 215]
p02597
u141786930
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["from collections import deque\n\nN = int(input())\nc = list(str(input()))\ndw = deque()\ndr = deque()\n\nfor i, c in enumerate(c, 1):\n if c == 'W':\n dw.append(i)\n else:\n dr.appendleft(i)\n\nans = 0\nwhile dw:\n w = dw.popleft()\n r = dr.popleft()\n print(w, r)\n if w < r:\n ans += 1\n\n else:\n break\nprint(ans)", "from collections import deque\n\nN = int(input())\nc = list(str(input()))\ndw = deque()\ndr = deque()\n\nfor i, c in enumerate(c, 1):\n if c == 'W':\n dw.append(i)\n else:\n dr.appendleft(i)\n\nans = 0\nwhile dw and dr:\n w = dw.popleft()\n r = dr.popleft()\n if w < r:\n ans += 1\n\n else:\n break\nprint(ans)"]
['Runtime Error', 'Accepted']
['s957924846', 's342537420']
[18684.0, 18720.0]
[133.0, 93.0]
[343, 334]
p02597
u145145077
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = input()\n\nw = []\nr = []\nfor i in range(n):\n if c[i] == 'W':\n w.append(i+1)\n else:\n r.append(i+1)\n\nw_len = len(w)\nr_len = len(r)\nif w_len == 0 or r_len == 0:\n print(0)\n exit(0)\n\nw_min = w[0]\nr_max = r[r_len-1]\ncount = 0\nfor i in range(n):\n tmp = w[i]\n w[i] = r[r_len-i-1]\n r[r_len-i-1] = tmp\n count += 1\n \n w_min = w[count]\n r_max = r[r_len - count - 1]\n \n if r_max < w_min:\n print(count)\n exit(0)\nprint(count)", "n = int(input())\nc = input()\n\nw = []\nr = []\nfor i in range(n):\n if c[i] == 'W':\n w.append(i+1)\n else:\n r.append(i+1)\n\nw_len = len(w)\nr_len = len(r)\nif w_len == 0 or r_len == 0:\n print(0)\n exit(0)\n\nif w_len < r_len:\n search = w_len\nelse:\n search = r_len\n\nw_min = w[0]\nr_max = r[r_len-1]\n\nif r_max < w_min:\n print(0)\n exit(0)\n\ncount = 0\nfor i in range(search):\n tmp = w[i]\n w[i] = r[r_len-i-1]\n r[r_len-i-1] = tmp\n count += 1\n \n if w_len > count and (r_len-count-1) >= 0:\n w_min = w[count]\n r_max = r[r_len - count - 1]\n else:\n w_min = w[w_len-1]\n r_max = r[0]\n \n if r_max < w_min:\n print(count)\n exit(0)\nprint(count)"]
['Runtime Error', 'Accepted']
['s651154266', 's708905430']
[17292.0, 17384.0]
[117.0, 136.0]
[454, 658]
p02597
u150788544
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\ns = list(input())\nnum = 0\nk = -1\nfor i in range(1,n):\n if i + k >= n-1:\n break\n if s[-i] == 'R':\n j = k+1\n while True:\n if j +i == n-1:\n k = j\n break\n if s[j] == 'W':\n s[j] = 'R'\n s[-i] = 'W'\n k = j\n num += 1\n break\n j += 1\n \n\nprint(num) \n \n ", "n = int(input())\ns = list(input())\nnum = 0\nk = -1\nfor i in range(1,n):\n if i + k >= n-1:\n break\n if s[-i] == 'R':\n j = k+1\n while True:\n if j +i == n:\n k = j\n break\n if s[j] == 'W':\n s[j] = 'R'\n s[-i] = 'W'\n k = j\n num += 1\n break\n j += 1\n \nprint(num) \n "]
['Wrong Answer', 'Accepted']
['s838451608', 's595699240']
[10584.0, 10728.0]
[83.0, 82.0]
[352, 343]
p02597
u165114979
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\ns = input()\na = [str(c) for c in s]\n\ndef sea(a, z, n):\n while z[0] < n-1:\n if a[z[0]] == 'W':\n break\n z[0] += 1\n \n while z[1] > 0:\n if a[z[1]] == 'R':\n break\n z[1] += 1\n \n return(z)\n\nz = [0, n-1]\n\nz = a(a, z, n)\nc = 0\nwhile z[0] < z[1]:\n a[z[0]], a[z[1]] = a[z[1]], a[z[0]]\n c += 1\n z = a(a,z,n)\n \nprint(c)", "n = int(input())\ns = input()\na = [str(c) for c in s]\n\ndef sea(a, x, y, n):\n while x < n-1:\n if a[x] == 'W':\n break\n x += 1\n \n while y > 0:\n if a[y] == 'R':\n break\n y -= 1\n \n return[x, y]\n\nz = [0, n-1]\n\nz = sea(a, z[0] ,z[1], n)\nc = 0\nwhile z[0] < z[1]:\n a[z[0]], a[z[1]] = a[z[1]], a[z[0]]\n c += 1\n z = sea(a,z[0], z[1],n)\n \nprint(c)\n\n"]
['Runtime Error', 'Accepted']
['s009490871', 's882441619']
[11012.0, 11032.0]
[49.0, 119.0]
[356, 368]
p02597
u168573507
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nlist=[]\nlist = (str(input()))\ncnt = 0\nR = 0\nW = 0\nans = 0\nfor i in range (N):\n if list[i] == "R":\n R += 1\n\nW = N-R\n\ncnt = min(R, W)\n\nif R >= W:\n for i in range(cnt):\n if list[N-cnt-1]=="R":\n ans +=1\n\nif R<W:\n for j in range(cnt):\n if list[j] == "W":\n ans +=1\n\n\nprint(ans)\n\n\n', 'N = int(input())\nlist=[]\nlist = (str(input()))\ncnt = 0\nR = 0\nW = 0\nans = 0\nfor i in range (N):\n if list[i] == "R":\n R += 1\n\nW = N-R\n\ncnt = min(R, W)\n\nif R > W:\n for i in range(0,cnt):\n if list[N-i-1]=="R":\n ans +=1\n\nif R<=W:\n for j in range(0,cnt):\n if list[j] == "W":\n ans +=1\n\n\nprint(ans)\n\n\n\n\n']
['Wrong Answer', 'Accepted']
['s419779260', 's326623162']
[9240.0, 9412.0]
[64.0, 63.0]
[343, 347]
p02597
u194228880
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['#n = int(input(\'\'))\n#clist = input(\'\')\nn=2\nclist="RR"\n\nwcnt=clist.count("W")\nrcnt=clist.count("R")\n\nclist1 = clist[0:rcnt]\n\nwcnt2 = clist1.count("W")\n\nprint(wcnt2)', 'n = int(input(\'\'))\nclist = input(\'\')\n\nwcnt=clist.count("W")\nrcnt=clist.count("R")\n\nclist1 = clist[0:rcnt]\n\nwcnt2 = clist1.count("W")\n\nprint(wcnt2)']
['Wrong Answer', 'Accepted']
['s674073926', 's917577847']
[9044.0, 9432.0]
[32.0, 30.0]
[163, 146]
p02597
u195272001
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["\nN = int(input())\nC = [str(i) for i in input().split()]\nr = 0\nw = 0 \na = 0\nr = int(C.count('R'))\nfor i in range(r):\n if [a] == w:\n b+=1\n a+=1\nprint(w)", "\nN = int(input())\nC = input()\nr = 0\nw = 0 \nb = 0\nr = C.count('R')\nfor i in range(r):\n if (C[i]=='W'):\n b+=1\nprint(b)"]
['Wrong Answer', 'Accepted']
['s482219819', 's316307286']
[9396.0, 9472.0]
[27.0, 44.0]
[157, 128]
p02597
u202317648
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N=int(input())\nc=input()\nW=[]\nR=[]\npw=0\npr=0\nfor i in range(N):\n if c[i]=="W":\n W+=[i]\n pw+=1\n\n if c[N-1-i]=="R":\n R+=[i]\n pr+=1\n\nfor i in range(200000):\n if min(len(W),len(R))==0:\n result=0\n break\n if W[i]+R[i]>=N:\n result=i\n break\nprint(result)\nresult=i\n', 'N=int(input())\nc=input()\nW=[]\nR=[]\npw=0\npr=0\nfor i in range(N):\n if c[i]=="W":\n W+=[i]\n pw+=1\n\n if c[N-1-i]=="R":\n R+=[i]\n pr+=1\n\nfor i in range(200000):\n if min(len(W),len(R))==i:\n result=i\n break\n if W[i]+R[i]>=N:\n result=i\n break\nprint(result)\nresult=i\n']
['Runtime Error', 'Accepted']
['s954970412', 's525487116']
[17236.0, 17484.0]
[123.0, 137.0]
[304, 304]
p02597
u206890818
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import math\nimport collections\nimport bisect\nfrom collections import deque\nfrom copy import copy, deepcopy\n \n \ndef main():\n N = int(input())\n S = input()\n l=0\n r=len(S)-1\n ans=0\n while(1):\n for i in range(l,len(S)):\n if S[i]=='W':\n l=i\n break\n for j in range(r,-1,-1):\n if S[j]=='R':\n r=j\n break\n print(i,j)\n if i<j:\n ans+=1\n l=i+1\n r=j-1\n else:\n break\n print(ans)\n\n \nif __name__ == '__main__':\n main()\n ", "import math\nimport collections\nimport bisect\nfrom collections import deque\nfrom copy import copy, deepcopy\n \n \ndef main():\n N,S = Input.split()\n print(N)\n N=int(N)\n l=0\n r=len(S)-1\n ans=0\n while(1):\n for i in range(l,len(S)):\n if S[i]=='W':\n l=i\n break\n for j in range(r,0,-1):\n if S[j]=='R':\n r=j\n break\n \n if i<j:\n ans+=1\n l=i+1\n r=j-1\n else:\n break\n print(ans)\n\n \nif __name__ == '__main__':\n main()", "import math\nimport collections\nimport bisect\nfrom collections import deque\nfrom copy import copy, deepcopy\n \n \ndef main():\n N = int(input())\n S = input()\n l=0\n r=len(S)-1\n ans=0\n while(1):\n for i in range(l,len(S)):\n if S[i]=='W':\n l=i\n break\n for j in range(r,-1,-1):\n if S[j]=='R':\n r=j\n break\n if i<j:\n ans+=1\n l=i+1\n r=j-1\n else:\n break\n print(ans)\n\n \nif __name__ == '__main__':\n main()\n "]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s556489244', 's659787111', 's208080034']
[9904.0, 9488.0, 9832.0]
[158.0, 24.0, 111.0]
[592, 589, 573]
p02597
u218834617
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N=int(input())\ns=input()\n\nans=0\ni,j=0,N-2\nwhile i<j:\n if s[i]=='R':\n i+=1\n elif s[j]=='W':\n j-=1\n else:\n ans+=1\n i+=1\n j-=1\n\nprint(ans)\n", "N=int(input())\ns=input()\n\nans=0\ni,j=0,N-2\nwhile i<j:\n if s[i]=='R':\n i+=1\n elif s[j]=='W':\n j-=1\n else:\n k+=1\n i+=1\n j-=1\n\nprint(k)\n", "N=int(input())\ns=input()\n\nans=0\ni,j=0,N-1\nwhile i<j:\n if s[i]=='R':\n i+=1\n elif s[j]=='W':\n j-=1\n else:\n ans+=1\n i+=1\n j-=1\n\nprint(ans)\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s275908326', 's296388305', 's871568194']
[9452.0, 9332.0, 9332.0]
[64.0, 65.0, 65.0]
[180, 176, 180]
p02597
u261427665
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\na = input()\nb = 0\ndef wr(x):\n c = 0\n for i in range(1, n):\n if a[i-1] == "W" and a[i] == "R":\n c = c + 1\n else:\n c = c\n return c\n \nfor i in range(1,n-1):\n if (a[i-1] == "W" and a[i] == "R" and a[i+1] == "R") or (a[i-1] == "W" and a[i] == "W" and a[i+1] == "R"):\n b = b + 1\n else: \n b = b\n print(b)\nif (wr(a) - b) % 2 == 0:\n print(((wr(a)-b)//2) + b)\nelse:\n print(((wr(a)-b-1)//2) + b + 1) \n', 'n = int(input())\na = input()\nb = 0\ndef wr(x):\n c = 0\n for i in range(1, n):\n if a[i-1] == "W" and a[i] == "R":\n c = c + 1\n else:\n c = c\n return c\n \nfor i in range(1,n-1):\n if (a[i-1] == "W" and a[i] == "R" and a[i+1] == "R") or (a[i-1] == "W" and a[i] == "W" and a[i+1] == "R"):\n b = b + 1\n else: \n b = b\n\nif (wr(a) - b) % 2 == 0:\n print(((wr(a)-b)/2) + b)\nelse:\n print(((wr(a)-b-1)/2) + b + 1) \n', 'n=int(input())\na=input()\n\na=list(a)\n\nt=0\ns=0\nfor i in range(0,n):\n if a[i]=="R":\n t=t+1\n \nfor i in range(0,t):\n if a[i]!="R":\n s=s+1\nprint(s)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s041674552', 's847767966', 's679295395']
[9428.0, 9516.0, 10708.0]
[211.0, 152.0, 70.0]
[493, 479, 168]
p02597
u268402865
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['s = input()\nR_num = s.count("R")\ns[:R_num].count("W")\n', 's = input()\nR_num = s.count("R")\nprint(s[:R_num].count("W")\n', 's = input()\nR_num = s.count("R")\nprint(s[:R_num].count("W"))\n', 's = input()\ns = input()\n\nR_num = s.count("R")\nprint(s[:R_num].count("W"))\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s153302159', 's425180271', 's815463282', 's887365140']
[8976.0, 8944.0, 9084.0, 9324.0]
[27.0, 24.0, 26.0, 29.0]
[54, 60, 61, 74]
p02597
u273339216
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nc = list(input())\na = c.count("R")\nb = 0\ncount = max(a, b)\n\nfor i in range(n+1):\n if c[i] == "R":\n a = a - 1\n else:\n b = b + 1\n ans = max(a, b)\n count = min(ans, count)\nprint(count)\n \n', 'n = int(input())\nc = list(input())\ncount = 0\n\n\nfor i in range(n-1):\n #print(c)\n if c[i] == "W" and c[i+1] == "R":\n c[i] = "R"\n count += 1\nprint(count)\n\n', 'n = int(input())\nc = list(input())\ncount = n\na = c.count("R")\nb = 0\nans = max(a, b)\ncount = min(ans, count)\n\nfor i in range(n+1):\n if c[i] == "R":\n a = a - 1\n else:\n b = b + 1\n ans = max(a, b)\n count = min(ans, count)\nprint(count)\n \n', 'n = int(input())\nc = list(input())\na = c.count("R")\nb = 0\ncount = max(a, b)\n\nfor i in range(n):\n if c[i] == "R":\n a = a - 1\n else:\n b = b + 1\n ans = max(a, b)\n count = min(ans, count)\nprint(count)\n ']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s261201134', 's651324908', 's971175853', 's815254750']
[10604.0, 10704.0, 10592.0, 10708.0]
[125.0, 60.0, 124.0, 128.0]
[276, 198, 308, 273]
p02597
u274080981
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = input()\nwhite_count, red_count = 0, 0\n\nfor i in range(0, n // 2 + 1):\n if c[i] == 'W':\n white_count += 1\nfor i in range(n // 2+1, n):\n if c[i] == 'R':\n red_count += 1\n\nprint(min(white_count, red_count))\n", "n = int(input())\nc = input()\ncount = 0\n\ni, j = 0, n - 1\nif c.count('W') == 0:\n count=0\nelif c.count('R') == 0:\n count = 0\nelse:\n white_cnt = []\n red_cnt = []\n for i in range(n):\n if c[i] == 'W':\n white_cnt.append(i)\n else:\n red_cnt.append(i)\n while 1:\n white_num = white_cnt.pop(0)\n red_num = red_cnt.pop()\n if white_num < red_num:\n count += 1\n if len(white_cnt) == 0:\n break\n if len(red_cnt) == 0:\n break\nprint(count)\n"]
['Wrong Answer', 'Accepted']
['s489037263', 's031535162']
[9480.0, 17156.0]
[53.0, 852.0]
[244, 541]
p02597
u292661157
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\n\nc = input()\n\nk = -1\nfor i in range(N):\n if c[i] == 'W' and k == -1:\n k = i \n\nif k == -1 or k == N-1:\n print(0)\nelse:\n w = [0] * N\n r = [0] * N\n\n if c[0] == 'W':\n w[0] = 1\n if c[N-1] == 'R':\n r[N-1] = 1\n for i in range(1,N):\n if c[i] == 'W':\n w[i] = w[i-1] + 1\n else:\n w[i] = w[i-1]\n\n if c[N-i-1] == 'R':\n r[N-i-1] = r[N-i] + 1\n else:\n r[N-i-1] = r[N-i]\n\n for i in range(N):\n if w[i] == r[i]:\n print(w[i])\n ", "N = int(input())\n\nc = input()\n\nk = -1\nfor i in range(N):\n if c[i] == 'W' and k == -1:\n k = i \n\nif k == -1 or k == N-1:\n print(0)\nelse:\n w = [0] * N\n r = [0] * N\n\n if c[0] == 'W':\n w[0] = 1\n if c[N-1] == 'R':\n r[N-1] = 1\n for i in range(1,N):\n if c[i] == 'W':\n w[i] = w[i-1] + 1\n else:\n w[i] = w[i-1]\n\n if c[N-i-1] == 'R':\n r[N-i-1] = r[N-i] + 1\n else:\n r[N-i-1] = r[N-i]\n\n print(w)\n print(r)\n for i in range(N):\n if w[i] == r[i]:\n print(w[i])\n ", "N = int(input())\n\nc = input()\n\nk = -1\nfor i in range(N):\n if c[i] == 'W' and k == -1:\n k = i \n\nif k == -1 or k == N-1:\n print(0)\nelse:\n w = [0] * N\n r = [0] * N\n\n if c[0] == 'W':\n w[0] = 1\n if c[N-1] == 'R':\n r[N-1] = 1\n for i in range(1,N):\n if c[i] == 'W':\n w[i] = w[i-1] + 1\n else:\n w[i] = w[i-1]\n\n if c[N-i-1] == 'R':\n r[N-i-1] = r[N-i] + 1\n else:\n r[N-i-1] = r[N-i]\n \n if w[N-1] == N:\n print(0)\n else:\n for i in range(N-1):\n if w[i] == r[i+1]:\n print(w[i])\n break "]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s269633039', 's689806203', 's772370941']
[18756.0, 21556.0, 18820.0]
[174.0, 219.0, 177.0]
[562, 588, 650]
p02597
u310381103
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n=int(input())\ns=input().split()\ns2=sorted(s)\nt=0\nfor i in range(n):\n if s[i]!=s2[i]:\n t+=1\nprint(t)', 'n=int(input())\ns=input()\ns2=sorted(s)\nt=0\nfor i in range(n):\n if s[i]!=s2[i]:\n t+=1\nprint(t//2)\n']
['Runtime Error', 'Accepted']
['s897151091', 's537622870']
[9404.0, 11356.0]
[22.0, 69.0]
[104, 100]
p02597
u317423698
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import sys\n\n\ndef resolve(in_):\n n = int(next(in_))\n c = next(in_).strip()\n\n c = c.lstrip('R')\n c = c.rstrip('W')\n if c.count('R') == 0 or c.count('W') == 0:\n return 0\n # print(f'{c=}')\n\n a, b = c[:len(c) // 2], c[len(c) // 2:]\n # while len(a) and len(b) and a.count('W') == 0:\n # print(f'{a=}')\n # print(f'{b=}')\n # a, b = b[:len(b) // 2 + 1], b[len(b) // 2 + 1:]\n # print(f'{a=}')\n # print(f'{b=}')\n\n wc = a.count('W')\n rc = b.count('R')\n # print(f'{wc=} {rc=}')\n\n return max(wc, rc) + 100\n\n\ndef main():\n answer = resolve(sys.stdin)\n print(answer)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\n\n\ndef resolve(in_):\n n = int(next(in_))\n c = next(in_).strip()\n\n c = c.lstrip('R')\n c = c.rstrip('W')\n if c.count('R') == 0 or c.count('W') == 0:\n return 0\n # print(f'{c=}')\n\n a, b = c[:len(c) // 2], c[len(c) // 2:]\n # while len(a) and len(b) and a.count('W') == 0:\n # print(f'{a=}')\n # print(f'{b=}')\n # a, b = b[:len(b) // 2 + 1], b[len(b) // 2 + 1:]\n # print(f'{a=}')\n # print(f'{b=}')\n\n wc = a.count('W')\n rc = b.count('R')\n # print(f'{wc=} {rc=}')\n\n return max(wc, rc) + 100\n\n\ndef main():\n answer = resolve(sys.stdin)\n print(answer)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\n\n\ndef resolve(in_):\n n = int(next(in_))\n c = next(in_).strip()\n\n ans = 0\n left = 0\n right = len(c) - 1\n while left < right:\n if c[left] == 'R':\n left += 1\n continue\n if c[right] == 'W':\n right -= 1\n continue\n left += 1\n right -= 1\n ans += 1\n\n return ans\n\n\ndef main():\n answer = resolve(sys.stdin)\n print(answer)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s304651356', 's373672688', 's985939515']
[9292.0, 9420.0, 9240.0]
[31.0, 28.0, 50.0]
[666, 666, 469]
p02597
u319589470
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['\nimport math\n\ndef I(): return int(input())\ndef LI(): return list(map(int,input().split()))\ndef MI(): return map(int,input().split())\ndef LLI(n): return [list(map(int, input().split())) for _ in range(n)]\n\n\n\n\n\n\n\n\nn,k = MI()\na = LI()\n\ndef cutting_isOK(x,li,k):\n ans = 0\n for i in range(n):\n ans += math.ceil(li[i]/x) - 1\n if ans <= k:\n return True\n else:\n return False\nleft = -1\nright = 10**9+1\nwhile right != left + 1:\n mid = (left+right)//2\n if cutting_isOK(mid,a,k):\n right = mid\n else:\n left = mid\nprint(right)\n\n', 'def I(): return int(input())\ndef LI(): return list(map(int,input().split()))\ndef MI(): return map(int,input().split())\ndef LLI(n): return [list(map(int, input().split())) for _ in range(n)]\n\nn = I()\nc = list(input())\nr = c.count(\'R\')\nprint(c[:r].count("W"))\n']
['Runtime Error', 'Accepted']
['s144123937', 's074164130']
[9220.0, 12000.0]
[24.0, 36.0]
[1098, 258]
p02597
u329319441
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['from math import floor, ceil\nN = int(input())\nWHITE = 0\nRED = 1\nstr = list(map(str, list(input())))\nr = []\nw = []\n\nfor i in range(N):\n w.append(i) if str[i] == "W" else r.append(i)\n str[i] = WHITE if str[i] == "W" else RED\nr.reverse()\n\nmax_count = max(len(r), len(w))\ncount = 0\nfor i in range(max_count):\n if r[i] - w[i] < 0:\n count = i\n break\n\nprint(count)\n', 'from math import floor, ceil\nN = int(input())\nWHITE = 0\nRED = 1\nstr = list(map(str, list(input())))\nr = []\nw = []\n\nfor i in range(N):\n w.append(i) if str[i] == "W" else r.append(i)\n str[i] = WHITE if str[i] == "W" else RED\nr.reverse()\nmax_count = min(len(r), len(w))\ncount = 0\nfor i in range(max_count):\n if r[i] - w[i] > 0:\n count += 1\n\nprint(count)\n']
['Runtime Error', 'Accepted']
['s768753007', 's951795985']
[19240.0, 19172.0]
[114.0, 113.0]
[367, 357]
p02597
u347640436
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nc = input()\n\nd = list(c)\n\ni = 0\nj = N - 1\nresult = 0\nwhile i < N and i < j:\n if d[i] == 'W':\n while d[j] != 'R' and i < j:\n j -= 1\n d[i] = 'R'\n d[j] = 'W'\n result += 1\nprint(result)\n", "N = int(input())\nc = input()\n\nd = list(c)\n\ni = 0\nj = N - 1\nresult = 0\nwhile True:\n while i < N and d[i] != 'W':\n i += 1\n while j > 0 and d[j] != 'R':\n j -= 1\n if i == N or j == -1 or i >= j:\n break\n d[i] = 'R'\n d[j] = 'W'\n result += 1\nprint(result)\n"]
['Wrong Answer', 'Accepted']
['s160528444', 's781412607']
[10836.0, 10700.0]
[2206.0, 98.0]
[241, 288]
p02597
u350093546
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n=int(input())\ns=list(input())\nx=[]\ny=[]\n\nfor i in range(n):\n if s[i]=='R':\n x+=[i]\n elif s[i]=='W':\n y+=[i]\n \nans=0\nif y==[]:\n print(ans)\nelse:\n while True:\n if x[-1]>y[0]:\n x.pop()\n y.pop(0)\n ans+=1\n continue\n \n else:\n print(ans)\n break", "n=int(input())\ns=list(input())\nx=[]\ny=[]\n\nfor i in range(n):\n if s[i]=='R':\n x+=[i]\n elif s[i]=='W':\n y+=[i]\n \nans=0\n\n\nwhile True:\n if len(y)==0:\n print(ans)\n break\n elif len(x)==0:\n print(ans)\n break\n elif x[-1]>y[0]:\n x.pop()\n y.pop(0)\n ans+=1\n continue\n \n else:\n print(ans)\n break"]
['Runtime Error', 'Accepted']
['s143747109', 's481516698']
[18660.0, 18772.0]
[817.0, 753.0]
[290, 359]
p02597
u363421241
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["from collections import deque\nn = int(input())\nc = deque(input())\n\ncnt = 0\nl = c.popleft()\nr = c.pop()\nwhile c:\n if l == 'R':\n l = c.popleft()\n if r == 'W':\n r = c.pop()\n if l == 'W' and r == 'R':\n cnt += 1\n l = c.popleft()\n if not c:\n break\n r = c.pop()\n\nprint(cnt)", "n = int(input())\nc = input()\n\ncnt = 0\ni = 0\nj = n-1\nwhile i < j:\n while c[i] == 'R' and i < j:\n i += 1\n while c[j] == 'W' and i < j:\n j -= 1\n if c[i] != 'W' or c[j] != 'R':\n break\n i += 1\n j -= 1\n cnt += 1\n\nprint(cnt)"]
['Runtime Error', 'Accepted']
['s670727143', 's765281827']
[10984.0, 9340.0]
[66.0, 65.0]
[328, 256]
p02597
u376754170
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nsaidan = input()\n\nisiall = min(saidan.count('W'), saidan.count('R'))\n\ntesuu = 0\nfor i in range(len(saidan)//2):\n r_iti = saidan.rfind('R')\n w_iti = saidan.find('W')\n \n if r_iti == -1 or w_iti == -1:\n break\n \n saidan = saidan[w_iti+1 : r_iti]\n tesuu += 1\n \n print(tesuu, saidan)\n \nprint(min(tesuu, isiall))", "n = int(input())\nsaidan = input()\n\nisiall = min(saidan.count('W'), saidan.count('R'))\n\ntesuu = 0\nfor i in range(len(saidan)//2):\n r_iti = saidan.rfind('R')\n w_iti = saidan.find('W')\n \n if r_iti == -1 or w_iti == -1 or r_iti < w_iti:\n break\n \n saidan = saidan[w_iti+1 : r_iti]\n tesuu += 1\n \nprint(min(tesuu, isiall))"]
['Runtime Error', 'Accepted']
['s832301663', 's644008955']
[138120.0, 9356.0]
[965.0, 324.0]
[359, 346]
p02597
u377989038
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nc = input()\n\nr = c.count("R")\ncnt = 0\nfor i, j in enumerate(c):\n if i + 1 == r:\n break\n if j == "W":\n cnt += 1\nprint(cnt)\n', 'n = int(input())\nc = input()\n\nr = c.count("R")\ncnt = 0\nfor i, j in enumerate(c):\n if i == r:\n break\n if j == "W":\n cnt += 1\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s614784406', 's797605277']
[9292.0, 9368.0]
[67.0, 51.0]
[159, 154]
p02597
u378349138
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nC = []\nfor c in list(input()):\n a = 0\n if c == "R":\n a = 1\n C.append(a)\nL = -1\nR = N\ncnt = 0\nwhile L < R:\n L += 1\n if L < R:\n break\n if C[L] != 0:\n continue\n while L < R:\n R -= 1\n if L < R:\n break\n if C[R] != 1:\n continue\n cnt += 1\n break \nprint(cnt)\n ', 'N = int(input())\nC = []\nfor c in list(input()):\n a = 0\n if c == "R":\n a = 1\n C.append(a)\nL = -1\nR = N\ncnt = 0\nwhile L < R:\n# print(str(L) + " " + str(R))\n L += 1\n if L >= R:\n break\n if C[L] != 0:\n continue\n while L < R:\n R -= 1\n if L >= R:\n break\n if C[R] != 1:\n continue\n cnt += 1\n break \nprint(cnt)\n ']
['Wrong Answer', 'Accepted']
['s076364656', 's804523757']
[12344.0, 12348.0]
[61.0, 99.0]
[315, 349]
p02597
u393224521
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['import sys\nimport math\n\nn = int(sys.stdin.readline().rstrip("\\n"))\nc = list(sys.stdin.readline().rstrip("\\n"))\nans = 0\nleft, right = 0, len(arr) - 1\n\nwhile(left < right):\n while(c[left] == \'R\'):\n left += 1\n if left >= n:\n break\n while(c[right] == \'W\'):\n right -= 1\n if right < 0:\n break\n if (left < right):\n c[left], c[right] = c[right], c[left]\n ans += 1\n else:\n break\n\nprint(ans)', 'import sys\nimport math\n\nn = int(sys.stdin.readline().rstrip("\\n"))\nc = list(sys.stdin.readline().rstrip("\\n"))\nans = 0\nleft, right = 0, n-1\n\nwhile(left < right):\n while(c[left] == \'R\'):\n left += 1\n if left >= n:\n break\n while(c[right] == \'W\'):\n right -= 1\n if right < 0:\n break\n if (left < right):\n c[left], c[right] = c[right], c[left]\n ans += 1\n else:\n break\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s220613472', 's050673990']
[10664.0, 10788.0]
[32.0, 97.0]
[464, 455]
p02597
u399759028
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\ns = input()\nw = s.count('W')\nan1 = s[-w:].count('R')\nan2 = s[:w].count('R')\n\nprint(min(an1, an2))", "n = int(input())\ns = input()\nw = s.count('w')\nprint( s[-w:].count('R') if w != 0 else 0)", "n = int(input())\ns = input()\nw = s.count('W')\nif w == 0:\n print(0)\nelse:\n print(s[-w:].count('R'))\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s362864033', 's862916535', 's873159557']
[9416.0, 9416.0, 9312.0]
[28.0, 27.0, 30.0]
[114, 88, 101]
p02597
u401487574
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['ma = lambda :map(int,input().split())\nni = lambda:int(input())\nyn = lambda fl:print("Yes") if fl else print("No")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\nn = ni()\ncs = input()\nr = cs.count("R")\nprint(cs[:r].count("R"))\n', 'ma = lambda :map(int,input().split())\nni = lambda:int(input())\nyn = lambda fl:print("Yes") if fl else print("No")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\nn = ni()\ncs = input()\nr = cs.count("R")\nprint(cs[r:].count("R"))\n']
['Wrong Answer', 'Accepted']
['s439051970', 's285657803']
[9720.0, 9668.0]
[34.0, 33.0]
[246, 246]
p02597
u406138190
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n=int(input())\nword=input()\nline=[]\nfor i in range(n):\n if(word[0]=='R'):\n line.append(1)\n else:\n line.append(0)\n word=word[1:]\nx=0\ny=n-1\nans=0\nwhile(1):\n while(1):\n print(22222222)\n if(line[x]==0):\n break\n if(x>=y):\n break\n x+=1\n while(1):\n print(3333333333)\n if(line[y]==1):\n break\n if(x>=y):\n break\n y-=1\n if(x>=y):\n break\n tmp=line[x]\n line[x]=line[y]\n line[y]=tmp\n print(ans)\n ans=ans+1\nprint(ans)", "n=int(input())\nword=input()\nline=[]\nfor i in range(n):\n if(word[0]=='R'):\n line.append(1)\n else:\n line.append(0)\n word=word[1:]\nx=0\ny=n-1\nans=0\nwhile(1):\n while(1):\n if(line[x]==0):\n break\n if(x>=y):\n break\n x+=1\n while(1):\n if(line[y]==1):\n break\n if(x>=y):\n break\n y-=1\n if(x>=y):\n break\n tmp=line[x]\n line[x]=line[y]\n line[y]=tmp\n ans=ans+1\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s537049845', 's120031615']
[10860.0, 10740.0]
[790.0, 655.0]
[556, 491]
p02597
u410558877
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['def func_rfindr(str, start):\n return str.rfind(\'R\', start)\n\ndef func_lfindw(str, start):\n return str.find(\'W\', start)\n\ndef func_replace(target, pos, str):\n ret = ""\n if pos != 0:\n ret = target[0:pos]\n ret = ret + str\n if len(target) - 1 != pos:\n ret = ret + target[pos + 1:]\n return ret\n\nN = int(input())\nC = input()\nans = 0\n\nposrr = func_rfindr(C)\nposlw = func_lfindw(C)\n\nwhile poslw != -1 and posrr != -1 and posrr > poslw:\n C = func_replace(C, posrr, "W")\n C = func_replace(C, poslw, "R")\n ans = ans + 1\n posrr = func_rfindr(C, posrr)\n poslw = func_lfindw(C, poslw)\n\nprint(ans)', 'def func_rfindr(str, start):\n return str.rfind(\'R\')\n\ndef func_lfindw(str, start):\n return str.find(\'W\')\n\ndef func_replace(target, pos, str):\n ret = ""\n if pos != 0:\n ret = target[0:pos]\n ret = ret + str\n if len(target) - 1 != pos:\n ret = ret + target[pos + 1:]\n return ret\n\nN = int(input())\nC = input()\nans = 0\n\nposrr = func_rfindr(C)\nposlw = func_lfindw(C)\n\nwhile poslw != -1 and posrr != -1 and posrr > poslw:\n C = func_replace(C, posrr, "W")\n C = func_replace(C, poslw, "R")\n ans = ans + 1\n posrr = func_rfindr(C, posrr)\n poslw = func_lfindw(C, poslw)\n\nprint(ans)', 'def func_rfindr(str):\n return str.rfind(\'R\')\n\ndef func_lfindw(str, start):\n return str.find(\'W\', start)\n\ndef func_replace(target, pos, str):\n ret = ""\n if pos != 0:\n ret = target[0:pos]\n ret = ret + str\n if len(target) - 1 != pos:\n ret = ret + target[pos + 1:]\n return ret\n\nN = int(input())\nC = input()\nans = 0\n\nposrr = func_rfindr(C)\nposlw = func_lfindw(C)\n\nwhile poslw != -1 and posrr != -1 and posrr > poslw:\n C = func_replace(C, posrr, "W")\n C = func_replace(C, poslw, "R")\n ans = ans + 1\n posrr = func_rfindr(C)\n poslw = func_lfindw(C, poslw)\n\nprint(ans)', 'def func_rfindr(str, start):\n return str.rfind(\'R\')\n\ndef func_lfindw(str, start):\n return str.find(\'W\', start)\n\ndef func_replace(target, pos, str):\n ret = ""\n if pos != 0:\n ret = target[0:pos]\n ret = ret + str\n if len(target) - 1 != pos:\n ret = ret + target[pos + 1:]\n return ret\n\nN = int(input())\nC = input()\nans = 0\n\nposrr = func_rfindr(C)\nposlw = func_lfindw(C)\n\nwhile poslw != -1 and posrr != -1 and posrr > poslw:\n C = func_replace(C, posrr, "W")\n C = func_replace(C, poslw, "R")\n ans = ans + 1\n posrr = func_rfindr(C, posrr)\n poslw = func_lfindw(C, poslw)\n\nprint(ans)', 'def func_rfindr(str):\n return str.rfind(\'R\')\n\ndef func_lfindw(str):\n return str.find(\'W\')\n\ndef func_replace(target, pos, str):\n ret = ""\n if pos != 0:\n ret = target[0:pos]\n ret = ret + str\n if len(target) - 1 != pos:\n ret = ret + target[pos + 1:]\n return ret\n\nN = int(input())\nC = input()\nans = 0\n\nposrr = func_rfindr(C)\nposlw = func_lfindw(C)\n\nwhile poslw != -1 and posrr > poslw:\n C = func_replace(C, posrr, "W")\n C = func_replace(C, poslw, "R")\n print(C)\n print(ans)\n ans = ans + 1\n posrr = func_rfindr(C)\n poslw = func_lfindw(C)\n\nprint(ans)', 'def func_rfindr(str):\n return str.rfind(\'R\')\n\ndef func_lfindw(str):\n return str.find(\'W\')\n\ndef func_replace(target, pos, str):\n ret = ""\n if pos != 0:\n ret = target[0:pos]\n ret = ret + str\n if len(target) - 1 != pos:\n ret = ret + target[pos + 1:]\n return ret\n\nN = int(input())\nC = input()\nans = 0\n\nposrr = func_rfindr(C)\nposlw = func_lfindw(C)\n\nwhile poslw != -1 and posrr != -1 and posrr > poslw:\n #C = func_replace(C, posrr, "W")\n #C = func_replace(C, poslw, "R")\n C = C[poslw + 1:posrr]\n ans = ans + 1\n posrr = func_rfindr(C)\n poslw = func_lfindw(C)\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s188997120', 's375733305', 's457877417', 's805428159', 's958208416', 's435510103']
[9348.0, 9264.0, 9416.0, 9444.0, 138536.0, 9452.0]
[30.0, 23.0, 27.0, 27.0, 959.0, 345.0]
[630, 616, 609, 623, 600, 617]
p02597
u410969902
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import re\n\ndef checkFunction(c):\n print(c)\n c = re.sub('W+$','',c)\n if (not 'WR' in c):\n return 0\n if c.index('WR') + 2 != len(c):\n c2 = c.replace('WR', 'RR',1)[:-1]\n return checkFunction(c2) + 1\n return 1\n\n\nN = int(input())\nc= input()\n\nprint(checkFunction(c))", "def checkFunction(c):\n count = 0\n\n while True:\n print(count, c)\n if not ('WR' in c):\n return count\n while c[0] == 'R':\n c = c[1:]\n while c[-1] == 'W':\n c = c[:-1]\n\n if c.index('R') == len(c) - 1:\n return count + 1\n else:\n c = c.replace('WR', 'RR',1)[:-1]\n count += 1\n\nN = int(input())\nc= input()\n\nprint(checkFunction(c))\n", "def checkFunction(c):\n # print(c)\n while True:\n if c[0] == 'R':\n c = c[1:]\n else:\n break\n while True:\n if c[-1] == 'W':\n c = c[:-1]\n else:\n break\n if (not 'WR' in c):\n return 0\n if c.index('R') + 1 != len(c):\n c2 = c.replace('WR', 'RR',1)[:-1]\n return checkFunction(c2) + 1\n return 1\n\n\nN = int(input())\nc= input()\n\nprint(checkFunction(c))\n", "\ndef check(N, c):\n RinRight = c.count('R')\n WinLeft = 0\n r = RinRight\n for i in range(N):\n if c[i] == 'R':\n RinRight -= 1\n else: # c[i] == 'W'\n WinLeft +=1\n r = min(r, max(RinRight,WinLeft))\n\n return r\n\n\nN = int(input())\nc= input()\nprint(check(N,c))"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s212109967', 's619820277', 's924174723', 's786547268']
[304024.0, 138480.0, 371428.0, 9360.0]
[2360.0, 652.0, 536.0, 96.0]
[296, 435, 450, 307]
p02597
u417365712
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nC = input()\nt = sum(c == 'R' for c in C)\nprint(sum(c == 'R' for c in C[:t]))", 'k = int(input())\nif k % 2 == 0 or k % 5 == 0:\n print(-1)\nelse:\n s = i = 0\n while True:\n i += 1\n s = (s*10 + 7) % k\n if s % k == 0:\n print(i)\n break', 'n = int(input())\nC = input()\nprint(C[:C.count(\'R\')].count("W"))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s204041303', 's612525919', 's423903420']
[9484.0, 9172.0, 9268.0]
[53.0, 44.0, 28.0]
[93, 199, 63]
p02597
u423624748
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = input()\n\nw = [0]*(n+1)\nr = [0]*(n+1)\nfor i in range(0,n):\n w[i+1] = w[i]\n r[n-i-1] = r[n-i]\n if c[i]=='W':\n w[i+1] += 1\n if c[n-i-1]=='R':\n r[n-i-1] += 1\n\nprint([w[i]+r[i]-min(w[i],r[i]) for i in range(0,n+1)])", "n = int(input())\nc = input()\n\nw = [0]*(n+1)\nr = [0]*(n+1)\nfor i in range(0,n):\n w[i+1] = w[i]\n r[n-i-1] = r[n-i]\n if c[i]=='W':\n w[i+1] += 1\n if c[n-i-1]=='R':\n r[n-i-1] += 1\n\nprint(min([w[i]+r[i]-min(w[i],r[i]) for i in range(0,n+1)]))\n"]
['Wrong Answer', 'Accepted']
['s107993031', 's815014414']
[29624.0, 26784.0]
[239.0, 217.0]
[241, 247]
p02597
u432295780
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nk = list(input())\nws = 0\nrs = 0\nmoves = 0\nfor i in range(0, n-1):\n if k[i] == "W":\n ws += 1\n else :\n rs += 1\nif ws == 0 or rs == 0:\n print(0)\nif rs < ws:\n for i in range(0, rs-1):\n if k[i] == "W":\n moves += 1\nelse:\n for i in range(n-1, ws):\n if k[i] == "R":\n moves += 1\nprint(moves)', 'n = int(input())\nl = input()\n\nrs = l.count("R")\nprint(l[:rs].count("W"))']
['Wrong Answer', 'Accepted']
['s931560511', 's953526491']
[10736.0, 9184.0]
[70.0, 29.0]
[364, 72]
p02597
u452512115
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\n\nC = input()\n\nif N % 2 == 0:\n mid = N//2\nelse:\n mid = N//2+1\n\nWcount = C.count("W", 0, mid)\nif C[mid-1] == "W":\n Wcount -= 1\nprint(Wcount)', 'N = int(input())\n\nC = input()\n\nif N % 2 == 0:\n mid = N//2\nelse:\n mid = N//2+1\n\nRcount = C.count("R")\nrcount = C.count("R", 0, Rcount)\nprint(Rcount-rcount)']
['Wrong Answer', 'Accepted']
['s811420577', 's723762235']
[9436.0, 9332.0]
[31.0, 31.0]
[158, 156]
p02597
u456342056
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = input()\n\nred = [i for i, x in enumerate(c) if x == 'R']\nwhite = [i for i, x in enumerate(c) if x == 'W']\n\nif len(white) == 0:\n print(0)\nelif len(red) == 0:\n print(len(white) - 1)\nelse:\n red.sort(reverse=True)\n count = 0\n while(1):\n if red[0] > white[0]:\n red.pop(0)\n red.append(white[0])\n white.pop(0)\n count += 1\n break\n \n print(count)", "n = int(input())\nc = input()\n\nred = [i for i, x in enumerate(c) if x == 'R']\nwhite = [i for i, x in enumerate(c) if x == 'W']\n\nif len(white) == 0 or len(red) == 0:\n print(0)\n \nelse:\n red.sort(reverse=True)\n red_p = 0\n white_p = 0\n \n count = 0\n while(1):\n if white_p >= len(white):\n break\n elif red[red_p] < white[white_p]:\n break\n else:\n red_p += 1\n red.append(white[white_p])\n white_p += 1\n count += 1\n \n print(count)"]
['Wrong Answer', 'Accepted']
['s323626295', 's128121801']
[17344.0, 18108.0]
[2206.0, 98.0]
[444, 543]
p02597
u459391214
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nhalf_N = int(N/2)\nwords = list(input())\nct_R = words.count('R')\nct_W = words.count('W')\n\nif ct_W == ct_R:\n jhw = words[0:half_N]\n\n print(jhw.count('W'))\n \nif ct_W <= ct_R:\n jhw = words[ct_R:-1]\n print(jhw.count('R'))\n \nif ct_W >= ct_R:\n jhw = words[0:ct_R]\n print(jhw.count('R'))\n", "N = int(input())\nwords = list(input())\nct_R = words.count('R')\nct_W = words.count('W')\na = words[0:ct_R]\nW_in_a_count = a.count('W')\nprint(W_in_a_count)\n"]
['Wrong Answer', 'Accepted']
['s578292056', 's131425526']
[11840.0, 11868.0]
[43.0, 42.0]
[315, 153]
p02597
u463068683
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\ns1 = input()\ns2 = s1[::-1]\ni1 = 0\ni2 = 0\nans = 0\nwhile i1 < n:\n if s1[i1]=='W':\n while i2 < n:\n if s2[i2]=='R':\n ans += 1\n i2 += 1\n break\n elif i1+i2 >= n-2:\n break\n else:\n i2 += 1\n i1 += 1\n if i1+i2 >= n-2:\n break\n \nprint(ans)", "n = int(input())\ns1 = input()\ns2 = s1[::-1]\ni1 = 0\ni2 = 0\nans = 0\nwhile i1 < n:\n if s1[i1]=='W':\n while i2 < n:\n if s2[i2]=='R':\n ans += 1\n i2 += 1\n break\n elif i1+i2 >= n-2:\n break\n else:\n i2 += 1\n if i1+i2 >= n-2:\n break\n i1 += 1\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s600741092', 's900580239']
[9368.0, 9396.0]
[73.0, 77.0]
[306, 301]
p02597
u471214054
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nS = input()\n\nc = Counter(S)\nS_target = 'R' * c['R'] + 'W' * c['W']\n\nans = 0\nfor a, b in zip(S, S_target):\n if b == 'W':\n break\n if a != b:\n ans += 1\nprint(ans)\n", "from collections import Counter\n\nclass Levenshtein:\n\n def initArray(self,str1,str2):\n distance = []\n for i in range(len(str1)+1):\n distance.append([0]*(len(str2)+1))\n distance[i][0] = i\n for j in range(len(str2)+1):\n distance[0][j] = j\n return distance\n\n def editDist(self,str1,str2,distance):\n dist = [0]*3\n for i in range(1,len(str1)+1):\n for j in range(1,len(str2)+1):\n dist[0] = distance[i-1][j-1] if str1[i-1]==str2[j-1] else distance[i-1][j-1]+1\n dist[1] = distance[i][j-1]+1\n dist[2] = distance[i-1][j]+1\n distance[i][j]=min(dist)\n return distance[i][j]\n\n def __init__(self,str1,str2):\n self.str1 = str1\n self.str2 = str2\n Levenshtein.distance = self.initArray(str1,str2)\n Levenshtein.dist = self.editDist(str1,str2,Levenshtein.distance)\n\nN = int(input())\nS = input()\n\nc = Counter(S)\nS_target = 'R' * c['R'] + 'W' * c['W']\nprint(S_target)\n\nleven = Levenshtein(S, S_target)\nprint(leven.dist // 2)", "from collections import Counter\n\nN = int(input())\nS = input()\n\nc = Counter(S)\nS_target = 'R' * c['R'] + 'W' * c['W']\n\nans = 0\nfor a, b in zip(S, S_target):\n if b == 'W':\n break\n if a != b:\n ans += 1\nprint(ans)\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s143696740', 's693231580', 's339778670']
[9472.0, 2562376.0, 9876.0]
[30.0, 2287.0, 66.0]
[197, 1092, 230]
p02597
u476674874
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
[" for c in C[r:]:\n _counter[c] = _counter.get(c, 0) + 1\n _r = _counter.get(R, 0)\n\n ans = _r\n print(ans)\nif __name__ == '__main__':\n main()\n", 'from queue import deque\ndef main():\n R, W = "R", "W"\n N = int(input())\n C = input()\n\n counter = dict()\n for c in C:\n counter[c] = counter.get(c, 0) + 1\n r = counter.get(R, 0)\n\n _counter = dict()\n for c in C[r:]:\n _counter[c] = _counter.get(c, 0) + 1\n _r = _counter.get(R, 0)\n\n ans = _r\n print(ans)\nif __name__ == \'__main__\':\n main()\n']
['Runtime Error', 'Accepted']
['s404262434', 's317588926']
[8916.0, 9872.0]
[26.0, 67.0]
[160, 383]
p02597
u477319617
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['ans = 0\nn = int(input())\nc = input()\nprint(c)\ncheck = c[0]\ncount = 0\nflag=0\nfor i in c:\n if(i=="R"):\n count+=1\nfor i,k in enumerate(c):\n print(check,k)\n if check=="W" and k=="R":\n ans+=1\n check = "W"\n if i<count:\n flag+=1\n else:\n check = k\nprint(ans-flag)\n ', 'ans = 0\nn = int(input())\nc = input()\n#print(c)\ncheck = c[0]\ncount = 0\nflag=0\nfor i in c:\n if(i=="R"):\n count+=1\nfor i,k in enumerate(c):\n# print(check,k)\n if check=="W" and k=="R":\n ans+=1\n check = "W"\n if i<count:\n flag+=1\n else:\n check = k\nprint(ans-flag)\n ']
['Wrong Answer', 'Accepted']
['s004661120', 's180664994']
[9352.0, 9388.0]
[165.0, 100.0]
[320, 322]
p02597
u478417863
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n=int(input())\ns=input().strip()\nR=s.count('R')\nt=0\nfor i in range(R):\n if s[i]=='W':\n t=t+1\nu=R-(n-R-t)\nf=max(t,u)\nif R==0 or R==n or t==R:\n f=0\nprint(f)\n ", "import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN = int(readline())\nC = read().rstrip().decode()\n\nl, r = 0, N - 1\ncost = 0\nwhile l < r:\n if C[l] == 'R':\n l += 1\n elif C[r] == 'W':\n r -= 1\n else:\n # R...W\n cost += 1\n l += 1\n r -= 1\n\nprint(cost)\n"]
['Wrong Answer', 'Accepted']
['s644604582', 's734826777']
[9480.0, 9436.0]
[47.0, 66.0]
[172, 365]
p02597
u480264129
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n=int(input())\nc=input()\nr=c.count('R')\nw=c.count('W')\nrch=c[:r].count('W')\nwch=c[r:].count('R')\nprint(min(rch,wch))\nprint(r,w,rch,wch)", "n=int(input())\nc=input()\nr=c.count('R')\nw=c.count('W')\nrch=c[:r].count('W')\nwch=c[r:].count('R')\nprint(min(rch,wch))"]
['Wrong Answer', 'Accepted']
['s849838261', 's312497215']
[9460.0, 9456.0]
[29.0, 33.0]
[135, 116]
p02597
u482157295
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nc = list(input())\n\n\n\nans1 = 0\nfor i in range(len(c)):\n if c[-(i+1)] == "R":\n break\nans1 = min(c[0:(n-i-1)].count("R"),c[0:(n-i-1)].count("W"))\nans2 = 0\nright = 0\nfor i in range(len(c)):\n if i >= (n-right-1):\n break\n if c[i] == "W":\n for j in range(right,len(c)):\n if c[-(j+1)] == "R":\n right = j\n ans2 += 1\n break\nprint(min(ans1,ans2))', 'n = int(input())\nc = list(input())\n\nans = 0\nright = n-1\nfor i in range(n):\n if c[i] == "W":\n for j in range(right,-1,-1):\n if j <= i:\n print(ans)\n exit()\n if c[j] == "R":\n ans += 1\n right = j-1\n break\nprint(ans)']
['Wrong Answer', 'Accepted']
['s552649582', 's657833194']
[12040.0, 10604.0]
[2205.0, 92.0]
[476, 318]
p02597
u486536494
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import datetime\nimport string\nimport re\nimport math\n\nN=int(input())\ninput = input()\nstr = []\nfor i in range(N):\n str.append(input[i])\n\ncount = 0\nbegin = 0\nend = len(str) - 1\nwhile True:\n if begin < len(str):\n while str[begin] == 'W':\n begin += 1\n if begin == len(str):\n break\n\n if end >= 0:\n while str[end] == 'R':\n end -= 1\n if end == -1:\n break\n\n if begin < end:\n str[begin] = 'R'\n str[end] = 'W'\n begin += 1\n end -= 1\n count += 1\n elif begin == len(str) and end != -1:\n if str[end + 1] == 'R':\n str[end] = 'W'\n end -= 1\n count += 1\n else:\n end -= 1\n elif begin != len(str) and end == -1:\n if str[begin - 1] == 'W':\n str[begin] = 'R'\n begin += 1\n count += 1\n else:\n begin += 1\n else:\n print(count)\n break", "import datetime\nimport string\nimport re\nimport math\n\nN=int(input())\ninput = input()\nstr = []\nfor i in range(N):\n str.append(input[i])\nstr.reverse()\n\ncount = 0\nbegin = 0\nend = len(str) - 1\nwhile True:\n if begin < len(str):\n while str[begin] == 'W':\n begin += 1\n if begin == len(str):\n break\n\n if end >= 0:\n while str[end] == 'R':\n end -= 1\n if end == -1:\n break\n\n if begin < end:\n str[begin] = 'R'\n str[end] = 'W'\n begin += 1\n end -= 1\n count += 1\n elif begin >= len(str) and end > -1:\n if end != len(str) - 1:\n if str[end + 1] == 'R':\n str[end] = 'W'\n end -= 1\n count += 1\n else:\n end -= 1\n else:\n end -= 1\n elif begin < len(str) and end <= -1:\n if begin != 0:\n if str[begin - 1] == 'W':\n str[begin] = 'R'\n begin += 1\n count += 1\n else:\n begin += 1\n else:\n begin += 1\n else:\n print(count)\n break"]
['Runtime Error', 'Accepted']
['s637971493', 's623883987']
[11784.0, 11780.0]
[185.0, 216.0]
[980, 1167]
p02597
u486646943
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nc = str(input())\n\na = 0\nb = 0\n\nfor i in range(N):\n if s[i] == 'R':\n a = a + 1\nans = max(a,b)\nfor i in range(N):\n if s[i] == 'R':\n a = a - 1\n else:\n b = b + 1\n now = max(a,b)\n ans = min(ans, now)\nprint(ans)\n", "N = int(input())\ns = str(input())\n\na = 0\nb = 0\n\nfor i in range(N):\n if s[i] == 'R':\n a = a + 1\nans = max(a,b)\nfor i in range(N):\n if s[i] == 'R':\n a = a - 1\n else:\n b = b + 1\n now = max(a,b)\n ans = min(ans, now)\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s626203381', 's829104497']
[9484.0, 9480.0]
[21.0, 148.0]
[259, 259]
p02597
u498575211
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nS = input()\nr_c = 0\nch = 0\nfor i in S:\n if i == "R":\n r_c += 1\nfor i in range(r_c):\n if i == "W"\n ch += 1\nprint(ch)', 'N = int(input())\nS = input()\nr_c = 0\nch = 0\nfor i in S:\n if i == "R":\n r_c += 1\nfor i in range(r_c):\n if S[i] == "W":\n ch += 1\nprint(ch)']
['Runtime Error', 'Accepted']
['s128299552', 's740154110']
[8884.0, 9456.0]
[18.0, 66.0]
[140, 144]
p02597
u501451051
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = list(input())\n\n\nrcnt = c.count('R')\nwcnt = c.count('W')\n\nans = 0\nif set(c) == {'R'} or set(c) == {'W'}:\n print(0)\nelse:\n cnt = 0\n for i in range(rcnt):\n if c[i] == 'R':\n cnt += 1\n \n print(cnt)\n", "n = int(input())\nc = list(input())\n\n\nrcnt = c.count('R')\nwcnt = c.count('W')\n\nans = 0\nif set(c) == {'R'} or set(c) == {'W'}:\n print(0)\nelse:\n cnt = 0\n for i in range(rcnt):\n if c[i] == 'R':\n cnt += 1\n \n print(rcnt - cnt)\n"]
['Wrong Answer', 'Accepted']
['s260995057', 's509714364']
[10752.0, 10572.0]
[62.0, 61.0]
[248, 255]
p02597
u514118270
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["'import zlib\nprint(eval(zlib.decompress(b\\\\'x\\xda\\xf3\\xd3I\\xb6\\xcd\\xcc+(-\\xd1\\xd0\\xd4\\x81\\xd2\\xd6\\x05E\\x99y%\\x1a\\xc9\\xd1V\\xc9z\\xc9\\xf9\\xa5@\\xa6z\\x90\\xbaf,\\x8c\\x1d\\xae\\xae\\xa9\\t\\x00\\xf0]\\x11O\\\\')))'", "N,c=input(),input()\nprint(c[:c.count('R')].count('W'))"]
['Runtime Error', 'Accepted']
['s047884884', 's456747277']
[8728.0, 9204.0]
[24.0, 28.0]
[197, 54]
p02597
u514334797
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nc = str(input())\n\nw = c.count("W")\nr = c.count("R")\n\nans = r\n\nif w == 0:\n print(0)\nelse:\n if c[0]=="R":\n for i in range(N):\n if c[i] == "W":\n ans -= i\n print(ans)\n break\n elif c[0]=="W":\n for k in range(N):\n if c[k] == "W" and c[k+1] == "W":\n ans -= k-1\n print(ans)\n break', 'N = int(input())\nc = str(input())\n\nw = c.count("W")\nr = c.count("R")\n\nans = r\n\nif w == 0:\n print(0)\nelse:\n if c[0]=="R":\n for i in range(N):\n if c[i] == "W":\n ans -= i\n print(ans)\n break\n break\n ', 'N = int(input())\nc = str(input())\n\nw = c.count("W")\nr = c.count("R")\n\ncnt = 0\n\nfor i in range(r):\n if c[i] == "W":\n cnt += 1\n\nprint(cnt)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s111294771', 's152446219', 's939823956']
[9488.0, 9492.0, 9360.0]
[32.0, 29.0, 44.0]
[424, 275, 146]
p02597
u521839937
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["balls = list(input())\n\nbackindex = len(balls) - 1\nfrontindex = 0\nactions = 0\n\nwhile frontindex < backindex:\n if balls[frontindex] == 'W':\n while backindex > frontindex:\n if balls[backindex] == 'R':\n balls[frontindex] = 'R'\n balls[backindex] = 'W'\n actions += 1\n break\n backindex -= 1\n frontindex += 1\n\nprint(actions)", "balls = list(input())\n\nbackindex = len(balls) - 1\nfrontindex = 0\nactions = 0\n\nwhile frontindex != backindex:\n if balls[frontindex] == 'W':\n while backindex > frontindex:\n if balls[backindex] == 'R':\n balls[frontindex] = 'R'\n balls[backindex] = 'W'\n actions += 1\n break\n backindex -= 1\n frontindex += 1\n\nprint(actions)", "n = input()\nballs = list(input())\n\nbackindex = len(balls) - 1\nfrontindex = 0\nactions = 0\n\nwhile frontindex < backindex:\n if balls[frontindex] == 'W':\n while backindex > frontindex:\n if balls[backindex] == 'R':\n balls[frontindex] = 'R'\n balls[backindex] = 'W'\n actions += 1\n break\n backindex -= 1\n frontindex += 1\n\nprint(actions)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s143942240', 's462778920', 's049451908']
[9056.0, 9124.0, 10576.0]
[30.0, 30.0, 84.0]
[359, 360, 371]
p02597
u523087093
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nstones = input()\ncount_R = stones.count('R')\n\nif N == count_R:\n answer = 0\nelif N - count_R > count_R:\n answer = count_R\nelse:\n answer = count_R - 1\n\nprint(answer)\n\n", "N = int(input())\nstones = input()\n\ntotal_count_R = stones.count('R')\nleft_count_R = stones[:total_count_R].count('R')\n\nanswer = total_count_R - left_count_R\n\nprint(answer)"]
['Wrong Answer', 'Accepted']
['s541402929', 's574043214']
[9356.0, 9276.0]
[30.0, 31.0]
[191, 171]
p02597
u543016260
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N=int(input())\nC=input()\nC=[str(c) for c in C]\n\nfor i in range(N):\n if C[i]=="R":\n C=C[i:]\n break\n \nprint(min(C.count("R"),C.count("W")))', 'N=int(input())\nC=input()\nC=[str(c) for c in C]\n\nfor i in range(N):\n if C[i]=="R":\n C=C[i:]\n break\n\nfor i in range(1,N):\n if C[-i]=="W":\n C=C[:-i+1]\n break \n \n\nprint(min(C.count("R"),C.count("W")))', 'N=int(input())\nC=input()\nC=[str(c) for c in C]\n\nfor i in range(N):\n if C[i]=="R":\n C=C[i:]\n break\nfor i in range(N):\n if C[-i]=="R":\n C=C[:-i]\n break \n \n\nprint(min(C.count("R"),C.count("W")))', 'N=int(input())\nC=input()\nC=[str(c) for c in C]\n\nfor i in range(N):\n if C[i]=="R":\n C=C[i:]\n break\n\nif C[-1]=="R":\n for i in range(1,N):\n if C[-i]=="W":\n C=C[:-i+1]\n break \n \n\nprint(min(C.count("R"),C.count("W")))', 'N=int(input())\nC=input()\nC=[str(c) for c in C]\n\nfor i in range(N):\n if C[i]=="R":\n C=C[i:]\n break\nfor i in range(N):\n if C[-i]=="W":\n C=C[:-i+1]\n break \n \n\nprint(min(C.count("R"),C.count("W")))', 'N=int(input())\nC=input()\n\nans=2000001\nfor i in range(N+1):\n WL=C[:i].count("W")\n RL=C[:i].count("R")\n WR=C[i:].count("W")\n RR=C[i:].count("R")\n \n if ans>max(WR,RL):\n ans=max(WR,RL)\nprint(ans)', 'N=int(input())\nC=input()\n\nW=0\nR=C.count("R")\nans=R\nfor i in range(N):\n \n if C[i]=="R":\n R-=1\n else:\n W+=1\n if ans>max(W,R):\n ans=max(W,R)\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s043885313', 's204551696', 's443235388', 's523951912', 's631164261', 's993166046', 's434518247']
[12248.0, 12200.0, 12236.0, 12072.0, 12288.0, 9488.0, 9356.0]
[63.0, 72.0, 89.0, 73.0, 73.0, 2206.0, 122.0]
[157, 236, 231, 267, 233, 217, 182]
p02597
u556594202
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nrw = list(input())\n\nrw_after=sorted(rw)\nprint(rw_after)\n\ncount=0\nfor i in range(N):\n if rw[i] != rw_after[i]:\n count+=1\nprint(int(count/2))\n', 'N = int(input())\nrw = list(input())\n\nrw_after=sorted(rw)\n\ncount=0\nfor i in range(N):\n if rw[i] != rw_after[i]:\n count+=1\nprint(int(count/2))\n']
['Wrong Answer', 'Accepted']
['s840756658', 's365092390']
[14392.0, 12660.0]
[86.0, 73.0]
[167, 151]
p02597
u557792847
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['Cc = copy.copy(Cn)\nif (Cn[0] == "R"):\n Rflg = True\nelse:\n Rflg = False\nans = 0\nK = N-1 \nallw = False\nfor i in range(N):\n if Rflg and Cc[i] == "R":\n continue\n else:\n Rflg = True\n if Cc[i] == "W":\n for j in range(K, i, -1):\n if Cc[j] == "R":\n# print("change")\n ans += 1\n Cc[i], Cc[j] = Cc[j], Cc[i]\n K = j\n# print(Cc)\n break\n else:\n allw = True\n\n else:\n# print("replace")\n ans += 1\n Cc[i] = "W"\n# print(Cc)\n if allw:\n break', 'import sys\nimport numpy as np\nimport math\nimport collections\nimport copy\nfrom collections import deque \nfrom functools import reduce\nfrom itertools import product\nfrom itertools import combinations\n\n# input = sys.stdin.readline\nN = int(input())\nCn = list(input())\n\nCc = copy.copy(Cn)\nif (Cn[0] == "R"):\n Rflg = True\nelse:\n Rflg = False\nans = 0\nK = N-1 \nallw = False\nfor i in range(N):\n if Rflg and Cc[i] == "R":\n continue\n else:\n Rflg = True\n if Cc[i] == "W":\n for j in range(K, i, -1):\n if Cc[j] == "R":\n# print("change")\n ans += 1\n Cc[i], Cc[j] = Cc[j], Cc[i]\n K = j\n# print(Cc)\n break\n else:\n allw = True\n\n else:\n# print("replace")\n ans += 1\n Cc[i] = "W"\n# print(Cc)\n if allw:\n break\n\nprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n']
['Runtime Error', 'Accepted']
['s057938725', 's363065271']
[9124.0, 29848.0]
[29.0, 200.0]
[624, 918]
p02597
u563711100
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nm = input()\nrunlength = []\ncount = 1\nfor i in range(len(m)):\n if i == n-1:\n runlength.append([m[i],count])\n break\n if m[i] == m[i+1]:\n count += 1\n elif m[i] != m[i+1]:\n runlength.append([m[i],count])\n count = 1\n\n\ncount = 0\n\n\nfor i,j in runlength:\n if i == "W":\n count += j\n\ncount -= 1\nprint(count)', 'n = input()\nm = input()\nmaxr = m.count("R")\nmaxw = m.count("W")\n\nmin_move = len(m)\nmax_r = m.count("R")\nmax_w = m.count("W")\nright = 0\nleft = 0\nfor i in range(len(m)):\n if m[i] == "W":\n left += 1\n else:\n max_r -= 1\n if max(left,max_r) < min_move:\n min_move = max(left,max_r)\nif maxw == 0 or maxr == 0:\n print(0)\nelse:\n print(min_move)']
['Wrong Answer', 'Accepted']
['s110010041', 's784518332']
[17748.0, 9348.0]
[120.0, 126.0]
[369, 370]
p02597
u566428756
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["from collections import deque\nN=int(input())\nC=list(input())\n\nqw=deque(list())\nqr=deque(list())\n\nans=0\nfor i in range(N//2):\n if C[i]=='W':\n qw.append(i)\n if C[-(i+1)]=='R':\n qr.append(-(i+1))\n if len(qw)>0 and len(qr)>0:\n ans+=1\n l=qw.popleft()\n r=qr.popleft()\n C[l],C[r]=C[r],C[l]\n\nif len(qw)>0:\n l=qw.popleft()\n if C[l+1]=='R':\n C[l+1]='W'\n ans+=1\nelif len(qr)>0:\n r=qr.popleft()\n if C[r-1]=='W':\n C[r-1]='R'\n ans+=1\n\nif (C[N//2-1]==C[N//2]==C[N//2+1]) or (C[N//2]=='R' and C[N//2-1]=='R' and C[N//2+1]=='W') or (C[N//2]=='W' and C[N//2-1]=='R' and C[N//2+1]=='R'):\n print(ans)\nelse:\n print(ans+1)\n\n", "N=int(input())\nC=list(input())\nans=0\n\nw=0\nr=0\nfor i in range(N//2):\n print(i,C[i])\n if C[i]=='W':\n w+=1\n if C[i-2]=='R':\n r+=1\n\nif w==0 or r==0:\n ans=0\nelse:\n ans=max(w,r)\n\nprint(ans)\n", 'N=int(input())\nC=list(input())\n\nwhite=[0]*(N+1)\nred=[0]*(N+1)\n\nfor i in range(N):\n if C[i]=="W":\n white[i+1]=white[i]+1\n red[i+1]=red[i]\n else:\n white[i+1]=white[i]\n red[i+1]=red[i]+1\n\nif white[-1]==N or red[-1]==N:\n print(0)\n exit()\n\nans=float("inf")\nfor i in range(1,N):\n wcnt=white[i]\n rcnt=red[-1]-red[i]\n m=max(wcnt,rcnt)\n ans=min(m,ans)\n\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s226447928', 's790472381', 's107943743']
[14552.0, 10692.0, 20164.0]
[116.0, 98.0, 198.0]
[699, 213, 406]
p02597
u577868286
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nc = input()\nc = [char for char in c]\n\ndef op1(l, id1, id2):\n temp = l[id1]\n l[id1] = l[id2]\n l[id2] = temp\n return l\n\nr_idx, w_idx = [], []\nfor j in range(n):\n if c[j] == "R":\n r_idx.append(j)\n elif c[j] == "W":\n w_idx.append(j)\n\nans = 0\nelse:\n for i in range(min(len(r_idx), len(w_idx))): # i is number of op1\n c_i = c[:]\n c_i = op1(c_i, w_idx[j], r_idx[-j - 1])\n ans[i] += 1\n if "W" in "".join(c_i).rstrip("W"):\n ans[i] += "".join(c_i).rstrip("W").count("W")\n print(min(ans))', 'n = int(input())\nc = input()\nc = [char for char in c]\n\ndef op1(l, id1, id2):\n temp = l[id1]\n l[id1] = l[id2]\n l[id2] = temp\n return l\n\nr_idx, w_idx = [], []\nfor j in range(n):\n if c[j] == "R":\n r_idx.append(j)\n elif c[j] == "W":\n w_idx.append(j)\n\nans = 0\nfor i in range(min(len(r_idx), len(w_idx))): # i is number of op1\n c_i = c[:]\n c_i = op1(c_i, w_idx[j], r_idx[-j - 1])\n ans[i] += 1\nif "W" in "".join(c_i).rstrip("W"):\n ans[i] += "".join(c_i).rstrip("W").count("W")\nprint(min(ans))', 'n = int(input())\nc = input()\nc = [char for char in c]\n\nans = 0\nfor i in range(c.count("R")):\n if c[i] == "W":\n ans += 1\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s724745489', 's785116993', 's435875238']
[8988.0, 20368.0, 10968.0]
[26.0, 81.0, 50.0]
[563, 529, 141]
p02597
u579508806
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["from collections import Counter\nimport sys\nn = int(input())\nc = input()\ns = Counter(c)\nif s['W'] == 0 or s['R'] == 0 or c.index('R') == 0 and c.index('W') == s['R']:\n print('0')\n sys.exit()\nr = s['R']\nlas_pos=0\ncount = 0\nfor i, v in enumerate(c):\n if v == 'R':\n if i - las_pos <= r:\n r = r - (i - las_pos + 1)\n count += (i - las_pos)\n las_pos = i\n else:\n count += r\n break\n if r == 0:\n break\nprint(count)", "import sys\nfrom collections import Counter\nn = int(input())\nc = list(input())\ns = Counter(c)\nif s['R'] == 0 or s['W'] == 0:\n print('0')\n sys.exit()\npos_w=0\npos_r=n-1\ncount = 0\nfor i in range(pos_w, n):\n if c[i] != 'W':\n continue\n pos_w = i\n for j in range(pos_r, -1, -1):\n if c[j] != 'R':\n continue\n pos_r = j\n if pos_w > pos_r:\n print(count)\n sys.exit()\n c[i] = 'R'\n c[j] = 'W'\n count += 1\n break"]
['Wrong Answer', 'Accepted']
['s502685485', 's956089926']
[9708.0, 10996.0]
[74.0, 120.0]
[442, 441]
p02597
u585670729
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["X = input()\ncount_w, n, count = X.count('W'), len(X), 0\nfor i in range(n - 1, n -1 - count_w, -1):\n count += 1 if X[i] == 'R' else 0\n \nprint(count)", "n, X = int(input()), input()\ncount_w, count = X.count('W'), 0\nfor i in range(n - 1, n -1 - count_w, -1):\n count += 1 if X[i] == 'R' else 0\n \nprint(count)"]
['Wrong Answer', 'Accepted']
['s562313579', 's074239864']
[8984.0, 9200.0]
[33.0, 56.0]
[149, 155]
p02597
u591287669
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\narr = list(input())\nprint(arr)\nhead = 0\ntail = n-1\ncount = 0\nwhile True:\n while arr[head]=='R' and head<tail:\n head+=1\n while arr[tail]=='W' and head<tail:\n tail-=1\n if arr[head]=='W' and arr[tail]=='R':\n count+=1\n head+=1\n tail-=1\n if head>=tail:\n break\nprint(count)", "n = int(input())\narr = list(input())\nhead = 0\ntail = n-1\ncount = 0\nwhile True:\n while arr[head]=='R' and head<tail:\n head+=1\n while arr[tail]=='W' and head<tail:\n tail-=1\n if arr[head]=='W' and arr[tail]=='R':\n count+=1\n head+=1\n tail-=1\n if head>=tail:\n break\nprint(count)"]
['Wrong Answer', 'Accepted']
['s103964809', 's290660698']
[12560.0, 10792.0]
[80.0, 70.0]
[330, 319]
p02597
u592826944
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["# Coding is about expressing your feeling and there is always a better way to express your feeling _feelme\nimport sys,math,numpy as np\n#sys.stdin,sys.stdout=open('input.txt','r'),open('output.txt','w')\nfrom sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode\nfrom collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt\nii1=lambda:int(stdin.readline().strip())\nis1=lambda:stdin.readline().strip()\niia=lambda:list(map(int,stdin.readline().strip().split()))\nisa=lambda:stdin.readline().strip().split()\n# print('{:.3f}'.format(1),round(1.123456789,4))\n# np.set_printoptions(sign=' ',legacy='1.13') # legacy add space at sign position\n\ndef lcm(a,b): return (a*b)//gcd(a,b)\ndef setbits(n):return bin(n).count('1')\ndef resetbits(n):return bin(n).count('0')\ndef modinv(n,p):return pow(n,p-2,p)\ndef ncr(n,r):\n num,den=1,1;r=min(n,n-r)\n for i in range(r):num*=(n-i);den*=(i+1)\n return num//den\ndef ncr_p(n, r, p):\n num,den=1,1;r=min(r,n-r)\n for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p\n return (num * modinv(den,p)) % p\ndef isPrime(num) :\n if num<=1:return False\n if num==2 or n==3:return True\n if (num % 2 == 0 or num % 3 == 0) :return False\n m = int(num**0.5)+1\n for i in range(5,m,6):\n if (num % i == 0 or num % (i + 2) == 0) :return False\n return True\ndef bin_search(arr, low, high, val):\n while low <= high:\n mid = low + (high - low) // 2;\n if arr[mid] == val:return mid\n elif arr[mid] < val:low = mid + 1\n else:high = mid - 1\n return -1\ndef sumofdigit(num):\n count=0;\n while num : count+=num % 10;num //= 10;\n return count;\ndef inputmatrix():\n r,c=iia();mat=[0]*r;\n for i in range(r):mat[i]=iia();\n return r,c,mat;\ndef prefix_sum(n,arr):\n for i in range(1,n):arr[i]+=arr[i-1]\n return arr;\ndef binomial(n, k):\n if 0 <= k <= n:\n ntok = 1;ktok = 1\n for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1\n return ntok // ktok\n else:return 0\ndef divisors(n):\n res = [];\n for i in range(1,ceil(sqrt(n))+1):\n if n%i == 0:\n if i==n//i:res.append(i)\n else:res.append(i);res.append(n//i)\n return res;\n\n\nn = ii1()\ns=is1()\na=Counter(s)\nW=a['W']\nR=a['R']\nprint(W,R)\nif W == n or R == n:\n print(0,'hi')\nelse:\n countr=0\n countw=0\n for i in range(R,n):\n if s[i]=='R':\n countr+=1\n else:\n countw+=1\n print(countr)\n", "# Coding is about expressing your feeling and there is always a better way to express your feeling _feelme\nimport sys,math,numpy as np\n#sys.stdin,sys.stdout=open('input.txt','r'),open('output.txt','w')\nfrom sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode\nfrom collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt\nii1=lambda:int(stdin.readline().strip())\nis1=lambda:stdin.readline().strip()\niia=lambda:list(map(int,stdin.readline().strip().split()))\nisa=lambda:stdin.readline().strip().split()\n# print('{:.3f}'.format(1),round(1.123456789,4))\n# np.set_printoptions(sign=' ',legacy='1.13') # legacy add space at sign position\n\ndef lcm(a,b): return (a*b)//gcd(a,b)\ndef setbits(n):return bin(n).count('1')\ndef resetbits(n):return bin(n).count('0')\ndef modinv(n,p):return pow(n,p-2,p)\ndef ncr(n,r):\n num,den=1,1;r=min(n,n-r)\n for i in range(r):num*=(n-i);den*=(i+1)\n return num//den\ndef ncr_p(n, r, p):\n num,den=1,1;r=min(r,n-r)\n for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p\n return (num * modinv(den,p)) % p\ndef isPrime(num) :\n if num<=1:return False\n if num==2 or n==3:return True\n if (num % 2 == 0 or num % 3 == 0) :return False\n m = int(num**0.5)+1\n for i in range(5,m,6):\n if (num % i == 0 or num % (i + 2) == 0) :return False\n return True\ndef bin_search(arr, low, high, val):\n while low <= high:\n mid = low + (high - low) // 2;\n if arr[mid] == val:return mid\n elif arr[mid] < val:low = mid + 1\n else:high = mid - 1\n return -1\ndef sumofdigit(num):\n count=0;\n while num : count+=num % 10;num //= 10;\n return count;\ndef inputmatrix():\n r,c=iia();mat=[0]*r;\n for i in range(r):mat[i]=iia();\n return r,c,mat;\ndef prefix_sum(n,arr):\n for i in range(1,n):arr[i]+=arr[i-1]\n return arr;\ndef binomial(n, k):\n if 0 <= k <= n:\n ntok = 1;ktok = 1\n for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1\n return ntok // ktok\n else:return 0\ndef divisors(n):\n res = [];\n for i in range(1,ceil(sqrt(n))+1):\n if n%i == 0:\n if i==n//i:res.append(i)\n else:res.append(i);res.append(n//i)\n return res;\n\n\nn = ii1()\ns=is1()\na=Counter(s)\nW=a['W']\nR=a['R']\n# print(W,R)\nif W == n or R == n:\n print(0)\nelse:\n countr=0\n countw=0\n for i in range(R,n):\n if s[i]=='R':\n countr+=1\n else:\n countw+=1\n print(countr)\n"]
['Wrong Answer', 'Accepted']
['s644270799', 's128301259']
[27468.0, 27460.0]
[150.0, 161.0]
[2514, 2511]
p02597
u600673553
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = input()\nd = c.count('w')\ne = c[:d].count('w')\nprint(d-e)", 'n = int(input())\nc = input()\nd = c.count(w)\ne = c.count(w)[:d]\nprint(d-e)', "n = int(input())\nc = input()\nd = c.count('R')\ne = c[:d].count('R')\nprint(d-e)"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s355723332', 's586786983', 's397004820']
[9396.0, 9460.0, 9420.0]
[32.0, 24.0, 28.0]
[77, 73, 77]
p02597
u602773379
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n=int(input())\nc=list(str(input()))\n\ncount=0\nflag=False\n\nfor i in range(n):\n\tif c[i]=="W":\n\t\tflag=True\n\telse:\n\t\tif flag==True:\n\t\t\tcount+=1\n\t\t\tflag=False\nprint(count)', 'n=int(input())\nc=str(input())\n\nR=c.count("R")\n\ncnt=0\nfor i in range(R):\n\tif c[i]=="R":\n\t\tcnt+=1\nprint(R-cnt)']
['Wrong Answer', 'Accepted']
['s088558355', 's149269973']
[10724.0, 9404.0]
[56.0, 55.0]
[165, 108]
p02597
u616382321
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nc = input()\n\nc = [c[i] for i in range(N)]\n\ncR = c.count('R')\ncW = c.count('W')\n\nlistR = [i for i, x in enumerate(c) if x == 'R']\nlistW = [i for i, x in enumerate(c) if x == 'W']\n\nif all([i == 'R' for i in c[:cR]]):\n print(0)\n exit()\n\nif all([i == 'W' for i in c[:cW]]):\n print(0)\n exit()\n\ncnt = 0\n\nfor i in range(N):\n c[listR[-(i+1)]] = 'W'\n c[listW[i]] = 'R'\n cnt += 1\n if all([i == 'R' for i in c[:cR]]):\n print(cnt)\n break\n", "N = int(input())\nc = input()\n\ncR = c.count('R')\ncW = c.count('W')\n\n\nif all([i == 'R' for i in c[:cR]]):\n print(0)\n exit()\n\nif all([i == 'W' for i in c[cR:cR+cW]]):\n print(0)\n exit()\n\nans = c[:cR].count('W')\n\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s336857113', 's433151878']
[21708.0, 11160.0]
[2206.0, 44.0]
[505, 231]
p02597
u619557935
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nc = list(input())\nans = 0\n#print(c)\nfor i in range(N):\n flag = 0\n if c[i] == "R":\n continue\n elif c[i] == "W":\n #print(c, ans, i, sep=" ",)\n for j in reversed(range(N)):\n if i == j:\n flag = 1\n break\n if c[j] == "R":\n c[i], c[j] = c[j], c[i]\n ans += 1\n print(c, ans, sep=" ")\n break\n else:\n continue\n if flag == 1:\n break\n\nprint(ans)', 'N = int(input())\nc = list(input())\nans = 0\ncnt = c.count("W")\nans = c[N-cnt:].count("R")\nif cnt != 0:\n print(ans)\nelse:\n print(0)']
['Runtime Error', 'Accepted']
['s972596569', 's845947010']
[141236.0, 12060.0]
[2509.0, 36.0]
[527, 135]
p02597
u626881915
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\ns = list(input())\nl = 0\nr = n-1\nc = 0\nwhile l < r:\n for i in range(l, r):\n if s[i] == "W":\n l = i\n break\n else:\n l = r\n for i in range(r, l, -1):\n if s[i] == "R":\n r = i\n break\n else:\n r = l\n if l < r:\n c += 1\nprint(c)\n \n ', 'n = int(input())\ns = list(input())\nl = 0\nr = n-1\nc = 0\nwhile l < r:\n for i in range(l, r):\n if s[i] == "W":\n c += 1\n l = i+1\n break\n else:\n l = r\n for i in range(r, l-1, -1):\n if s[i] == "R":\n r = i-1\n c += 1\n break\n else:\n r = l\n\nprint(c//2)\n \n ']
['Time Limit Exceeded', 'Accepted']
['s417561853', 's055247388']
[10816.0, 10812.0]
[2206.0, 115.0]
[287, 300]
p02597
u643679148
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["# -*- coding: utf-8 -*-\nn = int(input())\ncs = input()\nr_num = 0\nw_num = 0\n\nr_num = cs.count('R')\n\nif r_num == 0 or w_num == 0:\n print(0)\nelse:\n ans = []\n W = 0\n rl_num = 0\n for c in cs:\n if c == 'R':\n rl_num += 1\n elif c == 'W':\n W += 1 \n R = r_num - rl_num \n ans.append(max(W, R))\n\n print(min(ans))\n", "# -*- coding: utf-8 -*-\nn = int(input())\ncs = input()\nr_num = 0\nw_num = 0\n\nr_num = cs.count('R')\nw_num = cs.count('W')\n\nif r_num == 0 or w_num == 0:\n print(0)\nelse:\n ans = []\n W = 0\n rl_num = 0\n for c in cs:\n if c == 'R':\n rl_num += 1\n elif c == 'W':\n W += 1\n R = r_num - rl_num\n ans.append(max(W, R))\n\n print(min(ans))\n"]
['Wrong Answer', 'Accepted']
['s293891622', 's153033507']
[9260.0, 17392.0]
[31.0, 114.0]
[508, 408]
p02597
u648881683
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n N = I()\n c = list(SS())\n c_r = c[::-1]\n\n \n if 'R' not in c or 'W' not in c:\n print(0)\n else:\n idx_R = c.index('R')\n ans0 = c[idx_R:].count('W')\n idx_W = c_r.index('W')\n ans1 = c_r[idx_W:].count('R')\n print(min(ans0, ans1))\n\nif __name__ == '__main__':\n resolve()\n", "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n N = I()\n c = list(SS())\n\n \n # WRWWRWRR\n # RRWWRWRW\n # RRRWRWWW\n # RRRRWWWW\n cnt_r = c.count('R')\n ans = max(c[:cnt_r].count('W'), c[cnt_r:].count('R'))\n # print(c[:cnt_r], c[cnt_r:])\n print(ans)\n\nif __name__ == '__main__':\n resolve()\n"]
['Wrong Answer', 'Accepted']
['s853177776', 's482248160']
[14472.0, 12880.0]
[52.0, 46.0]
[865, 753]