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
function main(input) { let N = 0 | input.split("\n"); return N >= 30 ? "Yes" : "No"; } //****************************** exports.main = main; function Main(input) { console.log(main(input)); } if (process.argv[2] !== "test") { Main(require("fs").readFileSync("/dev/stdin", "utf8")); }
function main(input) { let N = 0 | input.split("\n"); return N >= 30 ? "Yes" : "No"; } //****************************** exports.main = main; function Main(input) { console.log(main(input.trim())); } if (process.argv[2] !== "test") { Main(require("fs").readFileSync("/dev/stdin", "utf8")); }
[["+", 0, 2, 3, 3, 0, 2, 63, 558, 0, 131], ["+", 0, 2, 3, 3, 0, 2, 63, 558, 559, 560], ["+", 0, 2, 3, 3, 0, 2, 3, 3, 0, 24], ["+", 0, 2, 3, 3, 0, 2, 3, 3, 0, 25]]
2
94
#pragma GCC optimize("Ofast") #pragma GCC target(*sse4 .2 *) #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define PB push_back #define all(x) x.begin(), x.end() #define vi vector<int> #define ii pair<int, int> #define vii vector<ii> #d...
#pragma GCC optimize("Ofast") #pragma GCC target(*sse4 .2 *) #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define PB push_back #define all(x) x.begin(), x.end() #define vi vector<int> #define ii pair<int, int> #define vii vector<ii> #d...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
161
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define lalalala \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define lalalala \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
79
#include <bits/stdc++.h> // deeply ingrained using namespace std; int main() { int n; cin >> n; if (n == 30) puts("Yes"); else puts("No"); return 0; }
#include <bits/stdc++.h> // deeply ingrained using namespace std; int main() { int n; cin >> n; if (n >= 30) puts("Yes"); else puts("No"); return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
44
#include <bits/stdc++.h> using namespace std; #define FIND(c, e) ((c).find(e) != (c).end()) #define NFIND(c, e) ((c).find(e) == (c).end()) #define ALL(t) (t).begin(), (t).end() #define ALLR(t) (t).rbegin(), (t).rend() #define MP make_pair template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); } temp...
#include <bits/stdc++.h> using namespace std; #define FIND(c, e) ((c).find(e) != (c).end()) #define NFIND(c, e) ((c).find(e) == (c).end()) #define ALL(t) (t).begin(), (t).end() #define ALLR(t) (t).rbegin(), (t).rend() #define MP make_pair template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); } temp...
[["-", 0, 57, 64, 1, 0, 16, 12, 103, 0, 104], ["-", 0, 57, 64, 1, 0, 16, 12, 103, 0, 125], ["-", 64, 1, 0, 16, 12, 103, 0, 42, 0, 22], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 62], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["-", 75, 76, 0, 1, 0, 16, 12, 103, 0, 104], ["-", 75, 76, 0, 1, 0, 16, 12, 103, 0, 125], ["-", 0, 1, ...
1
241
#include <stdio.h> int main() { int n; scanf("%d", &n); if (n >= 30) { printf("YES\n"); } else { printf("NO\n"); } }
#include <stdio.h> int main() { int n; scanf("%d", &n); if (n >= 30) { printf("Yes"); } else { printf("No"); } }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
48
#include <stdio.h> int main(void) { int X; scanf("%d", &X); if (X >= 30) printf("YES\n"); else printf("NO\n"); return 0; }
#include <stdio.h> int main(void) { int X; scanf("%d", &X); if (X >= 30) printf("Yes\n"); else printf("No\n"); return 0; }
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
48
#include <bits/stdc++.h> using namespace std; #define int long long #define REP(i, m, n) for (int i = (m); i < (n); i++) #define rep(i, n) REP(i, 0, n) #define pb push_back #define all(a) a.begin(), a.end() #define rall(c) (c).rbegin(), (c).rend() #define mp make_pair #define endl '\n' #define vec vector<ll> #define ma...
#include <bits/stdc++.h> using namespace std; #define int long long #define REP(i, m, n) for (int i = (m); i < (n); i++) #define rep(i, n) REP(i, 0, n) #define pb push_back #define all(a) a.begin(), a.end() #define rall(c) (c).rbegin(), (c).rend() #define mp make_pair #define endl '\n' #define vec vector<ll> #define ma...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
197
#include <bits/stdc++.h> #include <cctype> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int #define ld long double #define PRY cout << "YES\n" #define PRN cout << "NO\n" #define SETP(sp) fixed << setprecision(sp) #define PB push_back #define GO ...
#include <bits/stdc++.h> #include <cctype> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int #define ld long double #define PRY cout << "YES\n" #define PRN cout << "NO\n" #define SETP(sp) fixed << setprecision(sp) #define PB push_back #define GO ...
[["+", 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
255
k = int(input()) rem = 0 for i in range(k): rem = rem*10 + 7 rem %= k if rem==0: break if i==(k-1): print(-1) else: print(i+1)
k = int(input()) rem = 0 for i in range(k*10+1): rem = rem*10 + 7 rem %= k if rem==0: break if i==(k*10): print(-1) else: print(i+1)
[["+", 12, 652, 3, 4, 0, 657, 31, 657, 17, 48], ["+", 12, 652, 3, 4, 0, 657, 31, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 57, 15, 666, 0, 23, 0, 657, 17, 33], ["-", 0, 57, 15, 666, 0, 23, 0, 657, 12, 612], ["+", 0, 57, 15, 666, 0, 23, 0, 657, 17, 4...
5
57
// C++ implementation of the approach #include <bits/stdc++.h> using namespace std; using ll = long long; // Function to return length // of the resulatant number ll numLen(ll K) { // If K is a multiple of 2 or 5 if (K % 2 == 0 || K % 5 == 0) return -1; ll number = 0; ll len = 1; for (len = 1; len <= ...
// C++ implementation of the approach #include <bits/stdc++.h> using namespace std; using ll = long long; // Function to return length // of the resulatant number ll numLen(ll K) { // If K is a multiple of 2 or 5 if (K % 2 == 0 || K % 5 == 0) return -1; ll number = 0; ll len = 1; for (len = 1; len <= ...
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13]]
1
130
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int mod = 7; int ans = 1; while (mod % k) { mod = (mod * 10 + 7) % k; ++ans; if (ans >= k) { ans = -1; break; } } cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int mod = 7; int ans = 1; while (mod % k) { mod = (mod * 10 + 7) % k; ++ans; if (ans > k) { ans = -1; break; } } cout << ans << "\n"; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
74
import sys k=int(input()) n=7 if k%2==0: print(-1) for i in range(1,k+1): if n%k==0: print(i) sys.exit() else: n=(10*(n%k)+7)%k print(-1)
import sys k=int(input()) n=7 if k%2==0: print(-1) sys.exit() for i in range(1,k+1): if n%k==0: print(i) sys.exit() else: n=(10*(n%k)+7)%k print(-1)
[["+", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
75
k = int(input()) a = 0 for i in range(k-1): a = (a*10+7)%k if a == 0: print(i+1) break else: print(-1)
k = int(input()) a = 0 for i in range(k): a = (a*10+7)%k if a == 0: print(i+1) break else: print(-1)
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
51
k=int(input()) mod=0 ans=0 for i in range(1000000): ans+=1 mod=(mod*10+7)%k if mod==0: break print(ans if ans!=1000001 else -1)
k=int(input()) mod=0 ans=0 for i in range(1000000): ans+=1 mod=(mod*10+7)%k if mod==0: break print(ans if ans!=1000000 else -1)
[["-", 0, 652, 3, 4, 0, 41, 0, 666, 0, 612], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 0, 612]]
5
53
import sys k = int(input()) if k % 7 == 0: k = k // 7 tmp = 1 for i in range(k+2): if tmp == 0: print(i+1) sys.exit() tmp = (tmp * 10 + 1) % k print(-1)
import sys k = int(input()) if k % 7 == 0: k = k // 7 tmp = 1 for i in range(k+2): if tmp % k == 0: print(i+1) sys.exit() tmp = (tmp * 10 + 1) % k print(-1)
[["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 109], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 22]]
5
67
k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() while k % 7 == 0: k //= 7 num = 1 plus = 10 for i in range(1, k): if int(num) % k == 0: print(i) exit() num += plus num %= k plus *= 10 plus %= k print(-1)
k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() if k % 7 == 0: k //= 7 num = 1 plus = 10 for i in range(1, k + 1): if int(num) % k == 0: print(i) exit() num += plus num %= k plus *= 10 plus %= k print(-1)
[["-", 36, 36, 36, 36, 0, 656, 0, 52, 0, 89], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
89
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; #define PI 3.14159265359 typedef long long ll; using namespace std; int mod[1000010]; int main() { int k; cin...
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; #define PI 3.14159265359 typedef long long ll; using namespace std; int mod[1000010]; int main() { int k; cin...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
185
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < ll(n); i++) int main() { ll k; cin >> k; if (k == 7) { cout << 1 << endl; return 0; } ll num = 7; for (ll a = 1; a <= k; a++) { if (num == 0) { cout << a << endl; return 0; }...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < ll(n); i++) int main() { ll k; cin >> k; if (k == 1 || k == 7) { cout << 1 << endl; return 0; } ll num = 7; for (ll a = 1; a <= k; a++) { if (num == 0) { cout << a << endl; retur...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60]]
1
105
#include <bits/stdc++.h> using namespace std; #define int long long void solve() { int k; cin >> k; if (k % 7 == 0) k /= 7; int ost = 1; int cnt = 0; while (cnt < 2 * k) { ++cnt; if (ost == 0) { cout << cnt; return; } ost = (ost * 10 + 1) % k; } cout << -1; } signed m...
#include <bits/stdc++.h> using namespace std; #define int long long void solve() { int k; cin >> k; if (k % 7 == 0) k /= 7; int ost = 1 % k; int cnt = 0; while (cnt < 2 * k) { ++cnt; if (ost == 0) { cout << cnt; return; } ost = (ost * 10 + 1) % k; } cout << -1; } sign...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
121
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { ll k, i; cin >> k; if (k == 7 || k == 1) { cout << 1 << endl; return 0; } ll res = 1; for (i = 1; i <= 10000000; i++) { if (res % k == 0) { cout << i << endl; return 0; } ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { ll k, i; cin >> k; if (k == 7 || k == 1) { cout << 1 << endl; return 0; } ll res = 7; for (i = 1; i <= 10000000; i++) { if (res % k == 0) { cout << i << endl; return 0; } ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
115
#include <bits/stdc++.h> using namespace std; int main() { int64_t k, a, ans; a = 7; ans = 1; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; } else if (k == 1 || k == 7) { cout << 1 << endl; } else { while (a != 0) { ans++; a = (a * 10 + 7) % k; } } cout << ...
#include <bits/stdc++.h> using namespace std; int main() { int64_t k, a, ans; a = 7; ans = 1; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; } else if (k == 1 || k == 7) { cout << 1 << endl; } else { while (a != 0) { ans++; a = (a * 10 + 7) % k; } cout << an...
[["-", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46], ["+", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46]]
1
104
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define ENDL '\n' #define all(a) begin(a), end(a) #define sz(a) (int)(a.size()) #define deb(a) cout << #a << ": " << a << ENDL; #define fore(i, a, b) for (int i(a), ThkMk(b); i < ThkMk; ++i) #define _ ...
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define ENDL '\n' #define all(a) begin(a), end(a) #define sz(a) (int)(a.size()) #define deb(a) cout << #a << ": " << a << ENDL; #define fore(i, a, b) for (int i(a), ThkMk(b); i < ThkMk; ++i) #define _ ...
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 13]]
1
229
// Problem : C - Repsept // Contest : AtCoder - AtCoder Beginner Contest 174 // URL : https://atcoder.jp/contests/abc174/tasks/abc174_c // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #in...
// Problem : C - Repsept // Contest : AtCoder - AtCoder Beginner Contest 174 // URL : https://atcoder.jp/contests/abc174/tasks/abc174_c // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #in...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
230
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); long long k; cin >> k; long long r = 7; if (k == 7) { cout << 1; return 0; } for (int i = 1; i < 100000000; i++) { r = (10 * r + 7) % k; if (r == 0) { cout << i + 1; retur...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); long long k; cin >> k; long long r = 7; if (k == 7 || k == 1) { cout << 1; return 0; } for (int i = 1; i < 10000000; i++) { r = (10 * r + 7) % k; if (r == 0) { cout << i + 1; ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
107
#include <iostream> using namespace std; int main() { int k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; return 0; } if (k == 7) { cout << 1 << endl; return 0; } int ans = 1; int x = 7; while (x) { x = (x * 10 + 7) % k; ans++; } cout << ans << endl; }
#include <iostream> using namespace std; int main() { int k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; return 0; } if (k == 7 || k == 1) { cout << 1 << endl; return 0; } int ans = 1; int x = 7; while (x) { x = (x * 10 + 7) % k; ans++; } cout << ans << e...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
98
//#pragma GCC optimize("O3") #include <bits/stdc++.h> //#include <ctime> using namespace std; #define FAST_IO \ ios_base::sync_with_stdio(0); \ cin.tie(nullptr) #define FOR(i, a, b) for (int i = (a); i <...
//#pragma GCC optimize("O3") #include <bits/stdc++.h> //#include <ctime> using namespace std; #define FAST_IO \ ios_base::sync_with_stdio(0); \ cin.tie(nullptr) #define FOR(i, a, b) for (int i = (a); i <...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
270
k = int(input()) now = 7%k if now == 0: print(1) ans = 1 for i in range(k+1): ans += 1 now *= 10 now += 7 now %= k if now == 0: break if now == 0: print(ans) else: print(-1)
k = int(input()) now = 7%k if now == 0: print(1) exit() ans = 1 for i in range(k+1): ans += 1 now *= 10 now += 7 now %= k if now == 0: break if now == 0: print(ans) else: print(-1)
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
69
#include <bits/stdc++.h> using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cerr; using std::cin; using std::cout; using std::endl; template <typename T> std::vector<T> make_v(size_t a) { return std::vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, T...
#include <bits/stdc++.h> using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cerr; using std::cin; using std::cout; using std::endl; template <typename T> std::vector<T> make_v(size_t a) { return std::vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, T...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
203
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned; using pcc = pair<char, char>; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<ld, ld>; using tuplis = array<ll, 3>; template <class T> using pq = prio...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned; using pcc = pair<char, char>; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<ld, ld>; using tuplis = array<ll, 3>; template <class T> using pq = prio...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
3,063
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int w = 0; int ans = 0; for (int i = 0; i < n; i++) { if (s[i] == 'W') { w++; } } for (int i = 0; i < n; i++) { if (i < w) { if (s[i] == 'W') { ans++; } } } cout <<...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int w = 0; int ans = 0; for (int i = 0; i < n; i++) { if (s[i] == 'W') { w++; } } for (int i = 0; i < n; i++) { if (i < n - w) { if (s[i] == 'W') { ans++; } } } cou...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33]]
1
112
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // #define debug(a) cout << "["; rep(i,a.size()) cout ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // #define debug(a) cout << "["; rep(i,a.size()) cout ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
170
N=int(input()) ls=list(input()) left=0 right=N-1 count=0 while True: while left<N and ls[left]=='R': left+=1 while right>0 and ls[right]=='W': right-=1 if left>right: break left+=1 right-=1 count+=1 print(count)
N=int(input()) ls=list(input()) left=0 right=N-1 count=0 while True: while left<N and ls[left]=='R': left+=1 while right>0 and ls[right]=='W': right-=1 if left>=right: break left+=1 right-=1 count+=1 print(count)
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 20]]
5
83
read = sys.stdin.read from collections import deque def main(): n = int(input()) a = input() if not 'WR' in a: print(0) sys.exit() a = list(a) rnum = a.count('R') r = 0 for i1 in range(rnum): r += a[i1] == 'W' for j1 in range(n - rnum): r += a[rnum + j1] =...
import sys read = sys.stdin.read def main(): n = int(input()) a = input() if not 'WR' in a: print(0) sys.exit() a = list(a) rnum = a.count('R') r = 0 for i1 in range(rnum): r += a[i1] == 'W' for j1 in range(n - rnum): r += a[rnum + j1] == 'R' r = r // ...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 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
124
def abc174d(): n = int(input()) s = input() cnt = s.count('R') if cnt == len(s): print(0) return start = 0 while s[start] == 'R': start += 1 cnt -= 1 ans = cnt for i in range(start, cnt): if s[i] == 'R': ans -= 1 print(ans) abc174d(...
def abc174d(): n = int(input()) s = input() cnt = s.count('R') if cnt == len(s): print(0) return start = 0 while s[start] == 'R': start += 1 cnt -= 1 ans = cnt for i in range(start, start+cnt): if s[i] == 'R': ans -= 1 print(ans) ab...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72]]
5
93
#参考:https://marco-note.net/abc-174-work-log/ n = int(input()) c = input() R.count('R') cnt = 0 for i in range(R): if R[i]=="R": cnt += 1 print(R-cnt)
#参考:https://marco-note.net/abc-174-work-log/ n = int(input()) c = input() R=c.count('R') cnt = 0 for i in range(R): if c[i]=="R": cnt += 1 print(R-cnt)
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["-", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22]]
5
52
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> using namespace std; template <typename T> void print_vec(const vector<T> &v) { int n = v.size(); for (int i = 0; i < n; ++i) { if (i > 0) cout << ' '; cout << v[i]; } cou...
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> using namespace std; template <typename T> void print_vec(const vector<T> &v) { int n = v.size(); for (int i = 0; i < n; ++i) { if (i > 0) cout << ' '; cout << v[i]; } cou...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
208
n = int(input()) s = input() res = 0 tem = s.find('WR') if tem == -1: print(res) else: i, j = 0, len(s)-1 while i<=j: while i <= j and s[i] != 'W': i+=1 while i <= j and s[j] != 'R':j -= 1 if s[i] == 'W' and s[j] == 'R': res += 1 i += 1 j -= 1 ...
n = int(input()) s = input() res = 0 tem = s.find('WR') if tem == -1: print(res) else: i, j = 0, len(s)-1 while i<j: while i < j and s[i] != 'W': i+=1 while i < j and s[j] != 'R':j -= 1 if s[i] == 'W' and s[j] == 'R': res += 1 i += 1 j -= 1 pri...
[["-", 75, 76, 8, 196, 0, 52, 15, 666, 667, 19], ["+", 75, 76, 8, 196, 0, 52, 15, 666, 667, 18], ["-", 8, 196, 0, 52, 15, 679, 31, 666, 667, 19], ["+", 8, 196, 0, 52, 15, 679, 31, 666, 667, 18]]
5
121
#include <bits/stdc++.h> #define rep(i, N) for (int i = 0; i < (N); ++i) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using P = pair<int, int>; const int inf{int(1e9)}; int main(void) { int N; string c; cin >> N >> c; int a = 0, b = 0; rep(i, N) if (c[i] == 'R') a++; int ans ...
#include <bits/stdc++.h> #define rep(i, N) for (int i = 0; i < (N); ++i) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using P = pair<int, int>; const int inf{int(1e9)}; int main(void) { int N; string c; cin >> N >> c; int a = 0, b = 0; rep(i, N) if (c[i] == 'R') a++; int ans ...
[["-", 0, 57, 75, 76, 0, 1, 0, 27, 17, 68], ["+", 0, 57, 75, 76, 0, 1, 0, 27, 17, 29]]
1
159
N = int(input()) c = input() W = 0 R = c.count('R') if R == 0 or W == 0: print(0) exit() ans = N t = 0 for i in range(N): if c[i] == 'W': W += 1 else: R -= 1 t = max(R,W) ans = min(ans, t) print(ans)
N = int(input()) c = input() W = 0 R = c.count('R') if R == 0 or R == N: print(0) exit() ans = N t = 0 for i in range(N): if c[i] == 'W': W += 1 else: R -= 1 t = max(R,W) ans = min(ans, t) print(ans)
[["-", 0, 656, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 0, 656, 0, 57, 15, 679, 12, 666, 0, 22], ["-", 0, 656, 0, 57, 15, 679, 12, 666, 0, 612]]
5
94
s = input() R_num = s.count("R") print(s[:R_num].count("W"))
s = input() s = input() R_num = s.count("R") print(s[:R_num].count("W"))
[["+", 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
30
#include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #includ...
#include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #includ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
472
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int N; string S; cin >> N >> S; int A = 0, B = 0; rep(i, N) if (S[i] == 'R') A++; int ans = A; rep(i, N) { if (S[i] == 'W') B++; ans = min(ans, max(A, B)); } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int N; string S; cin >> N >> S; int A = 0, B = 0; rep(i, N) if (S[i] == 'R') A++; int ans = A; rep(i, N) { if (S[i] == 'W') B++; else A--; ans = min(ans, max(A, B)); } cout...
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 0, 57, 75, 76, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 75, 76, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 57, 75, 76, 0, 1, 0, 35]]
1
109
#include <bits/stdc++.h> #define dbug printf("I am here\n"); #define Fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); #define vs v.size() #define ss s.size() #define sot(v) sort(v.begin(), v.end()) #de...
#include <bits/stdc++.h> #define dbug printf("I am here\n"); #define Fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); #define vs v.size() #define ss s.size() #define sot(v) sort(v.begin(), v.end()) #de...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
256
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(v) v.begin(), v.end() int main() { int n; cin >> n; vector<ll> c(n); for (int i = 0; i < n; i++) { cin >> c[i]; } ll count = 0; for (int i = 0; i < n; i++) { if (c[i] == 'R') { count++; } } ll co = 0; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(v) v.begin(), v.end() int main() { int n; cin >> n; vector<char> c(n); for (int i = 0; i < n; i++) { cin >> c[i]; } ll count = 0; for (int i = 0; i < n; i++) { if (c[i] == 'R') { count++; } } ll co = 0; ...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40]]
1
144
n = int(input()) c = input() left, right = 0, n - 1 cnt = 0 while left <= right: while left < n and c[left] == 'R': left += 1 while right > -1 and c[right] == 'W': right -= 1 if left == n or right == -1: break left += 1 right -= 1 cnt += 1 print(cnt)
n = int(input()) c = input() left, right = 0, n - 1 cnt = 0 while left <= right: while left < n and c[left] == 'R': left += 1 while right > -1 and c[right] == 'W': right -= 1 if left == n or right == -1 or left >= right: break left += 1 right -= 1 cnt += 1 print(cnt)
[["+", 0, 52, 8, 196, 0, 57, 15, 679, 17, 354], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 20]]
5
89
n = int(input()) c = input() d = c.count('w') e = c[:d].count('w') print(d-e)
n = int(input()) c = input() d = c.count('R') e = c[:d].count('R') print(d-e)
[["-", 0, 662, 12, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 662, 12, 652, 3, 4, 0, 557, 0, 6]]
5
43
// #include<bits\stdc++.h> #include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <unordered_map> using namespace std; #define ll long long #define MOD 1000000007 void solve() { int n; string st; cin >> n >> st; int r = 0; for (int i = 0; i < n; i++) { i...
// #include<bits\stdc++.h> #include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <unordered_map> using namespace std; #define ll long long #define MOD 1000000007 void solve() { int n; string st; cin >> n >> st; int r = 0; for (int i = 0; i < n; i++) { i...
[["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
146
import bisect import sys import math from collections import deque from heapq import heappush, heappop def sRaw(): return input().rstrip("\r") def iRaw(): return int(input()) def ssRaw(): return input().split() def isRaw(): return list(map(int, ssRaw())) INF = 1 << 29 DIV = (10**9) + 7 #DIV = ...
import bisect import sys import math from collections import deque from heapq import heappush, heappop def sRaw(): return input().rstrip("\r") def iRaw(): return int(input()) def ssRaw(): return input().split() def isRaw(): return list(map(int, ssRaw())) INF = 1 << 29 DIV = (10**9) + 7 #DIV = ...
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22]]
5
614
ni = lambda: int(input()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) n=ni() c = [1 if _ == 'R' else 0 for _ in input()] b = sum(c) w=0 r=0 for i in range(n): if c[i] == 0 and i <= b: r+=1 if c[i] == 1 and i > b: w+=1 print(max(w,r))
ni = lambda: int(input()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) n=ni() c = [1 if _ == 'R' else 0 for _ in input()] b = sum(c) w=0 r=0 for i in range(n): if c[i] == 0 and i < b: r+=1 if c[i] == 1 and i >= b: w+=1 print(max(w,r))
[["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 19], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 18], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 47], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 20]]
5
128
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string x; cin >> x; int count = 0; int f = 0; int l = n - 1; while (f < l) { if (x[f] == 'R') { f++; continue; } if (x[l] = 'W') { l--; continue; } count++; f++; l--; } co...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string x; cin >> x; int count = 0; int f = 0; int l = n - 1; while (f < l) { if (x[f] == 'R') { f++; continue; } if (x[l] == 'W') { l--; continue; } count++; f++; l--; } c...
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
103
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int num = 0; int ans = 0; for (int i = 0; i < n; i++) { if (s.at(i) == 'w') { num++; } } for (int i = 0; i < num; i++) { if (s.at(n - 1 - i) == 'R') { ans++; } } cout << ans;...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int num = 0; int ans = 0; for (int i = 0; i < n; i++) { if (s.at(i) == 'W') { num++; } } for (int i = 0; i < num; i++) { if (s.at(n - 1 - i) == 'R') { ans++; } } cout << ans;...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
112
n = int(input()) c = input() t = n lw, rr = 0, c.count('R') for ci in c: swap = min(lw, rr) wtor, rtow = max(0, lw-swap), max(0, rr-swap) t = min(t, swap + wtor + rtow) lw = lw + (ci == 'W') rr = rr - (ci == 'R') print(t)
n = int(input()) c = input() t = n lw, rr = 0, c.count('R') for ci in c+'Z': swap = min(lw, rr) wtor, rtow = max(0, lw-swap), max(0, rr-swap) t = min(t, swap + wtor + rtow) lw = lw + (ci == 'W') rr = rr - (ci == 'R') print(t)
[["+", 36, 36, 0, 656, 0, 7, 12, 657, 17, 72], ["+", 0, 656, 0, 7, 12, 657, 12, 557, 0, 654], ["+", 0, 656, 0, 7, 12, 657, 12, 557, 0, 6], ["+", 0, 656, 0, 7, 12, 657, 12, 557, 0, 655]]
5
102
#include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; string b; cin >> b; int rb = n, lb = 0; int count = 0; for (;;) { while (b[rb] == 'W' && rb >= 0) --rb; while (b[lb] == 'R' && lb < n) ++lb; if (rb < 0 || lb >= n || rb <= lb) brea...
#include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; string b; cin >> b; int rb = n - 1, lb = 0; int count = 0; for (;;) { while (b[rb] == 'W' && rb >= 0) --rb; while (b[lb] == 'R' && lb < n) ++lb; if (rb < 0 || lb >= n || rb <= lb) { ...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
134
#include <bits/stdc++.h> using namespace std; typedef long long int ll; ll n; char a[200007]; int main() { ll res = 0, r = 0, w = 0; scanf("%lld", &n); for (ll i = 0; i < n; ++i) { cin >> a[i]; if (a[i] == 'R') r++; else w++; } if (!w) { printf("0\n"); return 0; } for ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; ll n; char a[200007]; int main() { ll res = 0, r = 0, w = 0; scanf("%lld", &n); for (ll i = 0; i < n; ++i) { cin >> a[i]; if (a[i] == 'R') r++; else w++; } if (!w || !r) { printf("0\n"); return 0; } ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 91, 17, 111], ["+", 0, 57, 15, 339, 51, 16, 12, 91, 28, 22], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
158
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 1e6 + 4; char c[N]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll int n; cin >> n; int cnt = 0; for (int i = 0; i < n; ++i) { cin >> c[i]; if (c[i] == 'W') cnt++; } int ans = cnt...
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 1e6 + 4; char c[N]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll int n; cin >> n; int cnt = 0; for (int i = 1; i <= n; ++i) { cin >> c[i]; if (c[i] == 'W') cnt++; } int ans = cn...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
151
N = int(input()) c = list(input()) w = c.count("W") r = c.count("R") wr = c[w:].count("W") print(min(r, w - wr))
N = int(input()) c = list(input()) w = c.count("W") r = c.count("R") wr = c[len(c) - w:].count("W") print(min(r, w - wr))
[["+", 500, 206, 206, 663, 0, 657, 31, 652, 63, 22], ["+", 206, 663, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 206, 663, 0, 657, 31, 652, 3, 4, 0, 22], ["+", 206, 663, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 63, 319, 500, 206, 206, 663, 0, 657, 17, 33]]
5
61
from sys import stdin n = int(stdin.readline()) c = stdin.readline()[:-1] red = c.count("R") ans = red numwhite = 0 for i in range(n): numwhite += 1 if c[i] == "W" else 0 numred = i - numwhite + 1 resred = red - numred ans = min(ans,min(resred,numwhite)) print(ans)
from sys import stdin n = int(stdin.readline()) c = stdin.readline()[:-1] red = c.count("R") ans = red numwhite = 0 for i in range(n): numwhite += 1 if c[i] == "W" else 0 numred = i - numwhite + 1 resred = red - numred ans = min(ans,max(resred,numwhite)) print(ans)
[["-", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22]]
5
93
N = int(input()) c = str(input()) a = 0 b = 0 for i in range(N): if s[i] == 'R': a = a + 1 ans = max(a,b) for i in range(N): if s[i] == 'R': a = a - 1 else: b = b + 1 now = max(a,b) ans = min(ans, now) print(ans)
N = int(input()) s = str(input()) a = 0 b = 0 for i in range(N): if s[i] == 'R': a = a + 1 ans = max(a,b) for i in range(N): if s[i] == 'R': a = a - 1 else: b = b + 1 now = max(a,b) ans = min(ans, now) print(ans)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22]]
5
103
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pii pair<int, int> #define pll pair<long long, long long> #define pb push_back #define ll long long #define ld long double #define precision(x, d) cout << fixed << setprecision(d) << x #define fill(a, b) memset((a), (b), sizeof((a...
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pii pair<int, int> #define pll pair<long long, long long> #define pb push_back #define ll long long #define ld long double #define precision(x, d) cout << fixed << setprecision(d) << x #define fill(a, b) memset((a), (b), sizeof((a...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
240
n = int(input()) s = list(input()) num = 0 k = -1 for i in range(1,n): if i + k >= n-1: break if s[-i] == 'R': j = k+1 while True: if j +i == n-1: k = j break if s[j] == 'W': s[j] = 'R' s[-i] = 'W' k = j num += 1 break j += 1 ...
n = int(input()) s = list(input()) num = 0 k = -1 for i in range(1,n): if i + k >= n-1: break if s[-i] == 'R': j = k+1 while True: if j +i == n: k = j break if s[j] == 'W': s[j] = 'R' s[-i] = 'W' k = j num += 1 break j += 1 ...
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
116
// Code by Nguyen Huu Lam #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long LL; #define y0 Sword_Art_Online #define y1 Your_lie_in_April #define yn Darling_in_the_Franxx #define tm Plastic_Memories ...
// Code by Nguyen Huu Lam #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long LL; #define y0 Sword_Art_Online #define y1 Your_lie_in_April #define yn Darling_in_the_Franxx #define tm Plastic_Memories ...
[["-", 8, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 8, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
383
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; vector<int> white(n), red(n); for (int i = 0; i < n; i++) { if (i) { red[i] = red[i - 1]; white[i] = white[i - 1...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; vector<int> white(n), red(n); for (int i = 0; i < n; i++) { if (i) { red[i] = red[i - 1]; white[i] = white[i - 1...
[["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
1
211
#include "bits/stdc++.h" using namespace std; #define ll long long #define mod 1000000007 int main() { ll n; cin >> n; string s; cin >> s; ll lr, rw; ll ans = mod; ll buf; ll i, j; lr = 0; rw = 0; for (i = 0; i <= n; i++) { if (s[i] == 'R') rw++; } for (i = 0; i < n; i++) { i...
#include "bits/stdc++.h" using namespace std; #define ll long long #define mod 1000000007 int main() { ll n; cin >> n; string s; cin >> s; ll lr, rw; ll ans = mod; ll buf; ll i, j; lr = 0; rw = 0; for (i = 0; i <= n; i++) { if (s[i] == 'R') rw++; } for (i = 0; i <= n; i++) { ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
193
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; string s; cin >> s; int start = 0, end = n - 1, count = 0; while (1) { if (s[end] == 'R') { while (1) { if (s[start] == 'W') { swap(s[start], s[end]); count++; start++; b...
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; string s; cin >> s; int start = 0, end = n - 1, count = 0; while (1) { if (s[end] == 'R') { while (1) { if (s[start] == 'W') { swap(s[start], s[end]); count++; start++; b...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
144
//インクルード(アルファベット順) #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #include <iomanip> //setprecision(浮動小数点の出力の誤差) #include <iostream> //入出力 #include <iterator>...
//インクルード(アルファベット順) #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #include <iomanip> //setprecision(浮動小数点の出力の誤差) #include <iostream> //入出力 #include <iterator>...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 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
470
N = int(input()) #stones = list(input()) stones = input() print(stones) a = stones.count('W') b = stones.count('R') left_side =stones.count('W', 0, b) print(left_side)
N = int(input()) #stones = list(input()) stones = input() #print(stones) a = stones.count('W') b = stones.count('R') left_side =stones.count('W', 0, b) print(left_side)
[["-", 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
56
N = int(input()) c = list(input()) a=0 b=0 a = c.count("R") ans = c.count("R") for i in range(N): print(i) if c[i] == "R": a -= 1 else: b += 1 now = max(a,b) ans = min(ans, now) print(ans)
N = int(input()) c = list(input()) a=0 b=0 a = c.count("R") ans = c.count("R") for i in range(N): if c[i] == "R": a -= 1 else: b += 1 now = max(a,b) ans = min(ans, now) print(ans)
[["-", 0, 7, 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, 25]]
5
92
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define fi first #define se second #define ep emplace #define eb emplace_back #define mp make_pair #define pi pair<int, int> #define vi vector<int> #define vpi vector<pair<int, int>> #define vll vector<ll> #define vpll vector<pair<ll, ll>> #define endl '\n' #define ...
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define fi first #define se second #define ep emplace #define eb emplace_back #define mp make_pair #define pi pair<int, int> #define vi vector<int> #define vpi vector<pair<int, int>> #define vll vector<ll> #define vpll vector<pair<ll, ll>> #define endl '\n' #define ...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
269
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; typedef long long ll; int main() { ll n; string c; cin >> n >> c; ll cnt = 0; rep(i, n) { if (c[i] == 'R') cnt++; } ll ans = 0; rep(i, cnt) { if (c[i] = '...
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; typedef long long ll; int main() { ll n; string c; cin >> n >> c; ll cnt = 0; rep(i, n) { if (c[i] == 'R') cnt++; } ll ans = 0; rep(i, cnt) { if (c[i] == ...
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
106
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; vector<char> c(n); for (int i = 0; i < n; i++) cin >> c[i]; int ans = 0; int r = n; for (int l = 0; l < r; l++) { if (c[l] == 'W') { while (l != r) { r--; if (c[r] == 'R'...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; vector<char> c(n); for (int i = 0; i < n; i++) cin >> c[i]; int ans = 0; int r = n; for (int l = 0; l < r; l++) { if (c[l] == 'W') { while (l != r) { r--; if (c[r] == 'R'...
[["+", 64, 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, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
178
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<char> storn(N); for (int i = 0; i < N; i++) { cin >> storn.at(i); } int count = 0; for (int i = 0; i < N; i++) { if (storn.at(i) == 'R') { count++; } } int count2 = 0; for (int i = 0; i < count; i++)...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<char> storn(N); for (int i = 0; i < N; i++) { cin >> storn.at(i); } int count = 0; for (int i = 0; i < N; i++) { if (storn.at(i) == 'R') { count++; } } int count2 = 0; for (int i = 0; i < count; i++)...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
139
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define rep(i, n) for (int i = 0; i < n; i++) #define MOD 1000000007 int main() { int n; string s; cin >> n >> s; int cnt = 0; rep(i, n) { if (s[i] == 'W') cnt++; } int ans = 0; rep(i, cnt) { if (s[i] == 'W') a...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define rep(i, n) for (int i = 0; i < n; i++) #define MOD 1000000007 int main() { int n; string s; cin >> n >> s; int cnt = 0; rep(i, n) { if (s[i] == 'W') cnt++; } int ans = 0; rep(i, n - cnt) { if (s[i] == 'W') ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
104
#include <bits/stdc++.h> using namespace std; int main() { int n; string str; cin >> n; cin >> str; int left = 0, right = n - 1; int cnt = 0; while (left < right) { while (left < n && str[left] != 'W') left++; while (right >= 0 && str[right] != 'R') right--; if (left < n && righ...
#include <bits/stdc++.h> using namespace std; int main() { int n; string str; cin >> n; cin >> str; int left = 0, right = n - 1; int cnt = 0; while (left <= right) { while (left < n && str[left] != 'W') left++; while (right >= 0 && str[right] != 'R') right--; if (left < n && rig...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 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
143
n = int(input()) c = input() count = 0 i, j = 0, n - 1 if c.count('W') == 0 | c.count('R') == 0: count = 0 else: white_cnt = [] red_cnt = [] for i in range(n): if c[i] == 'W': white_cnt.append(i) else: red_cnt.append(i) while 1: white_num = white_cnt.pop(0) ...
n = int(input()) c = input() count = 0 i, j = 0, n - 1 if c.count('W') == 0: count=0 elif c.count('R') == 0: count = 0 else: white_cnt = [] red_cnt = [] for i in range(n): if c[i] == 'W': white_cnt.append(i) else: red_cnt.append(i) while 1: white_...
[["-", 0, 656, 0, 57, 15, 666, 0, 657, 17, 139], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 57, 75, 665, 0, 683]]
5
141
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int(i) = 0; (i) < (n); ++(i)) const int INF = 1001001001; int main() { int n; cin >> n; vector<char> cn(n); rep(i, n) cin >> cn[i]; int cw = 0, cr = 0; rep(i, n) { if (cn[i] == 'W') { cw++; } else { ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int(i) = 0; (i) < (n); ++(i)) const int INF = 1001001001; int main() { int n; cin >> n; vector<char> cn(n); rep(i, n) cin >> cn[i]; int cw = 0, cr = 0; rep(i, n) { if (cn[i] == 'W') { cw++; } else { ...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
136
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char c[n]; for (int i = 0; i < n; ++i) cin >> c[i]; int i = 0, j = n - 1, ans = 0; while (i < j) { while (c[i] != 'W' && i < n) ++i; while (c[i] != 'R' && j >= 0) --j; if (i < j) { ++ans; int ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char c[n]; for (int i = 0; i < n; ++i) cin >> c[i]; int i = 0, j = n - 1, ans = 0; while (i < j) { while (c[i] != 'W' && i < n) ++i; while (c[j] != 'R' && j >= 0) --j; if (i < j) { ++ans; int ...
[["-", 51, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 16, 31, 69, 341, 342, 0, 22]]
1
154
#include <bits/stdc++.h> #define ll long long int using namespace std; ll i, temp, t, n, j, a[200600], C; string s; int main() { // I am Monim, a tiny creature of Allah cin >> n; cin >> s; while (s[i] != 'W' && i < n) i++; temp = i; for (; i < n; i++) { if (s[i] == 'R') C++; } for (i = tem...
#include <bits/stdc++.h> #define ll long long int using namespace std; ll i, temp, t, n, j, a[200600], C; string s; int main() { // I am Monim, a tiny creature of Allah cin >> n; cin >> s; while (s[i] != 'W' && i < n) i++; temp = i; for (; i < n; i++) { if (s[i] == 'R') C++; } j = C; // ...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22]]
1
133
#include <bits/stdc++.h> #define ll long long #define rep(i, a, b) for (long long i = a; i < b; i += 1) #define repr(i, a, b) for (long long i = a; i <= b; i += 1) #define vec vector<ll> #define map map<char, int> #define repa(p, A) for (auto p : A) #define pb push_back #define sort(a) sort(a.begin(), a.end()) #define ...
#include <bits/stdc++.h> #define ll long long #define rep(i, a, b) for (long long i = a; i < b; i += 1) #define repr(i, a, b) for (long long i = a; i <= b; i += 1) #define vec vector<ll> #define map map<char, int> #define repa(p, A) for (auto p : A) #define pb push_back #define sort(a) sort(a.begin(), a.end()) #define ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
158
#include <bits/stdc++.h> using namespace std; const int maxN = 2e5 + 5; void solve() { int n; cin >> n; int A[maxN]; int count_red = 0, count_red2 = 0; for (int i = 0; i < n; i++) { char c; cin >> c; if (c == 'W') A[i] = 0; else { A[i] = 1; count_red++; } } for (int...
#include <bits/stdc++.h> using namespace std; const int maxN = 2e5 + 5; void solve() { int n; cin >> n; int A[maxN]; int count_red = 0, count_red2 = 0; for (int i = 0; i < n; i++) { char c; cin >> c; if (c == 'W') A[i] = 0; else { A[i] = 1; count_red++; } } for (int...
[["+", 0, 43, 49, 50, 51, 16, 12, 23, 0, 24], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 31, 22], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 43, 49, 50, 51, 16, 12, 23, 0, 25]]
1
234
N = int(input()) A = list(input()) print(C[:C.count('R')].count("W"))
n = int(input()) C = input() print(C[:C.count('R')].count("W"))
[["-", 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, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
38
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1e9 + 7, INF = mod * mod * 3; // M_PI #define rep(i, N) for (ll i = 0; i < (N); i++) #define rep1(i, N) for (ll i = 1; i < (N); i++) #define pb push_back ll N; ll fans = INF; char C[200005]; ll cnt[200005]; ll an...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1e9 + 7, INF = mod * mod * 3; // M_PI #define rep(i, N) for (ll i = 0; i < (N); i++) #define rep1(i, N) for (ll i = 1; i < (N); i++) #define pb push_back ll N; ll fans = INF; char C[200005]; ll cnt[200005]; ll an...
[["-", 51, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
267
#include <bits/stdc++.h> using namespace std; #define ll long long #define double long double #define rep(i, n) for (int i = 0; i < n; i++) #include <math.h> /* M_PI */ #define INF 2147483647 int main() { ll n; cin >> n; //仕切りの位置で考える。この前も言ったが、ある方針で躓いたら、その一歩手前に行かないと方法が尽きる。 vector<char> data(n); ll count = 0; ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define double long double #define rep(i, n) for (int i = 0; i < n; i++) #include <math.h> /* M_PI */ #define INF 2147483647 int main() { ll n; cin >> n; //仕切りの位置で考える。この前も言ったが、ある方針で躓いたら、その一歩手前に行かないと方法が尽きる。 vector<char> data(n); ll count = 0; ...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
164
ma = lambda :map(int,input().split()) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq n = ni() cs = input() r = cs.count("R") print(cs[:r].count("R"))
ma = lambda :map(int,input().split()) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq n = ni() cs = input() r = cs.count("R") print(cs[r:].count("R"))
[["-", 0, 652, 63, 319, 500, 206, 206, 663, 0, 102], ["+", 0, 652, 63, 319, 500, 206, 206, 663, 0, 102]]
5
91
#include <bits/stdc++.h> #define fst first #define snd second #define ll long long #define ld long double #define pb push_back #define emp emplace_back #define pii pair<int, int> #define usg unsigned #define sg signed #define mp make_pair using namespace std; void setIO() { ios::sync_with_stdio(0); cin.tie(0); ...
#include <bits/stdc++.h> #define fst first #define snd second #define ll long long #define ld long double #define pb push_back #define emp emplace_back #define pii pair<int, int> #define usg unsigned #define sg signed #define mp make_pair using namespace std; void setIO() { ios::sync_with_stdio(0); cin.tie(0); ...
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 12, 22], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 12, 22]]
1
214
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double dd; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; const int mx = 1e6 + 11; const double PI = acos(-1); #define MOD 1000000007 #define nl '\n' #define pb push_back #define F first #define S second #define I...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double dd; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; const int mx = 1e6 + 11; const double PI = acos(-1); #define MOD 1000000007 #define nl '\n' #define pb push_back #define F first #define S second #define I...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]]
1
281
n = int(input()) c = input() wc = c.count("W") rc = c.count("R") ans = min(c[rc:].count("R"), c[:wc].count("W")) print(ans)
n = int(input()) c = input() wc = c.count("W") rc = c.count("R") ans = min(c[rc:].count("R"), c[:-wc].count("W")) print(ans)
[["+", 63, 319, 500, 206, 206, 663, 0, 664, 17, 33]]
5
67
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; string str; int l_white = 0; int r_red = 0; cin >> str; int w_num = 0; int r_num = 0; for (int i = 0; i < n; i++) { if (str[i] == 'R') r_num++; else w_num++; } for ...
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; string str; int l_white = 0; int r_red = 0; cin >> str; int w_num = 0; int r_num = 0; for (int i = 0; i < n; i++) { if (str[i] == 'R') r_num++; else w_num++; } for ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
193
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define agewari(a, b) ((ll)a + ((ll)b - 1)) / b const int MOD = 1000000007; const long long INF = 1LL << 60; using Graph = vector<vector<ll>>; int main() { ll n; cin >> n; string s; cin >> s...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define agewari(a, b) ((ll)a + ((ll)b - 1)) / b const int MOD = 1000000007; const long long INF = 1LL << 60; using Graph = vector<vector<ll>>; int main() { ll n; cin >> n; string s; cin >> s...
[["-", 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, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0,...
1
133
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string C; for (int i = 0; i < N; i++) { char Cn; cin >> Cn; C.push_back(Cn); } int X = 0; // XはC中のRの数 for (int i = 0; i < N; i++) { if (C.at(i) == 'R') X++; } int S = 0; //取り替えるとかかる回数 for (int i = 0; i...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string C; for (int i = 0; i < N; i++) { char Cn; cin >> Cn; C.push_back(Cn); } int X = 0; // XはC中のRの数 for (int i = 0; i < N; i++) { if (C.at(i) == 'R') X++; } int S = 0; //取り替えるとかかる回数 for (int i = 0; i...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
136
#include <stdio.h> int main() { int n, r = 0, R = 0; scanf("%d,&n"); char c[n + 1]; scanf("%s", c); for (int i = 0; i < n; i++) { if (c[i] == 'R') r += 1; } for (int i = 0; i < r; i++) { if (c[i] == 'R') R += 1; } printf("%d", r - R); return 0; }
#include <stdio.h> int main() { int n, r = 0, R = 0; scanf("%d", &n); char c[n + 1]; scanf("%s", c); for (int i = 0; i < n; i++) { if (c[i] == 'R') r += 1; } for (int i = 0; i < r; i++) { if (c[i] == 'R') R += 1; } printf("%d", r - R); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22]]
0
119
n = int(input()) s = input() l = 0 r = n - 1 ans = 0 while r > l: while r > l: if s[l] == 'W': break else: l += 1 while r > l: if s[r] == 'R': break else: r += 1 if r > l: ans += 1 r -= 1 l += 1 print(ans)
n = int(input()) s = input() l = 0 r = n - 1 ans = 0 while r > l: while r > l: if s[l] == 'W': break else: l += 1 while r > l: if s[r] == 'R': break else: r -= 1 if r > l: ans += 1 r -= 1 l += 1 print(ans)
[["-", 75, 76, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 17, 110]]
5
89
#include <bits/stdc++.h> using namespace std; int main() { int i, n, atob = 0, btoa = 0; string s; cin >> n >> s; for (i = 0; i < n; i++) { if (s[i] == 'R') atob++; } int ans = atob, now; for (i = 0; i < n; i++) { if (s[i] == 'R') atob--; else btoa++; now = max(atob, bto...
#include <bits/stdc++.h> using namespace std; int main() { int i, n, atob = 0, btoa = 0; string s; cin >> n >> s; for (i = 0; i < n; i++) { if (s[i] == 'R') atob++; } int ans = atob, now; for (i = 0; i < n; i++) { if (s[i] == 'R') atob--; else btoa++; now = max(atob, bto...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
124
#include <bits/stdc++.h> using namespace std; int n, i, c, times; string s; int main() { cin >> n; cin >> s; for (i = 0; i < n; i++) if (s[i] == 'W') c++; for (i = 0; i < n; i++) if (s[i] != 'W') times++; cout << times; return 0; }
#include <bits/stdc++.h> using namespace std; int n, i, c, times; string s; int main() { cin >> n; cin >> s; for (i = 0; i < n; i++) if (s[i] == 'W') c++; for (i = n - c; i < n; i++) if (s[i] != 'W') times++; cout << times; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 12, 22]]
1
93
N = int(input()) C = [] for c in list(input()): a = 0 if c == "R": a = 1 C.append(a) L = -1 R = N cnt = 0 while L < R: L += 1 if L < R: break if C[L] != 0: continue while L < R: R -= 1 if L < R: break if C[R] != 1: continue cnt += 1 break print(cnt)
N = int(input()) C = [] for c in list(input()): a = 0 if c == "R": a = 1 C.append(a) L = -1 R = N cnt = 0 while L < R: # print(str(L) + " " + str(R)) L += 1 if L >= R: break if C[L] != 0: continue while L < R: R -= 1 if L >= R: break if C[R] != 1: continue cnt += 1...
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 20]]
5
105
#include <bits/stdc++.h> using namespace std; int main(void) { int N; cin >> N; string c; cin >> c; vector<int> sum(N + 1, 0); for (int i = 0; i < N; i++) { sum[i + 1] = sum[i] + (c[i] == 'W'); } int ans = 100000000; for (int i = 0; i <= N; i++) { ans = min(ans, max(sum[i], sum[N] - (i - sum[...
#include <bits/stdc++.h> using namespace std; int main(void) { int N; cin >> N; string c; cin >> c; vector<int> sum(N + 1, 0); for (int i = 0; i < N; i++) { sum[i + 1] = sum[i] + (c[i] == 'W'); } int ans = 100000000; for (int i = 0; i <= N; i++) { ans = min(ans, max(sum[i], N - sum[N] - (i - ...
[["+", 0, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 17, 33]]
1
138
#include <bits/stdc++.h> #define all(X) X.begin(), X.end() // for(int i = 0; i < n; i++) using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); int n; cin >> n; string s; cin >> s; int red = 0, white = 0, ans = 0; int i = 0, j = n - 1; while (i < j) { if (s[i] ==...
#include <bits/stdc++.h> #define all(X) X.begin(), X.end() // for(int i = 0; i < n; i++) using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); int n; cin >> n; string s; cin >> s; int red = 0, white = 0, ans = 0; int i = 0, j = n - 1; while (i <= j) { if (s[i] =...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19]]
1
156
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <string.h> #include <vector> constexpr long long INFLL = 1e18; using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin ...
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <string.h> #include <vector> constexpr long long INFLL = 1e18; using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
189
#include <bits/stdc++.h> using namespace std; #define int long long int #define ff first #define ss second #define pb push_back int bexp(int a, int b, int mod) { int res = 1; if (mod <= 0) return 0; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return re...
#include <bits/stdc++.h> using namespace std; #define int long long int #define ff first #define ss second #define pb push_back int bexp(int a, int b, int mod) { int res = 1; if (mod <= 0) return 0; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return re...
[["+", 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, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
324
N = int(input()) C = input() W = 0 #仕切りより左側の白い石の個数 R = C.count('R') #仕切りより右側の赤い石の個数 ans = max(W, R) for i in range(N): if C[i] == 'W': #仕切りの左側に'W'が移動する W += 1 else: #仕切りの左側に'R'が移動する R += 1 ans = min(ans, max(W, R)) print(ans)
N = int(input()) C = input() W = 0 #仕切りより左側の白い石の個数 R = C.count('R') #仕切りより右側の赤い石の個数 ans = max(W, R) for i in range(N): if C[i] == 'W': #仕切りの左側に'W'が移動する W += 1 else: #仕切りの左側に'R'が移動する R -= 1 ans = min(ans, max(W, R)) print(ans)
[["-", 75, 76, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 17, 110]]
5
81