buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int n;
string s;
cin >> n >> s;
int wcount = 0;
int rcount = 0;
int count = 0;
rep(i, n) if (s[i] == 'W') wcount++;
rep(i, n) if (s[i] == 'R') rcoun... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int n;
string s;
cin >> n >> s;
int wcount = 0;
int rcount = 0;
int count = 0;
rep(i, n) if (s[i] == 'W') wcount++;
rep(i, n) if (s[i] == 'R') rcoun... | [["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]] | 1 | 157 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS ... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS ... | [["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]] | 1 | 355 |
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define INF long long int(1e18 + 1)
#define rep(i, n, m) for (int i = n; i < m; i++)
u... | #include <algorithm>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define INF long long int(1e18 + 1)
#define rep(i, n, m) for (int i = n; i < m; i++)
u... | [["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 106], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 98]] | 1 | 207 |
n = int(input())
cs = input()
cand1 = cs[:cs.count('R')].count('W')
cand2 = cs[cs.count('W'):].count('R')
if cand1 > cand2:
print(min(cand1, cand2))
else:
print(max(cand1, cand2)) | n = int(input())
cs = input()
cand1 = cs[:cs.count('R')].count('W')
cand2 = cs[cs.count('W'):].count('R')
if cand1 < cand2:
print(min(cand1, cand2))
else:
print(max(cand1, cand2)) | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]] | 5 | 80 |
function MainD(input) {
const arr = input.split('\n');
const N = arr[0];
const Ci = arr[1].split('');
let answer = 0;
// Wの数を数える
let Wnum = 0;
for (let i = 0; i < Ci.length; i++) {
if (Ci[i] === 'W') {
Wnum++;
}
}
if (Wnum === 0)
return console.log(0); // Wが現れなかったら0を出力
// Rの数以降のR... | function MainD(input) {
const arr = input.split('\n');
const N = arr[0];
const Ci = arr[1].split('');
let answer = 0;
// Wの数を数える
let Wnum = 0;
for (let i = 0; i < Ci.length; i++) {
if (Ci[i] === 'W') {
Wnum++;
}
}
if (Wnum === 0)
return console.log(0); // Wが現れなかったら0を出力
// Rの数以降のR... | [["-", 0, 7, 10, 570, 0, 200, 51, 16, 17, 33], ["-", 0, 7, 10, 570, 0, 200, 51, 16, 12, 555]] | 2 | 170 |
num = int(input())
stn = list(input())
num_W = stn.count('W')
num_R = stn.count('R')
cnt = 0
if num_W >= num_R:
for i in range(num_R):
if stn[i] == "W":
cnt += 1
else:
for i in range(num_W):
if stn[-i] == "R":
cnt += 1
print(cnt) | num = int(input())
stn = list(input())
num_W = stn.count('W')
num_R = stn.count('R')
cnt = 0
if num_W >= num_R:
for i in range(num_R):
if stn[i] == "W":
cnt += 1
else:
for i in range(num_W):
if stn[-i-1] == "R":
cnt += 1
print(cnt) | [["+", 0, 57, 15, 666, 0, 206, 206, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 206, 206, 657, 12, 612]] | 5 | 93 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int l = 0, h = n - 1;
int c = 0;
while (l < n && h >= 0 && l < h) {
while (l < n && s[l] == 'R') {
l++;
}
while (h >= 0 && s[l] == 'W') {
h--;
}
if (l < n && h >= 0 && l < h) {
... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int l = 0, h = n - 1;
int c = 0;
while (l < n && h >= 0 && l < h) {
while (l < n && s[l] == 'R') {
l++;
}
while (h >= 0 && s[h] == 'W') {
h--;
}
if (l < n && h >= 0 && l < h) {
... | [["-", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22]] | 1 | 134 |
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define MaxN 1000010
//#define MOD 998244353
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define endl '\n'
#define LL long long
#define PII pair<int, int>
#define rint register int
#define ULL unsigned long long
const int MOD... | #pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define MaxN 1000010
//#define MOD 998244353
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define endl '\n'
#define LL long long
#define PII pair<int, int>
#define rint register int
#define ULL unsigned long long
const int MOD... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 367 |
#include <iostream>
#include <string>
using namespace std;
#define MAX 200000
string str;
int main(void) {
int N, cnt;
cnt = 0;
cin >> N;
cin >> str;
int i = 0;
int j = N - 1;
while (i < j) {
while (str[i] = 'R')
i++;
while (str[j] = 'W')
j--;
if (str[i] == 'W' && str[j] == 'R'... | #include <iostream>
#include <string>
using namespace std;
#define MAX 200000
string str;
int main(void) {
int N, cnt;
cnt = 0;
cin >> N;
cin >> str;
int i = 0;
int j = N - 1;
while (i < j) {
while (str[i] == 'R')
i++;
while (str[j] == 'W')
j--;
if (str[i] == 'W' && str[j] == '... | [["-", 8, 9, 0, 52, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 60]] | 1 | 128 |
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n, b[N][2];
char str[N];
void trace() {
for (int i = 1; i <= n; i++)
cout << b[i][1] << "";
cout << endl;
for (int i = 1; i <= n; i++)
cout << b[i][0] << "";
cout << endl;
}
int main() {
cin >> n >> str + 1;
... | #include <iostream>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n, b[N][2];
char str[N];
void trace() {
for (int i = 1; i <= n; i++)
cout << b[i][1] << "";
cout << endl;
for (int i = 1; i <= n; i++)
cout << b[i][0] << "";
cout << endl;
}
int main() {
cin >> n >> str + 1;
... | [["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 265 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__
int main() {
int N;
cin >> N;
string C;
cin >> C;
int cnt = 0;
int l = 0;
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__
int main() {
int N;
cin >> N;
string C;
cin >> C;
int cnt = 0;
int l = 0;
... | [["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98]] | 1 | 171 |
def q4():
n = int(input())
line = input()
if 'WR' in line:
r = line.count('R')
safe = line[0:r-1].count('R')
else:
r = 0
safe = 0
print(r-safe)
if __name__ == "__main__":
q4()
| def q4():
n = int(input())
line = input()
if 'WR' in line:
r = line.count('R')
safe = line[0:r].count('R')
else:
r = 0
safe = 0
print(r-safe)
if __name__ == "__main__":
q4()
| [["-", 63, 319, 500, 206, 206, 663, 0, 657, 17, 33], ["-", 63, 319, 500, 206, 206, 663, 0, 657, 12, 612]] | 5 | 76 |
balls = list(input())
backindex = len(balls) - 1
frontindex = 0
actions = 0
while frontindex < backindex:
if balls[frontindex] == 'W':
while backindex > frontindex:
if balls[backindex] == 'R':
balls[frontindex] = 'R'
balls[backindex] = 'W'
actions += 1
break
backindex... | n = input()
balls = list(input())
backindex = len(balls) - 1
frontindex = 0
actions = 0
while frontindex < backindex:
if balls[frontindex] == 'W':
while backindex > frontindex:
if balls[backindex] == 'R':
balls[frontindex] = 'R'
balls[backindex] = 'W'
actions += 1
break
... | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 82 |
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;
const ll INF = 10000000000... | #include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;
const ll INF = 10000000000... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 275 |
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define pii pair<int, int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define All(x, v) for (auto x... | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define pii pair<int, int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define All(x, v) for (auto x... | [["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22]] | 1 | 677 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <class T> inline void read(T &res) {
char c;
T flag = 1;
while ((c = getchar()) < '0' || c > '9')
if (c == '-')
flag = -1;
res = c - '0';
while ((c = getchar()) >= '0' && c <= '9')
res = res * 10 + c - '0';
res *= flag... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
template <class T> inline void read(T &res) {
char c;
T flag = 1;
while ((c = getchar()) < '0' || c > '9')
if (c == '-')
flag = -1;
res = c - '0';
while ((c = getchar()) >= '0' && c <= '9')
res = res * 10 + c - '0';
res *= flag... | [["-", 8, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 8, 57, 15, 339, 51, 16, 12, 103, 0, 125]] | 1 | 320 |
N = int(input())
c = input()
C = []
for c_i in c:
C.append(c_i)
count = 0
left = N
for i in range(N):
if i >= left:
print(count)
break
if C[i] == 'W':
for j in reversed(range(left)):
if i == 1:
if j == i:
C[i] = 'R'
... | N = int(input())
c = input()
C = []
for c_i in c:
C.append(c_i)
count = 0
left = N-1
for i in range(N):
if i >= left:
print(count)
break
if C[i] == 'W':
for j in reversed(range(left+1)):
if i == 1:
if j == i:
C[i] = 'R'
... | [["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 141 |
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
const int cnt = 1e7 + 7;
map<int, int> mp;
int main() {
// freopen("input.txt","r",stdin);
int n;
cin >> n;
string s;
cin >> s;
int num = 0, ans = 0; // W的数量
for (int i = 0; i < n; i++)
if (s[i] == ... | #include <algorithm>
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
const int cnt = 1e7 + 7;
map<int, int> mp;
int main() {
// freopen("input.txt","r",stdin);
int n;
cin >> n;
string s;
cin >> s;
int num = 0, ans = 0; // W的数量
for (int i = 0; i < n; i++)
if (s[i] == ... | [["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]] | 1 | 129 |
// author: hitch_hiker42;
#include <bits/stdc++.h>
using namespace std;
// solution:
signed main() {
int n, count = n, moves = 0;
cin >> n;
string s;
cin >> s;
for (int i = n - 1; ~i; --i)
count -= (s[i] == 'W');
for (int i = 0; i < count; ++i)
moves += (s[i] == 'W');
cout << moves << "\n";
ret... | // author: hitch_hiker42;
#include <bits/stdc++.h>
using namespace std;
// solution:
signed main() {
int n, count, moves = 0;
cin >> n, count = n;
string s;
cin >> s;
for (int i = n - 1; ~i; --i)
count -= (s[i] == 'W');
for (int i = 0; i < count; ++i)
moves += (s[i] == 'W');
cout << moves << "\n"... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 1, 0, 34, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 8, 9, 0, 1, 0, 34, 12, 11, 31, 22], ["+", 8, 9, 0, 1, 0, 34, 12, 11, 17, 32]] | 1 | 103 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
ty... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
ty... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]] | 1 | 231 |
n = int(input())
c = input()
w = [0]*(n+1)
r = [0]*(n+1)
for i in range(0,n):
w[i+1] = w[i]
r[n-i-1] = r[n-i]
if c[i]=='W':
w[i+1] += 1
if c[n-i-1]=='R':
r[n-i-1] += 1
print([w[i]+r[i]-min(w[i],r[i]) for i in range(0,n+1)]) | n = int(input())
c = input()
w = [0]*(n+1)
r = [0]*(n+1)
for i in range(0,n):
w[i+1] = w[i]
r[n-i-1] = r[n-i]
if c[i]=='W':
w[i+1] += 1
if c[n-i-1]=='R':
r[n-i-1] += 1
print(min([w[i]+r[i]-min(w[i],r[i]) for i in range(0,n+1)]))
| [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 151 |
#include <iostream>
using namespace std;
int main() {
int n, w = 0;
char c[200010];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> c[i];
if (c[i] == 'W')
w++;
}
int ans = 0;
for (int i = 0; i < w; i++) {
if (c[i] == 'R')
ans++;
}
cout << ans << endl;
} | #include <iostream>
using namespace std;
int main() {
int n, r = 0;
char c[200010];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> c[i];
if (c[i] == 'R')
r++;
}
int ans = 0;
for (int i = 0; i < r; i++) {
if (c[i] == 'W')
ans++;
}
cout << ans << endl;
} | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["-", 8, 9, 0, 57, 64, 1, 0, 27, 28, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 27, 28, 22], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14... | 1 | 107 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
int r = 0, w = 0;
for (auto c : s)
r += c == 'r', w += c == 'w';
int cnt = 0;
for (int i = 0; i < r; i++)
cnt += s[i] == 'r';
r -= cnt;
r = max(r, 0);
cout << min(r, w) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
int r = 0, w = 0;
for (auto c : s)
r += c == 'R', w += c == 'W';
int cnt = 0;
for (int i = 0; i < r; i++)
cnt += s[i] == 'R';
r -= cnt;
r = max(r, 0);
cout << min(r, w) << endl;
return 0;
} | [["-", 0, 34, 31, 11, 12, 16, 12, 103, 0, 125], ["+", 0, 34, 31, 11, 12, 16, 12, 103, 0, 125], ["-", 0, 34, 12, 11, 12, 16, 12, 103, 0, 125], ["+", 0, 34, 12, 11, 12, 16, 12, 103, 0, 125], ["-", 8, 1, 0, 11, 12, 16, 12, 103, 0, 125], ["+", 8, 1, 0, 11, 12, 16, 12, 103, 0, 125]] | 1 | 113 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
char str[n + 1];
cin >> str;
int a = 0, b = 0;
for (int i = 0; i < n; i++) {
if (str[i] == 'R')
a++;
}
int ans = max(a, b);
for (int i = 0; i < n; i++) {
if (str[i] == 'R')
a--;
if (str[i] == 'W')
b++;
a... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
char str[n + 1];
cin >> str;
int a = 0, b = 0;
for (int i = 0; i < n; i++) {
if (str[i] == 'R')
a++;
}
int ans = max(a, b);
for (int i = 0; i < n; i++) {
if (str[i] == 'R')
a--;
if (str[i] == 'W')
... | [["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 140 |
N=int(input())
s=input()
ans=0
i,j=0,N-2
while i<j:
if s[i]=='R':
i+=1
elif s[j]=='W':
j-=1
else:
ans+=1
i+=1
j-=1
print(ans)
| N=int(input())
s=input()
ans=0
i,j=0,N-1
while i<j:
if s[i]=='R':
i+=1
elif s[j]=='W':
j-=1
else:
ans+=1
i+=1
j-=1
print(ans)
| [["-", 0, 1, 0, 662, 12, 432, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 432, 0, 657, 12, 612]] | 5 | 71 |
N = int(input())
c = input()
count = 0
rui_red = [0 for _ in range(N)]
rui_white = [0 for _ in range(N)]
now_red = 0
now_white = 0
for i in range(N):
if c[i] == "W":
now_white += 1
rui_white[i] = now_white
if c[-1-i] == "R":
now_red += 1
rui_red[-1-i] = now_red
left = 0
right =... | import sys
N = int(input())
c = input()
count = 0
rui_red = [0 for _ in range(N)]
rui_white = [0 for _ in range(N)]
now_red = 0
now_white = 0
for i in range(N):
if c[i] == "W":
now_white += 1
rui_white[i] = now_white
if c[-1-i] == "R":
now_red += 1
rui_red[-1-i] = now_red
left... | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 204 |
n=int(input())
s = input()
ans = 0
for i in s:
if i=="R":
ans+=1
for i in range(0,ans):
if i=="R":
ans-=1
print(ans) | n=int(input())
s = input()
ans = 0
for i in s:
if i=="R":
ans+=1
for i in range(0,ans):
if s[i]=="R":
ans-=1
print(ans) | [["+", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 70], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 73]] | 5 | 55 |
n = int(input())
c = list(input())#ciが R のとき赤、W のとき白
a = c.count("R")
b = 0
count = max(a, b)
# a: R->W, b: W->Rの回数
for i in range(n+1):
if c[i] == "R":
a = a - 1
else:
b = b + 1
ans = max(a, b)
count = min(ans, count)
print(count)
| n = int(input())
c = list(input())#ciが R のとき赤、W のとき白
a = c.count("R")
b = 0
count = max(a, b)
# a: R->W, b: W->Rの回数
for i in range(n):
if c[i] == "R":
a = a - 1
else:
b = b + 1
ans = max(a, b)
count = min(ans, count)
print(count)
| [["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 91 |
def main():
n = int(input())
word = list(input())
l, r = 0, n - 1
cnt = 0
while l < r:
while l < r and word[l] == 'R':
l += 1
while l < r and word[r] == 'L':
r -= 1
if l < r:
word[l], word[r] = word[r], word[l]
cnt += 1
... | def main():
n = int(input())
word = list(input())
l, r = 0, n - 1
cnt = 0
while l < r:
while l < r and word[l] == 'R':
l += 1
while l < r and word[r] == 'W':
r -= 1
if l < r:
word[l], word[r] = word[r], word[l]
cnt += 1
... | [["-", 0, 52, 15, 679, 12, 666, 0, 557, 0, 6], ["+", 0, 52, 15, 679, 12, 666, 0, 557, 0, 6]] | 5 | 119 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner kbd = new Scanner(System.in);
int n = kbd.nextInt();
String c = kbd.next();
String r = "W";
int num = 0;
int a = 0;
for (int i = 0; i < n; i++) {
if (c.charAt(i) == r.charAt(0)) {
... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner kbd = new Scanner(System.in);
int n = kbd.nextInt();
String c = kbd.next();
String r = "W";
int num = 0;
int a = 0;
for (int i = 0; i < n; i++) {
if (c.charAt(i) == r.charAt(0)) {
... | [["+", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33]] | 3 | 153 |
n=int(input())
a=input()
con=0
ans=n
for i in range(n):
if i==ans:
break
if a[i]=="W":
con+=1
while ans>=0:
ans-=1
if i==ans:
print(con)
exit()
if a[ans]=="R":
break
print(con) | n=int(input())
a=input()
con=0
ans=n
for i in range(n):
if i==ans:
break
if a[i]=="W":
con+=1
while ans>=0:
ans-=1
if i==ans:
print(con-1)
exit()
if a[ans]=="R":
break
print(con) | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 81 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, sum = 0, sum2 = 0;
;
string s;
cin >> n;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'W') {
sum++;
}
}
for (int i = n; i > n - sum; i--) {
if (s[i] == 'W')
sum2++;
}
cout << sum - sum2 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, sum = 0, sum2 = 0;
;
string s;
cin >> n;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'W') {
sum++;
}
}
for (int i = n - 1; i >= n - sum; i--) {
if (s[i] == 'W')
sum2++;
}
cout << sum - sum2 << en... | [["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]] | 1 | 111 |
#include <stdio.h>
int main() {
int b, is_red = 0, count = 0;
char a[200000] = {};
scanf("&d", &a);
scanf("%s", &a);
for (int i = 0; i < 200000; i++) {
if (a[i] == 'R')
is_red++;
}
count = is_red;
for (int i = 0; i < is_red; i++) {
if (a[i] == 'R')
count--;
}
printf("%d", count);... | #include <stdio.h>
int main() {
int b, is_red = 0, count = 0;
char a[200000] = {};
scanf("&d", &b);
scanf("%*s%s", &a);
for (int i = 0; i < 200000; i++) {
if (a[i] == 'R')
is_red++;
}
count = is_red;
for (int i = 0; i < is_red; i++) {
if (a[i] == 'R')
count--;
}
printf("%d", coun... | [["-", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 124 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
char str[N];
cin >> str;
int ans = 0;
int count = 0;
for (int i = 0; i < N; i++) {
if (str[i] == 'W') {
count++;
}
}
for (int i = count; i < N; i++) {
if (str[i] == 'R') {
ans++;
}
}
cout << a... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
char str[N];
cin >> str;
int ans = 0;
int count = 0;
for (int i = 0; i < N; i++) {
if (str[i] == 'R') {
count++;
}
}
for (int i = count; i < N; i++) {
if (str[i] == 'R') {
ans++;
}
}
cout << a... | [["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]] | 1 | 111 |
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template <class T> inline bool chmin(T &a, T b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if ... | #include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template <class T> inline bool chmin(T &a, T b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if ... | [["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 260 |
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
n = int(input())
c = input()
wcount = c.count("W")
rcount = c.count("R")
check = 0
num = min(wcount, rc... | #n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
n = int(input())
c = input()
wcount = c.count("W")
rcount = c.count("R")
check = 0
num = min(wcount, rc... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 22],... | 5 | 110 |
n = int(input())
c = list(input())
left = 0
cnt = 0
right = len(c) - 1
while left < n and right >=0 and left < right:
while left < n and c[left] != 'W':
left += 1
while right >= 0 and c[right] != 'R':
right -= 1
if left < n and right >= 0:
c[left], c[right] = c[right], c[left]
... | n = int(input())
c = list(input())
left = 0
cnt = 0
right = len(c) - 1
while left < n and right >=0 and left < right:
while left < n and c[left] != 'W':
left += 1
while right >= 0 and c[right] != 'R':
right -= 1
if left< n and right >= 0 and left<right:
c[left], c[right] = c[right], ... | [["+", 0, 52, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 18]] | 5 | 118 |
input()
l =list(input())
cw = l.count('W')
cr = l.count('R')
if cr < cw:
ans = l[:cr].count('W')
else:
ans = l[cw:].count('R')
print(ans) | input()
l =list(input())
cw = l.count('W')
cr = l.count('R')
if cr < cw:
ans = l[:cr].count('W')
else:
ans = l[cr:].count('R')
print(ans) | [["-", 12, 652, 63, 319, 500, 206, 206, 663, 0, 22], ["+", 12, 652, 63, 319, 500, 206, 206, 663, 0, 22]] | 5 | 70 |
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define i(x) cin >> x
#define fr(n, x) for (ll n = 0; n < x; n++)
#define pf(x) cout << x
const ll mod = 1e9 + 7;
void solv() {
ll x;
string s;
cin >> x >> s;
ll wt = 0, rd = 0;
fr(n, x) { s[n] == '... | #include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define i(x) cin >> x
#define fr(n, x) for (ll n = 0; n < x; n++)
#define pf(x) cout << x
const ll mod = 1e9 + 7;
void solv() {
ll x;
string s;
cin >> x >> s;
ll wt = 0, rd = 0;
fr(n, x) { s[n] == '... | [["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33]] | 1 | 184 |
#include <iostream>
#include <string>
int main() {
int N;
std::cin >> N;
std::string c;
std::cin >> c;
int result = 0;
for (int i = 0, j = N - 1; i < j; i++) {
if (c[i] == 'W') {
for (; i < j; j--) {
if (c[j] = 'R') {
result++;
auto t = c[i];
c[i] = c[j];
... | #include <iostream>
#include <string>
int main() {
int N;
std::cin >> N;
std::string c;
std::cin >> c;
int result = 0;
for (int i = 0, j = N - 1; i < j; i++) {
if (c[i] == 'W') {
for (; i < j; j--) {
if (c[j] == 'R') {
result++;
auto t = c[i];
c[i] = c[j];
... | [["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]] | 1 | 141 |
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve() {
int n;
cin >> n;
string s;
cin >> s;
int white[n], red[n];
int idx1 = 0, idx2 = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'W') {
white[idx1++] = i;
} else {
red[idx2++] = i;
}
}
int cnt = 0;
... | #include <bits/stdc++.h>
#define int long long
using namespace std;
void solve() {
int n;
cin >> n;
string s;
cin >> s;
int white[n], red[n];
int idx1 = 0, idx2 = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'W') {
white[idx1++] = i;
} else {
red[idx2++] = i;
}
}
int cnt = 0;
... | [["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73]] | 1 | 174 |
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <unistd.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(), (a).end()
#define vecin(a) rep(i, a.size()) cin >> a[i]
#define vecout(a) ... | #include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <unistd.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(), (a).end()
#define vecin(a) rep(i, a.size()) cin >> a[i]
#define vecout(a) ... | [["-", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 1,020 |
import sys
from collections import Counter
N = int(sys.stdin.readline().rstrip())
S = [x for x in input()]
C = Counter(S)
W = C["W"]
R = C["R"]
SS = S[:W]
CC = Counter(SS)
WW = CC["W"]
print(WW)
| import sys
from collections import Counter
N = int(sys.stdin.readline().rstrip())
S = [x for x in input()]
C = Counter(S)
W = C["W"]
R = C["R"]
SS = S[:R]
CC = Counter(SS)
RR = CC["W"]
print(RR)
| [["-", 0, 1, 0, 662, 12, 206, 206, 663, 0, 22], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 80 |
#include <cstdio>
#include <iostream>
using namespace std;
const int maxn = 2e5 + 50;
int n, tot, cnt, a[maxn];
int main() {
cin >> n;
getchar(), getchar();
for (int i = 1; i <= n; i++)
a[i] = (getchar() == 'R'), tot += a[i];
// for(int i = 1; i <= n; i ++) cout << a[i] << ' ';
// cout << endl;
for (int... | #include <cstdio>
#include <iostream>
using namespace std;
const int maxn = 2e5 + 50;
int n, tot, cnt, a[maxn];
int main() {
cin >> n;
getchar();
for (int i = 1; i <= n; i++)
a[i] = (getchar() == 'R'), tot += a[i];
// for(int i = 1; i <= n; i ++) cout << a[i] << ' ';
// cout << endl;
for (int i = 1; i <... | [["-", 0, 14, 8, 9, 0, 1, 0, 34, 0, 21], ["-", 8, 9, 0, 1, 0, 34, 12, 2, 63, 22], ["-", 0, 1, 0, 34, 12, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 34, 12, 2, 3, 4, 0, 25]] | 1 | 120 |
n = int(input())
c = input()
r_num = c.count("R")
for i in range(n):
if c[i] == "W":
break
print(max(c[i:].count("R")-c[:r_num].count("R"), 0))
| n = int(input())
c = input()
r_num = c.count("R")
for i in range(n):
if c[i] == "W":
break
print(max(c[i:].count("R")-c[i:r_num].count("R"), 0)) | [["+", 12, 652, 63, 319, 500, 206, 206, 663, 0, 22]] | 5 | 75 |
n=int(input())
a=list(input())
x = a.count('W')
ans = 0
for i in range(x):
if a[i] == 'W':
ans += 1
print(ans) | n=int(input())
a=list(input())
x = a.count('R')
ans = 0
for i in range(x):
if a[i] == 'W':
ans += 1
print(ans) | [["-", 0, 662, 12, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 662, 12, 652, 3, 4, 0, 557, 0, 6]] | 5 | 54 |
N = int(input())
C = input()
left = N - 1
count = 0
for right in range(N):
if right == left:
break
if C[right] == 'W':
while C[left] == 'W' and right <= left:
left -= 1
if C[left] == 'W':
break
count += 1
left -= 1
print(count) | N = int(input())
C = input()
left = N - 1
count = 0
for right in range(N):
if right == left:
break
if C[right] == 'W':
while C[left] == 'W' and right < left:
left -= 1
if C[left] == 'W':
break
count += 1
left -= 1
# print(left)
print(count) | [["-", 64, 196, 0, 52, 15, 679, 12, 666, 667, 19], ["+", 64, 196, 0, 52, 15, 679, 12, 666, 667, 18]] | 5 | 83 |
import java.math.BigInteger;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N =... | import java.math.BigInteger;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N =... | [["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 22]] | 3 | 228 |
import sys
import math
n = int(sys.stdin.readline().rstrip("\n"))
c = list(sys.stdin.readline().rstrip("\n"))
ans = 0
left, right = 0, len(arr) - 1
while(left < right):
while(c[left] == 'R'):
left += 1
if left >= n:
break
while(c[right] == 'W'):
right -= 1
if right ... | import sys
import math
n = int(sys.stdin.readline().rstrip("\n"))
c = list(sys.stdin.readline().rstrip("\n"))
ans = 0
left, right = 0, n-1
while(left < right):
while(c[left] == 'R'):
left += 1
if left >= n:
break
while(c[right] == 'W'):
right -= 1
if right < 0:
... | [["-", 0, 662, 12, 432, 0, 657, 31, 652, 63, 22], ["-", 12, 432, 0, 657, 31, 652, 3, 4, 0, 24], ["-", 12, 432, 0, 657, 31, 652, 3, 4, 0, 22], ["-", 12, 432, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 432, 0, 657, 31, 22]] | 5 | 142 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll ... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll ... | [["-", 8, 9, 0, 1, 0, 16, 12, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 2, 63, 22]] | 1 | 392 |
#include <bits/stdc++.h>
#define f(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main(void) {
int len, ans = 0;
cin >> len;
// char s[200010];
string s;
cin >> s;
// memset(s, 0, sizeof(s));
// for(int i = 0; i <= len; i++){
// scanf("%c", &s[i]);
// }
// for(int ... | #include <bits/stdc++.h>
#define f(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main(void) {
int len, ans = 0;
cin >> len;
// char s[200010];
string s;
cin >> s;
// memset(s, 0, sizeof(s));
// for(int i = 0; i <= len; i++){
// scanf("%c", &s[i]);
// }
// for(int ... | [["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 136 |
n=int(input())
a=list(input())
c=a.count("W")
b=a[:n-c]
d=b.count("W")
print(d)
print(b) | n=int(input())
a=list(input())
c=a.count("W")
b=a[:n-c]
d=b.count("W")
print(d)
| [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 53 |
package main
import (
"fmt"
)
func main() {
var n int
var s string
fmt.Scan(&n)
fmt.Scan(&s)
countR := 0
countW := 0
for _, r := range s {
if r == 'R' {
countR++
} else {
countW++
}
}
if countR == 0 || countW == 0 {
fmt.Println(0)
return
}
maxR := make([]int, 0)
minW := make([]int, 0)
... | package main
import (
"fmt"
)
func main() {
var n int
var s string
fmt.Scan(&n)
fmt.Scan(&s)
countR := 0
countW := 0
for _, r := range s {
if r == 'R' {
countR++
} else {
countW++
}
}
if countR == 0 || countW == 0 {
fmt.Println(0)
return
}
maxR := make([]int, 0)
minW := make([]int, 0)
... | [["-", 8, 196, 0, 431, 12, 432, 0, 2, 63, 22], ["+", 8, 196, 0, 431, 12, 432, 0, 2, 63, 22], ["-", 36, 36, 36, 36, 0, 434, 0, 435, 141, 22], ["+", 36, 36, 36, 36, 0, 434, 0, 435, 141, 22], ["-", 0, 435, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 435, 8, 196, 0, 57, 15, 16, 17, 18]] | 7 | 244 |
n = int(input())
c_str = input()
c_list = list(c_str)
cnt = 0
flag = 1
w_pos = 0
r_pos = 0
range_start = 0
range_end = n
while flag:
for i in range(range_start, range_end):
if c_list[i] == "W":
w_pos = i
range_start = i
break
if i == range_end-1:
w_p... | n = int(input())
c_str = input()
c_list = list(c_str)
cnt = 0
flag = 1
w_pos = 0
r_pos = 0
range_start = 0
range_end = n
while flag:
for i in range(range_start, range_end):
if c_list[i] == "W":
w_pos = i
range_start = i
break
if i == range_end-1:
w_p... | [["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 154 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string S;
cin >> S;
vector<char> A(N);
for (int i = 0; i < N; i++)
A.at(i) = S.at(i);
int s = S.size();
string rS = S;
reverse(rS.begin(), rS.end());
int count = 0;
if (rS.find("R") != string::npos && rS.find("W") !=... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string S;
cin >> S;
vector<char> A(N);
for (int i = 0; i < N; i++)
A.at(i) = S.at(i);
int s = S.size();
string rS = S;
reverse(rS.begin(), rS.end());
int count = 0;
if (rS.find("R") != string::npos && rS.find("W") !=... | [["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 245 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long N;
long numR = 0;
long numW = 0;
long RtoW = 0;
long WtoR = 0;
cin >> N;
char c[200000];
for (long i = 0; i < N; i++) {
cin >> c[i];
if (c[i] == 'R') {
numR++;
}
if (c[i] == 'W') {
numW++;
}
}
for (long ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long N;
long numR = 0;
long numW = 0;
long RtoW = 0;
long WtoR = 0;
cin >> N;
char c[200000];
for (long i = 0; i < N; i++) {
cin >> c[i];
if (c[i] == 'R') {
numR++;
}
if (c[i] == 'W') {
numW++;
}
}
for (long ... | [["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]] | 1 | 191 |
N = int(input())
S = input()
prev = S[0]
cur = 'R'
count = 0
wNum = 0
changedPoint = -1
changed = False
for i in range(N-1, -1, -1):
cur = S[i]
changed = False
if cur == 'R':
for j in range(wNum, i):
wNum = j + 1
if S[j] == 'W':
changedPoint = j
... | N = int(input())
S = input()
prev = S[0]
cur = 'R'
count = 0
wNum = 0
changedPoint = -1
changed = False
for i in range(N-1, -1, -1):
cur = S[i]
changed = False
if cur == 'R':
for j in range(wNum, i):
wNum = j + 1
if S[j] == 'W':
changedPoint = j
... | [["-", 0, 57, 75, 665, 15, 679, 12, 666, 667, 79], ["+", 0, 57, 75, 665, 15, 679, 12, 666, 667, 18]] | 5 | 141 |
#include <bits/stdc++.h>
using namespace std;
void solve(int N, string c) {
int i = 0, j = N - 1;
int ans = 0;
while (1) {
while (i < N - 1 && c[i] == 'R') {
i++;
}
if (i == N - 1) {
break;
}
if (j > 0 && c[j] == 'C') {
j--;
}
if (j == 0) {
break;
}
if ... | #include <bits/stdc++.h>
using namespace std;
void solve(int N, string c) {
int i = 0, j = N - 1;
int ans = 0;
// WR をなくす
// →左から W を探して、右から R を探して、入れ替える
while (1) {
while (i < N - 1 && c[i] == 'R') {
i++;
}
if (i == N - 1) {
break;
}
while (j > 0 && c[j] == 'W') {
j--;
... | [["-", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["+", 8, 9, 0, 52, 8, 9, 0, 52, 0, 89], ["-", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125]] | 1 | 165 |
#include <algorithm>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define DBL_MIN 0.000000000000001
#de... | #include <algorithm>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define DBL_MIN 0.000000000000001
#de... | [["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13]] | 1 | 228 |
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#incl... | #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#incl... | [["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 442 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int wnum = 0;
int rnum = 0;
int ans = 0;
char[] C = new char[N];
String text = sc.next();
for (int i = 0; i < N; i++) {
C[i] = text.ch... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int wnum = 0;
int rnum = 0;
int ans = 0;
char[] C = new char[N];
String text = sc.next();
for (int i = 0; i < N; i++) {
C[i] = text.ch... | [["-", 502, 503, 49, 200, 51, 16, 31, 16, 31, 22], ["-", 502, 503, 49, 200, 51, 16, 31, 16, 17, 33], ["-", 502, 503, 49, 200, 51, 16, 31, 16, 12, 499], ["-", 0, 7, 502, 503, 49, 200, 51, 16, 17, 33], ["-", 0, 7, 502, 503, 49, 200, 51, 16, 12, 22], ["+", 75, 196, 0, 7, 502, 503, 49, 200, 51, 22]] | 3 | 185 |
n = int(input())
c = input()
r=0
w=0
p=0
count = 0
for i in range(len(c)):
if c[i]=="R":
r+=1
else:
w+=1
white = []
for i in range(len(c)):
if c[i]=="R":
r-=1
else:
white.append(r)
if r==0:
break
if len(white)==0:
print(0)
if white[0]==0:
pri... | n = int(input())
c = input()
r=0
w=0
p=0
count = 0
for i in range(len(c)):
if c[i]=="R":
r+=1
else:
w+=1
white = []
for i in range(len(c)):
if c[i]=="R":
r-=1
else:
white.append(r)
if r==0:
break
if len(white)==0:
print(0)
elif white[0]==0:
p... | [["-", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 75, 665, 0, 683], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 163 |
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy
def main():
N = int(input())
S = input()
l=0
r=len(S)-1
ans=0
while(1):
for i in range(l,len(S)):
if S[i]=='W':
l=i
break
for... | import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy
def main():
N = int(input())
S = input()
l=0
r=len(S)-1
ans=0
while(1):
for i in range(l,len(S)):
if S[i]=='W':
l=i
break
for... | [["-", 0, 52, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 149 |
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
char s[n + 1];
scanf("%s", s);
int l = 0, r = n;
int cnt_W = 0, cnt_R = 0, turn = 0;
while (l < r) {
if (s[l] == 'W' && !turn) {
cnt_W++;
turn = 1;
} else if (s[r] == 'R' && turn) {
cnt_R++;
turn = 0;
}
if (!t... | #include <stdio.h>
int main() {
int n;
scanf("%d", &n);
char s[n + 1];
scanf("%s", s);
int l = 0, r = n;
int cnt_W = 0, cnt_R = 0, turn = 0;
while (l < r) {
if (s[l] == 'W' && !turn) {
cnt_W++;
turn = 1;
} else if (s[r] == 'R' && turn) {
cnt_R++;
turn = 0;
}
if (!t... | [["-", 0, 2, 3, 4, 0, 41, 15, 16, 17, 60], ["+", 0, 2, 3, 4, 0, 41, 15, 16, 17, 19], ["-", 0, 1, 0, 2, 3, 4, 0, 41, 75, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 41, 75, 22]] | 0 | 152 |
s = int(input())
n = input()
str_list = list(n)
w_cnt = str_list.count('W')
r_cnt = str_list.count('R')
if w_cnt == 0 or r_cnt == 0:
print(0)
else:
w_result = str_list[w_cnt:]
r_result = str_list[:r_cnt]
r = w_result.count('R')
w = r_result.count('W')
if w <= r:
print(r)
else:
... | s = int(input())
n = input()
str_list = list(n)
w_cnt = str_list.count('W')
r_cnt = str_list.count('R')
if w_cnt == 0 or r_cnt == 0:
print(0)
else:
w_result = str_list[r_cnt:]
r_result = str_list[:r_cnt]
r = w_result.count('R')
w = r_result.count('W')
if w <= r:
print(w)
else:
... | [["-", 0, 1, 0, 662, 12, 206, 206, 663, 0, 22], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 103 |
n=int(input())
C=list(input())
if C.count("W")==0:
print(0)
elif C.count("W")==1:
if C[-1]=="W":
print(0)
else:
print(1)
else:
tmpw=C.count("W")
#print(tmpw,C)
C=C[tmpw:]
#print(tmpw,C)
print(C.count("R"))
| n=int(input())
C=list(input())
if C.count("W")==0:
print(0)
elif C.count("W")==1:
if C[-1]=="W":
print(0)
else:
print(1)
else:
tmpw=C.count("W")
#print(tmpw,C)
#if tmpw%2==0:
C=C[(n-tmpw):]
#print(tmpw,C)
print(C.count("R"))
#else:
... | [["+", 0, 662, 12, 206, 206, 663, 0, 23, 0, 24], ["+", 12, 206, 206, 663, 0, 23, 0, 657, 31, 22], ["+", 12, 206, 206, 663, 0, 23, 0, 657, 17, 33], ["+", 0, 662, 12, 206, 206, 663, 0, 23, 0, 25]] | 5 | 97 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
char c[maxn];
int a[maxn], b[maxn];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> c[i];
int ans = 0x3f3f3f3f;
for (int i = 1; i <= n + 1; i++) {
if (c[i] == 'W')
a[i] = a[i - 1] + 1;
else
a[i] ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
char c[maxn];
int a[maxn], b[maxn];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> c[i];
int ans = 0x3f3f3f3f;
for (int i = 1; i <= n + 1; i++) {
if (c[i] == 'W')
a[i] = a[i - 1] + 1;
else
a[i] ... | [["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]] | 1 | 222 |
#include <bits/stdc++.h>
#define zton(i, n) for (int i = 0; i <= n; i++)
#define oneton(i, n) for (int i = 1; i <= n; i++)
#define fo(i, n) for (int i = 0; i < n; i++)
#define fab(i, a, b) for (int i = a; i < b; i++)
#define loop(i, b, a) for (int i = a; i >= b; i--)
#define dsort(arr, n) sort(arr, arr + n, greater<in... | #include <bits/stdc++.h>
#define zton(i, n) for (int i = 0; i <= n; i++)
#define oneton(i, n) for (int i = 1; i <= n; i++)
#define fo(i, n) for (int i = 0; i < n; i++)
#define fab(i, a, b) for (int i = a; i < b; i++)
#define loop(i, b, a) for (int i = a; i >= b; i--)
#define dsort(arr, n) sort(arr, arr + n, greater<in... | [["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95]] | 1 | 564 |
#include <iostream>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
string stones;
cin >> stones;
int i = 0;
int j = N - 1;
int count = 0;
while (i < j) {
while (stones[i] == 'R') {
i++;
}
if (i >= j)
break;
while (stones[j] == 'W') {
if (j == 0)
... | #include <iostream>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
string stones;
cin >> stones;
int i = 0;
int j = N - 1;
int count = 0;
while (i < j) {
while (stones[i] == 'R') {
i++;
}
if (i >= j)
break;
while (stones[j] == 'W') {
if (j == 0)
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 124 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int i;
int n;
char *x;
x = (char *)malloc(200000);
int w = 0;
int ans = 0;
scanf("%d", &n);
scanf("%s", x);
char *y;
y = x;
for (i = 0; i < n; i++) {
if (strncmp(y, "W", 1) == 0) {
w++;
}
++y;
}
y = x;
... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int i;
int n;
char *x;
x = (char *)malloc(200000);
int w = 0;
int ans = 0;
scanf("%d", &n);
scanf("%s", x);
char *y;
y = x;
for (i = 0; i < n; i++) {
if (strncmp(y, "R", 1) == 0) {
w++;
}
++y;
}
y = x;
... | [["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6]] | 0 | 167 |
from collections import Counter
N = int(input())
C = input()
l = 0
r = N - 1
cnt = 0
while l < r:
while l < r and C[l] == 'R':
l += 1
while l < r and C[r] == 'W':
r -= 1
cnt += 1
l += 1
r -= 1
d = Counter(C)
min_ = min(d['W'], d['R'])
print(min(min_, cnt))
| from collections import Counter
N = int(input())
C = input()
l = 0
r = N - 1
cnt = 0
while l < r:
while l < r and C[l] == 'R':
l += 1
while l < r and C[r] == 'W':
r -= 1
if l < r:
cnt += 1
l += 1
r -= 1
d = Counter(C)
min_ = min(d['W'], d['R'])
print(min(min_, cnt))
| [["+", 0, 656, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 656, 0, 52, 8, 196, 0, 57, 0, 102]] | 5 | 109 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int n;
cin >> n;
string c;
cin >> c;
int num_w = count(c.begin(), c.end(), 'W');
string sub = c.substr(0, num_w);
cout << count(sub.begin(), sub.end(... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int n;
cin >> n;
string c;
cin >> c;
int num_w = count(c.begin(), c.end(), 'R');
string sub = c.substr(0, num_w);
cout << count(sub.begin(), sub.end()... | [["-", 49, 50, 51, 2, 3, 4, 0, 103, 0, 125], ["+", 49, 50, 51, 2, 3, 4, 0, 103, 0, 125]] | 1 | 107 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
int white = 0;
int red = 0;
int w[200005] = {0};
int r[200005] = {0};
string t;
for (int i = 0; i < n; i++) {
char c;
cin >> c;
t += c;
}
for (int i = 0; i < n; i++) {
if (t[i] == 'W') {... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
int white = 0;
int red = 0;
int w[200005] = {0};
int r[200005] = {0};
string t;
for (int i = 0; i < n; i++) {
char c;
cin >> c;
t += c;
}
for (int i = 0; i < n; i++) {
if (t[i] == 'W') {... | [["-", 12, 69, 341, 342, 0, 16, 31, 16, 12, 13], ["+", 12, 69, 341, 342, 0, 16, 31, 16, 12, 13]] | 1 | 253 |
n = int(input())
red = []
white = []
s = input()
for i in range(n):
if s[i] == "R":
red.append(i)
else:
white.append(i)
roop_min_num = min(len(red), len(white))
res = 0
for i in range(roop_min_num):
if white[i] < red[-i]:
res += 1
print(res)
| n = int(input())
red = []
white = []
s = input()
for i in range(n):
if s[i] == "R":
red.append(i)
else:
white.append(i)
roop_min_num = min(len(red), len(white))
res = 0
for i in range(roop_min_num):
if white[i] < red[-i - 1]:
res += 1
print(res)
| [["+", 0, 57, 15, 666, 0, 206, 206, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 206, 206, 657, 12, 612]] | 5 | 97 |
N = int(input())
S = input()
A = int(S.count("R"))
if A == N:
print(A)
exit()
s = S[:A]
B = int(s.count("R"))
print(A-B) | N = int(input())
S = input()
A = int(S.count("R"))
if A == N:
print(0)
exit()
s = S[:A]
B = int(s.count("R"))
print(A-B) | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]] | 5 | 64 |
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
int find_left(const std::string &s, int start, char c) {
auto index = s.find(c, start);
return index == std::string::npos ? -1 : index;
}
int find_right(const std::string &s, int start, char c) {
auto index = s.rfind... | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
int find_left(const std::string &s, int start, char c) {
auto index = s.find(c, start);
return index == std::string::npos ? -1 : index;
}
int find_right(const std::string &s, int start, char c) {
auto index = s.rfind... | [["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22]] | 1 | 268 |
N = int(input())
S = input()
l = 0
r = len(S) - 1
W = 'W'
R = 'R'
cnt = 0
while l < r:
if S[l] == R:
l += 1
continue
else:
while l < r:
if S[r] == W:
r -= 1
continue
else:
cnt += 1
l += 1
... | N = int(input())
S = input()
l = 0
r = len(S) - 1
W = 'W'
R = 'R'
cnt = 0
while l < r:
if S[l] == R:
l += 1
continue
else:
while l < r:
if S[r] == W:
r -= 1
continue
else:
cnt += 1
l += 1
... | [["+", 0, 57, 75, 76, 8, 196, 0, 93, 0, 94]] | 5 | 88 |
#include <stdio.h>
#include <stdlib.h>
int main() {
int i = 0, j = 0;
int n;
scanf("%d", &n);
char *c = malloc(sizeof(char) * n + 10);
scanf("%s", c);
int cnt = 0;
while (i + j < n - 1) {
while (c[i] == 'R') {
i++;
}
while (c[n - j] == 'W') {
j++;
}
c[i] = 'R';
c[n - ... | #include <stdio.h>
#include <stdlib.h>
int main() {
int i = 0, j = 0;
int n;
scanf("%d", &n);
char *c = malloc(sizeof(char) * n + 10);
scanf("%s", c);
int cnt = 0;
while (i + j < n - 1) {
while (c[i] == 'R') {
i++;
}
while (c[n - j - 1] == 'W') {
j++;
}
c[i] = 'R';
c[... | [["+", 15, 23, 0, 16, 31, 69, 71, 16, 17, 33], ["+", 15, 23, 0, 16, 31, 69, 71, 16, 12, 13], ["+", 0, 1, 0, 11, 31, 69, 71, 16, 17, 33], ["+", 0, 1, 0, 11, 31, 69, 71, 16, 12, 13]] | 0 | 145 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N = 0;
cin >> N;
string A;
cin >> A;
int temp = 0;
int ans = 0;
int ansans = 0;
for (int i = 0; i < N; i++) {
if (A.at(i) == 'W') {
ansans++;
}
}
for (size_t i = 0; i < min(ansans, N - ansans); i++) {
if (A.at(i) == ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N = 0;
cin >> N;
string A;
cin >> A;
int temp = 0;
int ans = 0;
int ansans = 0;
for (int i = 0; i < N; i++) {
if (A.at(i) == 'W') {
ansans++;
}
}
for (size_t i = 0; i < N - ansans; i++) {
if (A.at(i) == 'W') {
... | [["-", 8, 9, 0, 7, 15, 16, 12, 2, 63, 22], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 24], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 22], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 21], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 25]] | 1 | 141 |
N=int(input())
c=input()
C=[]
for i in range(N):
C.append(c[i])
num= C.count("W")
CC=C[num:]
numnum=CC.count("W")
print(num-numnum) | N=int(input())
c=input()
C=[]
for i in range(N):
C.append(c[i])
num= C.count("W")
CC=C[(N-num):]
numnum=CC.count("W")
print(num-numnum) | [["+", 0, 662, 12, 206, 206, 663, 0, 23, 0, 24], ["+", 12, 206, 206, 663, 0, 23, 0, 657, 31, 22], ["+", 12, 206, 206, 663, 0, 23, 0, 657, 17, 33], ["+", 0, 662, 12, 206, 206, 663, 0, 23, 0, 25]] | 5 | 67 |
#include <bits/stdc++.h>
#define MAX 10000001
using namespace std;
int main() {
int N;
string C;
cin >> N >> C;
int w[N] = {0}, r[N] = {0};
if (C.at(0) == 'W')
w[0] = 1;
if (C.at(N - 1) == 'R')
r[N - 1] = 1;
for (int i = 1; i < N; i++) {
w[i] = w[i - 1];
if (C.at(i) == 'W') {
w[i]++;... | #include <bits/stdc++.h>
#define MAX 10000001
using namespace std;
int main() {
int N;
string C;
cin >> N >> C;
int w[N] = {0}, r[N] = {0};
if (C.at(0) == 'W')
w[0] = 1;
if (C.at(N - 1) == 'R')
r[N - 1] = 1;
for (int i = 1; i < N; i++) {
w[i] = w[i - 1];
if (C.at(i) == 'W') {
w[i]++;... | [["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 245 |
n=int(input())
s=input()
l=[0]
for i in range(n):
l.append(l[i]+(s[i]=="R"))
ans=n
print(l)
for i in range(n+1):
ans=min(ans,abs(l[i]-i)+abs(l[-1]-l[i]))
#print(ans,i)
if i==l[-1]:
ans=min(ans,abs(l[i]-i))
#print(ans)
print(ans) | n=int(input())
s=input()
l=[0]
for i in range(n):
l.append(l[i]+(s[i]=="R"))
ans=n
#print(l)
for i in range(n+1):
ans=min(ans,abs(l[i]-i)+abs(l[-1]-l[i]))
#print(ans,i)
if i==l[-1]:
ans=min(ans,abs(l[i]-i))
#print(ans)
print(ans)
| [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 124 |
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N];
int main() {
int red = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
char ch;
cin >> ch;
a[i] = ch == 'W' ? 0 : 1;
red += a[i];
}
int x = 0, y = 0, c = 0;
for (int i = 1; i <= red; i++)
c += a[i];
for (int... | #include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N];
int main() {
int red = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
char ch;
cin >> ch;
a[i] = ch == 'W' ? 0 : 1;
red += a[i];
}
int x = 0, y = 0, c = 0;
for (int i = 1; i <= red; i++)
c += a[i];
for (int... | [["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 17, 33]] | 1 | 196 |
N = int(input())
C = list(input())
i = 0
j = N-1
count = 0
frag = True
Frag_f = True
Frag_b = True
while (frag):
if i >= j:
break
if Frag_f == True:
if C[i] == "R":
i = i + 1
else:
Frag_f = False
if Frag_b == True:
if C[j] == "w":
j ... | N = int(input())
C = list(input())
i = 0
j = N-1
count = 0
frag = True
Frag_f = True
Frag_b = True
while (frag):
if i >= j:
break
if Frag_f == True:
if C[i] == "R":
i = i + 1
else:
Frag_f = False
if Frag_b == True:
if C[j] == "W":
j = j -... | [["-", 64, 196, 0, 57, 15, 666, 0, 557, 0, 6], ["+", 64, 196, 0, 57, 15, 666, 0, 557, 0, 6]] | 5 | 129 |
n=int(input())
c=list(input())
l,r=0,n-1
ans=0
while l<r:
while c[l]!='W':
l+=1
if l>n-1:
break
while c[r]!='R' or r>=0:
r-=1
if r<0:
break
if l<r:
ans+=1
l+=1
r-=1
print(ans) | n=int(input())
c=list(input())
l,r=0,n-1
ans=0
while l<r:
while c[l]!='W':
l+=1
if l>n-1:
break
while c[r]!='R':
r-=1
if r<0:
break
if l<r:
ans+=1
l+=1
r-=1
print(ans) | [["-", 0, 52, 8, 196, 0, 52, 15, 679, 17, 354], ["-", 8, 196, 0, 52, 15, 679, 12, 666, 0, 22], ["-", 8, 196, 0, 52, 15, 679, 12, 666, 667, 20], ["-", 8, 196, 0, 52, 15, 679, 12, 666, 0, 612]] | 5 | 95 |
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int n, ans = 0, indx;
string str;
int main() {
cin >> n >> str;
indx = n - 1;
for (int i = 0; i < indx; i++) {
if (str[i] == 'W') {
while (str[indx] == 'W')
indx--;
if (str[indx] == 'R') {
... | #include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int n, ans = 0, indx;
string str;
int main() {
cin >> n >> str;
indx = n - 1;
for (int i = 0; i < indx; i++) {
if (str[i] == 'W') {
while (str[indx] == 'W' && i < indx)
indx--;
if (str[indx] ==... | [["+", 64, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 131 |
N = int(input())
S = input()
c = Counter(S)
S_target = 'R' * c['R'] + 'W' * c['W']
ans = 0
for a, b in zip(S, S_target):
if b == 'W':
break
if a != b:
ans += 1
print(ans)
| from collections import Counter
N = int(input())
S = input()
c = Counter(S)
S_target = 'R' * c['R'] + 'W' * c['W']
ans = 0
for a, b in zip(S, S_target):
if b == 'W':
break
if a != b:
ans += 1
print(ans)
| [["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]] | 5 | 77 |
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 1; i <= (n); i++)
#define drep(i, n) for (int i = (n)-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define rng(a) a.begin(), a.end()
using ll = long long;
using namespace std;
int... | #include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 1; i <= (n); i++)
#define drep(i, n) for (int i = (n)-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define rng(a) a.begin(), a.end()
using ll = long long;
using namespace std;
int... | [["-", 0, 57, 64, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]] | 1 | 215 |
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long n;
cin >> n;
long i, j;
char temp;
long count = 0;
vector<char> c(n);
for (long a = 0; a < n; a++) {
cin >> c.at(a);
}
i = 0;
j = n - 1;
while (c.at(i) != 'W' && i <= j) {
i++;
if ... | #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long n;
cin >> n;
long i, j;
char temp;
long count = 0;
vector<char> c(n);
for (long a = 0; a < n; a++) {
cin >> c.at(a);
}
i = 0;
j = n - 1;
while (c.at(i) != 'W' && i <= j) {
i++;
if ... | [["-", 15, 339, 51, 16, 31, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 31, 16, 12, 103, 0, 125]] | 1 | 238 |
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 2e5 + 500;
char st[N];
int n, s[N][2];
int main() {
scanf("%d", &n);
scanf("%s", st + 1);
for (int i = 1; i <= n; i++)
s[i][0] = s[i - 1][0] + (st[i] == 'W'),
s[i][1] = s[i - 1][1] + (st[i] == 'R');
int ans = 100... | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 2e5 + 500;
char st[N];
int n, s[N][2];
int main() {
scanf("%d", &n);
scanf("%s", st + 1);
for (int i = 1; i <= n; i++)
s[i][0] = s[i - 1][0] + (st[i] == 'W'),
s[i][1] = s[i - 1][1] + (st[i] == 'R');
int ans = 100... | [["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]] | 1 | 208 |
N = int(input())
c = list(input())
ans = 0
cnt = c.count("W")
ans = c[N-4:].count("R")
if cnt != 0:
print(ans)
else:
print(0) | N = int(input())
c = list(input())
ans = 0
cnt = c.count("W")
ans = c[N-cnt:].count("R")
if cnt != 0:
print(ans)
else:
print(0) | [["-", 63, 319, 500, 206, 206, 663, 0, 657, 12, 612], ["+", 63, 319, 500, 206, 206, 663, 0, 657, 12, 22]] | 5 | 60 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
char s[N];
int sumw[N], sumr[N];
int main() {
int n;
scanf("%d", &n);
scanf("%s", s + 1);
for (int i = 1; i <= n; i++) {
sumw[i] = sumw[i - 1];
if (s[i] == 'W')
sumw[i]++;
}
for (int i = n; i >= 1; i--) {
sumr[i] = sumr[i... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
char s[N];
int sumw[N], sumr[N];
int main() {
int n;
scanf("%d", &n);
scanf("%s", s + 1);
for (int i = 1; i <= n; i++) {
sumw[i] = sumw[i - 1];
if (s[i] == 'W')
sumw[i]++;
}
for (int i = n; i >= 1; i--) {
sumr[i] = sumr[i... | [["+", 51, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 235 |
n = int(input())
c = str(input())
# print(list(c))
import collections
a = collections.Counter(c)
t = a["W"]
# print(a)
m = min(a["W"],a["R"])
# print(m)
co = 0
for i,j in enumerate(c):
if co >=m or i>=t:
break
else:
if j == "W":
co +=1
# print(i,j)
# print(m,co)
... | n = int(input())
c = str(input())
# print(list(c))
import collections
a = collections.Counter(c)
t = a["R"]
# print(a)
m = min(a["W"],a["R"])
# print(m)
co = 0
for i,j in enumerate(c):
if co >=m or i>=t:
break
else:
if j == "W":
co +=1
# print(i,j)
# print(m,co)
... | [["-", 0, 1, 0, 662, 12, 206, 206, 557, 0, 6], ["+", 0, 1, 0, 662, 12, 206, 206, 557, 0, 6]] | 5 | 101 |
N = int(input())
S = input()
r = S.count('R')
w = S.count('W')
if r == N or r == 0:
print(0)
exit()
a = S[:r+1].count('W')
print(a) | N = int(input())
S = input()
r = S.count('R')
w = S.count('W')
if r == N or r == 0:
print(0)
exit()
a = S[:r].count('W')
print(a) | [["-", 63, 319, 500, 206, 206, 663, 0, 657, 17, 72], ["-", 63, 319, 500, 206, 206, 663, 0, 657, 12, 612]] | 5 | 69 |
package main
import (
"fmt"
)
func main() {
var N, r, ans int
var C string
fmt.Scan(&N, &C)
W := make([]int, 0)
for i := range C {
if string(C[N-1-i]) == "R" {
r++
} else {
W = append(W, r)
}
}
for i := range W {
if W[len(W)-1-i] >= ans {
ans++
}
}
fmt.Println(ans)
}
| package main
import (
"fmt"
)
func main() {
var N, r, ans int
var C string
fmt.Scan(&N, &C)
W := make([]int, 0)
for i := range C {
if string(C[N-1-i]) == "R" {
r++
} else {
W = append(W, r)
}
}
for i := range W {
if W[len(W)-1-i] > ans {
ans++
}
}
fmt.Println(ans)
}
| [["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47]] | 7 | 129 |
n = int(input())
stones = list(input())
w_num = 0
r_num = 0
for i in stones:
if i == 'W':
w_num += 1
else:
r_num += 1
goal = 'R' * w_num + 'W' * r_num
index = 0
poplist = list()
for i in stones:
if i == goal[index]:
poplist.append(index)
index += 1
for i in sorted(poplist, rever... | n = int(input())
stones = list(input())
w_num = 0
r_num = 0
for i in stones:
if i == 'W':
w_num += 1
else:
r_num += 1
goal = 'R' * r_num + 'W' * w_num
index = 0
poplist = list()
for i in stones:
if i == goal[index]:
poplist.append(index)
index += 1
for i in sorted(poplist, rever... | [["-", 0, 1, 0, 662, 12, 657, 31, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 12, 22], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 12, 22]] | 5 | 138 |
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef vector<pairs> p;
struct edge {
ll to, cost;
};
ll gcd(ll a, ll b) {
if (b == 0) {
return a;
} else {
ret... | #include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef vector<pairs> p;
struct edge {
ll to, cost;
};
ll gcd(ll a, ll b) {
if (b == 0) {
return a;
} else {
ret... | [["-", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 17, 85], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 620 |
def main():
n = int(input())
li = list(input())
i = 0
j = n-1
ans = 0
while(i < j):
while(li[i] == "R" and i < j):
i += 1
while(li[j] == "W" and i < j):
j -= 1
if li[i] == "W" and li[j] == "R":
li[i] = "R"
li[j] = "W"
ans += 1
print(li)
print(ans)
if __name_... | def main():
n = int(input())
li = list(input())
i = 0
j = n-1
ans = 0
while(i < j):
while(li[i] == "R" and i < j):
i += 1
while(li[j] == "W" and i < j):
j -= 1
if li[i] == "W" and li[j] == "R":
li[i] = "R"
li[j] = "W"
ans += 1
print(ans)
if __name__ == '__mai... | [["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24]] | 5 | 133 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define in(n) \
ll n; \
cin >> n;
#define fo(m, n) for (int i = m; i < n; i++)
#define rfo(m, n) for (ll i =... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define in(n) \
ll n; \
cin >> n;
#define fo(m, n) for (int i = m; i < n; i++)
#define rfo(m, n) for (ll i =... | [["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]] | 1 | 208 |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
int k;
cin >> k;
string s;
cin >> s;
deque<int> w;
deque<int> r;
int ats = 0;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'W')
w.push_back(i);
else
r.push_back(i);
}
if (r.size() != 0) {
re... | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
int k;
cin >> k;
string s;
cin >> s;
deque<int> w;
deque<int> r;
int ats = 0;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'W')
w.push_back(i);
else
r.push_back(i);
}
if (r.size() != 0) {
re... | [["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 98]] | 1 | 177 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.