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 <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <utility> #include <vector> using nam...
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <utility> #include <vector> using nam...
[["+", 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
340
from itertools import accumulate N = int(input()) S = list(input()) W = [0]*N R = [0]*N ans = N for i in range(N): if S[i] == "W": W[i] = 1 else: R[i] = 1 R.reverse() R = list(accumulate(R)) W = list(accumulate(W)) if R[0] == 0 or W[N-1] == 0: ans = 0 else: sakai = R[N-1] ans = max(...
from itertools import accumulate N = int(input()) S = list(input()) W = [0]*N R = [0]*N ans = N for i in range(N): if S[i] == "W": W[i] = 1 else: R[i] = 1 R.reverse() R = list(accumulate(R)) W = list(accumulate(W)) if R[N-1] == 0 or W[N-1] == 0: ans = 0 else: sakai = R[N-1] ans = ma...
[["-", 0, 57, 15, 679, 31, 666, 0, 206, 206, 612], ["+", 15, 679, 31, 666, 0, 206, 206, 657, 31, 22], ["+", 15, 679, 31, 666, 0, 206, 206, 657, 17, 33], ["+", 15, 679, 31, 666, 0, 206, 206, 657, 12, 612]]
5
146
#include <algorithm> #include <iostream> #include <map> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; ll d; string s; cin >> n >> s; int cntr = 0, cntw = 0; int ans = 0; rep(i, n) ...
#include <algorithm> #include <iostream> #include <map> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; string s; cin >> n >> s; int cntr = 0, cntw = 0; int ans = 0; rep(i, n) { if...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
130
// ABC_128_B// pair型の中にpair型 /*int main() { int n; cin >> n; vector<pair<pair<string,int>,int>> a(n); for(int i=0;i<n;i++){ string s; cin >> s; int num; cin >> num; num = num * -1; a.at(i).first.first = s; a.at(i).first.second = num; a.at(i).second = i; } sort(a.begin(),...
// ABC_128_B// pair型の中にpair型 /*int main() { int n; cin >> n; vector<pair<pair<string,int>,int>> a(n); for(int i=0;i<n;i++){ string s; cin >> s; int num; cin >> num; num = num * -1; a.at(i).first.first = s; a.at(i).first.second = num; a.at(i).second = i; } sort(a.begin(),...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
664
N = int(input()) C = input() w = sum([True for c in C if c == "W"]) r = N - w count = 0 for i, c in enumerate(C): if i < w and c == 'W': count += 1 print(count)
N = int(input()) C = input() w = sum([True for c in C if c == "W"]) r = N - w count = 0 for i, c in enumerate(C): if i < r and c == 'W': count += 1 print(count)
[["-", 8, 196, 0, 57, 15, 679, 31, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 0, 22]]
5
67
n = int(input()) stones = list(input()) a = 0 rlist = [] wlist = [] for i in range(n): if stones[i] == "W": wlist.append(i+1) elif stones[i] == "R": rlist.append(i+1) rlist.sort(reverse=True) r_numbers = len(rlist) w_numbers = len(wlist) if r_numbers == 0 or w_numbers == 0: print(0) elif r_numbers>=w_...
n = int(input()) stones = list(input()) a = 0 rlist = [] wlist = [] for i in range(n): if stones[i] == "W": wlist.append(i+1) elif stones[i] == "R": rlist.append(i+1) rlist.sort(reverse=True) r_numbers = len(rlist) w_numbers = len(wlist) if r_numbers == 0 or w_numbers == 0: print(0) elif r_numbers>=w_...
[["-", 64, 196, 0, 52, 15, 679, 31, 666, 667, 18], ["+", 64, 196, 0, 52, 15, 679, 31, 666, 667, 47], ["-", 75, 665, 64, 196, 0, 57, 15, 666, 667, 18], ["+", 75, 665, 64, 196, 0, 57, 15, 666, 667, 47]]
5
206
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, const T &b...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, const T &b...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
1
365
#include "bits/stdc++.h" using namespace std; int main() { int n; cin >> n; string s; cin >> s; int i = 0, j = n - 1; int count = 0; while (i < j) { while (i < n && s[i] == 'R') i++; while (j >= 0 && s[j] == 'W') j--; if (i < n && j >= 0 && i != j) count++; i++, j--; }...
#include "bits/stdc++.h" using namespace std; int main() { int n; cin >> n; string s; cin >> s; int i = 0, j = n - 1; int count = 0; while (i < j) { while (i < n && s[i] == 'R') i++; while (j >= 0 && s[j] == 'W') j--; if (i < n && j >= 0 && i < j) count++; i++, j--; } ...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18]]
1
120
#include <bits/stdc++.h> #include <iostream> using namespace std; #define ll long long #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define pb push_back #define endl '\n' #define mod 100...
#include <bits/stdc++.h> #include <iostream> using namespace std; #define ll long long #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define pb push_back #define endl '\n' #define mod 100...
[["-", 15, 339, 51, 16, 12, 16, 12, 16, 12, 22], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 12, 22]]
1
198
#include <bits/stdc++.h> #include <string> using namespace std; const int mod = 1e9 + 7; const long long INF = 1e18; #define PI 3.141592653589793 #define REP(i, n) for (int i = 0; i < n; ++i) int H, W, K, N, D; char x[200010]; int main() { int count = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> x[i]; ...
#include <bits/stdc++.h> #include <string> using namespace std; const int mod = 1e9 + 7; const long long INF = 1e18; #define PI 3.141592653589793 #define REP(i, n) for (int i = 0; i < n; ++i) int H, W, K, N, D; char x[200010]; int main() { int count = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> x[i]; ...
[["-", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["+", 8, 9, 0, 52, 8, 9, 0, 52, 0, 89]]
1
162
#include <bits/stdc++.h> #include <cmath> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <string> #define pb push_back #define ll long long #define ull unsigned long long #define deb(x) cerr << #x << " " << x << "\n" #define debi cerr << "hey sparky\n" #define x first #define y s...
#include <bits/stdc++.h> #include <cmath> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <string> #define pb push_back #define ll long long #define ull unsigned long long #define deb(x) cerr << #x << " " << x << "\n" #define debi cerr << "hey sparky\n" #define x first #define y s...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47]]
1
607
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] c = new char[n]; c = sc.next().toCharArray(); int left = 0, right = n - 1; int res = 0; while (left < right) { if (c[left] == 'R') { ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] c = new char[n]; c = sc.next().toCharArray(); int left = 0, right = n - 1; int res = 0; while (left < right) { if (c[left] == 'R') { ...
[["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 0, 52, 8, 196, 0, 57, 15, 15, 0, 24], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 15, 0, 25]]
3
141
n=int(input()) c=input() wnum=0 for i in range(n): if c[i]=="W": wnum+=1 cnt=0 for ci in c[:wnum]: if ci=="W": cnt+=1 print(cnt)
n=int(input()) c=input() wnum=0 for i in range(n): if c[i]=="W": wnum+=1 cnt=0 for ci in c[:n-wnum]: if ci=="W": cnt+=1 print(cnt)
[["+", 0, 7, 12, 206, 206, 663, 0, 657, 31, 22], ["+", 0, 7, 12, 206, 206, 663, 0, 657, 17, 33]]
5
63
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); String c_str = in...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); String c_str = in...
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 85], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
3
187
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <utility> #inc...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <utility> #inc...
[["+", 51, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 72]]
1
629
N = int(input()) c = input() w = [] r = [] for i, ci in enumerate(c): if ci == 'W': w.append(i) if ci == 'R': r.append(i) # print(w, r) answer = 0 lenw = len(w) lenr = len(r) while answer < min(lenr, lenw) and w[answer] < r[-answer]: answer += 1 print(answer)
N = int(input()) c = input() w = [] r = [] for i, ci in enumerate(c): if ci == 'W': w.append(i) if ci == 'R': r.append(i) # print(w, r) answer = 0 lenw = len(w) lenr = len(r) while answer < min(lenr, lenw) and w[answer] < r[-answer-1]: # print(w[answer], r[-answer]) answer += 1 print(ans...
[["+", 15, 679, 12, 666, 0, 206, 206, 657, 17, 33], ["+", 15, 679, 12, 666, 0, 206, 206, 657, 12, 612]]
5
101
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; using vll = vector<vl>; using Pll = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(v) v.begin(), v.end() #define sz(x) ((int)x.size()) #define pb push_back #define mp make_pai...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; using vll = vector<vl>; using Pll = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(v) v.begin(), v.end() #define sz(x) ((int)x.size()) #define pb push_back #define mp make_pai...
[["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22]]
1
417
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const ll mod = 1e9 + 7; const ll mod1 = 998244353; const ll inf = 9e18 + 5; const double pi = acosl(-1.0l); #define rep(i, a, b) for (ll i = a; i < b; i++) const long double eps = 1e-9; bool equalTo(double a, double b) { if (fabs(a - b) <= eps) ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const ll mod = 1e9 + 7; const ll mod1 = 998244353; const ll inf = 9e18 + 5; const double pi = acosl(-1.0l); #define rep(i, a, b) for (ll i = a; i < b; i++) const long double eps = 1e-9; bool equalTo(double a, double b) { if (fabs(a - b) <= eps) ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
1,399
import collections def main(): n = int(input()) c = list(input()) wcnt = c.count("W") rcnt = c.count("R") if wcnt == 0 or rcnt == 0: print(0) return ans = c[0:wcnt].count("W") print(ans) if __name__ == '__main__': main()
import collections def main(): n = int(input()) c = list(input()) wcnt = c.count("W") rcnt = c.count("R") if wcnt == 0 or rcnt == 0: print(0) return ans = c[0:rcnt].count("W") print(ans) if __name__ == '__main__': main()
[["-", 12, 652, 63, 319, 500, 206, 206, 663, 0, 22], ["+", 12, 652, 63, 319, 500, 206, 206, 663, 0, 22]]
5
86
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <vector> #define INCANT ...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <vector> #define INCANT ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
349
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define mkp make_pair #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define ff first #define ss second #define endl "\n" #define MOD 1...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define mkp make_pair #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define ff first #define ss second #define endl "\n" #define MOD 1...
[["-", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["+", 8, 9, 0, 52, 8, 9, 0, 52, 0, 89]]
1
543
import java.io.*; import java.util.*; public class Main { private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); private static StringTokenizer st; ...
import java.io.*; import java.util.*; public class Main { private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); private static StringTokenizer st; ...
[["-", 0, 52, 15, 15, 0, 16, 31, 16, 31, 22], ["-", 0, 52, 15, 15, 0, 16, 31, 16, 17, 18], ["+", 0, 52, 15, 15, 0, 16, 31, 16, 17, 18], ["+", 0, 52, 15, 15, 0, 16, 31, 16, 12, 22]]
3
292
#pragma GCC optimize("Ofast") #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; using ll = long long; using u64 = uint_fast64_t; using pii = pair<int, int>; using pll = pair<long long, long long>; #define rep(i, n) for...
#pragma GCC optimize("Ofast") #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; using ll = long long; using u64 = uint_fast64_t; using pii = pair<int, int>; using pll = pair<long long, long long>; #define rep(i, n) for...
[["+", 0, 27, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 27, 28, 69, 341, 342, 0, 16, 12, 13]]
1
416
#include <bits/stdc++.h> using namespace std; #define fi first #define endl "\n" #define se second #define ll long long #define inf 0x3f3f3f3f #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; #define fi first #define endl "\n" #define se second #define ll long long #define inf 0x3f3f3f3f #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 47]]
1
146
#include <bits/stdc++.h> using namespace std; #define fi first #define endl "\n" #define se second #define ll long long #define inf 0x3f3f3f3f #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; #define fi first #define endl "\n" #define se second #define ll long long #define inf 0x3f3f3f3f #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46]]
1
146
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int left = 0; int count = 0; int right = s.size() - 1; while (left < right) { while (left < right && s[left] != 'R') left++; while (left < right && s[right] != 'W') right--; if (left <...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int left = 0; int count = 0; int right = s.size() - 1; while (left < right) { while (left < right && s[left] != 'W') left++; while (left < right && s[right] != 'R') right--; if (left <...
[["-", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125]]
1
124
n = int(input()) s = input() nowL = 0 # 今見てる左側の位置 nowR = n-1 # 今見てる右側の位置 ans = 0 # swapした回数 while(True): print(nowL,nowR) while(nowL < n-1): # 左側で、右に移動しながら次のWを探す if(s[nowL]=='W'): break else: nowL+=1 while(nowR > 0): # 右側で、次のRを探す if(s[nowR]=...
n = int(input()) s = input() nowL = 0 # 今見てる左側の位置 nowR = n-1 # 今見てる右側の位置 ans = 0 # swapした回数 while(True): while(nowL < n-1): # 左側で、右に移動しながら次のWを探す if(s[nowL]=='W'): break else: nowL+=1 while(nowR > 0): # 右側で、次のRを探す if(s[nowR]=='R'): bre...
[["-", 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
114
//============================================================================ // Name : template.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <...
//============================================================================ // Name : template.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 57, 64, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 57, 64, 1, 0, 27, 17, 29]]
1
430
N = int(input()) c = input() W = 0 R = 0 for x in c: if x=='R': R += 1 ans = R for x in c: if c=='W': W += 1 else: R -= 1 ans = min(ans,max(R,W)) print(ans)
N = int(input()) c = input() W = 0 R = 0 for x in c: if x=='R': R += 1 ans = R for x in c: if x=='W': W += 1 else: R -= 1 ans = min(ans,max(R,W)) print(ans)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22]]
5
74
import sys readline = sys.stdin.readline from collections import deque def solve(): N = int(readline()) C = readline().rstrip() R, W = 'R', 'W' reds = deque(i for i in range(len(C)) if C[i] == 'R') whites = deque(i for i in range(len(C)) if C[i] == 'W') count = 0 print(reds, whites) w...
import sys readline = sys.stdin.readline from collections import deque def solve(): N = int(readline()) C = readline().rstrip() R, W = 'R', 'W' reds = deque(i for i in range(len(C)) if C[i] == 'R') whites = deque(i for i in range(len(C)) if C[i] == 'W') count = 0 while len(whites) > 0 and...
[["-", 0, 14, 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
151
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define mod 1000000007 #define ten5 100005 #define ten52 200005 #define ten6 1000005 #...
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define mod 1000000007 #define ten5 100005 #define ten52 200005 #define ten6 1000005 #...
[["-", 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, 1, 0, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
188
#include <bits/stdc++.h> #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repi(i, 0, n) #define SZ(x) ((int)(x).size()) typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; struct Vec { double x, y; }; template <class T> inline bool chmin(T &a, T b) { if ...
#include <bits/stdc++.h> #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repi(i, 0, n) #define SZ(x) ((int)(x).size()) typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; struct Vec { double x, y; }; template <class T> inline bool chmin(T &a, T b) { if ...
[["-", 51, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["-", 51, 16, 31, 69, 341, 342, 0, 16, 17, 33]]
1
285
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #...
[["+", 0, 2, 3, 4, 0, 16, 31, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 69, 341, 342, 0, 70], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 33], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 3, 4, 0, 16, 31, 69, 341, 342, 0, 73]]
1
364
#include <bits/stdc++.h> using namespace std; int32_t main() { int n; cin >> n; string s; cin >> s; int r = 0, w = 0, res, temp = 0; for (int i = 0; i < n; i++) { if (s[i] == 'W') { w++; } else { r++; } } for (int i = n - 1; i >= w; i--) { if (s[i] == 'W') { temp++; ...
#include <bits/stdc++.h> using namespace std; int32_t main() { int n; cin >> n; string s; cin >> s; int r = 0, w = 0, res, temp = 0; for (int i = 0; i < n; i++) { if (s[i] == 'W') { w++; } else { r++; } } for (int i = n - 1; i >= n - w; i--) { if (s[i] == 'W') { temp+...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33]]
1
129
n = int(input()) C = input() A = [0]*(n+1) cnt = 0 for i, c in enumerate(C): if c == "R": cnt += 1 A[i+1] = 1 A[i+1] += A[i] ans = float("inf") for i in range(1, n+1): W_l = i - A[i] R_r = cnt - A[i] temp = min(W_l, R_r) + abs(W_l-R_r) ans = min(ans, temp) print(ans)
n = int(input()) C = input() A = [0]*(n+1) cnt = 0 for i, c in enumerate(C): if c == "R": cnt += 1 A[i+1] = 1 A[i+1] += A[i] ans = float("inf") for i in range(n+1): W_l = i - A[i] R_r = cnt - A[i] temp = min(W_l, R_r) + abs(W_l-R_r) ans = min(ans, temp) print(ans)
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21]]
5
129
n=int(input()) s=input() l,r=0,n-1 ans=0 while l<r: cnt=0 while r>=0 and s[r]=='W':r-=1 while l<n and s[l]=='R':l+=1 if l>=r:break while s[r]=='R': cnt+=1 r-=1 cm=cnt while cnt: if s[l]=='W':cnt-=1 l+=1 if l==r:break ans+=abs(cm-cnt) print(ans)
n=int(input()) s=input() l,r=0,n-1 ans=0 while l<r: cnt=0 while r>=0 and s[r]=='W':r-=1 while l<n and s[l]=='R':l+=1 if l>=r:break while s[r]=='R': cnt+=1 r-=1 cm=cnt while cnt: if s[l]=='W':cnt-=1 l+=1 if l>r:break ans+=cm-cnt print(ans)
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 47], ["-", 8, 196, 0, 1, 0, 677, 12, 652, 63, 22], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 25]]
5
129
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { string str; int N, i, j, count = 0; cin >> N >> str; i = 0; j = N - 1; while (i < j) { if (str[i] == 'W' && str[j] == 'R') { count += 1;...
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { string str; int N, i, j, count = 0; cin >> N >> str; i = 0; j = N - 1; while (i < j) { if (str[i] == 'W' && str[j] == 'R') { count += 1;...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 110], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107]]
1
167
#include <algorithm> //ソート等に使用 #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> // #include <vector> // #define _USE_MATH_DEFINES #include <bitset> #include <cmath> #include <math.h> #include <queue> //幅優先等のキュー #include <stack> #include <stdio.h> #include <th...
#include <algorithm> //ソート等に使用 #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> // #include <vector> // #define _USE_MATH_DEFINES #include <bitset> #include <cmath> #include <math.h> #include <queue> //幅優先等のキュー #include <stack> #include <stdio.h> #include <th...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
306
n = input() s = input() L = 0 r = len(s) cnt = 0 while True: L = s.find('W') if L == -1: break r = s.rfind('R') if r == -1: break if (L > r): break s = s[L + 1:r].lstrip('R').rstrip('W') cnt += 1 if L != -1 and L > r: cnt += L + 1 print(cnt)
n = input() s = input() L = 0 r = len(s) cnt = 0 while True: L = s.find('W') if L == -1: break r = s.rfind('R') if r == -1: break if (L > r): break s = s[L + 1:r].lstrip('R').rstrip('W') cnt += 1 if L != -1 and L < r: cnt += L + 1 print(cnt)
[["-", 0, 656, 0, 57, 15, 679, 12, 666, 667, 47], ["+", 0, 656, 0, 57, 15, 679, 12, 666, 667, 18]]
5
113
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int N; cin >> N; vector<char> V(N); int Rcounter = 0; rep(i, N) { char c; cin >> c; V[i] = c; if (c == 'R') Rcounter++; } int ans = 0; rep(i, N - Rcounter) { if (V[i] == '...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int N; cin >> N; vector<char> V(N); int Rcounter = 0; rep(i, N) { char c; cin >> c; V[i] = c; if (c == 'R') Rcounter++; } int ans = 0; rep(i, Rcounter) { if (V[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
110
#include "bits/stdc++.h" using namespace std; #define REP(k, m, n) for (int(k) = (m); (k) < (n); (k)++) #define rep(i, n) REP((i), 0, (n)) using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using tp3 = tuple<int, int, int>; using Mat = vector<vector<ll>>; constexpr int INF = 1 << 28; constexpr ...
#include "bits/stdc++.h" using namespace std; #define REP(k, m, n) for (int(k) = (m); (k) < (n); (k)++) #define rep(i, n) REP((i), 0, (n)) using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using tp3 = tuple<int, int, int>; using Mat = vector<vector<ll>>; constexpr int INF = 1 << 28; constexpr ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
411
#include <bits/stdc++.h> using namespace std; #define SPEED \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define fileio ...
#include <bits/stdc++.h> using namespace std; #define SPEED \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define fileio ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
143
#include <bits/stdc++.h> using namespace std; #define REP(i, m, n) for (int i = (m); i < (int)(n); i++) #define RREP(i, m, n) for (int i = (int)((n)-1); i >= m; i--) #define rep(i, n) REP(i, 0, n) #define rrep(i, n) RREP(i, 0, n) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define fi...
#include <bits/stdc++.h> using namespace std; #define REP(i, m, n) for (int i = (m); i < (int)(n); i++) #define RREP(i, m, n) for (int i = (int)((n)-1); i >= m; i--) #define rep(i, n) REP(i, 0, n) #define rrep(i, n) RREP(i, 0, n) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define fi...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
696
import collections c=input() c=input() tmp=collections.Counter(c) count_r=0 count_w=0 ans=0 dis_r=0 for i in c: if dis_r == tmp["R"]: break elif i == "W": if count_r<=tmp["R"]-count_r: ans+=1 dis_r+=1 else: ans+=1 else: count_r...
import collections c=input() c=input() tmp=collections.Counter(c) count_r=0 count_w=0 ans=0 dis_r=0 for i in c: if dis_r == tmp["R"]: break elif i == "W": if count_r<=tmp["R"]: ans+=1 dis_r+=1 else: ans+=1 else: count_r+=1 ...
[["-", 64, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["-", 64, 196, 0, 57, 15, 666, 0, 657, 12, 22]]
5
90
N=int(input()) c=list(input()) print(c) i=0 count1=0 count2=0 for i in c: if i=="R": count1+=1 for j in range(count1): if c[j]=="R": count2+=1 print(count1-count2)
N=int(input()) c=list(input()) i=0 count1=0 count2=0 for i in c: if i=="R": count1+=1 for j in range(count1): if c[j]=="R": count2+=1 print(count1-count2)
[["-", 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
71
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define mp make_pair #define sz(x) ((int)(x).size()) #define endl "\n" #define fastio \ ios_base::sync_with_stdio(false); \ cin....
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define mp make_pair #define sz(x) ((int)(x).size()) #define endl "\n" #define fastio \ ios_base::sync_with_stdio(false); \ cin....
[["+", 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
265
#include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int, int>; #include <algorithm> #include <map> #include <math.h> #include <queue> int main() { ll n; cin >> n; string a; cin >> a; ll cnt(0); ll cntw(0); rep(i, ...
#include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int, int>; #include <algorithm> #include <map> #include <math.h> #include <queue> int main() { ll n; cin >> n; string a; cin >> a; ll cnt(0); ll cntw(0); rep(i, ...
[["-", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
166
#define ll long long #define lld long double #define cn(n) \ ll n; \ cin >> n; #define tes(t) \ ll t; ...
#define ll long long #define lld long double #define cn(n) \ ll n; \ cin >> n; #define tes(t) \ ll t; ...
[["-", 8, 9, 0, 1, 0, 11, 12, 91, 17, 33]]
1
460
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string Iro; cin >> Iro; int Ans = 0; int Red = 0; for (int i = 0; i < N; i++) { if (Iro.at(i) == 'R') { Red++; } } if (Red != 0) { Red--; for (int i = 0; i < Red; i++) { if (Iro.at(i) == 'W') { ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string Iro; cin >> Iro; int Ans = 0; int Red = 0; for (int i = 0; i < N; i++) { if (Iro.at(i) == 'R') { Red++; } } if (Red != 0) { Red--; for (int i = 0; i <= Red; i++) { if (Iro.at(i) == 'W') { ...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 19]]
1
119
n = int(input()) s = input() l = 0 r = n-1 ans = 0 while(True): while(s[l]=='R' and l<n-1): l+=1 while(s[r]=='W' and r<0): r-=1 if l < r: ans += 1 l += 1 r -= 1 else: break print(ans)
n = int(input()) s = input() l = 0 r = n-1 ans = 0 while(True): while(s[l]=='R' and l<n-1): l+=1 while(s[r]=='W' and 0<r): r-=1 if l < r: ans += 1 l += 1 r -= 1 else: break print(ans)
[["-", 0, 52, 15, 23, 0, 679, 12, 666, 0, 22], ["-", 0, 52, 15, 23, 0, 679, 12, 666, 667, 18], ["+", 0, 52, 15, 23, 0, 679, 12, 666, 667, 18], ["+", 0, 52, 15, 23, 0, 679, 12, 666, 0, 22]]
5
90
#include <bits/stdc++.h> #include <chrono> using namespace std; // using namespace std::chrono; #define all(x) x.begin(), x.end() #define vi vector<int> #define vll vector<long long> typedef long long ll; void print(vi v) { cout << "Contents of vector:\n"; for (auto x : v) cout << x << " "; cout << endl <...
#include <bits/stdc++.h> #include <chrono> using namespace std; // using namespace std::chrono; #define all(x) x.begin(), x.end() #define vi vector<int> #define vll vector<long long> typedef long long ll; void print(vi v) { cout << "Contents of vector:\n"; for (auto x : v) cout << x << " "; cout << endl <...
[["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 0, 35], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
1
207
#include <bits/stdc++.h> using namespace std; //#define local #ifdef local template <class T> void _E(T x) { cerr << x; } void _E(double x) { cerr << fixed << setprecision(6) << x; } void _E(string s) { cerr << "\"" << s << "\""; } template <class A, class B> void _E(pair<A, B> x) { cerr << '('; _E(x.first); ...
#include <bits/stdc++.h> using namespace std; //#define local #ifdef local template <class T> void _E(T x) { cerr << x; } void _E(double x) { cerr << fixed << setprecision(6) << x; } void _E(string s) { cerr << "\"" << s << "\""; } template <class A, class B> void _E(pair<A, B> x) { cerr << '('; _E(x.first); ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
858
#include <bits/stdc++.h> typedef long long lint; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) int main() { int n; cin >> n; string c; cin >> c; int l, r; l = 0; r = n - 1; int ans = 0; while (l < r) { while (l < n && c[l] != 'W') l++; while (r ...
#include <bits/stdc++.h> typedef long long lint; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) int main() { int n; cin >> n; string c; cin >> c; int l, r; l = 0; r = n - 1; int ans = 0; while (l < r) { while (l < n && c[l] != 'W') l++; while (r ...
[["+", 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
129
K = int(input()) C = input() C = list(C) r = C.count("W") A = C[:r].count("W") B = C[-K+r:].count("W") # print(A) # print(B) cnt = 0 for _ in range(200000): if A > 0: if B > 0: A -= 1 B += 1 cnt += 1 else: A -= 1 cnt += 1 else: ...
K = int(input()) C = input() C = list(C) r = C.count("R") A = C[:r].count("W") B = C[-K+r:].count("W") # print(A) # print(B) cnt = 0 for _ in range(200000): if A > 0: if B > 0: A -= 1 B += 1 cnt += 1 else: A -= 1 cnt += 1 else: ...
[["-", 0, 662, 12, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 662, 12, 652, 3, 4, 0, 557, 0, 6]]
5
107
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int r = 0, w = 0; for (int i = 0; i < s.size(); i++) if (s[i] == 'R') r++; for (int i = 0; i < s.size(); i++) { if (w >= r) { cout << r << endl; return 0; } if (s[i] == w) ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int r = 0, w = 0; for (int i = 0; i < s.size(); i++) if (s[i] == 'R') r++; for (int i = 0; i < s.size(); i++) { if (w >= r) { cout << r << endl; return 0; } if (s[i] == 'W') ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 104], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
129
#define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> //マクロ #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define REPS(i, n) for (int i = 1; i <= (int)(n); ++i)...
#define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> //マクロ #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define REPS(i, n) for (int i = 1; i <= (int)(n); ++i)...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 11, 31, 69, 341, 342, 0, 27, 17, 68]]
1
401
/*input 4 WWRR */ #include <bits/stdc++.h> using namespace std; #define ld long double #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define pii pair<int, int> #define pll pair<long long, long long> #define vpll vector<pair<long long, long long>> #define fill(a, val) m...
/*input 5 WRWWR */ #include <bits/stdc++.h> using namespace std; #define ld long double #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define pii pair<int, int> #define pll pair<long long, long long> #define vpll vector<pair<long long, long long>> #define fill(a, val) ...
[["+", 64, 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, 19], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
398
import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) C=input() L=[0]*(n+1) R=[0]*(n+1) for i in range(n): if C[i]=="W": L[i+1]=L[i]+1 else: L[i+1]=L[i] if C[n-1-i]=="R": R[n-i-1]=R[n-i]+1 else: R[n-i-1]=R[n-i] ans=n for i in range(n): cur=max(L[i],R[i]) ans=min(ans,cur) prin...
import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) C=input() L=[0]*(n+1) R=[0]*(n+1) for i in range(n): if C[i]=="W": L[i+1]=L[i]+1 else: L[i+1]=L[i] if C[n-1-i]=="R": R[n-i-1]=R[n-i]+1 else: R[n-i-1]=R[n-i] ans=n for i in range(n+1): cur=max(L[i],R[i]) ans=min(ans,cur) pr...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
181
#include <bits/stdc++.h> using namespace std; int main() { int N, Z = 0; cin >> N; vector<char> p(N); for (int i = 0; i < N; i++) { cin >> p[i]; } int l = 0, r = N - 1; while (l < r) { while (l < r) { if (p[l] == 'W') { break; } else { l++; } } while (l <...
#include <bits/stdc++.h> using namespace std; int main() { int N, Z = 0; cin >> N; vector<char> p(N); for (int i = 0; i < N; i++) { cin >> p[i]; } int l = 0, r = N - 1; while (l < r) { while (l < r) { if (p[l] == 'W') { break; } else { l++; } } while (l <...
[["-", 75, 76, 0, 9, 0, 1, 0, 27, 17, 29], ["+", 75, 76, 0, 9, 0, 1, 0, 27, 17, 68]]
1
155
/* NAME : RISHABH SINGH INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY */ #include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long #define pii pair<int, int> #define bi __builtin_inf() #define ll long ...
/* NAME : RISHABH SINGH INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY */ #include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long #define pii pair<int, int> #define bi __builtin_inf() #define ll long ...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33]]
1
378
import sys input = sys.stdin.readline N = int(input()) c = input().rstrip() white = [0] * N red = [0] * N if c[0] == 'W': white[0] = 1 for i in range(1, N): white[i] = white[i-1] if c[i] == 'W': white[i] += 1 for i in range(1, N)[::-1]: red[i-1] = red[i] if c[i] == 'R': red[i-1] += ...
import sys input = sys.stdin.readline N = int(input()) c = input().rstrip() white = [0] * N red = [0] * N if c[0] == 'W': white[0] = 1 for i in range(1, N): white[i] = white[i-1] if c[i] == 'W': white[i] += 1 for i in range(1, N)[::-1]: red[i-1] = red[i] if c[i] == 'R': red[i-1] += ...
[["+", 0, 1, 0, 652, 3, 4, 0, 206, 51, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]]
5
187
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); char[] s = br.readLine().toCharArray(); br....
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); char[] s = br.readLine().toCharArray(); br....
[["-", 0, 52, 15, 15, 0, 16, 31, 16, 17, 19], ["+", 0, 52, 15, 15, 0, 16, 31, 16, 17, 20]]
3
170
n = int(input()) a = input() red = 0 for i in range(n): if a[i] == 'R': red += 1 ans = 0 for i in range(n-red): if a[i] == 'W': ans += 1 print(ans)
n = int(input()) a = input() red = 0 for i in range(n): if a[i] == 'R': red += 1 ans = 0 for i in range(red): if a[i] == 'W': ans += 1 print(ans)
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33]]
5
67
#include <iostream> using namespace std; string s; main() { int N; cin >> N >> s; int ans = 0; int l = 0, r = N - 1; while (l < r) { while (l < N && s[l] == 'R') l++; while (r >= 0 && s[r] == 'L') r--; if (l < r) { ans++; l++; r--; } } cout << ans << endl; }
#include <iostream> using namespace std; string s; main() { int N; cin >> N >> s; int ans = 0; int l = 0, r = N - 1; while (l < r) { while (l < N && s[l] == 'R') l++; while (r >= 0 && s[r] == 'W') r--; if (l < r) { ans++; l++; r--; } } cout << ans << endl; }
[["-", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125]]
1
106
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "../debug.h" #else #define debug(x...) 141 #endif #define forn(i, x, n) for (int i = x; i < n; ++i) #define forit(it, m) for (auto it = m.begin(); it != m.end(); ++it) typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); int ...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "../debug.h" #else #define debug(x...) 141 #endif #define forn(i, x, n) for (int i = x; i < n; ++i) #define forit(it, m) for (auto it = m.begin(); it != m.end(); ++it) typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); int ...
[["+", 12, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 12, 2, 3, 4, 0, 16, 31, 16, 17, 33], ["+", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
1
196
#include <bits/stdc++.h> #define pir pair<int, int> #define qmin(x, y) (x = min(x, y)) #define qmax(x, y) (x = max(x, y)) #define rsort(x, y) sort(x, y), reverse(x, y) #define fr first #define se second using namespace std; typedef long long ll; const int Maxn = 2100000; const int inf = 0x3f3f3f3f; int n, ans; char s[...
#include <bits/stdc++.h> #define pir pair<int, int> #define qmin(x, y) (x = min(x, y)) #define qmax(x, y) (x = max(x, y)) #define rsort(x, y) sort(x, y), reverse(x, y) #define fr first #define se second using namespace std; typedef long long ll; const int Maxn = 2100000; const int inf = 0x3f3f3f3f; int n, ans; char s[...
[["-", 0, 57, 64, 1, 0, 34, 31, 2, 63, 22], ["-", 64, 1, 0, 34, 31, 2, 3, 4, 0, 24], ["-", 0, 34, 31, 2, 3, 4, 0, 5, 0, 62], ["-", 0, 34, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 34, 31, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 57, 64, 1, 0, 34, 0, 21]]
1
201
/* Simplicity and Goodness */ #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; // typedef tree<int, null_type, less<int>, rb_tree_tag, // tree_order_statistics_node_update> indexed_set; void my...
/* Simplicity and Goodness */ #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; // typedef tree<int, null_type, less<int>, rb_tree_tag, // tree_order_statistics_node_update> indexed_set; void my...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
486
n=int(input()) c=list(input()) s=c.count("W") d=c[:n-s+1].count("W") print(d)
n=int(input()) c=list(input()) s=c.count("W") d=c[:n-s].count("W") print(d)
[["-", 63, 319, 500, 206, 206, 663, 0, 657, 17, 72], ["-", 63, 319, 500, 206, 206, 663, 0, 657, 12, 612]]
5
48
// // header_useful.h // c++_acm // // Created by 李弘辰 on 2019/7/23. // Copyright 2019 李弘辰. All rights reserved. // #include <algorithm> // sort #include <bitset> #include <fstream> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <sta...
// // header_useful.h // c++_acm // // Created by 李弘辰 on 2019/7/23. // Copyright 2019 李弘辰. All rights reserved. // #include <algorithm> // sort #include <bitset> #include <fstream> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <sta...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22]]
1
355
n=int(input()) c=list(input()) rall=c.count('R') wlef=c[:rall+1].count('W') print(wlef)
n=int(input()) c=list(input()) rall=c.count('R') wlef=c[:rall].count('W') #print(c[:rall]) print(wlef)
[["-", 63, 319, 500, 206, 206, 663, 0, 657, 17, 72], ["-", 63, 319, 500, 206, 206, 663, 0, 657, 12, 612]]
5
46
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <set> #include <string> #include <vector> #define fastio \ ios_base::sync_with_st...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <set> #include <string> #include <vector> #define fastio \ ios_base::sync_with_st...
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
500
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define pf push_front #define all(t) t.begin(), t.end() #define inrange(i, a, b) (((i) >= min((a), (b))) && ((i) <= max((a), (b)))) typedef vector<ll> vi; typedef pair<ll, ll> pii; #define fi first #define se ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define pf push_front #define all(t) t.begin(), t.end() #define inrange(i, a, b) (((i) >= min((a), (b))) && ((i) <= max((a), (b)))) typedef vector<ll> vi; typedef pair<ll, ll> pii; #define fi first #define se ...
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 18]]
1
578
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define ll long long #define INF 21474836...
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define ll long long #define INF 21474836...
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
147
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5 + 7; int n, ans, s1[N], s2[N]; char c[N]; int main() { scanf("%d%s", &n, c + 1); for (int i = 1; i <= n; i++) s1[i] = s1[i - 1] + (c[i] == 'W'), s2[i] = s2[i - 1] + (c[i] == 'R'); ans = min(s1[n], s2[n]); for (int i = 1; i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5 + 7; int n, ans, s1[N], s2[N]; char c[N]; int main() { scanf("%d%s", &n, c + 1); for (int i = 1; i <= n; i++) s1[i] = s1[i - 1] + (c[i] == 'W'), s2[i] = s2[i - 1] + (c[i] == 'R'); ans = min(s1[n], s2[n]); for (int i = 1; i...
[["-", 0, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
185
#include <algorithm> #include <assert.h> #include <bitset> #include <chrono> #include <cstdio> #include <ctime> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <vector> using namespace std; typedef long long int ll; typed...
#include <algorithm> #include <assert.h> #include <bitset> #include <chrono> #include <cstdio> #include <ctime> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <vector> using namespace std; typedef long long int ll; typed...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
314
#include <bits/stdc++.h> using namespace std; int main() { int n, r = 0, a = 0; cin >> n; char c[n]; for (int i = 0; i < n; i++) { cin >> c[i]; if (c[i] == 'W') r++; } for (int i = 0; i < r; i++) { if (c[i] == 'W') a++; } cout << a; }
#include <bits/stdc++.h> using namespace std; int main() { int n, r = 0, a = 0; cin >> n; char c[n]; for (int i = 0; i < n; i++) { cin >> c[i]; if (c[i] == 'R') r++; } for (int i = 0; i < r; i++) { if (c[i] == 'W') a++; } cout << a; }
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
104
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int N; cin >> N; string C; cin >> C; vector<int> rcount(N, 0); int cou = 0; for (int i = 0; i < N; i++) { if (C[i] == 'R') cou++; rcount[i] = cou; } int ans = 0; cou = 0; for (int i = N - 1; 0 <= i; i--...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int N; cin >> N; string C; cin >> C; vector<int> rcount(N, 0); int cou = 0; for (int i = 0; i < N; i++) { if (C[i] == 'R') cou++; rcount[i] = cou; } int ans = 0; for (int i = N - 1; 0 <= i; i--) { if ...
[["-", 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, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 57...
1
145
/*#include <boost/multiprecision/cpp_dec_float.hpp> #include <boost/multiprecision/cpp_int.hpp> #include <boost/rational.hpp> */ #include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, t) for (ll i = (ll)(0); i < (ll)(t); i++) #define rep2(i, s, t) for (ll i = (ll)(s); i < (ll)(t); i++) #de...
/*#include <boost/multiprecision/cpp_dec_float.hpp> #include <boost/multiprecision/cpp_int.hpp> #include <boost/rational.hpp> */ #include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, t) for (ll i = (ll)(0); i < (ll)(t); i++) #define rep2(i, s, t) for (ll i = (ll)(s); i < (ll)(t); i++) #de...
[["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72]]
1
2,993
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int lon...
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int lon...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
202
#include <bits/stdc++.h> #define F first #define S second using namespace std; using ll = long long; typedef pair<int, int> P; ll Mod = 1000000007; int main() { int N; cin >> N; string S; cin >> S; int R[N]; int rR[N]; for (int i = 0; i < N; i++) { if (i == 0) { if (S[i] == 'W') { R[0] =...
#include <bits/stdc++.h> #define F first #define S second using namespace std; using ll = long long; typedef pair<int, int> P; ll Mod = 1000000007; int main() { int N; cin >> N; string S; cin >> S; int R[N]; int rR[N]; for (int i = 0; i < N; i++) { if (i == 0) { if (S[i] == 'W') { R[0] =...
[["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22]]
1
339
import sys input=sys.stdin.readline sys.setrecursionlimit(10 ** 8) from itertools import accumulate from itertools import permutations from itertools import combinations from collections import defaultdict from collections import Counter import fractions import math from collections import deque from bisect import bise...
import sys input=sys.stdin.readline sys.setrecursionlimit(10 ** 8) from itertools import accumulate from itertools import permutations from itertools import combinations from collections import defaultdict from collections import Counter import fractions import math from collections import deque from bisect import bise...
[["+", 36, 36, 0, 656, 0, 57, 15, 679, 17, 354], ["+", 0, 656, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 0, 656, 0, 57, 15, 679, 12, 666, 667, 60], ["+", 0, 656, 0, 57, 15, 679, 12, 666, 0, 612]]
5
199
k = int(input()) if(k==7): print(1) exit() if(k%2==0): print(-1) exit() x = 7 ans = None for i in range(2,10**6+5): nex_x = 10*x+7 nex_x = nex_x%k if(nex_x==0): ans = i break x = nex_x if(ans is None): print(-1) else: print(ans)
k = int(input()) if(k==1 or k==7): print(1) exit() if(k%2==0): print(-1) exit() x = 7 ans = None for i in range(2,10**6+5): nex_x = 10*x+7 nex_x = nex_x%k if(nex_x==0): ans = i break x = nex_x if(ans is None): print(-1) else: print(ans)
[["+", 0, 57, 15, 23, 0, 679, 31, 666, 0, 612], ["+", 0, 656, 0, 57, 15, 23, 0, 679, 17, 354], ["+", 0, 57, 15, 23, 0, 679, 12, 666, 0, 22], ["+", 0, 57, 15, 23, 0, 679, 12, 666, 667, 60]]
5
103
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <iterator> #include <limits.h> #include <map> #include <ostream> #include <queue> #include <set> #include <stack> #include <time.h> using namespace std; #define rep_1(i, m, n) for (int i = m; i <= n; i++) #define mem...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <iterator> #include <limits.h> #include <map> #include <ostream> #include <queue> #include <set> #include <stack> #include <time.h> using namespace std; #define rep_1(i, m, n) for (int i = m; i <= n; i++) #define mem...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 78], ["-", 0, 11, 12, 16, 31, 16, 31, 16, 12, 13], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 12, 22]]
1
276
k = int(input()) if k == 1 or k == 7: print(1) count = 1 tmp = 7 s = [0 for i in range(k+8)] while True: if s[tmp] != 0: print(-1) exit() s[tmp]+=1 tmp*=10 tmp+=7 tmp %= k count+=1 if tmp == 0: print(count) exit()
k = int(input()) if k == 1 or k == 7: print(1) exit() count = 1 tmp = 7 s = [0 for i in range(k+8)] while True: if s[tmp] != 0: print(-1) exit() s[tmp]+=1 tmp*=10 tmp+=7 tmp %= k count+=1 if tmp == 0: print(count) exit()
[["+", 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
90
import sys input = sys.stdin.readline k = int(input()) res = 1 a = 7 p = 7 d = set() while True: if a == 0: print(res) exit() p = p*10%k a = (a+p)%k res += 1 if a in d: print(-1) exit() d.add(a) print(-1)
import sys input = sys.stdin.readline k = int(input()) res = 1 a = 7%k p = 7 d = set() while True: if a == 0: print(res) exit() p = p*10%k a = (a+p)%k res += 1 if a in d: print(-1) exit() d.add(a) print(-1)
[["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 109], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22]]
5
89
k=gets.to_i tmp=[false]*k m = 7%k (1...k).each {|i| if m == 0 print i exit end if tmp[m] print -1 exit end tmp[m]=true m = (m*10+7)%k }
k=gets.to_i tmp=[false]*k m = 7%k (1..k).each {|i| if m == 0 print i exit end if tmp[m] print -1 exit end tmp[m]=true m = (m*10+7)%k }
[["-", 0, 493, 0, 652, 486, 739, 0, 475, 17, 389], ["+", 0, 493, 0, 652, 486, 739, 0, 475, 17, 757]]
4
64
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) #define lint long long const lint mod = 1e9 + 7; const lint inf = 2.19e15 + 1; const long double eps = 1e-10; template <class T, class U> bool chmin(T &a, U b) { if (a > b) { a = b; return true; } return false; }...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) #define lint long long const lint mod = 1e9 + 7; const lint inf = 2.19e15 + 1; const long double eps = 1e-10; template <class T, class U> bool chmin(T &a, U b) { if (a > b) { a = b; return true; } return false; }...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
244
import sys K=int(input()) rest = 7 % K if rest == 0: print(1) sys.exit() for i in range(2,K): rest = (rest*10+7) % K if rest == 0: print(i) sys.exit() else: print(-1)
import sys K=int(input()) rest = 7 % K if rest == 0: print(1) sys.exit() for i in range(2,K+5): rest = (rest*10+7) % K if rest == 0: print(i) sys.exit() else: print(-1)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
71
K = int(input()) if K == 7: print(1) else: ans = 1 b = 7%K while ans < 10**7: b = (b*10+7)%K if b == 0: print(ans+1) break else: ans += 1 else: print(-1)
K = int(input()) if 7%K==0: print(1) else: ans = 1 b = 7%K while ans < 10**7+1000: b = (b*10+7)%K if b == 0: print(ans+1) break else: ans += 1 else: print(-1)
[["+", 0, 656, 0, 57, 15, 666, 0, 657, 31, 612], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 109], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 52, 15, 666, 0, 657, 17, 72], ["+", 8, 196, 0, 52, 15, 666, 0, 657, 12, 612]]
5
69
#include <bits/stdc++.h> using namespace std; #define ll long long #define go(i, a, n) for (ll i = a; i < (ll)n; i++) #define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--) #define gos(i, a, n, step) for (ll i = a; i < (ll)n; i += step) #define show(a) cout << a << '\n' #define show2(a, b) cout << a << " " << b << '\...
#include <bits/stdc++.h> using namespace std; #define ll long long #define go(i, a, n) for (ll i = a; i < (ll)n; i++) #define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--) #define gos(i, a, n, step) for (ll i = a; i < (ll)n; i += step) #define show(a) cout << a << '\n' #define show2(a, b) cout << a << " " << b << '\...
[["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13]]
1
297
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define ll long long #define ...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define ll long long #define ...
[["+", 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]]
1
121
k=int(input()) cnt=1 flag=True if k%2==0: print(-1) else: keta=10 tmp=0 while cnt<=10**6: tmp+=pow(keta,cnt-1,k)*7 if tmp%k==0: print(cnt) flag=False break cnt+=1 if flag: print(-1)
k=int(input()) cnt=1 flag=True if k%2==0: flag=False print(-1) else: keta=10 tmp=0 while cnt<=10**6: tmp+=pow(keta,cnt-1,k)*7 if tmp%k==0: print(cnt) flag=False break cnt+=1 if flag: print(-1)
[["+", 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, 147]]
5
81
#include <bits/stdc++.h> typedef long long lint; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) vector<int> primeFactorization(int n) { vector<int> result; int i = 2; while (i <= sqrt(n)) { if (n % i == 0) { result.push_back(i); n /= i; } else i ...
#include <bits/stdc++.h> typedef long long lint; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) vector<int> primeFactorization(int n) { vector<int> result; int i = 2; while (i <= sqrt(n)) { if (n % i == 0) { result.push_back(i); n /= i; } else i ...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
167
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { long long int i, j, n, k, ans = 0, po = 7; scanf("%lld", &k); for (i = 1; i < k; i++) { po = po % k; if (po == 0) { ans = i; break; } po = po * 10 + 7; } if (ans == 0) printf("-1"); ...
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { long long int i, j, n, k, ans = 0, po = 7; scanf("%lld", &k); for (i = 1; i <= k; i++) { po = po % k; if (po == 0) { ans = i; break; } po = po * 10 + 7; } if (ans == 0) printf("-1"); ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
110
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if (k % 5 == 0 || k % 2 == 0) { cout << -1; exit(0); } long long pow = 10; int ind = 1; while (7 * (pow - 1) % (9 * k) != 0) { ind++; pow *= 10; pow %= k; } cout << ind << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if (k % 5 == 0 || k % 2 == 0) { cout << -1; exit(0); } long long pow = 10; int ind = 1; while (7 * (pow - 1) % (9 * k) != 0) { ind++; pow *= 10; pow %= (9 * k); } cout << ind << '\n'; }
[["+", 8, 9, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 23, 0, 16, 31, 13], ["+", 0, 1, 0, 11, 12, 23, 0, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 23, 0, 25]]
1
94
k = int(input()) ml = [] a = 7 m = 7 i = 0 while m>0: m = a%k a = 10*m+7 i += 1 if i>k : break print(i)
k = int(input()) ml = [] a = 7 m = 7 i = 0 while m>0: m = a%k a = 10*m+7 i += 1 if i>k : i=-1 break print(i)
[["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 64, 196, 0, 1, 0, 662, 12, 664, 17, 33], ["+", 64, 196, 0, 1, 0, 662, 12, 664, 28, 612]]
5
51
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using VI = vector<int>; using VL = vector<ll>; using VS = vector<string>; template <class T> using PQ = priority_queue<T, vector<T>, greater<T>>; #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define eFOR(i, a, n) for (in...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using VI = vector<int>; using VL = vector<ll>; using VS = vector<string>; template <class T> using PQ = priority_queue<T, vector<T>, greater<T>>; #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define eFOR(i, a, n) for (in...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
865
k=int(input("")) s=0 a=7%k for i in range(1,k): s+=a s%=k if(s==0): print(i) break a=(10*a)%k else: print(-1)
k=int(input("")) s=0 a=7%k for i in range(1,k+1): s+=a s%=k if(s==0): print(i) break a=(10*a)%k else: print(-1)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
62
K = int(input()) cnt = 0 n = 7 while cnt < K: cnt += 1 if n % K == 0: break n = (10 * n + 7) % K if cnt == K: print(-1) else: print(cnt)
K = int(input()) cnt = 0 n = 7 while cnt <= K: cnt += 1 if n % K == 0: break n = (10 * n + 7) % K if cnt == K+1: print(-1) else: print(cnt)
[["-", 36, 36, 0, 656, 0, 52, 15, 666, 667, 18], ["+", 36, 36, 0, 656, 0, 52, 15, 666, 667, 19], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 72], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 12, 612]]
5
57
k = int(input()) cnt = 0 tmp = 0 while cnt < k: tmp += 7 * pow(10, cnt, k) cnt += 1 tmp %= k if tmp == 0: break if cnt == k: print(-1) else: print(cnt)
k = int(input()) cnt = 0 tmp = 0 while cnt < 1000000: tmp += 7 * pow(10, cnt, k) cnt += 1 tmp %= k if tmp == 0: break if cnt == 1000000: print(-1) else: print(cnt)
[["-", 36, 36, 0, 656, 0, 52, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 52, 15, 666, 0, 612], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612]]
5
59