problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k ⌀ | fixed_code stringlengths 12 526k ⌀ | labels listlengths 0 15 ⌀ | buggy_submission_id int64 1 1.54M ⌀ | fixed_submission_id int64 2 1.54M ⌀ | user_id stringlengths 10 10 ⌀ | language stringclasses 9 values |
|---|---|---|---|---|---|---|---|
p02953 | #include <algorithm>
#include <cmath>
#include <cstdio>
#define rg register
#define llint long long
using namespace std;
struct ios {
template <typename _tp> inline ios operator>>(_tp &x) {
char c = getchar();
int f = 1;
x = 0;
for (; c < '0' || c > '9'; c = getchar())
if (c == '-')
f = -1;
for (; c >= '0' && c <= '9'; c = getchar())
x = (x << 1) + (x << 3) + (c ^ 48);
x *= f;
return *this;
}
template <typename _tp> inline ios operator<<(_tp x) {
char s[66];
int dgt = 0;
if (x == 0)
putchar('0');
if (x < 0)
putchar('-'), x = -x;
while (x)
++dgt, s[dgt] = x % 10 + '0', x /= 10;
while (dgt)
putchar(s[dgt]), --dgt;
return *this;
}
} io;
int n, inv, mx;
int main() {
io >> n;
for (rg int i = 1; i <= n; ++i) {
io >> inv;
if (i == 1) {
mx = inv;
} else {
if (abs(mx - inv) > 1) {
puts("No");
return 0;
}
mx = max(mx, inv);
}
}
puts("Yes");
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#define rg register
#define llint long long
using namespace std;
struct ios {
template <typename _tp> inline ios operator>>(_tp &x) {
char c = getchar();
int f = 1;
x = 0;
for (; c < '0' || c > '9'; c = getchar())
if (c == '-')
f = -1;
for (; c >= '0' && c <= '9'; c = getchar())
x = (x << 1) + (x << 3) + (c ^ 48);
x *= f;
return *this;
}
template <typename _tp> inline ios operator<<(_tp x) {
char s[66];
int dgt = 0;
if (x == 0)
putchar('0');
if (x < 0)
putchar('-'), x = -x;
while (x)
++dgt, s[dgt] = x % 10 + '0', x /= 10;
while (dgt)
putchar(s[dgt]), --dgt;
return *this;
}
} io;
int n, inv, mx;
int main() {
io >> n;
for (rg int i = 1; i <= n; ++i) {
io >> inv;
if (i == 1) {
mx = inv;
} else {
if (mx - inv > 1) {
puts("No");
return 0;
}
mx = max(mx, inv);
}
}
puts("Yes");
return 0;
} | [
"control_flow.loop.for.condition.change",
"control_flow.branch.if.condition.change"
] | 757,927 | 757,928 | u849190128 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int N;
cin >> N;
vector<int> H(N);
for (int i = 0; i < N; i++) {
cin >> H[i];
}
bool flag = true;
for (int i = N - 2; i >= 0; i--) {
if (H[i] > H[i + 1]) {
if (H[i] - 1 <= H[i + 1])
H[i] -= 1;
else
flag = false;
}
}
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int N;
cin >> N;
vector<int> H(N);
for (int i = 0; i < N; i++) {
cin >> H[i];
}
bool flag = true;
for (int i = N - 2; i >= 0; i--) {
if (H[i] > H[i + 1]) {
if (H[i] - 1 <= H[i + 1])
H[i] -= 1;
else
flag = false;
}
}
if (flag)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 757,935 | 757,936 | u117345342 | cpp |
p02953 | #include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int n;
cin >> n;
bool down = false;
bool p = true;
int before = 0;
for (int i = 0; i < n; i++) {
int j;
cin >> j;
if (j < before) {
if (before - j >= 2) {
p = false;
}
if (down == true) {
p = false;
} else {
down = false;
}
}
if (j > before) {
down = false;
}
before = j;
}
if (p == true) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | #include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int n;
cin >> n;
bool down = false;
bool p = true;
int before = 0;
for (int i = 0; i < n; i++) {
int j;
cin >> j;
if (j < before) {
if (before - j >= 2) {
p = false;
}
if (down == true) {
p = false;
} else {
down = true;
}
}
if (j > before) {
down = false;
}
before = j;
}
if (p == true) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | [
"misc.opposites",
"assignment.value.change"
] | 757,939 | 757,940 | u023751250 | cpp |
p02953 | #include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int n;
cin >> n;
bool down = false;
bool p = true;
int before = 0;
for (int i = 0; i < n; i++) {
int j;
cin >> j;
if (j < before) {
if (before - j >= 2) {
p = false;
}
if (down == true) {
p = false;
} else {
down = false;
}
}
if (j > before) {
down = true;
}
before = j;
}
if (p == true) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | #include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int n;
cin >> n;
bool down = false;
bool p = true;
int before = 0;
for (int i = 0; i < n; i++) {
int j;
cin >> j;
if (j < before) {
if (before - j >= 2) {
p = false;
}
if (down == true) {
p = false;
} else {
down = true;
}
}
if (j > before) {
down = false;
}
before = j;
}
if (p == true) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | [
"misc.opposites",
"assignment.value.change"
] | 757,941 | 757,940 | u023751250 | cpp |
p02953 | /*
_ _ ___ __ _ _ _ _
_ _ ___| | |/ _ \__ __/ _| | || | ___| |__
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \
| |_| | __/ | | |_| |\ V V /| _| |__ _\__ \ | | |
\__, |\___|_|_|\___/ \_/\_/ |_| |_| |_| |___/_| |_|
|___/
*/
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for (ll i = st; i < en; i++)
#define tr(x) for (auto it = x.begin(); it != x.end(); it++)
#define fast \
std::ios::sync_with_stdio(false); \
cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005
signed main() {
fast int n;
cin >> n;
vector<int> v;
int temp;
For(i, 0, n) {
cin >> temp;
v.pb(temp);
}
v[0]--;
int flag = 0;
For(i, 1, n) {
if (v[i] > v[i - 1]) {
v[i]--;
} else if (v[i] < v[i - 1]) {
flag = 1;
break;
}
}
// tr(v){
// cout<<*it<<" ";
// }
if (flag) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
}
return 0;
}
| /*
_ _ ___ __ _ _ _ _
_ _ ___| | |/ _ \__ __/ _| | || | ___| |__
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \
| |_| | __/ | | |_| |\ V V /| _| |__ _\__ \ | | |
\__, |\___|_|_|\___/ \_/\_/ |_| |_| |_| |___/_| |_|
|___/
*/
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for (ll i = st; i < en; i++)
#define tr(x) for (auto it = x.begin(); it != x.end(); it++)
#define fast \
std::ios::sync_with_stdio(false); \
cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005
signed main() {
fast int n;
cin >> n;
vector<int> v;
int temp;
For(i, 0, n) {
cin >> temp;
v.pb(temp);
}
v[0]--;
int flag = 0;
For(i, 1, n) {
if (v[i] > v[i - 1]) {
v[i]--;
} else if (v[i] < v[i - 1]) {
flag = 1;
break;
}
}
// tr(v){
// cout<<*it<<" ";
// }
if (flag) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 757,942 | 757,943 | u278136654 | cpp |
p02953 | #include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll n;
bool can = false;
cin >> n;
ll h[n];
for (int i = 0; i < n; i++) {
cin >> h[i];
}
if (n == 1) {
cout << "Yes\n";
return 0;
}
for (int i = 1; i < n; i++) {
if (h[i] < h[i + 1])
h[i]--;
}
for (int i = 1; i < n; i++) {
if (h[i - 1] > h[i]) {
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
}
| #include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll n;
bool can = false;
cin >> n;
ll h[n];
for (int i = 0; i < n; i++) {
cin >> h[i];
}
if (n == 1) {
cout << "Yes\n";
return 0;
}
for (int i = 1; i < n; i++) {
if (h[i - 1] < h[i])
h[i]--;
}
for (int i = 1; i < n; i++) {
if (h[i - 1] > h[i]) {
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
}
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one",
"expression.operation.binary.remove"
] | 757,948 | 757,949 | u352248517 | cpp |
p02953 | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define oset \
tree<int, null_type, less_equal<int>, rb_tree_tag, \
tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n, i;
cin >> n;
vector<long long int> num(n);
for (i = 0; i < n; i++) {
cin >> num[i];
}
long long int maxi = INT_MIN;
for (i = 0; i < n; i++) {
if (num[i] > maxi) {
maxi = num[i];
} else {
if (maxi - num[i] >= 2) {
cout << "NO" << endl;
return 0;
}
}
}
cout << "YES" << endl;
return 0;
} | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define oset \
tree<int, null_type, less_equal<int>, rb_tree_tag, \
tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n, i;
cin >> n;
vector<long long int> num(n);
for (i = 0; i < n; i++) {
cin >> num[i];
}
long long int maxi = INT_MIN;
for (i = 0; i < n; i++) {
if (num[i] > maxi) {
maxi = num[i];
} else {
if (maxi - num[i] >= 2) {
cout << "No" << endl;
return 0;
}
}
}
cout << "Yes" << endl;
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 757,950 | 757,951 | u461200315 | cpp |
p02953 | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
long long int n;
cin >> n;
vector<long long int> h;
for (int i = 0; i < n; i++) {
long long int a;
cin >> a;
h.push_back(a);
}
if (n == 1) {
cout << "Yes" << endl;
return 0;
}
long long int max = 0;
for (long long int i = 1; i < n; i++) {
if (h[i - 1] < h[i]) {
max = h[i] - 1;
}
if (max > h[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
long long int n;
cin >> n;
vector<long long int> h;
for (int i = 0; i < n; i++) {
long long int a;
cin >> a;
h.push_back(a);
}
if (n == 1) {
cout << "Yes" << endl;
return 0;
}
long long int max = h[0];
for (long long int i = 1; i < n; i++) {
if (h[i - 1] < h[i]) {
max = h[i] - 1;
}
if (max > h[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
| [] | 757,956 | 757,957 | u115819033 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
int count = 0;
for (int i = 0; i < n; i++)
cin >> a[i];
int c = 1;
int minm = a[0] - 1;
for (int i = 1; i < n; i++) {
if (a[i] >= minm)
minm = max(minm, a[i] - 1);
else {
c = 0;
break;
}
}
if (c)
cout << "yes" << endl;
else
cout << "No" << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
int count = 0;
for (int i = 0; i < n; i++)
cin >> a[i];
int c = 1;
int minm = a[0] - 1;
for (int i = 1; i < n; i++) {
if (a[i] >= minm)
minm = max(minm, a[i] - 1);
else {
c = 0;
break;
}
}
if (c)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 757,965 | 757,966 | u802406405 | cpp |
p02953 | #include <algorithm>
#include <cstdio>
const int MAXN = 1e5 + 5;
int dp[MAXN][2], n, val[MAXN];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
dp[i][0] = dp[i][1] = 2147483647;
scanf("%d", &val[i]);
}
dp[0][0] = dp[0][1] = 0;
for (int i = 1; i <= n; i++)
for (int j = 0; j <= 1; j++)
for (int k = 0; k <= 1; k++)
if (val[i] - k >= dp[i - 1][j]) {
dp[i][k] = std::min(dp[i][k], val[i] - k);
}
if (dp[n][0] == 2147483647 && dp[n][1] == 2147483647)
printf("NO");
else
printf("YES");
return 0;
}
| #include <algorithm>
#include <cstdio>
const int MAXN = 1e5 + 5;
int dp[MAXN][2], n, val[MAXN];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
dp[i][0] = dp[i][1] = 2147483647;
scanf("%d", &val[i]);
}
dp[0][0] = dp[0][1] = 0;
for (int i = 1; i <= n; i++)
for (int j = 0; j <= 1; j++)
for (int k = 0; k <= 1; k++) {
if (val[i] - k >= dp[i - 1][j]) {
dp[i][k] = std::min(dp[i][k], val[i] - k);
}
}
if (dp[n][0] == 2147483647 && dp[n][1] == 2147483647)
printf("No");
else
printf("Yes");
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 757,976 | 757,977 | u767700714 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll p = 1000000007ll;
const int N = 100005;
template <class IT> inline void cmin(IT &a, IT b) {
if (b < a)
a = b;
}
template <class IT> inline void cmax(IT &a, IT b) {
if (a < b)
a = b;
}
int dp[N][2], h[N];
int main() {
int n, i, a, b;
scanf("%d", &n);
for (i = 1; i <= n; ++i)
scanf("%d", &h[i]);
dp[1][0] = dp[1][1] = 1;
for (i = 2; i <= n; ++i)
for (a = 0; a < 2; ++a)
if (dp[i - 1][a])
for (b = 0; b < 2; ++b)
if (h[i - 1] - a <= h[i] - b)
dp[i][b] = 1;
if (dp[n][0] || dp[n][1])
puts("YES");
else
puts("NO");
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll p = 1000000007ll;
const int N = 100005;
template <class IT> inline void cmin(IT &a, IT b) {
if (b < a)
a = b;
}
template <class IT> inline void cmax(IT &a, IT b) {
if (a < b)
a = b;
}
int dp[N][2], h[N];
int main() {
int n, i, a, b;
scanf("%d", &n);
for (i = 1; i <= n; ++i)
scanf("%d", &h[i]);
dp[1][0] = dp[1][1] = 1;
for (i = 2; i <= n; ++i)
for (a = 0; a < 2; ++a)
if (dp[i - 1][a])
for (b = 0; b < 2; ++b)
if (h[i - 1] - a <= h[i] - b)
dp[i][b] = 1;
if (dp[n][0] || dp[n][1])
puts("Yes");
else
puts("No");
return 0;
} | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 757,980 | 757,981 | u238671650 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll p = 1000000007ll;
const int N = 100005;
template <class IT> inline void cmin(IT &a, IT b) {
if (b < a)
a = b;
}
template <class IT> inline void cmax(IT &a, IT b) {
if (a < b)
a = b;
}
int dp[N][2], h[N];
int main() {
int n, i, a, b;
scanf("%d", &n);
for (i = 1; i <= n; ++i)
scanf("%d", &h[i]);
dp[1][0] = dp[1][1] = 1;
for (i = 2; i <= n; ++i)
for (a = 0; a < 2; ++a)
if (dp[i - 1][a])
for (b = 0; b < 2; ++b)
if (h[i - 1] + a <= h[i] + b)
dp[i][b] = 1;
if (dp[n][0] || dp[n][1])
puts("YES");
else
puts("NO");
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll p = 1000000007ll;
const int N = 100005;
template <class IT> inline void cmin(IT &a, IT b) {
if (b < a)
a = b;
}
template <class IT> inline void cmax(IT &a, IT b) {
if (a < b)
a = b;
}
int dp[N][2], h[N];
int main() {
int n, i, a, b;
scanf("%d", &n);
for (i = 1; i <= n; ++i)
scanf("%d", &h[i]);
dp[1][0] = dp[1][1] = 1;
for (i = 2; i <= n; ++i)
for (a = 0; a < 2; ++a)
if (dp[i - 1][a])
for (b = 0; b < 2; ++b)
if (h[i - 1] - a <= h[i] - b)
dp[i][b] = 1;
if (dp[n][0] || dp[n][1])
puts("Yes");
else
puts("No");
return 0;
} | [
"misc.opposites",
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change",
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 757,982 | 757,981 | u238671650 | cpp |
p02953 | #include <cstdio>
int n, a[100005];
int main() {
scanf("%d", &n);
for (int i = n; i; i--)
scanf("%d", a + i);
for (int i = 2; i <= n; i++) {
if (a[i] - a[i - 1] > 1)
return puts("NO") & 0;
if (a[i] > a[i - 1])
a[i]--;
}
return puts("YES") & 0;
} | #include <cstdio>
int n, a[100005];
int main() {
scanf("%d", &n);
for (int i = n; i; i--)
scanf("%d", a + i);
for (int i = 2; i <= n; i++) {
if (a[i] - a[i - 1] > 1)
return puts("No") & 0;
if (a[i] > a[i - 1])
a[i]--;
}
return puts("Yes") & 0;
} | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"function.return_value.change",
"expression.operation.binary.change",
"io.output.change"
] | 757,985 | 757,986 | u776525990 | cpp |
p02953 | // Created by liszt on 2019/08/04.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, tmp;
cin >> n;
if (n == 1) {
cout << "Yes" << endl;
return 0;
}
vector<long long> h(n);
for (int i = 0; i < n; i++)
cin >> h[i];
long long now = h[0];
for (int i = 1; i < n; i++) {
if (h[i] < now - 1) {
cout << "No" << endl;
return 0;
} else {
now = h[i];
}
}
cout << "Yes" << endl;
} | // Created by liszt on 2019/08/04.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, tmp;
cin >> n;
if (n == 1) {
cout << "Yes" << endl;
return 0;
}
vector<long long> h(n);
for (int i = 0; i < n; i++)
cin >> h[i];
long long now = h[0];
for (int i = 1; i < n; i++) {
if (h[i] < now - 1) {
cout << "No" << endl;
return 0;
} else {
now = max(now, h[i]);
}
}
cout << "Yes" << endl;
} | [
"call.add",
"call.arguments.change"
] | 757,987 | 757,988 | u370447425 | cpp |
p02953 | #include <bits/stdc++.h>
#define range 524289
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ << " " <<
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<int, pair<int, int>> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
int main(int argc, char const *argv[]) {
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, l;
cin >> n;
vi a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int count = 0;
for (int i = n - 1; i >= 1; --i) {
if (a[i] - a[i - 1] > 0)
continue;
else if (a[i - 1] - a[i] == 1) {
a[i - 1]--;
} else {
count = 1;
break;
}
}
if (count)
cout << "No" << endl;
else
cout << "Yes" << endl;
return 0;
}
| #include <bits/stdc++.h>
#define range 524289
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ << " " <<
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<int, pair<int, int>> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
int main(int argc, char const *argv[]) {
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, l;
cin >> n;
vi a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int count = 0;
for (int i = n - 1; i >= 1; --i) {
if (a[i] - a[i - 1] >= 0)
continue;
else if (a[i - 1] - a[i] == 1) {
a[i - 1]--;
} else {
count = 1;
break;
}
}
if (count)
cout << "No" << endl;
else
cout << "Yes" << endl;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,001 | 758,002 | u377069206 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD = 1e9 + 7;
#ifndef HOME
#define cerr \
if (0) \
cerr
#endif
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
bool flag = false;
for (int i = n - 2; i >= 0; i--) {
if (a[i] <= a[i + 1]) {
continue;
} else {
a[i]--;
if (a[i] > a[i + 1]) {
cout << "No" << endl;
return 0;
}
}
}
cout << "YES" << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD = 1e9 + 7;
#ifndef HOME
#define cerr \
if (0) \
cerr
#endif
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
bool flag = false;
for (int i = n - 2; i >= 0; i--) {
if (a[i] <= a[i + 1]) {
continue;
} else {
a[i]--;
if (a[i] > a[i + 1]) {
cout << "No" << endl;
return 0;
}
}
}
cout << "Yes" << endl;
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 758,007 | 758,008 | u124992729 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define test() \
ull t; \
cin >> t; \
while (t--)
#define pb push_back
#define mkp make_pair
#define nl cout << endl
#define MOD 1000000007
#define loop(i, start, end) for (int i = start; i < end; i++)
#define N 100001
#define oa(a, n) \
for (int i = 0; i < n; i++) \
cout << a[i] << " "; \
nl;
#define ov(a) \
for (int i = 0; i < a.size(); i++) \
cout << a[i] << endl;
#define pi M_PI
int main() {
fastio();
int n;
cin >> n;
ll arr[n];
loop(i, 0, n) { cin >> arr[i]; }
int x;
int flag = 0;
loop(i, 0, n - 1) {
x = arr[i + 1] - arr[i];
if (x == -1)
arr[i + 1]++;
if (x <= -2) {
flag = 1;
break;
}
}
if (flag == 0) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define test() \
ull t; \
cin >> t; \
while (t--)
#define pb push_back
#define mkp make_pair
#define nl cout << endl
#define MOD 1000000007
#define loop(i, start, end) for (int i = start; i < end; i++)
#define N 100001
#define oa(a, n) \
for (int i = 0; i < n; i++) \
cout << a[i] << " "; \
nl;
#define ov(a) \
for (int i = 0; i < a.size(); i++) \
cout << a[i] << endl;
#define pi M_PI
int main() {
fastio();
int n;
cin >> n;
ll arr[n];
loop(i, 0, n) { cin >> arr[i]; }
int x;
int flag = 0;
loop(i, 0, n - 1) {
x = arr[i + 1] - arr[i];
if (x == -1)
arr[i + 1]++;
if (x <= -2) {
flag = 1;
break;
}
}
if (flag == 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
} | [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 758,011 | 758,012 | u419301893 | cpp |
p02953 | #include <bits/stdc++.h>
#define pp pair<int, int>
#define fi first
#define se second
#define maxx 100012
#define ll long long
#define pb push_back
#define mp make_pair
#define lb lower_bound
const int mod = 998244353;
using namespace std;
int n, a[maxx];
int create(int num) {
int res = 1;
while (num--) {
res *= 10;
}
return res;
}
int dem(int k) {
int res = 0;
while (k > 0) {
res++;
k /= 10;
}
return res;
}
void input() {
// freopen("TEST.INP","r",stdin);
// freopen("TEST.OUT","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = n - 1; i >= 1; i--) {
if (a[i] == a[i + 1] + 1) {
a[i]--;
} else {
if (a[i] > a[i + 1] + 1) {
cout << "NO";
return;
}
}
}
cout << "YES";
}
int main() {
input();
return 0;
}
| #include <bits/stdc++.h>
#define pp pair<int, int>
#define fi first
#define se second
#define maxx 100012
#define ll long long
#define pb push_back
#define mp make_pair
#define lb lower_bound
const int mod = 998244353;
using namespace std;
int n, a[maxx];
int create(int num) {
int res = 1;
while (num--) {
res *= 10;
}
return res;
}
int dem(int k) {
int res = 0;
while (k > 0) {
res++;
k /= 10;
}
return res;
}
void input() {
// freopen("TEST.INP","r",stdin);
// freopen("TEST.OUT","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = n - 1; i >= 1; i--) {
if (a[i] == a[i + 1] + 1) {
a[i]--;
} else {
if (a[i] > a[i + 1] + 1) {
cout << "No";
return;
}
}
}
cout << "Yes";
}
int main() {
input();
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 758,015 | 758,016 | u309723391 | cpp |
p02953 | // {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
using vint = vector<int>;
using pint = pair<int, int>;
// }}}
signed main() {
int n;
cin >> n;
vint h(n);
vector<bool> check(n, true);
for (auto &e : h)
cin >> e;
reverse(ALL(h));
rep(i, n) {
if (h[i + 1] - h[i] > 2) {
cout << "No" << endl;
return 0;
} else if (h[i + 1] - h[i] > 0) {
if (check[i + 1]) {
h[i + 1]--;
check[i + 1] = false;
}
}
}
cout << "Yes" << endl;
}
| // {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
using vint = vector<int>;
using pint = pair<int, int>;
// }}}
signed main() {
int n;
cin >> n;
vint h(n);
vector<bool> check(n, true);
for (auto &e : h)
cin >> e;
reverse(ALL(h));
rep(i, n - 1) {
if (h[i + 1] - h[i] > 1) {
cout << "No" << endl;
return 0;
} else if (h[i + 1] - h[i] > 0) {
if (check[i + 1]) {
h[i + 1]--;
check[i + 1] = false;
}
}
}
cout << "Yes" << endl;
}
| [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 758,025 | 758,026 | u637515289 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve() {
int n;
cin >> n;
int i, a[n];
for (i = 0; i < n; i++)
cin >> a[i];
bool flag = true;
for (int i = n - 2; i >= 0; i--) {
if (a[i] > a[i + 1]) {
a[i]--;
if (a[i] > a[i + 1]) {
cout << "No";
flag = false;
}
}
}
if (flag)
cout << "Yes";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve() {
int n;
cin >> n;
ll i, a[n];
for (i = 0; i < n; i++)
cin >> a[i];
bool flag = true;
for (int i = n - 2; i >= 0; i--) {
if (a[i] > a[i + 1]) {
a[i]--;
if (a[i] > a[i + 1]) {
cout << "No";
flag = false;
break;
}
}
}
if (flag)
cout << "Yes";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
| [
"variable_declaration.type.change"
] | 758,027 | 758,028 | u312943292 | cpp |
p02953 | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> H(N);
for (auto &h : H)
cin >> h;
for (int i = N - 2; i > 0; --i) {
if (H[i] > H[i + 1]) {
--H[i];
}
if (H[i] > H[i + 1]) {
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
}
| #include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> H(N);
for (auto &h : H)
cin >> h;
for (int i = N - 2; i > 0; --i) {
if (H[i] > H[i + 1]) {
--H[i];
}
if (H[i] > H[i + 1]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 758,032 | 758,033 | u107077660 | cpp |
p02953 | #include "bits/stdc++.h"
using namespace std;
int cnt(int x) {
int rv = 0;
while (x) {
rv++;
x /= 10;
}
return rv;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> v(n + 1);
for (int i = 1; i <= n; i++)
cin >> v[i];
for (int i = 1; i <= n; i++) {
if (v[i] > v[i - 1]) {
v[i]--;
}
if (v[i] < v[i - 1])
return cout << "NO\n", 0;
}
cout << "YES\n";
}
| #include "bits/stdc++.h"
using namespace std;
int cnt(int x) {
int rv = 0;
while (x) {
rv++;
x /= 10;
}
return rv;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> v(n + 1);
for (int i = 1; i <= n; i++)
cin >> v[i];
for (int i = 1; i <= n; i++) {
if (v[i] > v[i - 1]) {
v[i]--;
}
if (v[i] < v[i - 1])
return cout << "No\n", 0;
}
cout << "Yes\n";
}
| [
"literal.string.change",
"literal.string.case.change",
"function.return_value.change",
"expression.operation.binary.change",
"io.output.change"
] | 758,034 | 758,035 | u753391427 | cpp |
p02953 | #include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
const int LIM = 4e6 + 3;
pair<int, int> arr[LIM + 3];
int main() {
int n;
cin >> n;
bool is = true;
int last = -1;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (!i)
x--;
else if (x - 1 >= last)
x--;
if (x < last)
is = false;
last = x;
}
if (is)
puts("YES");
else
puts("NO");
} | #include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
const int LIM = 4e6 + 3;
pair<int, int> arr[LIM + 3];
int main() {
int n;
cin >> n;
bool is = true;
int last = -1;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (!i)
x--;
else if (x - 1 >= last)
x--;
if (x < last)
is = false;
last = x;
}
if (is)
puts("Yes");
else
puts("No");
} | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 758,042 | 758,043 | u540045035 | cpp |
p02953 | /// Let us start the game
#pragma GCC optimize("O3")
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define pb push_back
using ll = long long;
using ii = pair<int, int>;
using db = long double;
using ull = unsigned long long;
const int N = 2e3 + 5, M = 1e7 + 5, MOD = 1e9 + 7;
const db EPS = 1e-7;
int get(int x) {
bool f = false;
while (x) {
x /= 10;
f ^= 1;
}
return f;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (auto &x : a)
cin >> x;
if (a[0] > 1)
a[0]--;
for (int i = 1; i < n; i++) {
if (a[i] < a[i - 1]) {
cout << "No\n";
return 0;
}
if (a[i] >= a[i - 1])
a[i]--;
}
cout << "Yes\n";
return 0;
}
| /// Let us start the game
#pragma GCC optimize("O3")
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define pb push_back
using ll = long long;
using ii = pair<int, int>;
using db = long double;
using ull = unsigned long long;
const int N = 2e3 + 5, M = 1e7 + 5, MOD = 1e9 + 7;
const db EPS = 1e-7;
int get(int x) {
bool f = false;
while (x) {
x /= 10;
f ^= 1;
}
return f;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (auto &x : a)
cin >> x;
if (a[0] > 1)
a[0]--;
for (int i = 1; i < n; i++) {
if (a[i] < a[i - 1]) {
cout << "No\n";
return 0;
}
if (a[i] > a[i - 1])
a[i]--;
}
cout << "Yes\n";
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,050 | 758,051 | u220114950 | cpp |
p02953 | #pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> v;
int main() {
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(false);
int N;
cin >> N;
int ma = 0;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
v.push_back(a);
}
for (int i = 0; i < N; i++) {
ma = max(ma, v[i]);
if (ma - v[i] > 1) {
cout << "NO";
return 0;
}
}
cout << "YES";
return 0;
}
| #pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> v;
int main() {
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(false);
int N;
cin >> N;
int ma = 0;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
v.push_back(a);
}
for (int i = 0; i < N; i++) {
ma = max(ma, v[i]);
if (ma - v[i] > 1) {
cout << "No";
return 0;
}
}
cout << "Yes";
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 758,052 | 758,053 | u854904794 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, a[N];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
--a[1];
for (int i = 2; i <= n; ++i)
if (a[i] > a[i - 1])
--a[i];
for (int i = 2; i <= n; ++i)
if (a[i] < a[i - 1])
return puts("NO"), 0;
puts("YES");
} | #include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, a[N];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
--a[1];
for (int i = 2; i <= n; ++i)
if (a[i] > a[i - 1])
--a[i];
for (int i = 2; i <= n; ++i)
if (a[i] < a[i - 1])
return puts("No"), 0;
puts("Yes");
} | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"function.return_value.change",
"io.output.change"
] | 758,054 | 758,055 | u993519359 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define LAR(a, b) ((a) = max((a), (b)))
#define SML(a, b) ((a) = min((a), (b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
int a[112345];
int main() {
int n;
scanf("%d", &n);
REP(i, n) scanf("%d", a + i);
reverse(a, a + n);
FOR(i, 1, n) {
if (a[i] - a[i - 1] > 1) {
printf("NO\n");
return 0;
} else if (a[i] - a[i - 1] == 1) {
a[i]--;
}
}
printf("YES\n");
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define LAR(a, b) ((a) = max((a), (b)))
#define SML(a, b) ((a) = min((a), (b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
int a[112345];
int main() {
int n;
scanf("%d", &n);
REP(i, n) scanf("%d", a + i);
reverse(a, a + n);
FOR(i, 1, n) {
if (a[i] - a[i - 1] > 1) {
printf("No\n");
return 0;
} else if (a[i] - a[i - 1] == 1) {
a[i]--;
}
}
printf("Yes\n");
}
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 758,058 | 758,059 | u483277935 | cpp |
p02953 | #include <bits/stdc++.h>
#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define long long long int
using namespace std;
// @author: pashka
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = n - 1; i >= 0; i--) {
if (a[i] > a[i + 1]) {
a[i]--;
}
if (a[i] > a[i + 1]) {
cout << "No";
return 0;
}
}
cout << "Yes";
return 0;
} | #include <bits/stdc++.h>
#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define long long long int
using namespace std;
// @author: pashka
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = n - 2; i >= 0; i--) {
if (a[i] > a[i + 1]) {
a[i]--;
}
if (a[i] > a[i + 1]) {
cout << "No";
return 0;
}
}
cout << "Yes";
return 0;
} | [
"literal.number.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 758,060 | 758,061 | u136509923 | cpp |
p02953 | #include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
// AtCoderC++.cpp
using namespace std;
inline int ceileing(int a, int b) { return a % b == 0 ? a / b : a / b + 1; }
int main() {
int N;
cin >> N;
int prev = 0;
int next;
for (size_t i = 0; i < N; i++) {
cin >> next;
if (next <= prev) {
cout << "No" << endl;
return 0;
}
prev = prev < next ? next - 1 : next;
}
cout << "Yes" << endl;
} | #include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
// AtCoderC++.cpp
using namespace std;
inline int ceileing(int a, int b) { return a % b == 0 ? a / b : a / b + 1; }
int main() {
int N;
cin >> N;
int prev = 0;
int next;
for (size_t i = 0; i < N; i++) {
cin >> next;
if (next < prev) {
cout << "No" << endl;
return 0;
}
prev = prev < next ? next - 1 : next;
}
cout << "Yes" << endl;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,062 | 758,063 | u822155101 | cpp |
p02954 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
int main() {
string S;
cin >> S;
int l = 1;
int ind_R = 0, ind_L = 0;
int cnt = 0;
int lenS = S.size();
lenS++;
S.push_back('R');
vector<int> ans(lenS);
for (int i = 0; i < lenS; i++) {
// cout << "=== : " << i << " : ===" << '\n';
if (l && S[i] == 'L') {
cnt++;
ind_L = i;
int tmp = ind_L - ind_R;
ans[ind_L] += int(tmp / 2);
ans[ind_L - 1] += (tmp + 1) / 2;
/*
cout << "Now RRR... L \n";
cout << "ind_R : " << ind_R << '\n';
cout << ind_L << ' ' << (tmp+1) / 2 << '\n';
cout << ind_L - 1 << ' ' << int(tmp / 2) << '\n';
*/
l = 0;
ind_R = ind_L - 1;
}
if (!l && S[i] == 'R') {
ind_L = i - 1;
int tmp = ind_L - ind_R;
ans[ind_R] += int(tmp / 2);
ans[ind_R + 1] += (tmp + 1) / 2;
/*
cout << "Now RLLL... R \n";
cout << "ind_R : " << ind_R << '\n';
cout << ind_R << ' ' << int(tmp / 2) << '\n';
cout << ind_R + 1 << ' ' << (tmp+1) / 2 << '\n';
*/
l = 1;
ind_R = ind_L + 1;
}
/*
for (int i = 0; i < lenS - 1; i++) {
cout << ans[i] << ' ';
} cout << '\n';
*/
}
for (int i = 0; i < lenS; i++) {
cout << ans[i] << ' ';
}
cout << '\n';
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
int main() {
string S;
cin >> S;
int l = 1;
int ind_R = 0, ind_L = 0;
int cnt = 0;
int lenS = S.size();
lenS++;
S.push_back('R');
vector<int> ans(lenS);
for (int i = 0; i < lenS; i++) {
// cout << "=== : " << i << " : ===" << '\n';
if (l && S[i] == 'L') {
cnt++;
ind_L = i;
int tmp = ind_L - ind_R;
ans[ind_L] += int(tmp / 2);
ans[ind_L - 1] += (tmp + 1) / 2;
/*
cout << "Now RRR... L \n";
cout << "ind_R : " << ind_R << '\n';
cout << ind_L << ' ' << (tmp+1) / 2 << '\n';
cout << ind_L - 1 << ' ' << int(tmp / 2) << '\n';
*/
l = 0;
ind_R = ind_L - 1;
}
if (!l && S[i] == 'R') {
ind_L = i - 1;
int tmp = ind_L - ind_R;
ans[ind_R] += int(tmp / 2);
ans[ind_R + 1] += (tmp + 1) / 2;
/*
cout << "Now RLLL... R \n";
cout << "ind_R : " << ind_R << '\n';
cout << ind_R << ' ' << int(tmp / 2) << '\n';
cout << ind_R + 1 << ' ' << (tmp+1) / 2 << '\n';
*/
l = 1;
ind_R = ind_L + 1;
}
/*
for (int i = 0; i < lenS - 1; i++) {
cout << ans[i] << ' ';
} cout << '\n';
*/
}
for (int i = 0; i < lenS - 1; i++) {
cout << ans[i] << ' ';
}
cout << '\n';
}
| [
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 758,064 | 758,065 | u603234915 | cpp |
p02953 | #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#define ll long long
#define il inline
#define rgi register int
using namespace std;
const int N = 100000 + 10;
int n, flag;
int h[N];
il int read() {
rgi x = 0, f = 0, ch;
while (!isdigit(ch = getchar()))
f |= ch == '-';
while (isdigit(ch))
x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return f ? -x : x;
}
int main() {
n = read();
for (rgi i = 1; i <= n; ++i)
h[i] = read();
for (rgi i = n; i >= 2; --i) {
if (h[i] < h[i - 1])
h[i - 1]--;
}
for (rgi i = 1; i <= n - 1; ++i)
if (h[i + 1] < h[i]) {
flag = 1;
break;
}
if (flag)
printf("NO");
else
printf("YES");
return 0;
}
| #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#define ll long long
#define il inline
#define rgi register int
using namespace std;
const int N = 100000 + 10;
int n, flag;
int h[N];
il int read() {
rgi x = 0, f = 0, ch;
while (!isdigit(ch = getchar()))
f |= ch == '-';
while (isdigit(ch))
x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return f ? -x : x;
}
int main() {
n = read();
for (rgi i = 1; i <= n; ++i)
h[i] = read();
for (rgi i = n; i >= 2; --i) {
if (h[i] < h[i - 1])
h[i - 1]--;
}
for (rgi i = 1; i <= n - 1; ++i)
if (h[i + 1] < h[i]) {
flag = 1;
break;
}
if (flag)
printf("No");
else
printf("Yes");
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 758,074 | 758,075 | u469810874 | cpp |
p02953 | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
for (int i = n - 1; i >= 1; i--) {
if (h[i] < h[i - 1]) {
cout << "No";
return 0;
} else if (h[i] == h[i - 1])
h[i - 1]--;
}
cout << "Yes";
return 0;
}
| #include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
for (int i = n - 1; i >= 1; i--) {
if (h[i] < h[i - 1] - 1) {
cout << "No";
return 0;
} else if (h[i] == h[i - 1] - 1)
h[i - 1]--;
}
cout << "Yes";
return 0;
}
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 758,076 | 758,077 | u809153881 | cpp |
p02953 | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
for (int i = n - 1; i >= 0; i--) {
if (h[i] < h[i - 1]) {
cout << "No";
return 0;
} else if (h[i] == h[i - 1])
h[i - 1]--;
}
cout << "Yes";
return 0;
}
| #include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
for (int i = n - 1; i >= 1; i--) {
if (h[i] < h[i - 1] - 1) {
cout << "No";
return 0;
} else if (h[i] == h[i - 1] - 1)
h[i - 1]--;
}
cout << "Yes";
return 0;
}
| [
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change",
"misc.off_by_one"
] | 758,078 | 758,077 | u809153881 | cpp |
p02953 | /*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i, s, l) for (int i = s; i < l; i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long, long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
using namespace std;
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int main() {
fast();
int n;
cin >> n;
vector<int> a(n);
r(i, 0, n) cin >> a[i];
int flag = 1;
for (int i = n - 1; i > 0; i--)
if (a[i] < a[i - 1]) {
a[i - 1]--;
if (a[i] < a[i - 1]) {
flag = 0;
break;
}
}
if (flag)
cout << "YES";
else
cout << "NO";
return 0;
}
| /*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i, s, l) for (int i = s; i < l; i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long, long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
using namespace std;
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int main() {
fast();
int n;
cin >> n;
vector<int> a(n);
r(i, 0, n) cin >> a[i];
int flag = 1;
for (int i = n - 1; i > 0; i--)
if (a[i] < a[i - 1]) {
a[i - 1]--;
if (a[i] < a[i - 1]) {
flag = 0;
break;
}
}
if (flag)
cout << "Yes";
else
cout << "No";
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 758,079 | 758,080 | u264877306 | cpp |
p02953 | #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;
int n, m;
string s;
int main() {
cin >> n;
VI h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
int now = h[0] - 1;
for (int i = 1; i < n; i++) {
if (h[i] > now + 1) {
now = h[i] - 1;
} else if (h[i] == now) {
continue;
} else {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
| #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;
int n, m;
string s;
int main() {
cin >> n;
VI h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
int now = h[0] - 1;
for (int i = 1; i < n; i++) {
if (h[i] >= now + 1) {
now = h[i] - 1;
} else if (h[i] == now) {
continue;
} else {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,081 | 758,082 | u587724217 | cpp |
p02953 | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FASTIO \
ios::sync_with_stdio(0); \
cin.tie(0);
#define show(x) cout << #x << " = " << x << "\n"
#define mem(a, b) memset(a, b, sizeof a)
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define mod(x, m) ((x % m + m) % m)
#define SZ(a) (int)a.size()
#define ll long long
#define ld long double
#define vii vector<ll>
#define dqi deque<ll>
#define sii set<ll>
#define vpi vector<pii>
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define pi pair<int, int>
#define pb push_back
#define F first
#define S second
#define L length()
#define OO (ll)1e18
#define lSOne(x) (x & -x)
#define EPS 1e-20
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
pii swapii(pii pr) { return {pr.S, pr.F}; }
ll binEXP(ll x, ll pw, ll MOD = LLONG_MAX);
int dx[] = {0, 0, -1, +1, -1, +1, -1, +1};
int dy[] = {-1, +1, 0, 0, -1, +1, +1, -1};
const ll MOD = 1e9 + 7;
const ll MAX = 2e6 + 7;
ll x;
vii vec;
int main() {
FASTIO // ONLINE__JUDGE();
cin >>
x;
vec.resize(x);
for (ll &i : vec)
cin >> i;
for (int i = x - 2; i > -1; --i) {
if (vec[i] > vec[i + 1]) {
if (vec[i] - 1 <= vec[i + 1]) {
vec[i]--;
} else {
return cout << "NO", 0;
}
}
}
cout << "Yes";
return 0;
}
void ONLINE__JUDGE() {
#ifndef ONLINE_JUDGE
freopen("inp.c", "r", stdin);
// freopen( "OutPut.txt" , "w" , stdout );
#endif // ONLINE_JUDGE
}
ll binEXP(ll x, ll pw, ll MOD) {
ll res = 1;
while (pw > 0) {
pw % 2 ? res *= x : 0;
x *= x;
x %= MOD;
pw /= 2;
res %= MOD;
}
return res %= MOD;
}
| #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FASTIO \
ios::sync_with_stdio(0); \
cin.tie(0);
#define show(x) cout << #x << " = " << x << "\n"
#define mem(a, b) memset(a, b, sizeof a)
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define mod(x, m) ((x % m + m) % m)
#define SZ(a) (int)a.size()
#define ll long long
#define ld long double
#define vii vector<ll>
#define dqi deque<ll>
#define sii set<ll>
#define vpi vector<pii>
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define pi pair<int, int>
#define pb push_back
#define F first
#define S second
#define L length()
#define OO (ll)1e18
#define lSOne(x) (x & -x)
#define EPS 1e-20
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
pii swapii(pii pr) { return {pr.S, pr.F}; }
ll binEXP(ll x, ll pw, ll MOD = LLONG_MAX);
int dx[] = {0, 0, -1, +1, -1, +1, -1, +1};
int dy[] = {-1, +1, 0, 0, -1, +1, +1, -1};
const ll MOD = 1e9 + 7;
const ll MAX = 2e6 + 7;
ll x;
vii vec;
int main() {
FASTIO // ONLINE__JUDGE();
cin >>
x;
vec.resize(x);
for (ll &i : vec)
cin >> i;
for (int i = x - 2; i > -1; --i) {
if (vec[i] > vec[i + 1]) {
if (vec[i] - 1 <= vec[i + 1]) {
vec[i]--;
} else {
return cout << "No", 0;
}
}
}
cout << "Yes";
return 0;
}
void ONLINE__JUDGE() {
#ifndef ONLINE_JUDGE
freopen("inp.c", "r", stdin);
// freopen( "OutPut.txt" , "w" , stdout );
#endif // ONLINE_JUDGE
}
ll binEXP(ll x, ll pw, ll MOD) {
ll res = 1;
while (pw > 0) {
pw % 2 ? res *= x : 0;
x *= x;
x %= MOD;
pw /= 2;
res %= MOD;
}
return res %= MOD;
}
| [
"literal.string.change",
"literal.string.case.change",
"function.return_value.change",
"expression.operation.binary.change"
] | 758,087 | 758,088 | u302539304 | cpp |
p02953 | #include <assert.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>
template <typename T> void in(T &x) { std::cin >> x; }
template <typename T> void out(const T H) { std::cout << (H); }
template <typename T1, typename... T2> void out(const T1 H, const T2... T) {
std::cout << (H) << " ";
out(T...);
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &v) {
return os << v.first << " " << v.second;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
int n = (int)v.size();
for (int i = 0; i < n - 1; ++i)
os << v[i] << ' ';
return os << v[n - 1];
}
template <typename T> void eout(const char *s, const T H) {
std::cerr << s << "=" << H << "\n";
}
template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
while (*s != ',')
std::cerr << *s++;
std::cerr << "=" << H << " | ";
eout(++s, T...);
}
#define nl std::cout << "\n"
#define err(args...) eout(#args, args)
#define inn(x) \
int x; \
in(x)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define per(i, n) for (int i = (n)-1; i > -1; --i)
#define repr(i, l, r) for (int i = (l); i < (r); ++i)
#define sz(v) ((int)v.size())
#define all(v) (v).begin(), (v).end()
#define lla(v) (v).rbegin(), (v).rend()
#define no std::cout << "NO\n"
#define yes std::cout << "YES\n"
const int INF = 2147483647;
const long long int LNF = 9223372036854775807LL;
using ll = long long int;
using vi = std::vector<int>;
using vb = std::vector<bool>;
using ii = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;
const int N = 505050;
const int MD = 1000 * 1000 * 1000 + 7;
int solve();
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
// std::cout.tie(0);
// inn(t); repr(tc, 1, t + 1)
solve();
return 0;
}
int solve() {
inn(n);
vi h(n);
rep(i, n) in(h[i]);
--h[0];
repr(i, 1, n) if (h[i] > h[i - 1])-- h[i];
bool ans = 1;
rep(i, n - 1) { ans &= (h[i] <= h[i + 1]); }
ans ? yes : no;
return 0;
}
| #include <assert.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>
template <typename T> void in(T &x) { std::cin >> x; }
template <typename T> void out(const T H) { std::cout << (H); }
template <typename T1, typename... T2> void out(const T1 H, const T2... T) {
std::cout << (H) << " ";
out(T...);
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &v) {
return os << v.first << " " << v.second;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
int n = (int)v.size();
for (int i = 0; i < n - 1; ++i)
os << v[i] << ' ';
return os << v[n - 1];
}
template <typename T> void eout(const char *s, const T H) {
std::cerr << s << "=" << H << "\n";
}
template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
while (*s != ',')
std::cerr << *s++;
std::cerr << "=" << H << " | ";
eout(++s, T...);
}
#define nl std::cout << "\n"
#define err(args...) eout(#args, args)
#define inn(x) \
int x; \
in(x)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define per(i, n) for (int i = (n)-1; i > -1; --i)
#define repr(i, l, r) for (int i = (l); i < (r); ++i)
#define sz(v) ((int)v.size())
#define all(v) (v).begin(), (v).end()
#define lla(v) (v).rbegin(), (v).rend()
#define no std::cout << "No\n"
#define yes std::cout << "Yes\n"
const int INF = 2147483647;
const long long int LNF = 9223372036854775807LL;
using ll = long long int;
using vi = std::vector<int>;
using vb = std::vector<bool>;
using ii = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;
const int N = 505050;
const int MD = 1000 * 1000 * 1000 + 7;
int solve();
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
// std::cout.tie(0);
// inn(t); repr(tc, 1, t + 1)
solve();
return 0;
}
int solve() {
inn(n);
vi h(n);
rep(i, n) in(h[i]);
--h[0];
repr(i, 1, n) if (h[i] > h[i - 1])-- h[i];
bool ans = 1;
rep(i, n - 1) { ans &= (h[i] <= h[i + 1]); }
ans ? yes : no;
return 0;
}
| [
"preprocessor.define.value.change"
] | 758,089 | 758,090 | u811925505 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
int A[100004];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &A[i]);
for (int i = 1; i <= n; i++) {
if (i + 1 <= n && i - 1 >= 1 && A[i] > A[i + 1] && A[i - 1] == A[i]) {
puts("No");
return 0;
} else if (i - 1 >= 1 && A[i] > A[i - 1]) {
puts("No");
return 0;
} else if (A[i - 1] < A[i])
A[i]--;
}
puts("Yes");
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int A[100004];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &A[i]);
for (int i = 1; i <= n; i++) {
if (i + 1 <= n && i - 1 >= 1 && A[i] > A[i + 1] && A[i - 1] == A[i]) {
puts("No");
return 0;
} else if (i - 1 >= 1 && A[i] < A[i - 1]) {
puts("No");
return 0;
} else if (A[i - 1] < A[i])
A[i]--;
}
puts("Yes");
return 0;
} | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,091 | 758,092 | u765391939 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i, start, lim) for (ll i = start; i < lim; i++)
#define forn_d(i, start, lim) for (ll i = start; i >= lim; i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) \
cout << "------\n" << #a << " = " << a << endl << "------" << endl
#define debug2(a, b) \
cout << "--------------\n" \
<< #a << " = " << a << " ; " << #b << " = " << b << endl \
<< "--------------" << endl
#define debug3(a, b, c) \
cout << "----------------------\n" \
<< #a << " = " << a << " ; " << #b << " = " << b << " ; " << #c \
<< " = " << c << endl \
<< "----------------------" << endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout << "chu " << a << endl
#define endl "\n"
ll a[100005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
forn(i, 0, n) cin >> a[i];
a[0] -= 1;
forn(i, 1, n) {
if (a[i] >= a[i - 1] + 1)
a[i] -= 1;
}
bool f = 1;
forn(i, 1, n) {
if (a[i] < a[i - 1]) {
f = 0;
break;
}
}
if (f)
cout << "YES\n";
else
cout << "NO\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i, start, lim) for (ll i = start; i < lim; i++)
#define forn_d(i, start, lim) for (ll i = start; i >= lim; i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) \
cout << "------\n" << #a << " = " << a << endl << "------" << endl
#define debug2(a, b) \
cout << "--------------\n" \
<< #a << " = " << a << " ; " << #b << " = " << b << endl \
<< "--------------" << endl
#define debug3(a, b, c) \
cout << "----------------------\n" \
<< #a << " = " << a << " ; " << #b << " = " << b << " ; " << #c \
<< " = " << c << endl \
<< "----------------------" << endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout << "chu " << a << endl
#define endl "\n"
ll a[100005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
forn(i, 0, n) cin >> a[i];
a[0] -= 1;
forn(i, 1, n) {
if (a[i] >= a[i - 1] + 1)
a[i] -= 1;
}
bool f = 1;
forn(i, 1, n) {
if (a[i] < a[i - 1]) {
f = 0;
break;
}
}
if (f)
cout << "Yes\n";
else
cout << "No\n";
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 758,102 | 758,103 | u772514767 | cpp |
p02953 | #include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++)
cin >> h[i];
bool flag = true;
if (n > 1) {
for (int i = n - 2; i >= 0; i--) {
if (h[i] > h[i - 1] + 1)
flag = false;
else if (h[i] > h[i - 1])
h[i]--;
}
}
cout << ((flag) ? "Yes" : "No") << endl;
return 0;
} | #include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++)
cin >> h[i];
bool flag = true;
if (n > 1) {
for (int i = n - 2; i >= 0; i--) {
if (h[i] > h[i + 1] + 1)
flag = false;
else if (h[i] > h[i + 1])
h[i]--;
}
}
cout << ((flag) ? "Yes" : "No") << endl;
return 0;
} | [
"misc.opposites",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 758,104 | 758,105 | u394759653 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
#define N 140000
#define mod 1000000007
#define pp pair<ll, ll>
typedef long long int ll;
typedef long double ld;
#define MP make_pair
#define endl "\n"
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, n) for (ll i = 1; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define repb(i, n) for (ll i = 1; i < n - 1; i++)
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll);
ll modinv(ll, ll);
int main() {
ll n;
cin >> n;
ll a[n];
rep(i, n) cin >> a[i];
a[0]--;
rep1(i, n) {
if (a[i] > a[i - 1])
a[i]--;
}
rep1(i, n) {
if (a[i] < a[i - 1]) {
cout << "NO\n";
return 0;
}
}
cout << "YES\n";
}
void fastIO(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
void decimal(int n) {
cout << fixed;
cout << setprecision(n);
}
ll modmulti(ll a, ll b, ll m) { return ((a % m) * (b % m)) % m; }
ll modadd(ll a, ll b, ll m) { return ((a % m) + (b % m)) % m; }
ll modpower(ll a, ll n, ll m) {
if (n == 0)
return 1;
ll result = 1;
while (n > 0) {
if (n % 2 == 1)
result = modmulti(result, a, m);
a = modmulti(a, a, m);
n = n / 2;
}
return result;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll modinv(ll a, ll m) { return modpower(a, m - 2, m); }
| #include <bits/stdc++.h>
using namespace std;
#define N 140000
#define mod 1000000007
#define pp pair<ll, ll>
typedef long long int ll;
typedef long double ld;
#define MP make_pair
#define endl "\n"
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, n) for (ll i = 1; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define repb(i, n) for (ll i = 1; i < n - 1; i++)
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll);
ll modinv(ll, ll);
int main() {
ll n;
cin >> n;
ll a[n];
rep(i, n) cin >> a[i];
a[0]--;
rep1(i, n) {
if (a[i] > a[i - 1])
a[i]--;
}
rep1(i, n) {
if (a[i] < a[i - 1]) {
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
}
void fastIO(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
void decimal(int n) {
cout << fixed;
cout << setprecision(n);
}
ll modmulti(ll a, ll b, ll m) { return ((a % m) * (b % m)) % m; }
ll modadd(ll a, ll b, ll m) { return ((a % m) + (b % m)) % m; }
ll modpower(ll a, ll n, ll m) {
if (n == 0)
return 1;
ll result = 1;
while (n > 0) {
if (n % 2 == 1)
result = modmulti(result, a, m);
a = modmulti(a, a, m);
n = n / 2;
}
return result;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll modinv(ll a, ll m) { return modpower(a, m - 2, m); }
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 758,106 | 758,107 | u377572376 | cpp |
p02953 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(), vec.end()
#define P pair<int, int>
#define S second
#define F first
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
bool prime(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (x % i == 0)
return false;
}
return true;
}
int kai(int x) {
if (x == 1)
return 1;
return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int moder) {
int res = 1;
while (y > 0) {
if (y & 1)
res = res * x % moder;
x = x * x % moder;
y >>= 1;
}
return res;
}
int comb(int x, int y) {
if (y > x)
return 0;
if (x == y)
return 1;
return kai(x) * mod_pow(kai(x - y), mod - 2, mod) % mod *
mod_pow(kai(y), mod - 2, mod) % mod;
}
int n, h[100010];
int cnt;
signed main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
if (i >= 1) {
if (cnt == h[i] - 1)
cnt = h[i] - 1;
else if (cnt > h[i]) {
cout << "No" << endl;
return 0;
} else
cnt = h[i];
} else
cnt = h[i];
}
cout << "Yes" << endl;
} | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(), vec.end()
#define P pair<int, int>
#define S second
#define F first
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
bool prime(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (x % i == 0)
return false;
}
return true;
}
int kai(int x) {
if (x == 1)
return 1;
return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int moder) {
int res = 1;
while (y > 0) {
if (y & 1)
res = res * x % moder;
x = x * x % moder;
y >>= 1;
}
return res;
}
int comb(int x, int y) {
if (y > x)
return 0;
if (x == y)
return 1;
return kai(x) * mod_pow(kai(x - y), mod - 2, mod) % mod *
mod_pow(kai(y), mod - 2, mod) % mod;
}
int n, h[100010];
int cnt;
signed main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
if (i >= 1) {
if (cnt <= h[i] - 1)
cnt = h[i] - 1;
else if (cnt > h[i]) {
cout << "No" << endl;
return 0;
} else
cnt = h[i];
} else
cnt = h[i];
}
cout << "Yes" << endl;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,112 | 758,113 | u277153875 | cpp |
p02953 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl '\n'
#define F first
#define S second
#define mod (ll)998244353
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ios \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define inf 1e18
#define mem(a, x) \
for (int i = 0; i < (int)(sizeof(a) / sizeof(a[0])); i++) \
a[i] = x;
#define trace(a) cout << (#a) << " --> " << a << endl
#define trace2(a, b) \
{ \
trace(a); \
trace(b); \
}
#define trace3(a, b, c) \
{ \
trace(a); \
trace(b); \
trace(c); \
}
#define trace4(a, b, c, d) \
{ \
trace(a); \
trace(b); \
trace(c); \
trace(d); \
}
#define M_PI 3.14159265358979323846
signed main() {
ios;
int n;
cin >> n;
int h[n];
for (int i = 0; i < n; i++)
cin >> h[i];
bool ans = true;
for (int i = 1; i < n; i++) {
if (h[i] > h[i - 1])
h[i]--;
else if (h[i] < h[i - 1]) {
ans = false;
break;
}
}
if (ans)
cout << "YES";
else
cout << "NO";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl '\n'
#define F first
#define S second
#define mod (ll)998244353
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ios \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define inf 1e18
#define mem(a, x) \
for (int i = 0; i < (int)(sizeof(a) / sizeof(a[0])); i++) \
a[i] = x;
#define trace(a) cout << (#a) << " --> " << a << endl
#define trace2(a, b) \
{ \
trace(a); \
trace(b); \
}
#define trace3(a, b, c) \
{ \
trace(a); \
trace(b); \
trace(c); \
}
#define trace4(a, b, c, d) \
{ \
trace(a); \
trace(b); \
trace(c); \
trace(d); \
}
#define M_PI 3.14159265358979323846
signed main() {
ios;
int n;
cin >> n;
int h[n];
for (int i = 0; i < n; i++)
cin >> h[i];
bool ans = true;
for (int i = 1; i < n; i++) {
if (h[i] > h[i - 1])
h[i]--;
else if (h[i] < h[i - 1]) {
ans = false;
break;
}
}
if (ans)
cout << "Yes";
else
cout << "No";
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 758,114 | 758,115 | u510221731 | cpp |
p02954 | /***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt)
* blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include <bits/stdc++.h>
using namespace std;
#define fastt \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define ll long long
#define debug printf("Come here!")
#define inf 1000000000000000000
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define mem(a, b) memset(a, b, sizeof(a))
#define clr(x) x.clear()
#define ff first
#define ss second
#define case (x) cout << "Case " << x << ": "
#define md 1000000007
#define pi acos(-1.0)
#define cos(a) cos(a *pi / 180)
#define sin(a) sin(a *pi / 180)
#define tan(a) tan(a *pi / 180)
#define cosi(a) acos(a) / (pi / 180)
#define sini(a) asin(a) / (pi / 180)
#define tani(a) atan(a) / (pi / 180)
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vpll vector<pair<ll, ll>>
#define vpsl vector<pair<string, ll>>
#define vpls vector<pair<ll, string>>
#define pql priority_queue<ll>
#define minpql priority_queue<ll, vector<ll>, greater<ll>>
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define toll(a) atoll(a.c_str())
string tostr(ll a) {
stringstream rr;
rr << a;
return rr.str();
}
ll pow(ll c, ll d) { return d == 0 ?: c * pow(c, d - 1); }
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return ((a * b) / gcd(a, b)); }
/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/
int main() {
ll n, m, k, i, j, x, y, p = 0, h, f = 0;
string s;
cin >> s;
k = s.size();
ll a[k];
for (i = 0; i < s.size() - 1; i++) {
if (s[i] == 'R') {
p++;
if (s[i + 1] == 'R') {
a[i] = 0;
} else {
a[i] = p;
}
} else {
p = 0;
}
}
p = 0;
for (i = s.size() - 1; i > 0; i--) {
if (s[i] == 'L') {
p++;
if (s[i - 1] == 'L') {
a[i] = 0;
} else {
a[i] = p;
}
} else {
p = 0;
}
}
for (i = 0; i < k - 1; i++) {
if (a[i] != 0) {
if ((a[i] + a[i + 1]) % 2 == 0) {
x = (a[i] + a[i + 1]) / 2;
a[i] = x;
a[i + 1] = x;
} else {
x = (a[i] + a[i + 1]) / 2;
if (a[i] < a[i + 1]) {
x = a[i + 1] - 1;
if (x % 2 == 0) {
a[i + 1] = x + 1;
a[i] = x;
} else {
a[i] = x + 1;
a[i + 1] = x;
}
} else {
x = a[i] - 1;
if (x % 2 == 0) {
a[i] = x + 1;
a[i + 1] = x;
} else {
a[i + 1] = x + 1;
a[i] = x;
}
}
}
i++;
}
}
for (i = 0; i < k; i++) {
cout << a[i] << " ";
}
cout << endl;
return 0;
}
| /***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt)
* blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include <bits/stdc++.h>
using namespace std;
#define fastt \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define ll long long
#define debug printf("Come here!")
#define inf 1000000000000000000
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define mem(a, b) memset(a, b, sizeof(a))
#define clr(x) x.clear()
#define ff first
#define ss second
#define case (x) cout << "Case " << x << ": "
#define md 1000000007
#define pi acos(-1.0)
#define cos(a) cos(a *pi / 180)
#define sin(a) sin(a *pi / 180)
#define tan(a) tan(a *pi / 180)
#define cosi(a) acos(a) / (pi / 180)
#define sini(a) asin(a) / (pi / 180)
#define tani(a) atan(a) / (pi / 180)
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vpll vector<pair<ll, ll>>
#define vpsl vector<pair<string, ll>>
#define vpls vector<pair<ll, string>>
#define pql priority_queue<ll>
#define minpql priority_queue<ll, vector<ll>, greater<ll>>
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define toll(a) atoll(a.c_str())
string tostr(ll a) {
stringstream rr;
rr << a;
return rr.str();
}
ll pow(ll c, ll d) { return d == 0 ?: c * pow(c, d - 1); }
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return ((a * b) / gcd(a, b)); }
/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/
int main() {
ll n, m, k, i, j, x, y, p = 0, h, f = 0;
string s;
cin >> s;
k = s.size();
ll a[k];
for (i = 0; i < s.size() - 1; i++) {
if (s[i] == 'R') {
p++;
if (s[i + 1] == 'R') {
a[i] = 0;
} else {
a[i] = p;
}
} else {
p = 0;
}
}
p = 0;
for (i = s.size() - 1; i > 0; i--) {
if (s[i] == 'L') {
p++;
if (s[i - 1] == 'L') {
a[i] = 0;
} else {
a[i] = p;
}
} else {
p = 0;
}
}
for (i = 0; i < k - 1; i++) {
if (a[i] != 0) {
if ((a[i] + a[i + 1]) % 2 == 0) {
x = (a[i] + a[i + 1]) / 2;
a[i] = x;
a[i + 1] = x;
} else {
x = (a[i] + a[i + 1]) / 2;
if (a[i] < a[i + 1]) {
y = a[i + 1] - 1;
if (y % 2 == 0) {
a[i + 1] = x + 1;
a[i] = x;
} else {
a[i] = x + 1;
a[i + 1] = x;
}
} else {
y = a[i] - 1;
if (y % 2 == 0) {
a[i] = x + 1;
a[i + 1] = x;
} else {
a[i + 1] = x + 1;
a[i] = x;
}
}
}
i++;
}
}
for (i = 0; i < k; i++) {
cout << a[i] << " ";
}
cout << endl;
return 0;
}
| [
"assignment.variable.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 758,116 | 758,117 | u035712458 | cpp |
p02954 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define FOR(i, a, b) for (ll i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<ll>>;
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};
// const ll LINF = (ll)1e18 - 1;
// const int INF = 1e9 - 1;
// int:±2*10^9くらい ll:±9*10^18くらい
void Main() {
string S;
ll l, r, p, n;
cin >> S;
n = S.size();
VI ans(n, 0);
r = 0;
rep(i, n - 1) {
if (S[i] == 'L' && r != -1) {
ans[i] = (i - r) / 2;
ans[i - 1] = (i - r) / 2 + (i - r) % 2;
r = -1;
} else if (S[i] == 'R' && r == -1) {
r = i;
}
}
l = n - 1;
RFOR(i, n - 1, 0) {
if (S[i] == 'R' && l != -1) {
ans[i] += (l - i) / 2;
ans[i + 1] += (l - i) / 2 + (l - i) % 2;
l = -1;
} else if (S[i] == 'L' && l == -1) {
l = i;
}
}
rep(i, n) { cout << ans[i] << " "; }
cout << endl;
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(15);
Main();
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define FOR(i, a, b) for (ll i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<ll>>;
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};
// const ll LINF = (ll)1e18 - 1;
// const int INF = 1e9 - 1;
// int:±2*10^9くらい ll:±9*10^18くらい
void Main() {
string S;
ll l, r, p, n;
cin >> S;
n = S.size();
VI ans(n, 0);
r = 0;
rep(i, n) {
if (S[i] == 'L' && r != -1) {
ans[i] = (i - r) / 2;
ans[i - 1] = (i - r) / 2 + (i - r) % 2;
r = -1;
} else if (S[i] == 'R' && r == -1) {
r = i;
}
}
l = n - 1;
RFOR(i, n - 1, 0) {
if (S[i] == 'R' && l != -1) {
ans[i] += (l - i) / 2;
ans[i + 1] += (l - i) / 2 + (l - i) % 2;
l = -1;
} else if (S[i] == 'L' && l == -1) {
l = i;
}
}
rep(i, n) { cout << ans[i] << " "; }
cout << endl;
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(15);
Main();
return 0;
}
| [
"expression.operation.binary.remove"
] | 758,118 | 758,119 | u444645674 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
string S;
int main() {
cin >> S;
vector<ll> ans(S.size());
rep(ri, 2) {
int cnt = 0;
rep(i, S.size()) {
if (S[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i] += (cnt + 1) / 2;
cnt = 0;
}
}
reverse(ans.begin(), ans.end());
reverse(S.begin(), S.end());
rep(i, S.size()) {
if (S[i] == 'R')
S[i] = 'L';
else
S[i] = 'R';
}
}
rep(i, S.size()) { cout << ans[i] << " "; }
cout << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
string S;
int main() {
cin >> S;
vector<ll> ans(S.size());
rep(ri, 2) {
int cnt = 0;
rep(i, S.size()) {
if (S[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
reverse(ans.begin(), ans.end());
reverse(S.begin(), S.end());
rep(i, S.size()) {
if (S[i] == 'R')
S[i] = 'L';
else
S[i] = 'R';
}
}
rep(i, S.size()) { cout << ans[i] << " "; }
cout << endl;
} | [
"assignment.change"
] | 758,129 | 758,130 | u455366471 | cpp |
p02954 | #include <bits/stdc++.h>
#define endl '\n'
#define fast_in \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define bit(x) __builtin_popcountll(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
const int inf = (int)1e9 + 99999, mod = (int)1e9 + 7;
const ll linf = (ll)2e18 + 99999;
int mul(int x, int y) { return ((ll)x * y) % mod; }
int sub(int x, int y) {
x -= y;
if (x < 0)
return x + mod;
return x;
}
int add(int x, int y) {
x += y;
if (x >= mod)
return x - mod;
return x;
}
const int maxn = (int)3e5;
int a[maxn], b[maxn];
void solve() {
string s;
cin >> s;
s += 'R';
s = '$' + s;
int n = sz(s);
int cntL, cntR, c;
cntL = cntR = 0;
vector<pii> v;
for (int i = 0; i < n; i++) {
if (s[i] == 'R' && s[i - 1] == 'L') {
if ((cntL + cntR) % 2 == 0) {
v.pb(mp(c - 1, (cntL + cntR) / 2));
v.pb(mp(c, (cntL + cntR) / 2));
} else {
if (cntR > cntL && cntR % 2 == 1) {
v.pb(mp(c - 1, (cntL + cntR) / 2 + 1));
v.pb(mp(c, (cntL + cntR) / 2));
} else if (cntR > cntL && cntR % 2 == 0) {
v.pb(mp(c - 1, (cntL + cntR) / 2));
v.pb(mp(c, (cntL + cntR) / 2 + 1));
}
if (cntR < cntL && cntL % 2 == 0) {
v.pb(mp(c - 1, (cntL + cntR) / 2 + 1));
v.pb(mp(c, (cntL + cntR) / 2));
} else if (cntR < cntL && cntL % 2 == 0) {
v.pb(mp(c - 1, (cntL + cntR) / 2));
v.pb(mp(c, (cntL + cntR) / 2 + 1));
}
}
cntL = 0, cntR = 1;
} else if (s[i] == 'R') {
cntR++;
} else if (s[i] == 'L' && s[i - 1] == 'R') {
c = i;
cntL++;
} else if (s[i] == 'L') {
cntL++;
}
// cout << cntL << ' ' << cntR << endl;
}
for (auto to : v) {
a[to.first] = to.second;
}
for (int i = 1; i < n - 1; i++)
cout << a[i] << ' ';
}
main() {
fast_in;
int t = 1; // cin >> t;
while (t--) {
solve();
}
return 0;
} | #include <bits/stdc++.h>
#define endl '\n'
#define fast_in \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define bit(x) __builtin_popcountll(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
const int inf = (int)1e9 + 99999, mod = (int)1e9 + 7;
const ll linf = (ll)2e18 + 99999;
int mul(int x, int y) { return ((ll)x * y) % mod; }
int sub(int x, int y) {
x -= y;
if (x < 0)
return x + mod;
return x;
}
int add(int x, int y) {
x += y;
if (x >= mod)
return x - mod;
return x;
}
const int maxn = (int)3e5;
int a[maxn], b[maxn];
void solve() {
string s;
cin >> s;
s += 'R';
s = '$' + s;
int n = sz(s);
int cntL, cntR, c;
cntL = cntR = 0;
vector<pii> v;
for (int i = 0; i < n; i++) {
if (s[i] == 'R' && s[i - 1] == 'L') {
if ((cntL + cntR) % 2 == 0) {
v.pb(mp(c - 1, (cntL + cntR) / 2));
v.pb(mp(c, (cntL + cntR) / 2));
} else {
if (cntR > cntL && cntR % 2 == 1) {
v.pb(mp(c - 1, (cntL + cntR) / 2 + 1));
v.pb(mp(c, (cntL + cntR) / 2));
} else if (cntR > cntL && cntR % 2 == 0) {
v.pb(mp(c - 1, (cntL + cntR) / 2));
v.pb(mp(c, (cntL + cntR) / 2 + 1));
}
if (cntR < cntL && cntL % 2 == 0) {
v.pb(mp(c - 1, (cntL + cntR) / 2 + 1));
v.pb(mp(c, (cntL + cntR) / 2));
} else if (cntR < cntL && cntL % 2 == 1) {
v.pb(mp(c - 1, (cntL + cntR) / 2));
v.pb(mp(c, (cntL + cntR) / 2 + 1));
}
}
cntL = 0, cntR = 1;
} else if (s[i] == 'R') {
cntR++;
} else if (s[i] == 'L' && s[i - 1] == 'R') {
c = i;
cntL++;
} else if (s[i] == 'L') {
cntL++;
}
// cout << cntL << ' ' << cntR << endl;
}
for (auto to : v) {
a[to.first] = to.second;
}
for (int i = 1; i < n - 1; i++)
cout << a[i] << ' ';
}
main() {
fast_in;
int t = 1; // cin >> t;
while (t--) {
solve();
}
return 0;
} | [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 758,131 | 758,132 | u922547438 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main() {
string s;
cin >> s;
vector<int> data(s.size(), 1);
ll right = 0;
ll left = 0;
ll rposi;
ll lposi;
rep(i, 0, s.size() + 1) {
if (left > 0 && s[i] == 'R' || i == s.size()) {
ll M = max(left, right);
int L, R;
lposi = right;
rposi = right - 1;
if (left < right) {
L = (left + right) / 2;
R = left + right - L;
} else {
R = (left + right) / 2;
L = left + right - R;
}
M--;
if (M / 2 == 0) { //終わっ時の状態が最終状態
rep(j, 0, right + left) {
if (j == rposi) {
cout << R << " ";
} else if (j == lposi) {
cout << L << " ";
} else {
cout << 0 << " ";
}
}
} else {
rep(j, 0, right + left) {
if (j == rposi) {
cout << L << " ";
} else if (j == lposi) {
cout << R << " ";
} else {
cout << 0 << " ";
}
}
}
left = 0;
right = 1;
// rposi = i;
} else if (s[i] == 'L') {
// if(left==0){
// lposi=i;
// }
left++;
} else if (s[i] == 'R') {
// rposi=i;
right++;
}
}
cout << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main() {
string s;
cin >> s;
vector<int> data(s.size(), 1);
ll right = 0;
ll left = 0;
ll rposi;
ll lposi;
rep(i, 0, s.size() + 1) {
if (left > 0 && s[i] == 'R' || i == s.size()) {
ll M = max(left, right);
int L, R;
lposi = right;
rposi = right - 1;
if (left < right) {
L = (left + right) / 2;
R = left + right - L;
} else {
R = (left + right) / 2;
L = left + right - R;
}
M--;
// cout<<M<<R<<L<<endl;
if (M % 2 == 0) { //終わっ時の状態が最終状態
rep(j, 0, right + left) {
if (j == rposi) {
cout << R << " ";
} else if (j == lposi) {
cout << L << " ";
} else {
cout << 0 << " ";
}
}
} else {
rep(j, 0, right + left) {
if (j == rposi) {
cout << L << " ";
} else if (j == lposi) {
cout << R << " ";
} else {
cout << 0 << " ";
}
}
}
left = 0;
right = 1;
// rposi = i;
} else if (s[i] == 'L') {
// if(left==0){
// lposi=i;
// }
left++;
} else if (s[i] == 'R') {
// rposi=i;
right++;
}
}
cout << endl;
return 0;
} | [
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change"
] | 758,135 | 758,136 | u169190252 | cpp |
p02954 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-14)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
using Graph = vector<VE>;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < MOD);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} com(300010);
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
class UnionFind {
public:
vector<ll> par;
vector<ll> siz;
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
// Member Function
// Find
ll root(ll x) {
while (par[x] != x) {
x = par[x] = par[par[x]];
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { return root(x) == root(y); }
ll size(ll x) { return siz[root(x)]; }
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(15);
string s;
cin >> s;
int n = s.size();
auto p = RunLength(s);
VE ans(n);
int now = 0;
rep(i, s.size()) {
now += p[i].second;
int tmp = p[i].second + p[i + 1].second;
if (tmp % 2) {
if (p[i].second % 2) {
ans[now - 1] = (tmp + 1) / 2;
ans[now] = tmp / 2;
} else {
ans[now - 1] = tmp / 2;
ans[now] = (tmp + 1) / 2;
}
} else {
ans[now - 1] = tmp / 2;
ans[now] = tmp / 2;
}
now += p[i + 1].second;
i++;
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-14)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
using Graph = vector<VE>;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < MOD);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} com(300010);
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
class UnionFind {
public:
vector<ll> par;
vector<ll> siz;
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
// Member Function
// Find
ll root(ll x) {
while (par[x] != x) {
x = par[x] = par[par[x]];
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { return root(x) == root(y); }
ll size(ll x) { return siz[root(x)]; }
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(15);
string s;
cin >> s;
int n = s.size();
auto p = RunLength(s);
VE ans(n);
int now = 0;
rep(i, p.size()) {
now += p[i].second;
int tmp = p[i].second + p[i + 1].second;
if (tmp % 2) {
if (p[i].second % 2) {
ans[now - 1] = (tmp + 1) / 2;
ans[now] = tmp / 2;
} else {
ans[now - 1] = tmp / 2;
ans[now] = (tmp + 1) / 2;
}
} else {
ans[now - 1] = tmp / 2;
ans[now] = tmp / 2;
}
now += p[i + 1].second;
i++;
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
return 0;
} | [
"identifier.change",
"call.arguments.change"
] | 758,139 | 758,140 | u809967037 | cpp |
p02954 | #include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define all(x) (x).begin(), (x).end()
//略記
#define pb emplace_back // vectorヘの挿入
#define mp make_pair // pairのコンストラクタ
#define F first // pairの一つ目の要素
#define S second // pairの二つ目の要素
#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)
#define perm(c) \
sort(all(c)); \
for (bool c##p = 1; c##p; \
c##p = next_permutation(all(c))) //順列 123 132 213 231 312 321
#define BIT(n) (1LL << (n))
#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif
//入力高速化
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} iosetup;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
signed main() {
string S;
cin >> S;
vector<int> ans(S.length(), 0);
int Rcount = 0;
int lastRpos = 0;
rep(i, S.length()) {
if (S[i] == 'R') {
Rcount++;
lastRpos = i;
} else {
ans[i] += Rcount - Rcount / 2;
ans[i - 1] += Rcount / 2;
Rcount = 0;
if ((i - lastRpos) % 2 == 1) {
ans[lastRpos]++;
} else {
ans[lastRpos + 1]++;
}
}
}
rep(i, S.length()) { cout << ans[i] << " "; }
cout << endl;
}
| #include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define all(x) (x).begin(), (x).end()
//略記
#define pb emplace_back // vectorヘの挿入
#define mp make_pair // pairのコンストラクタ
#define F first // pairの一つ目の要素
#define S second // pairの二つ目の要素
#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)
#define perm(c) \
sort(all(c)); \
for (bool c##p = 1; c##p; \
c##p = next_permutation(all(c))) //順列 123 132 213 231 312 321
#define BIT(n) (1LL << (n))
#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif
//入力高速化
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} iosetup;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
signed main() {
string S;
cin >> S;
vector<int> ans(S.length(), 0);
int Rcount = 0;
int lastRpos = 0;
rep(i, S.length()) {
if (S[i] == 'R') {
Rcount++;
lastRpos = i;
} else {
ans[i - 1] += Rcount - Rcount / 2;
ans[i] += Rcount / 2;
Rcount = 0;
if ((i - lastRpos) % 2 == 0) {
ans[lastRpos]++;
} else {
ans[lastRpos + 1]++;
}
}
}
rep(i, S.length()) { cout << ans[i] << " "; }
cout << endl;
}
| [
"assignment.change",
"expression.operation.binary.remove",
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 758,162 | 758,163 | u322110493 | cpp |
p02954 | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string S;
cin >> S;
int n = S.size();
vector<int> ans(n);
for (int i = 0; i < 2; i++) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (S[i] == 'R') {
cnt++;
} else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
reverse(ans.begin(), ans.end());
reverse(S.begin(), S.end());
for (int i = 0; i < n; i++) {
if (S[i] == 'L') {
S[i] = 'R';
} else {
S[i] = 'L';
}
}
}
for (int i = 0; i < n; i++) {
if (i == n - 1) {
cout << ans[i] << endl;
}
cout << ans[i] << " ";
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string S;
cin >> S;
int n = S.size();
vector<int> ans(n);
for (int i = 0; i < 2; i++) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (S[i] == 'R') {
cnt++;
} else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
reverse(ans.begin(), ans.end());
reverse(S.begin(), S.end());
for (int i = 0; i < n; i++) {
if (S[i] == 'L') {
S[i] = 'R';
} else {
S[i] = 'L';
}
}
}
for (int i = 0; i < n; i++) {
if (i == n - 1) {
cout << ans[i] << endl;
} else {
cout << ans[i] << " ";
}
}
return 0;
} | [
"control_flow.branch.else.add"
] | 758,170 | 758,171 | u963164554 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int, int>;
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2);
/*
任意の場所にどのマスの子供が集まるか
*/
int main() {
string S;
cin >> S;
ll n = S.size();
vector<ll> a(n);
ll i = 0;
ll count = 0;
ll num = 0; //何個に別れるか
while (i < n) {
count = 0;
while (S[i] == S[i + 1]) {
i++;
count++;
}
a[num] = count + 1;
i++;
num++;
}
// for (int i=0;i<num;i++)
// cout<<a[i]<<" ";
vector<ll> ans(n, 0); //答えを格納する配列
ll now = 0;
for (int i = 0; i < num; i += 2) {
if (a[i] % 2 != a[i + 1] % 2) {
if (max(a[i], a[i + 1]) % 2 == 0) {
ans[now + a[i] + 1] = (a[i] + a[i + 1]) / 2 + 1;
ans[now + a[i]] = (a[i] + a[i + 1]) / 2;
if (a[i] < a[i + 1])
swap(ans[now + a[i] + 1], ans[now + a[i]]);
} else {
ans[now + a[i] + 1] = (a[i] + a[i + 1]) / 2;
ans[now + a[i]] = (a[i] + a[i + 1]) / 2 + 1;
if (a[i] < a[i + 1])
swap(ans[now + a[i] + 1], ans[now + a[i]]);
}
} else {
ans[now + a[i]] = (a[i] + a[i + 1]) / 2;
ans[now + a[i] + 1] = (a[i] + a[i + 1]) / 2;
}
now += a[i] + a[i + 1];
}
for (int i = 1; i <= n; i++)
cout << ans[i] << " ";
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int, int>;
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2);
/*
任意の場所にどのマスの子供が集まるか
*/
int main() {
string S;
cin >> S;
ll n = S.size();
vector<ll> a(n + 1);
ll i = 0;
ll count = 0;
ll num = 0; //何個に別れるか
while (i < n) {
count = 0;
while (S[i] == S[i + 1]) {
i++;
count++;
}
a[num] = count + 1;
i++;
num++;
}
// for (int i=0;i<num;i++)
// cout<<a[i]<<" ";
vector<ll> ans(n + 1, 0); //答えを格納する配列
ll now = 0;
for (int i = 0; i < num; i += 2) {
if (a[i] % 2 != a[i + 1] % 2) {
if (max(a[i], a[i + 1]) % 2 == 0) {
ans[now + a[i] + 1] = (a[i] + a[i + 1]) / 2 + 1;
ans[now + a[i]] = (a[i] + a[i + 1]) / 2;
if (a[i] < a[i + 1])
swap(ans[now + a[i] + 1], ans[now + a[i]]);
} else {
ans[now + a[i] + 1] = (a[i] + a[i + 1]) / 2;
ans[now + a[i]] = (a[i] + a[i + 1]) / 2 + 1;
if (a[i] < a[i + 1])
swap(ans[now + a[i] + 1], ans[now + a[i]]);
}
} else {
ans[now + a[i]] = (a[i] + a[i + 1]) / 2;
ans[now + a[i] + 1] = (a[i] + a[i + 1]) / 2;
}
now += a[i] + a[i + 1];
}
for (int i = 1; i <= n; i++)
cout << ans[i] << " ";
} | [
"assignment.change"
] | 758,184 | 758,185 | u711676593 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//実装面倒→ランレングス圧縮
int main() {
string s;
cin >> s;
vector<int> ans(s.length());
int firstR = 0; //島のはじめのRのインデックス
int firstL; //島のはじめのLのインデックス
rep(i, s.length() - 1) {
if (s[i + 1] == 'L' && s[i] == 'R')
firstL = i + 1;
if (s[i + 1] == 'R' && s[i] == 'L') {
int sima = i + 1 - firstR;
if (sima % 2 == 0) {
ans[firstL - 1] = sima / 2;
ans[firstL] = sima / 2;
} else if (firstR % 2 == firstL - 1 % 2) {
ans[firstL - 1] = sima / 2 + 1;
ans[firstL] = sima / 2;
} else {
ans[firstL - 1] = sima / 2;
ans[firstL] = sima / 2 + 1;
}
firstR = i + 1;
}
}
//最後だけ例外処理
int sima = s.length() - firstR;
if (sima % 2 == 0) {
ans[firstL - 1] = sima / 2;
ans[firstL] = sima / 2;
} else if (firstR % 2 == firstL - 1 % 2) {
ans[firstL - 1] = sima / 2 + 1;
ans[firstL] = sima / 2;
} else {
ans[firstL - 1] = sima / 2;
ans[firstL] = sima / 2 + 1;
}
rep(i, s.length()) cout << ans[i] << " ";
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//実装面倒→ランレングス圧縮
int main() {
string s;
cin >> s;
vector<int> ans(s.length());
int firstR = 0; //島のはじめのRのインデックス
int firstL; //島のはじめのLのインデックス
rep(i, s.length() - 1) {
if (s[i + 1] == 'L' && s[i] == 'R')
firstL = i + 1;
if (s[i + 1] == 'R' && s[i] == 'L') {
int sima = i + 1 - firstR;
if (sima % 2 == 0) {
ans[firstL - 1] = sima / 2;
ans[firstL] = sima / 2;
} else if (firstR % 2 == (firstL - 1) % 2) {
ans[firstL - 1] = sima / 2 + 1;
ans[firstL] = sima / 2;
} else {
ans[firstL - 1] = sima / 2;
ans[firstL] = sima / 2 + 1;
}
firstR = i + 1;
}
}
//最後だけ例外処理
int sima = s.length() - firstR;
if (sima % 2 == 0) {
ans[firstL - 1] = sima / 2;
ans[firstL] = sima / 2;
} else if (firstR % 2 == (firstL - 1) % 2) {
ans[firstL - 1] = sima / 2 + 1;
ans[firstL] = sima / 2;
} else {
ans[firstL - 1] = sima / 2;
ans[firstL] = sima / 2 + 1;
}
rep(i, s.length()) cout << ans[i] << " ";
}
//サンプルは通ったが... | [
"control_flow.branch.if.condition.change"
] | 758,193 | 758,194 | u650236619 | cpp |
p02954 | // c++ テンプレ
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint, vector<llint>, greater<llint>> que;
priority_queue<llint> Que;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
void solve() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
for (int j = 0; j < 2; j++) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
}
reverse(ans.begin(), ans.end());
reverse(s.begin(), s.end());
for (int i = 0; i < n; i++) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
for (int i = 0; i < n; i++)
cout << ans[i] << " ";
cout << endl;
}
int main() {
solve();
return 0;
}
| // c++ テンプレ
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint, vector<llint>, greater<llint>> que;
priority_queue<llint> Que;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
void solve() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
for (int j = 0; j < 2; j++) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
reverse(ans.begin(), ans.end());
reverse(s.begin(), s.end());
for (int i = 0; i < n; i++) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
for (int i = 0; i < n; i++)
cout << ans[i] << " ";
cout << endl;
}
int main() {
solve();
return 0;
}
| [] | 758,195 | 758,196 | u332253305 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int ddx[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int ddy[8] = {0, 1, -1, 0, 1, -1, 1, -1};
const int maxn = 2e6 + 5;
const int maxs = 1e5;
int dub[20][maxn];
int now[maxn];
int ans[maxn];
void solve() {
string s;
cin >> s;
int n = s.length();
for (int i = 0; i < n; i++) {
now[i] = i;
}
for (int i = 0; i < n; i++) {
if (s[i] == 'L')
dub[0][i] = i - 1;
else
dub[0][i] = i + 1;
}
for (int i = 0; i < 20; i++) {
for (int j = 0; j < n; j++) {
dub[i + 1][j] = dub[i][dub[i][j]];
}
}
for (int i = 20; i >= 0; i--) {
if (1LL << i & maxs) {
for (int j = 0; j < n; j++) {
now[j] = dub[i][now[j]];
}
}
}
for (int i = 0; i < n; i++) {
ans[now[i]]++;
}
for (int i = 0; i < n; i++) {
cout << ans[i] << " ";
}
cout << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
solve();
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int ddx[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int ddy[8] = {0, 1, -1, 0, 1, -1, 1, -1};
const int maxn = 2e6 + 5;
const int maxs = 1e5;
int dub[21][maxn];
int now[maxn];
int ans[maxn];
void solve() {
string s;
cin >> s;
int n = s.length();
for (int i = 0; i < n; i++) {
now[i] = i;
}
for (int i = 0; i < n; i++) {
if (s[i] == 'L')
dub[0][i] = i - 1;
else
dub[0][i] = i + 1;
}
for (int i = 0; i < 20; i++) {
for (int j = 0; j < n; j++) {
dub[i + 1][j] = dub[i][dub[i][j]];
}
}
for (int i = 20; i >= 0; i--) {
if (1LL << i & maxs) {
for (int j = 0; j < n; j++) {
now[j] = dub[i][now[j]];
}
}
}
for (int i = 0; i < n; i++) {
ans[now[i]]++;
}
for (int i = 0; i < n; i++) {
cout << ans[i] << " ";
}
cout << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
solve();
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 758,202 | 758,203 | u279033107 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep2(x, fr, to) for (int x = (fr); x < (to); x++)
#define rep(x, to) for (int x = 0; x < (to); x++)
#define repr(x, fr, to) for (int x = (fr); x >= (to); x--)
#define all(c) c.begin(), c.end()
#define sz(v) (int)v.size()
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<ll> VL;
const int MD = 1e9 + 7;
void dbg() { cerr << "\n"; }
template <typename T, typename... T2> void dbg(const T &fst, const T2 &...rst) {
cerr << fst << ": ";
dbg(rst...);
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
string s;
cin >> s;
int n = sz(s);
VI ans(n), kgr, atm;
rep(i, n) {
if (s.substr(i, 2) == "LR")
kgr.push_back(i + 1);
if (s.substr(i, 2) == "RL")
atm.push_back(i);
}
kgr.push_back(n);
int stt = 0;
rep(i, sz(kgr)) {
int m = kgr[i] - stt;
ans[atm[i]] = ans[atm[i] + 1] = m / 2;
if (m % 2) {
if (atm[i] % 2)
ans[atm[i]]++;
else
ans[atm[i] + 1]++;
}
stt = kgr[i];
}
for (auto x : ans)
cout << x << " ";
cout << "\n";
return 0;
}
| #include <bits/stdc++.h>
#define rep2(x, fr, to) for (int x = (fr); x < (to); x++)
#define rep(x, to) for (int x = 0; x < (to); x++)
#define repr(x, fr, to) for (int x = (fr); x >= (to); x--)
#define all(c) c.begin(), c.end()
#define sz(v) (int)v.size()
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<ll> VL;
const int MD = 1e9 + 7;
void dbg() { cerr << "\n"; }
template <typename T, typename... T2> void dbg(const T &fst, const T2 &...rst) {
cerr << fst << ": ";
dbg(rst...);
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
string s;
cin >> s;
int n = sz(s);
VI ans(n), kgr, atm;
rep(i, n) {
if (s.substr(i, 2) == "LR")
kgr.push_back(i + 1);
if (s.substr(i, 2) == "RL")
atm.push_back(i);
}
kgr.push_back(n);
int stt = 0;
rep(i, sz(kgr)) {
int m = kgr[i] - stt;
ans[atm[i]] = ans[atm[i] + 1] = m / 2;
if (m % 2) {
if (stt % 2 == atm[i] % 2)
ans[atm[i]]++;
else
ans[atm[i] + 1]++;
}
stt = kgr[i];
}
for (auto x : ans)
cout << x << " ";
cout << "\n";
return 0;
}
| [
"control_flow.branch.if.condition.change"
] | 758,206 | 758,207 | u714564133 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.size();
vector<int> count(N, 0);
int R = 0;
int L = 0;
for (int i = 0; i < N - 1; i++) {
if (S.at(i) == 'R') {
R++;
} else {
L++;
}
if (i == N - 2) {
if (S.at(i + 1) == 'R') {
R++;
} else {
L++;
}
}
if (S.at(i) == 'L' && S.at(i + 1) == 'R') {
if ((R + L) % 2 == 0) {
count.at(i - L) = (R + L) / 2;
count.at(i - L + 1) = (R + L) / 2;
} else if (R % 2 == 0) {
count.at(i - L) = (R + L) / 2;
count.at(i - L + 1) = R + L - (R + L) / 2;
} else {
count.at(i - L + 1) = (R + L) / 2;
count.at(i - L) = R + L - (R + L) / 2;
}
R = 0;
L = 0;
} else if (i == N - 2) {
if ((R + L) % 2 == 0) {
count.at(i - L + 1) = (R + L) / 2;
count.at(i - L + 2) = (R + L) / 2;
} else if (R % 2 == 0) {
count.at(i - L + 1) = (R + L) / 2;
count.at(i - L + 2) = R + L - (R + L) / 2;
} else {
count.at(i - L + 1) = (R + L) / 2;
count.at(i - L + 2) = R + L - (R + L) / 2;
}
}
}
for (int i = 0; i < N; i++) {
cout << count.at(i);
if (i == N - 1) {
cout << endl;
} else {
cout << ' ';
}
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.size();
vector<int> count(N, 0);
int R = 0;
int L = 0;
for (int i = 0; i < N - 1; i++) {
if (S.at(i) == 'R') {
R++;
} else {
L++;
}
if (i == N - 2) {
if (S.at(i + 1) == 'R') {
R++;
} else {
L++;
}
}
if (S.at(i) == 'L' && S.at(i + 1) == 'R') {
if ((R + L) % 2 == 0) {
count.at(i - L) = (R + L) / 2;
count.at(i - L + 1) = (R + L) / 2;
} else if (R % 2 == 0) {
count.at(i - L) = (R + L) / 2;
count.at(i - L + 1) = R + L - (R + L) / 2;
} else {
count.at(i - L + 1) = (R + L) / 2;
count.at(i - L) = R + L - (R + L) / 2;
}
R = 0;
L = 0;
} else if (i == N - 2) {
if ((R + L) % 2 == 0) {
count.at(i - L + 1) = (R + L) / 2;
count.at(i - L + 2) = (R + L) / 2;
} else if (R % 2 == 0) {
count.at(i - L + 1) = (R + L) / 2;
count.at(i - L + 2) = R + L - (R + L) / 2;
} else {
count.at(i - L + 2) = (R + L) / 2;
count.at(i - L + 1) = R + L - (R + L) / 2;
}
}
}
for (int i = 0; i < N; i++) {
cout << count.at(i);
if (i == N - 1) {
cout << endl;
} else {
cout << ' ';
}
}
}
| [
"assignment.variable.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 758,220 | 758,221 | u710877960 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int n = s.size();
s += 'R';
int pos = 0;
bool fr = true;
vector<int> cnt(n, 0);
for (int i = 0; i < n; i++) {
if (s[i] != s[i + 1]) {
if (fr) {
for (int j = pos; j <= i; j++) {
if ((i - j) % 2 == 0)
cnt[i]++;
else
cnt[i + 1]++;
}
} else {
for (int j = pos; j <= i; j++) {
if ((j - pos) % 2 == 0)
cnt[pos]++;
else
cnt[pos - 1]++;
}
}
fr = !fr;
pos = i + 1;
}
}
for (int i = 0; i < n; i++)
cout << cnt[i] << "\n"[i + 1 == n];
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int n = s.size();
s += 'R';
int pos = 0;
bool fr = true;
vector<int> cnt(n, 0);
for (int i = 0; i < n; i++) {
if (s[i] != s[i + 1]) {
if (fr) {
for (int j = pos; j <= i; j++) {
if ((i - j) % 2 == 0)
cnt[i]++;
else
cnt[i + 1]++;
}
} else {
for (int j = pos; j <= i; j++) {
if ((j - pos) % 2 == 0)
cnt[pos]++;
else
cnt[pos - 1]++;
}
}
fr = !fr;
pos = i + 1;
}
}
for (int i = 0; i < n; i++) {
cout << cnt[i] << " \n"[i + 1 == n];
}
return 0;
}
| [
"literal.string.change",
"io.output.change"
] | 758,228 | 758,229 | u415325136 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> num(s.size(), 1);
for (int i = 0; i < s.size() - 2; i++) {
if (s[i] == 'R' && s[i + 1] == 'R') {
num[i + 2] += num[i];
num[i] = 0;
}
}
for (int i = s.size(); i > 2; i--) {
if (s[i] == 'L' && s[i - 1] == 'L') {
num[i - 2] += num[i];
num[i] = 0;
}
}
for (int i = 0; i < s.size(); i++) {
cout << num[i];
if (i < s.size() - 1) {
cout << " ";
}
}
cout << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> num(s.size(), 1);
for (int i = 0; i < s.size() - 2; i++) {
if (s[i] == 'R' && s[i + 1] == 'R') {
num[i + 2] += num[i];
num[i] = 0;
}
}
for (int i = s.size() - 1; i > 1; i--) {
if (s[i] == 'L' && s[i - 1] == 'L') {
num[i - 2] += num[i];
num[i] = 0;
}
}
for (int i = 0; i < s.size(); i++) {
cout << num[i];
if (i < s.size() - 1) {
cout << " ";
}
}
cout << endl;
return 0;
} | [
"control_flow.loop.for.initializer.change",
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 758,232 | 758,233 | u440276250 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;
int main() {
string s;
cin >> s;
int n = s.size();
int l = 0;
int to[n];
rep(i, n) to[i] = -1;
for (int i = 1; i < n; i++) {
if (s[i] != 'R') {
for (int j = l; j < i; j++) {
to[j] = i - 1;
}
l = i + 1;
}
}
int r = n - 1;
for (int i = n - 2; i > 0; i--) {
if (s[i] != 'L') {
for (int j = r; j > i; j--) {
to[j] = i + 1;
}
r = i - 1;
}
}
int ans[n];
rep(i, n) ans[i] = 0;
rep(i, n) {
if (abs(i - to[i]) % 2) {
if (s[i] == 'R')
ans[to[i] + 1]++;
else
ans[to[i] - 1]++;
} else
ans[to[i]]++;
}
rep(i, n - 1) printf("%d ", ans[i]);
printf("%d\n", ans[n - 1]);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;
int main() {
string s;
cin >> s;
int n = s.size();
int l = 0;
int to[n];
rep(i, n) to[i] = -1;
for (int i = 1; i < n; i++) {
if (s[i] != 'R') {
for (int j = l; j < i; j++) {
to[j] = i - 1;
}
l = i + 1;
}
}
int r = n - 1;
for (int i = n - 2; i >= 0; i--) {
if (s[i] != 'L') {
for (int j = r; j > i; j--) {
to[j] = i + 1;
}
r = i - 1;
}
}
int ans[n];
rep(i, n) ans[i] = 0;
rep(i, n) {
if (abs(i - to[i]) % 2) {
if (s[i] == 'R')
ans[to[i] + 1]++;
else
ans[to[i] - 1]++;
} else
ans[to[i]]++;
}
rep(i, n - 1) printf("%d ", ans[i]);
printf("%d\n", ans[n - 1]);
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,234 | 758,235 | u747602774 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
s += 'R';
int b[n] = {};
vector<int> a;
char c = s.at(0);
int d = 1;
for (int i = 0; i < n; i++) {
if (s.at(i + 1) == c)
d++;
else {
c = s.at(i + 1);
a.push_back(d);
d = 1;
}
}
int j = 0;
for (int i = 0; i < a.size() - 1; i += 2) {
int s = a[i] + a[i + 1];
if (s % 2 == 0) {
b[a[i] - 1 + j] = s / 2;
b[a[i] + j] = s / 2;
} else {
b[a[i] - 1 + j] = s / 2 + 1 - (a[i] - 1 + j) % 2;
b[a[i] + j] = s / 2 + (a[i] - 1 + j) % 2;
}
j += s;
}
for (int i = 0; i < n - 1; i++)
cout << b[i] << " ";
cout << b[n - 1] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
s += 'R';
int b[n] = {};
vector<int> a;
char c = s.at(0);
int d = 1;
for (int i = 0; i < n; i++) {
if (s.at(i + 1) == c)
d++;
else {
c = s.at(i + 1);
a.push_back(d);
d = 1;
}
}
int j = 0;
for (int i = 0; i < a.size() - 1; i += 2) {
int s = a[i] + a[i + 1];
if (s % 2 == 0) {
b[a[i] - 1 + j] = s / 2;
b[a[i] + j] = s / 2;
} else {
b[a[i] - 1 + j] = s / 2 + 1 - (a[i] - 1) % 2;
b[a[i] + j] = s / 2 + (a[i] - 1) % 2;
}
j += s;
}
for (int i = 0; i < n - 1; i++)
cout << b[i] << " ";
cout << b[n - 1] << endl;
}
| [
"expression.operation.binary.remove"
] | 758,238 | 758,239 | u298768617 | cpp |
p02954 | #include <iostream>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.size();
int ans[N];
for (int i = 0; i < N; i++) {
ans[i] = 0;
}
int p = 0, l = 0;
for (int i = 0; i < N - 1; i++) {
if (S[i] == 'R' && S[i + 1] == 'L') {
l = i - p;
if (l == 0) {
ans[i] += 1;
} else if (l % 2 == 0) {
ans[i] += l / 2 + 1;
ans[i + 1] += l / 2;
} else {
ans[i] += l / 2 + 1;
ans[i + 1] += l / 2 + 1;
}
p = i;
} else if (S[i] == 'L') {
p = i + 1;
}
}
p = N - 1;
for (int i = N - 1; i > 1; i--) {
if (S[i] == 'L' && S[i - 1] == 'R') {
l = p - i;
if (l == 0) {
ans[i] += 1;
} else if (l % 2 == 0) {
ans[i] += l / 2 + 1;
ans[i - 1] += l / 2;
} else {
ans[i] += l / 2 + 1;
ans[i - 1] += l / 2 + 1;
}
p = i;
} else if (S[i] == 'R') {
p = i - 1;
}
}
for (int i = 0; i < N; i++) {
cout << ans[i] << " ";
}
cout << endl;
}
| #include <iostream>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.size();
int ans[N];
for (int i = 0; i < N; i++) {
ans[i] = 0;
}
int p = 0, l = 0;
for (int i = 0; i < N - 1; i++) {
if (S[i] == 'R' && S[i + 1] == 'L') {
l = i - p;
if (l == 0) {
ans[i] += 1;
} else if (l % 2 == 0) {
ans[i] += l / 2 + 1;
ans[i + 1] += l / 2;
} else {
ans[i] += l / 2 + 1;
ans[i + 1] += l / 2 + 1;
}
p = i;
} else if (S[i] == 'L') {
p = i + 1;
}
}
p = N - 1;
for (int i = N - 1; i > 0; i--) {
if (S[i] == 'L' && S[i - 1] == 'R') {
l = p - i;
if (l == 0) {
ans[i] += 1;
} else if (l % 2 == 0) {
ans[i] += l / 2 + 1;
ans[i - 1] += l / 2;
} else {
ans[i] += l / 2 + 1;
ans[i - 1] += l / 2 + 1;
}
p = i;
} else if (S[i] == 'R') {
p = i - 1;
}
}
for (int i = 0; i < N; i++) {
cout << ans[i] << " ";
}
cout << endl;
}
| [
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 758,260 | 758,261 | u154904553 | cpp |
p02954 | #include <iostream>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.size();
int ans[N];
for (int i = 0; i < N; i++) {
ans[i] = 0;
}
int p = 0, l = 0;
for (int i = 0; i < N - 1; i++) {
if (S[i] == 'R' && S[i + 1] == 'L') {
l = i - p;
if (l == 0) {
ans[i] += 1;
} else if (l % 2 == 0) {
ans[i] += l / 2 + 1;
ans[i + 1] += l / 2;
} else {
ans[i] += l / 2 + 1;
ans[i + 1] += l / 2 + 1;
}
p = i;
} else if (S[i] == 'L') {
p = i + 1;
}
}
p = N - 1;
for (int i = N - 1; i > 1; i--) {
if (S[i] == 'L' && S[i - 1] == 'R') {
l = p - i;
if (l == 0) {
ans[i] += 1;
} else if (l % 2 == 0) {
ans[i] += l / 2 + 1;
ans[i - 1] += l / 2;
} else {
ans[i] += l / 2 + 1;
ans[i - 1] += l / 2 + 1;
}
p = i;
} else if (S[i] == 'R') {
p = i - 1;
}
}
for (int i = 0; i < N; i++) {
cout << ans[i];
}
cout << endl;
}
| #include <iostream>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.size();
int ans[N];
for (int i = 0; i < N; i++) {
ans[i] = 0;
}
int p = 0, l = 0;
for (int i = 0; i < N - 1; i++) {
if (S[i] == 'R' && S[i + 1] == 'L') {
l = i - p;
if (l == 0) {
ans[i] += 1;
} else if (l % 2 == 0) {
ans[i] += l / 2 + 1;
ans[i + 1] += l / 2;
} else {
ans[i] += l / 2 + 1;
ans[i + 1] += l / 2 + 1;
}
p = i;
} else if (S[i] == 'L') {
p = i + 1;
}
}
p = N - 1;
for (int i = N - 1; i > 0; i--) {
if (S[i] == 'L' && S[i - 1] == 'R') {
l = p - i;
if (l == 0) {
ans[i] += 1;
} else if (l % 2 == 0) {
ans[i] += l / 2 + 1;
ans[i - 1] += l / 2;
} else {
ans[i] += l / 2 + 1;
ans[i - 1] += l / 2 + 1;
}
p = i;
} else if (S[i] == 'R') {
p = i - 1;
}
}
for (int i = 0; i < N; i++) {
cout << ans[i] << " ";
}
cout << endl;
}
| [
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change",
"io.output.change"
] | 758,262 | 758,261 | u154904553 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
string s;
cin >> s;
ll n = s.size();
vector<ll> num(n, 0);
for (ll i = 0; i < n - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
for (ll j = i; j >= 0 && s[j] == 'R'; j--) {
num[i + ((i - j) % 2 == 1)]++;
}
for (ll j = i + 1; j < n && s[j] == 'L'; j--) {
num[i + ((j - i) % 2 == 1)]++;
}
}
}
for (ll i = 0; i < n; i++) {
cout << num[i] << " ";
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
string s;
cin >> s;
ll n = s.size();
vector<ll> num(n, 0);
for (ll i = 0; i < n - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
for (ll j = i; j >= 0 && s[j] == 'R'; j--) {
num[i + ((i - j) % 2 == 1)]++;
}
for (ll j = i + 1; j < n && s[j] == 'L'; j++) {
num[i + ((j - i) % 2 == 1)]++;
}
}
}
for (ll i = 0; i < n; i++) {
cout << num[i] << " ";
}
} | [] | 758,267 | 758,268 | u191114518 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
ll ans[100010];
int main() {
string s;
cin >> s;
ll cnt = 0;
for (ll i = 0; i < s.size(); i++) {
if (s[i] == 'R') {
cnt++;
} else {
ans[i] = cnt / 2;
ans[i - 1] = (cnt + 2 - 1) / 2;
cnt = 0;
}
}
for (ll i = s.size() - 1; i >= 0; i--) {
if (s[i] == 'L') {
cnt++;
} else {
ans[i] += cnt / 2;
ans[i + 1] += (cnt + 2 - 1) / 2;
cnt = 0;
}
}
for (ll i = 0; i < s.size(); i++) {
cout << ans[i] << " ";
}
// your code goes here
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
ll ans[100010];
int main() {
string s;
cin >> s;
ll cnt = 0;
for (ll i = 0; i < s.size(); i++) {
if (s[i] == 'R') {
cnt++;
} else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 2 - 1) / 2;
cnt = 0;
}
}
for (ll i = s.size() - 1; i >= 0; i--) {
if (s[i] == 'L') {
cnt++;
} else {
ans[i] += cnt / 2;
ans[i + 1] += (cnt + 2 - 1) / 2;
cnt = 0;
}
}
for (ll i = 0; i < s.size(); i++) {
cout << ans[i] << " ";
}
// your code goes here
return 0;
} | [
"assignment.value.change"
] | 758,269 | 758,270 | u166378830 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
ll a[100010];
ll b[100010];
int main() {
string s;
cin >> s;
ll sum = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'R') {
sum++;
continue;
}
a[i - 1] = sum;
sum = 0;
}
for (int i = s.size() - 1; i >= 0; i--) {
if (s[i] == 'L') {
sum++;
continue;
}
if (s[i + 1] == 'L') {
a[i + 1] = sum;
sum = 0;
}
}
for (int i = 0; i < s.size() - 1; i++) {
if (a[i] != 0) {
b[i] = (a[i] + 2 - 1) / 2 + a[i + 1] / 2;
b[i + 1] = a[i] / 2 + (a[i + 1] + 2 - 1) / 2;
i++;
}
}
for (int i = 0; i < s.size(); i++) {
cout << b[i];
}
// your code goes here
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
ll a[100010];
ll b[100010];
int main() {
string s;
cin >> s;
ll sum = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'R') {
sum++;
continue;
}
a[i - 1] = sum;
sum = 0;
}
for (int i = s.size() - 1; i >= 0; i--) {
if (s[i] == 'L') {
sum++;
continue;
}
if (s[i + 1] == 'L') {
a[i + 1] = sum;
sum = 0;
}
}
for (int i = 0; i < s.size() - 1; i++) {
if (a[i] != 0) {
b[i] = (a[i] + 2 - 1) / 2 + a[i + 1] / 2;
b[i + 1] = a[i] / 2 + (a[i + 1] + 2 - 1) / 2;
i++;
}
}
for (int i = 0; i < s.size(); i++) {
cout << b[i] << " ";
}
// your code goes here
return 0;
} | [
"io.output.change"
] | 758,271 | 758,272 | u166378830 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, a, b, c, d, e, f, g, h, p, q, r, fr, sc, tr, sz, tz, i, j, k,
mx = LLONG_MIN, mn = LLONG_MAX;
long long x = 0, y = 0, cnt = 0, res = 0, ttl = 0, ans = 0, sum = 0;
long long flg = 0, flag = 1, na = 0, as = 1;
vector<long long> u, v, w;
vector<pair<long long, long long>> vct;
vector<string> vst;
set<long long> st, nt, tt;
map<long long, long long> mp, nq, qr;
string str, ttr, ntr;
// scanf("%lld",&n);
cin >> str;
sz = str.size();
for (i = 0; i < sz; i++) {
x++;
if (str[i] == 'L')
cnt++;
if (str[i] == 'L' && str[i + 1] == 'R') {
h = x / 2;
g = h;
if (x % 2 == 1)
g = h + 1;
if (cnt == 1)
swap(g, h);
for (j = y; j <= i; j++) {
if (str[j] == 'R' && str[j + 1] == 'L') {
printf("%lld ", g);
} else if (str[j] == 'L' && str[j - 1] == 'R') {
printf("%lld ", h);
} else {
printf("0 ");
}
}
y = i + 1;
x = 0;
cnt = 0;
}
}
h = x / 2;
g = h;
if (x % 2 == 1)
g = h + 1;
if (cnt == 1)
swap(g, h);
for (j = y; j < sz; j++) {
if (str[j] == 'R' && str[j + 1] == 'L') {
printf("%lld ", g);
} else if (str[j] == 'L' && str[j - 1] == 'R') {
printf("%lld ", h);
} else {
printf("0 ");
}
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, a, b, c, d, e, f, g, h, p, q, r, fr, sc, tr, sz, tz, i, j, k,
mx = LLONG_MIN, mn = LLONG_MAX;
long long x = 0, y = 0, cnt = 0, res = 0, ttl = 0, ans = 0, sum = 0;
long long flg = 0, flag = 1, na = 0, as = 1;
vector<long long> u, v, w;
vector<pair<long long, long long>> vct;
vector<string> vst;
set<long long> st, nt, tt;
map<long long, long long> mp, nq, qr;
string str, ttr, ntr;
// scanf("%lld",&n);
cin >> str;
sz = str.size();
for (i = 0; i < sz; i++) {
x++;
if (str[i] == 'L')
cnt++;
if (str[i] == 'L' && str[i + 1] == 'R') {
h = x / 2;
g = h;
if (x % 2 == 1)
g = h + 1;
if (cnt % 2 == 1)
swap(g, h);
for (j = y; j <= i; j++) {
if (str[j] == 'R' && str[j + 1] == 'L') {
printf("%lld ", g);
} else if (str[j] == 'L' && str[j - 1] == 'R') {
printf("%lld ", h);
} else {
printf("0 ");
}
}
y = i + 1;
x = 0;
cnt = 0;
}
}
h = x / 2;
g = h;
if (x % 2 == 1)
g = h + 1;
if (cnt % 2 == 1)
swap(g, h);
for (j = y; j < sz; j++) {
if (str[j] == 'R' && str[j + 1] == 'L') {
printf("%lld ", g);
} else if (str[j] == 'L' && str[j - 1] == 'R') {
printf("%lld ", h);
} else {
printf("0 ");
}
}
return 0;
}
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 758,276 | 758,277 | u053980422 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
// long long
using ll = long long;
//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
// begin() end()
#define all(x) (x).begin(), (x).end()
// for
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
//最大公約数
unsigned gcd(unsigned a, unsigned b) {
if (a < b)
return gcd(b, a);
unsigned r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
int main() {
string S;
cin >> S;
int N = S.size();
vector<int> ans(N);
int cnt = 0;
REP(j, 2) {
REP(i, N) {
if (S.at(i) = -'R')
cnt++;
else {
ans.at(i) += cnt / 2;
ans.at(i + 1) += (cnt + 1) / 2;
cnt = 0;
}
}
reverse(all(ans));
reverse(all(S));
REP(i, N) {
if (S.at(i) == 'L')
S.at(i) = 'R';
else
S.at(i) = 'L';
}
}
REP(i, N) cout << ans.at(i) << ' ';
} | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
// long long
using ll = long long;
//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
// begin() end()
#define all(x) (x).begin(), (x).end()
// for
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
//最大公約数
unsigned gcd(unsigned a, unsigned b) {
if (a < b)
return gcd(b, a);
unsigned r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
int main() {
string S;
cin >> S;
int N = S.size();
vector<int> ans(N);
int cnt = 0;
REP(j, 2) {
REP(i, N) {
if (S.at(i) == 'R')
cnt++;
else {
ans.at(i) += cnt / 2;
ans.at(i - 1) += (cnt + 1) / 2;
cnt = 0;
}
}
reverse(all(ans));
reverse(all(S));
REP(i, N) {
if (S.at(i) == 'L')
S.at(i) = 'R';
else
S.at(i) = 'L';
}
}
REP(i, N) cout << ans.at(i) << ' ';
} | [
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo",
"expression.operation.unary.arithmetic.remove",
"control_flow.branch.if.condition.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.variable.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 758,278 | 758,279 | u832995587 | cpp |
p02954 | #include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
using namespace std;
const int mm = 1e9;
int mp[100010], n;
string s;
int main() {
ios::sync_with_stdio(false);
cin >> s;
int len = s.size(), res = 0;
memset(mp, 0, sizeof mp);
for (int i = 0; i < len; i++) {
if (s[i] == 'R')
res++;
else if (s[i - 1] != 'L') {
if (res & 1) {
mp[i] += (res + 1) / 2;
mp[i - 1] += (res + 1) / 2;
} else {
mp[i] += (res / 2 + 1);
mp[i - 1] += (res / 2);
}
res = 0;
}
}
for (int i = len - 1; i > 0; i--) {
if (s[i] == 'L')
res++;
else {
if (res & 1) {
mp[i] += res / 2;
mp[i + 1] += res / 2;
} else {
mp[i] += res / 2;
mp[i + 1] += (res - 1) / 2;
}
res = 0;
}
}
for (int i = 0; i < len; i++)
printf("%d ", mp[i]);
return 0;
} | #include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
using namespace std;
const int mm = 1e9;
int mp[100010], n;
string s;
int main() {
ios::sync_with_stdio(false);
cin >> s;
int len = s.size(), res = 0;
memset(mp, 0, sizeof mp);
for (int i = 0; i < len; i++) {
if (s[i] == 'R')
res++;
else if (s[i - 1] != 'L') {
if (res & 1) {
mp[i] += (res + 1) / 2;
mp[i - 1] += (res + 1) / 2;
} else {
mp[i] += (res / 2 + 1);
mp[i - 1] += (res / 2);
}
res = 0;
}
}
for (int i = len - 1; i >= 0; i--) {
if (s[i] == 'L')
res++;
else {
if (res & 1) {
mp[i] += res / 2;
mp[i + 1] += res / 2;
} else {
mp[i] += res / 2;
mp[i + 1] += (res - 1) / 2;
}
res = 0;
}
}
for (int i = 0; i < len; i++)
printf("%d ", mp[i]);
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,282 | 758,283 | u018679195 | cpp |
p02954 | #include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
int main() {
string s;
cin >> s;
// 移動のステップ
vector<int> ans(s.size(), 0);
for (size_t i = 0; i < s.size(); i++) {
// L が出てくるまで進む
int l = 0;
while (s[i + l] != 'L') {
l++;
}
if (l == 0) {
continue;
}
for (int j = 0; j < l; j++) {
if (abs(l - j) % 2 == 0) {
ans[i + l]++;
} else {
ans[i + l - 1]++;
}
}
i += l;
}
for (size_t i = s.size() - 1; i > 0; i--) {
// R が出てくるまで進む
int r = 0;
while (s[i - r] != 'R') {
r++;
}
if (r == 0) {
continue;
}
for (int j = 0; j < r; j++) {
if (abs(r - j) % 2 == 0) {
ans[i - r]++;
} else {
ans[i - r + 1]++;
}
}
i -= r;
}
for (size_t i = 0; i < s.size(); i++) {
cout << ans[i];
if (i == s.size() - 1) {
cout << endl;
} else {
cout << " ";
}
}
} | #include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
int main() {
string s;
cin >> s;
// 移動のステップ
vector<int> ans(s.size(), 0);
for (int i = 0; i < s.size(); i++) {
// L が出てくるまで進む
int l = 0;
while (s[i + l] != 'L') {
l++;
}
if (l == 0) {
continue;
}
for (int j = 0; j < l; j++) {
if (abs(l - j) % 2 == 0) {
ans[i + l]++;
} else {
ans[i + l - 1]++;
}
}
i += l;
}
for (int i = s.size() - 1; i > 0; i--) {
// R が出てくるまで進む
int r = 0;
while (s[i - r] != 'R') {
r++;
}
if (r == 0) {
continue;
}
for (int j = 0; j < r; j++) {
if (abs(r - j) % 2 == 0) {
ans[i - r]++;
} else {
ans[i - r + 1]++;
}
}
i -= r;
}
for (size_t i = 0; i < s.size(); i++) {
cout << ans[i];
if (i == s.size() - 1) {
cout << endl;
} else {
cout << " ";
}
}
} | [
"control_flow.loop.for.initializer.change",
"variable_declaration.type.primitive.change"
] | 758,286 | 758,287 | u789199225 | cpp |
p02954 | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string s;
int i, idxR, idxL, cnt = 1;
cin >> s;
vector<int> v(s.length());
for (i = 1; i < s.length(); ++i) {
++cnt;
if (s[i - 1] == 'R' && s[i] == 'L') {
idxR = i - 1;
idxL = i;
v.at(i - 1) += cnt / 2;
v.at(i) += cnt - cnt / 2;
cnt = 0;
} else if (s[i - 1] == 'L' && s[i] == 'R') {
--cnt;
v.at(idxL) += cnt / 2;
v.at(idxR) += cnt - cnt / 2;
cnt = 1;
}
}
if (cnt > 0) {
--cnt;
v.at(idxL) += cnt / 2;
v.at(idxR) += cnt - cnt / 2;
}
for (i = 0; i < v.size(); ++i)
cout << v.at(i) << " ";
cout << endl;
return 0;
} | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string s;
int i, idxR, idxL, cnt = 1;
cin >> s;
vector<int> v(s.length());
for (i = 1; i < s.length(); ++i) {
++cnt;
if (s[i - 1] == 'R' && s[i] == 'L') {
idxR = i - 1;
idxL = i;
v.at(i - 1) += cnt / 2;
v.at(i) += cnt - cnt / 2;
cnt = 0;
} else if (s[i - 1] == 'L' && s[i] == 'R') {
--cnt;
v.at(idxL) += cnt / 2;
v.at(idxR) += cnt - cnt / 2;
cnt = 1;
}
}
if (cnt > 0) {
v.at(idxL) += cnt / 2;
v.at(idxR) += cnt - cnt / 2;
}
for (i = 0; i < v.size(); ++i)
cout << v.at(i) << " ";
cout << endl;
return 0;
} | [
"expression.unary.arithmetic.remove"
] | 758,294 | 758,295 | u714732628 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define boost \
ios::sync_with_stdio(false); \
cin.tie(nullptr)
#define int long long
#include "string"
int32_t main() {
boost;
string s;
cin >> s;
int n = s.size();
vector<int> dp(n, 0);
for (int i = 0; i < n;) {
int j = i;
while (j < n && s[i] == s[j])
j++;
if (s[i] == 'R')
dp[j - 1] = j - i;
else
dp[i] = j - i;
i = j;
}
int maxi = 0;
for (int i = 1; i < n; i++)
maxi = max(maxi, dp[i] + dp[i - 1]);
for (int i = 1; i < n; i++) {
if (s[i] != 'L' or s[i - 1] != 'R')
continue;
int sum = dp[i] + dp[i - 1];
if (sum % 2 == 0)
dp[i] = dp[i - 1] = sum / 2;
else {
if (maxi % 2 == 1) {
dp[i] = 1;
dp[i - 1] = 0;
} else {
dp[i - 1] = 1;
dp[i] = 0;
}
dp[i] += sum / 2;
dp[i - 1] += sum / 2;
}
}
for (int &i : dp)
cout << i << " ";
cout << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define boost \
ios::sync_with_stdio(false); \
cin.tie(nullptr)
#define int long long
#include "string"
int32_t main() {
boost;
string s;
cin >> s;
int n = s.size();
vector<int> dp(n, 0);
for (int i = 0; i < n;) {
int j = i;
while (j < n && s[i] == s[j])
j++;
if (s[i] == 'R')
dp[j - 1] = j - i;
else
dp[i] = j - i;
i = j;
}
int maxi = 0;
for (int i = 1; i < n; i++)
maxi = max(maxi, dp[i] + dp[i - 1]);
for (int i = 1; i < n; i++) {
if (s[i] != 'L' or s[i - 1] != 'R')
continue;
int sum = dp[i] + dp[i - 1];
if (sum % 2 == 0)
dp[i] = dp[i - 1] = sum / 2;
else {
if (dp[i] % 2 == 1) {
dp[i] = 1;
dp[i - 1] = 0;
} else {
dp[i - 1] = 1;
dp[i] = 0;
}
dp[i] += sum / 2;
dp[i - 1] += sum / 2;
}
}
for (int &i : dp)
cout << i << " ";
cout << endl;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 758,300 | 758,301 | u371555975 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
string s;
cin >> s;
int ans[s.size()]{};
for (int i = 1; i < s.size(); i++)
if (s.substr(i - 1, 2) == "RL") {
int j = i - 1;
while (0 <= j && s[j] == 'R') {
ans[i - 1 + (i - j) % 2]++;
j--;
}
j = i;
while (j < s.size() && s[j] == 'L') {
ans[i - (j - i) % 2]++;
j++;
}
i = j;
}
for (int i = 0; i < s.size(); i++) {
if (i != 0)
cout << ' ';
cout << ans[i];
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
string s;
cin >> s;
int ans[s.size()]{};
for (int i = 1; i < s.size(); i++)
if (s.substr(i - 1, 2) == "RL") {
int j = i - 1;
while (0 <= j && s[j] == 'R') {
ans[i - 1 + (i - 1 - j) % 2]++;
j--;
}
j = i;
while (j < s.size() && s[j] == 'L') {
ans[i - (j - i) % 2]++;
j++;
}
i = j;
}
for (int i = 0; i < s.size(); i++) {
if (i != 0)
cout << ' ';
cout << ans[i];
}
return 0;
} | [
"expression.operation.binary.add"
] | 758,306 | 758,307 | u804999113 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll>;
#define all(v) v.begin(), v.end()
int main() {
string S;
cin >> S;
vll ans(S.size(), 0);
ll left = 0, right = 0;
rep(i, S.size()) {
if (S[i] == 'L')
left++;
else
break;
}
rep(i, S.size()) {
if (S[S.size() - 1 - i] == 'R')
right++;
else
break;
}
ans[0] = left;
ans[S.size() - 1] = right;
//切り替わり点と区間
vector<pair<ll, pair<ll, ll>>> p;
int r_left = left, tmp = 0;
while (r_left + tmp < S.size() - right) {
while (S[r_left + tmp] == 'R') {
tmp++;
}
int r_right = r_left + tmp - 1;
tmp++;
while (S[r_left + tmp] == 'L') {
tmp++;
}
int l_right = r_left + tmp - 1;
p.push_back(make_pair(r_right, make_pair(r_left, l_right)));
r_left = l_right + 1;
tmp = 0;
}
// rep(i,p.size()) cout << p[i].first << p[i].second.first <<
// p[i].second.second << endl;
rep(i, p.size()) {
int rl = p[i].first;
int l = p[i].second.first, r = p[i].second.second;
ans[rl] =
(r - l + 1) / 2 + ((r - l + 1) % 2 == 1 && (rl - r) % 2 == 0 ? 1 : 0);
ans[rl + 1] = (r - l + 1) - ans[rl];
}
rep(i, S.size()) cout << ans[i];
cout << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll>;
#define all(v) v.begin(), v.end()
int main() {
string S;
cin >> S;
vll ans(S.size(), 0);
ll left = 0, right = 0;
rep(i, S.size()) {
if (S[i] == 'L')
left++;
else
break;
}
rep(i, S.size()) {
if (S[S.size() - 1 - i] == 'R')
right++;
else
break;
}
ans[0] = left;
ans[S.size() - 1] = right;
//切り替わり点と区間
vector<pair<ll, pair<ll, ll>>> p;
int r_left = left, tmp = 0;
while (r_left + tmp < S.size() - right) {
while (S[r_left + tmp] == 'R') {
tmp++;
}
int r_right = r_left + tmp - 1;
tmp++;
while (S[r_left + tmp] == 'L') {
tmp++;
}
int l_right = r_left + tmp - 1;
p.push_back(make_pair(r_right, make_pair(r_left, l_right)));
r_left = l_right + 1;
tmp = 0;
}
// rep(i,p.size()) cout << p[i].first << p[i].second.first <<
// p[i].second.second << endl;
rep(i, p.size()) {
int rl = p[i].first;
int l = p[i].second.first, r = p[i].second.second;
ans[rl] =
(r - l + 1) / 2 + ((r - l + 1) % 2 == 1 && (rl - r) % 2 == 0 ? 1 : 0);
ans[rl + 1] = (r - l + 1) - ans[rl];
}
rep(i, S.size()) cout << ans[i] << " ";
cout << endl;
} | [
"expression.operation.binary.add"
] | 758,313 | 758,314 | u883725898 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int N = s.size();
vector<int> A = {-1};
for (int i = 0; i < N - 1; i++) {
if (s.at(i) == 'L' && s.at(i + 1) == 'R')
A.push_back(i);
}
A.push_back(N - 1);
vector<int> B = {};
for (int i = 0; i < N - 1; i++) {
if (s.at(i) == 'R' && s.at(i) == 'L')
B.push_back(i);
}
map<int, int> M;
int n = B.size();
for (int i = 0; i < n; i++) {
int x = A.at(1 + i) - A.at(i);
if (x % 2 == 0) {
M[B.at(i)] = x / 2;
M[1 + B.at(i)] = x / 2;
} else {
if ((B.at(i) - A.at(i)) % 2 == 1) {
M[B.at(i)] = (x / 2) + 1;
M[1 + B.at(i)] = x / 2;
} else {
M[B.at(i)] = x / 2;
M[1 + B.at(i)] = (x / 2) + 1;
}
}
}
vector<int> Ans(N, 0);
for (int i = 0; i < N; i++) {
if (M.count(i))
Ans.at(i) = M.at(i);
}
for (int i = 0; i < N - 1; i++)
cout << Ans.at(i) << " ";
cout << Ans.at(N - 1) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int N = s.size();
vector<int> A = {-1};
for (int i = 0; i < N - 1; i++) {
if (s.at(i) == 'L' && s.at(i + 1) == 'R')
A.push_back(i);
}
A.push_back(N - 1);
vector<int> B = {};
for (int i = 0; i < N - 1; i++) {
if (s.at(i) == 'R' && s.at(i + 1) == 'L')
B.push_back(i);
}
map<int, int> M;
int n = B.size();
for (int i = 0; i < n; i++) {
int x = A.at(1 + i) - A.at(i);
if (x % 2 == 0) {
M[B.at(i)] = x / 2;
M[1 + B.at(i)] = x / 2;
} else {
if ((B.at(i) - A.at(i)) % 2 == 1) {
M[B.at(i)] = (x / 2) + 1;
M[1 + B.at(i)] = x / 2;
} else {
M[B.at(i)] = x / 2;
M[1 + B.at(i)] = (x / 2) + 1;
}
}
}
vector<int> Ans(N, 0);
for (int i = 0; i < N; i++) {
if (M.count(i))
Ans.at(i) = M.at(i);
}
for (int i = 0; i < N - 1; i++)
cout << Ans.at(i) << " ";
cout << Ans.at(N - 1) << endl;
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 758,328 | 758,329 | u101018317 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string S;
cin >> S;
int N = S.size();
vi is_lb(N, 0);
vi is_rb(N, 0);
vi is_lm(N, 0);
vi is_rm(N, 0);
for (int i = 0; i < N; i++)
if (i == 0 || (i > 1 && S.at(i) == 'R' && S.at(i - 1) == 'L'))
is_lb.at(i) = 1;
for (int i = 0; i < N; i++)
if (i == N - 1 || (i < N - 1 && S.at(i) == 'L' && S.at(i + 1) == 'R'))
is_rb.at(i) = 1;
for (int i = 0; i < N; i++)
if ((i < N - 1 && S.at(i) == 'R' && S.at(i + 1) == 'L'))
is_lm.at(i) = 1;
for (int i = 0; i < N; i++)
if ((i > 1 && S.at(i) == 'L' && S.at(i - 1) == 'R'))
is_rm.at(i) = 1;
vi count1(N, 0);
count1.at(0) = 1;
for (int i = 1; i < N; i++)
if (is_lb.at(i) == 0) {
count1.at(i) = count1.at(i - 1) + 1;
} else {
count1.at(i) = 1;
}
vi count2(N, 0);
count2.at(N - 1) = count1.at(N - 1);
int i = N - 1;
int tmp = count1.at(N - 1);
int idx = 0;
while (i > 0) {
if (count1.at(i) > count1.at(i - 1)) {
count2.at(i - 1) = count2.at(i);
} else {
count2.at(i - 1) = count1.at(i - 1);
}
i -= 1;
}
vi v_ans(N, 0);
for (int i = 0; i < N; i++) {
if (is_lm.at(i) == 1 || is_rm.at(i) == 1) {
if (count1.at(i) % 2 == 1) {
v_ans.at(i) = (count2.at(i) + 1) / 2;
} else {
v_ans.at(i) = (count2.at(i)) / 2;
}
}
}
for (int i = 0; i < N; i++)
cout << v_ans.at(i) << ' ';
cout << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string S;
cin >> S;
int N = S.size();
vi is_lb(N, 0);
vi is_rb(N, 0);
vi is_lm(N, 0);
vi is_rm(N, 0);
for (int i = 0; i < N; i++)
if (i == 0 || (i > 0 && S.at(i) == 'R' && S.at(i - 1) == 'L'))
is_lb.at(i) = 1;
for (int i = 0; i < N; i++)
if (i == N - 1 || (i < N - 1 && S.at(i) == 'L' && S.at(i + 1) == 'R'))
is_rb.at(i) = 1;
for (int i = 0; i < N; i++)
if ((i < N - 1 && S.at(i) == 'R' && S.at(i + 1) == 'L'))
is_lm.at(i) = 1;
for (int i = 0; i < N; i++)
if ((i > 0 && S.at(i) == 'L' && S.at(i - 1) == 'R'))
is_rm.at(i) = 1;
vi count1(N, 0);
count1.at(0) = 1;
for (int i = 1; i < N; i++)
if (is_lb.at(i) == 0) {
count1.at(i) = count1.at(i - 1) + 1;
} else {
count1.at(i) = 1;
}
vi count2(N, 0);
count2.at(N - 1) = count1.at(N - 1);
int i = N - 1;
int tmp = count1.at(N - 1);
int idx = 0;
while (i > 0) {
if (count1.at(i) > count1.at(i - 1)) {
count2.at(i - 1) = count2.at(i);
} else {
count2.at(i - 1) = count1.at(i - 1);
}
i -= 1;
}
vi v_ans(N, 0);
for (int i = 0; i < N; i++) {
if (is_lm.at(i) == 1 || is_rm.at(i) == 1) {
if (count1.at(i) % 2 == 1) {
v_ans.at(i) = (count2.at(i) + 1) / 2;
} else {
v_ans.at(i) = (count2.at(i)) / 2;
}
}
}
for (int i = 0; i < N; i++)
cout << v_ans.at(i) << ' ';
cout << endl;
} | [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 758,332 | 758,333 | u063962277 | cpp |
p02954 | #include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;
ll combination(ll n, ll r) {
if (n < r)
return 0;
if (r == 0 || r == n)
return 1;
else if (r == 1)
return n;
return (combination(n - 1, r - 1) + combination(n - 1, r));
}
bool checkKaibun(string str) {
string checkStr = str;
reverse(checkStr.begin(), checkStr.end());
if (str == checkStr)
return true;
else
return false;
}
int keta(ll num) {
int digits = 0;
while (num > 0) {
num /= 10;
digits++;
}
return digits;
}
ll mpow(ll x, ll n) { //繰り返し二乗法 計算量O(logN)
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % MOD;
x = x * x % MOD;
n = n >> 1;
}
return ans;
}
int gcd(int a, int b) {
if (a % b == 0)
return b;
else
return (gcd(b, a % b));
}
int main() {
string S;
cin >> S;
vector<int> Lindex, Rindex;
char formalC = 'R';
S.push_back('R');
rep(i, S.length()) {
if (formalC == 'L' && S[i] == 'R') {
Lindex.push_back(i - 1);
}
if (S[i] == 'R' && S[i + 1] == 'L') {
Rindex.push_back(i);
}
formalC = S[i];
}
vector<int> ans(S.length(), 0);
rep(i, Rindex.size()) {
int num = 0;
int index = Rindex[i];
while (index <= Lindex[i]) {
num++;
index += 2;
}
index = Rindex[i] - 2;
if (i != 0) {
while (index > Lindex[i - 1]) {
num++;
index -= 2;
}
} else {
while (index >= 0) {
num++;
index -= 2;
}
}
ans[Rindex[i]] = num;
int lnum = 0;
if (i != 0) {
lnum = Lindex[i] - Lindex[i - 1] - num;
} else {
lnum = Lindex[i] - num + 1;
}
ans[Rindex[i] + 1] = lnum;
// cout << "num: " << num << " lnum: " << lnum << endl;
}
rep(i, S.length() - 1) cout << ans[i];
cout << endl;
} | #include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;
ll combination(ll n, ll r) {
if (n < r)
return 0;
if (r == 0 || r == n)
return 1;
else if (r == 1)
return n;
return (combination(n - 1, r - 1) + combination(n - 1, r));
}
bool checkKaibun(string str) {
string checkStr = str;
reverse(checkStr.begin(), checkStr.end());
if (str == checkStr)
return true;
else
return false;
}
int keta(ll num) {
int digits = 0;
while (num > 0) {
num /= 10;
digits++;
}
return digits;
}
ll mpow(ll x, ll n) { //繰り返し二乗法 計算量O(logN)
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % MOD;
x = x * x % MOD;
n = n >> 1;
}
return ans;
}
int gcd(int a, int b) {
if (a % b == 0)
return b;
else
return (gcd(b, a % b));
}
int main() {
string S;
cin >> S;
vector<int> Lindex, Rindex;
char formalC = 'R';
S.push_back('R');
rep(i, S.length()) {
if (formalC == 'L' && S[i] == 'R') {
Lindex.push_back(i - 1);
}
if (S[i] == 'R' && S[i + 1] == 'L') {
Rindex.push_back(i);
}
formalC = S[i];
}
vector<int> ans(S.length(), 0);
rep(i, Rindex.size()) {
int num = 0;
int index = Rindex[i];
while (index <= Lindex[i]) {
num++;
index += 2;
}
index = Rindex[i] - 2;
if (i != 0) {
while (index > Lindex[i - 1]) {
num++;
index -= 2;
}
} else {
while (index >= 0) {
num++;
index -= 2;
}
}
ans[Rindex[i]] = num;
int lnum = 0;
if (i != 0) {
lnum = Lindex[i] - Lindex[i - 1] - num;
} else {
lnum = Lindex[i] - num + 1;
}
ans[Rindex[i] + 1] = lnum;
// cout << "num: " << num << " lnum: " << lnum << endl;
}
rep(i, S.length() - 1) cout << ans[i] << " ";
cout << endl;
} | [
"expression.operation.binary.add"
] | 758,334 | 758,335 | u750466050 | cpp |
p02954 | #include <iostream>
#include <map>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
int main() {
string S;
cin >> S;
int len = S.size();
map<int, int> mii;
int mode = 1; // right:0 left:1
int cnt[2];
int kiPos = 0, guPos = 0;
cnt[0] = 0;
cnt[1] = 1;
rep(i, len) {
if (mode == 1) {
if (S[i] == 'R') {
mii[guPos] = cnt[0];
mii[kiPos] = cnt[1];
cnt[0] = 0;
cnt[1] = 0;
mode = 0;
}
++cnt[i % 2];
} else {
if (S[i] == 'L') {
if (i % 2) { // 奇数
kiPos = i;
guPos = i - 1;
} else { // 偶数
guPos = i;
kiPos = i - 1;
}
mode = 1;
}
++cnt[i % 2];
}
}
mii[guPos] = cnt[0];
mii[kiPos] = cnt[1];
rep(i, len) { cout << mii[i] << " "; }
cout << "\n";
return 0;
}
| #include <iostream>
#include <map>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
int main() {
string S;
cin >> S;
int len = S.size();
map<int, int> mii;
int mode = 1; // right:0 left:1
int cnt[2];
int kiPos = 0, guPos = 0;
cnt[0] = 0;
cnt[1] = 0;
rep(i, len) {
if (mode == 1) {
if (S[i] == 'R') {
mii[guPos] = cnt[0];
mii[kiPos] = cnt[1];
cnt[0] = 0;
cnt[1] = 0;
mode = 0;
}
++cnt[i % 2];
} else {
if (S[i] == 'L') {
if (i % 2) { // 奇数
kiPos = i;
guPos = i - 1;
} else { // 偶数
guPos = i;
kiPos = i - 1;
}
mode = 1;
}
++cnt[i % 2];
}
}
mii[guPos] = cnt[0];
mii[kiPos] = cnt[1];
rep(i, len) { cout << mii[i] << " "; }
cout << "\n";
return 0;
}
| [
"literal.number.change",
"assignment.value.change"
] | 758,336 | 758,337 | u202260176 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N - 1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)
using ll = long long;
using namespace std;
int main() {
string S;
cin >> S;
int N = S.length();
vector<int> A(N, 0);
int i = 0;
while (i < N) {
int R_cnt = 1;
for (int j = i + 1; j < N - 1; j++) {
if (S[j] == 'R') {
R_cnt++;
} else {
break;
}
}
A[i + R_cnt - 1] += (R_cnt + 1) / 2;
A[i + R_cnt] += R_cnt - (R_cnt + 1) / 2;
int L_cnt = 1;
for (int j = i + R_cnt + 1; j < N - 1; j++) {
if (S[j] == 'L') {
L_cnt++;
} else {
break;
}
}
A[i + R_cnt - 1] += L_cnt - (L_cnt + 1) / 2;
A[i + R_cnt] += (L_cnt + 1) / 2;
i += R_cnt + L_cnt;
}
rep(i, N) cout << A[i] << ' ';
}
| #include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N - 1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)
using ll = long long;
using namespace std;
int main() {
string S;
cin >> S;
int N = S.length();
vector<int> A(N, 0);
int i = 0;
while (i < N) {
int R_cnt = 1;
for (int j = i + 1; j < N - 1; j++) {
if (S[j] == 'R') {
R_cnt++;
} else {
break;
}
}
A[i + R_cnt - 1] += (R_cnt + 1) / 2;
A[i + R_cnt] += R_cnt - (R_cnt + 1) / 2;
int L_cnt = 1;
for (int j = i + R_cnt + 1; j < N; j++) {
if (S[j] == 'L') {
L_cnt++;
} else {
break;
}
}
A[i + R_cnt - 1] += L_cnt - (L_cnt + 1) / 2;
A[i + R_cnt] += (L_cnt + 1) / 2;
i += R_cnt + L_cnt;
}
rep(i, N) cout << A[i] << ' ';
}
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 758,342 | 758,343 | u099619676 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
string S;
cin >> S;
int size = S.size();
vector<int> ans(size + 1, 0);
int count = 1;
int tmp = 0;
S = S + 'a';
for (int i = 1; i <= size; i++) {
if (S[i - 1] != S[i] || i == size) {
if (S[i] == 'L') {
if (count % 2 == 0) {
ans[i - 1] = ans[i - 1] + count / 2;
ans[i] = ans[i] + count / 2;
} else {
ans[i - 1] = ans[i - 1] + (count + 1) / 2;
ans[i] = ans[i] + (count - 1) / 2;
}
} else { // S[i]=='R'
if (count % 2 == 0) {
ans[tmp - 1] = ans[tmp - 1] + count / 2;
ans[tmp] = ans[tmp] + count / 2;
} else {
ans[tmp - 1] = ans[tmp - 1] + (count - 1) / 2;
ans[tmp] = ans[tmp] + (count + 1) / 2;
}
}
count = 1;
tmp = i; // tmpに記号が変わる時のインデックス代入
} else { // S[i-1]==S[i]
count++;
}
}
for (int i = 0; i < size; i++) {
cout << ans[i];
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
string S;
cin >> S;
int size = S.size();
vector<int> ans(size + 1, 0);
int count = 1;
int tmp = 0;
S = S + 'a';
for (int i = 1; i <= size; i++) {
if (S[i - 1] != S[i] || i == size) {
if (S[i] == 'L') {
if (count % 2 == 0) {
ans[i - 1] = ans[i - 1] + count / 2;
ans[i] = ans[i] + count / 2;
} else {
ans[i - 1] = ans[i - 1] + (count + 1) / 2;
ans[i] = ans[i] + (count - 1) / 2;
}
} else { // S[i]=='R'
if (count % 2 == 0) {
ans[tmp - 1] = ans[tmp - 1] + count / 2;
ans[tmp] = ans[tmp] + count / 2;
} else {
ans[tmp - 1] = ans[tmp - 1] + (count - 1) / 2;
ans[tmp] = ans[tmp] + (count + 1) / 2;
}
}
count = 1;
tmp = i; // tmpに記号が変わる時のインデックス代入
} else { // S[i-1]==S[i]
count++;
}
}
for (int i = 0; i < size; i++) {
cout << ans[i] << ' ';
}
return 0;
} | [
"io.output.change"
] | 758,349 | 758,350 | u231455327 | cpp |
p02954 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
int main() {
string s;
cin >> s;
int n = s.size();
int ans[n] = {0};
repi(ri, 2, 0) {
{ // solve
int cnt = 0;
repi(i, n, 0) {
if (s[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
}
reverse(ans, ans + n);
reverse(s.begin(), s.end());
repi(i, n, 0) {
if (s[i] == 'L')
s[i] == 'R';
else
s[i] == 'L';
}
}
repi(i, n, 0) { cout << ans[i] << ((i + 1) % n ? " " : "\n"); }
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
int main() {
string s;
cin >> s;
int n = s.size();
int ans[n] = {0};
repi(ri, 2, 0) {
{ // solve
int cnt = 0;
repi(i, n, 0) {
if (s[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
}
reverse(ans, ans + n);
reverse(s.begin(), s.end());
repi(i, n, 0) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
repi(i, n, 0) { cout << ans[i] << ((i + 1) % n ? " " : "\n"); }
return 0;
} | [
"expression.operation.compare.replace.remove",
"assignment.replace.add",
"misc.typo"
] | 758,357 | 758,358 | u187013893 | cpp |
p02954 | // INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
// DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a) (a).begin(), (a).end()
#define ALL(a, n) (a), (a) + n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
// CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
// REPEAT
//------------------------------------------
#define FOR(i, m, n) for (ll(i) = (m); (i) < (n); (i)++)
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define REPS(i, x) for (ll(i) = 1; (i) <= (x); (i)++)
#define RREP(i, x) for (ll(i) = (x)-1; (i) >= 0; (i)--)
#define RREPS(i, x) for (ll(i) = (x); (i) > 0; (i)--)
#define WREP(i, in, j, jn) REP(i, in) REP(j, jn)
//-----------------------------------------
#define dcml(n) fixed << setprecision(n)
using namespace std;
typedef pair<ll, ll> P;
int main(void) {
string S;
cin >> S;
ll N = S.size();
//ランレングス圧縮
vector<P> v;
for (ll i = 0, n1 = 0, n2 = 0; i < N; n1 = n2 = 0) {
while (S[i] == 'R')
n1++, i++;
while (S[i] == 'L')
n2++, i++;
v.push_back(make_pair(n1, n2));
}
/*//結果の確認
for(auto r:v){
cout<<'R'<<r.first<<'L'<<r.second;
}cout<<"\n";*/
ll ans[N];
REP(i, N) ans[i] = 0;
ll n = 0;
for (auto r : v) {
ll len = r.first + r.second;
ll idxR = n + r.first - 1, idxL = idxR + 1;
if (len % 2 == 0) { //文字数が偶数
ans[idxR] = ans[idxL] = len / 2;
} else if (len % 2 == 1) { //文字数が奇数
if (r.first > r.second && r.second == 1) { // lの長さ>rの長さ=1
ans[idxR] = (len - 1) / 2, ans[idxL] = (len + 1) / 2;
} else if (r.first == 1 && r.first < r.second) { // lの長さ=1<rの長さ
ans[idxR] = (len + 1) / 2, ans[idxL] = (len - 1) / 2;
} else if (r.first < r.second) { // lの長さ<rの長さ
ans[idxR] = (len - 1) / 2, ans[idxL] = (len + 1) / 2;
} else if (r.first > r.second) { // lの長さ>rの長さ
ans[idxR] = (len + 1) / 2, ans[idxL] = (len - 1) / 2;
}
}
n += len;
}
REP(i, N) { cout << ans[i] << " "; }
cout << "\n";
}
| // INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
// DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a) (a).begin(), (a).end()
#define ALL(a, n) (a), (a) + n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
// CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
// REPEAT
//------------------------------------------
#define FOR(i, m, n) for (ll(i) = (m); (i) < (n); (i)++)
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define REPS(i, x) for (ll(i) = 1; (i) <= (x); (i)++)
#define RREP(i, x) for (ll(i) = (x)-1; (i) >= 0; (i)--)
#define RREPS(i, x) for (ll(i) = (x); (i) > 0; (i)--)
#define WREP(i, in, j, jn) REP(i, in) REP(j, jn)
//-----------------------------------------
#define dcml(n) fixed << setprecision(n)
using namespace std;
typedef pair<ll, ll> P;
int main(void) {
string S;
cin >> S;
ll N = S.size();
//ランレングス圧縮
vector<P> v;
for (ll i = 0, n1 = 0, n2 = 0; i < N; n1 = n2 = 0) {
while (S[i] == 'R')
n1++, i++;
while (S[i] == 'L')
n2++, i++;
v.push_back(make_pair(n1, n2));
}
/*//結果の確認
for(auto r:v){
cout<<'R'<<r.first<<'L'<<r.second;
}cout<<"\n";*/
ll ans[N];
REP(i, N) ans[i] = 0;
ll n = 0;
for (auto r : v) {
ll len = r.first + r.second;
ll idxR = n + r.first - 1, idxL = idxR + 1;
if (len % 2 == 0) { //文字数が偶数
ans[idxR] = ans[idxL] = len / 2;
} else if (len % 2 == 1) { //文字数が奇数
if (r.first > r.second && r.second % 2 == 1) { // lの長さ>rの長さ=1
ans[idxR] = (len - 1) / 2, ans[idxL] = (len + 1) / 2;
} else if (r.first % 2 == 1 && r.first < r.second) { // lの長さ=1<rの長さ
ans[idxR] = (len + 1) / 2, ans[idxL] = (len - 1) / 2;
} else if (r.first < r.second) { // lの長さ<rの長さ
ans[idxR] = (len - 1) / 2, ans[idxL] = (len + 1) / 2;
} else if (r.first > r.second) { // lの長さ>rの長さ
ans[idxR] = (len + 1) / 2, ans[idxL] = (len - 1) / 2;
}
}
n += len;
}
REP(i, N) { cout << ans[i] << " "; }
cout << "\n";
}
| [
"control_flow.branch.if.condition.change"
] | 758,361 | 758,362 | u334644046 | cpp |
p02954 | #include <bits/stdc++.h>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
rep(i, (int)v.size()) {
if (i)
os << ",";
os << v[i];
}
os << "}";
return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
for (auto val : array)
std::cout << val << ", ";
std::cout << "\n";
}
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(10);
string s;
std::cin >> s;
int n = s.size();
vector<ll> ans(n);
rep(i, n) {
int ni = i;
while (ni + 1 < n && s[i] == s[ni + 1])
ni++;
ll cnt = ni - i + 1;
if (s[i] == 'L') {
ans[i] += (cnt + 1) / 2;
if (i - 1 > 0)
ans[i - 1] += cnt / 2;
else
ans[i] += cnt / 2;
} else {
ans[ni] += (cnt + 1) / 2;
if (ni + 1 < n)
ans[ni + 1] += cnt / 2;
else
ans[ni] += cnt / 2;
}
i = ni;
}
rep(i, n) std::cout << ans[i] << (i + 1 < n ? " " : "\n");
}
| #include <bits/stdc++.h>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
rep(i, (int)v.size()) {
if (i)
os << ",";
os << v[i];
}
os << "}";
return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
for (auto val : array)
std::cout << val << ", ";
std::cout << "\n";
}
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(10);
string s;
std::cin >> s;
int n = s.size();
vi ans(n);
rep(i, n) {
int ni = i;
while (ni + 1 < n && s[i] == s[ni + 1])
ni++;
int cnt = ni - i + 1;
if (s[i] == 'L') {
ans[i] += (cnt + 1) / 2;
if (i - 1 >= 0)
ans[i - 1] += cnt / 2;
else
ans[i] += cnt / 2;
} else {
ans[ni] += (cnt + 1) / 2;
if (ni + 1 < n)
ans[ni + 1] += cnt / 2;
else
ans[ni] += cnt / 2;
}
i = ni;
}
rep(i, n) std::cout << ans[i] << (i + 1 < n ? " " : "\n");
}
| [
"variable_declaration.type.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,366 | 758,367 | u700484101 | cpp |
p02954 | #include <bits/stdc++.h>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
rep(i, (int)v.size()) {
if (i)
os << ",";
os << v[i];
}
os << "}";
return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
for (auto val : array)
std::cout << val << ", ";
std::cout << "\n";
}
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(10);
string s;
std::cin >> s;
int n = s.size();
vi ans(n);
rep(i, n) {
int ni = i;
while (ni + 1 < n && s[i] == s[ni + 1])
ni++;
int cnt = ni - i + 1;
if (s[i] == 'L') {
ans[i] += (cnt + 1) / 2;
if (i - 1 > 0)
ans[i - 1] += cnt / 2;
else
ans[i] += cnt / 2;
} else {
ans[ni] += (cnt + 1) / 2;
if (ni + 1 < n)
ans[ni + 1] += cnt / 2;
else
ans[ni] += cnt / 2;
}
i = ni;
}
rep(i, n) std::cout << ans[i] << (i + 1 < n ? " " : "\n");
}
| #include <bits/stdc++.h>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
rep(i, (int)v.size()) {
if (i)
os << ",";
os << v[i];
}
os << "}";
return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
for (auto val : array)
std::cout << val << ", ";
std::cout << "\n";
}
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(10);
string s;
std::cin >> s;
int n = s.size();
vi ans(n);
rep(i, n) {
int ni = i;
while (ni + 1 < n && s[i] == s[ni + 1])
ni++;
int cnt = ni - i + 1;
if (s[i] == 'L') {
ans[i] += (cnt + 1) / 2;
if (i - 1 >= 0)
ans[i - 1] += cnt / 2;
else
ans[i] += cnt / 2;
} else {
ans[ni] += (cnt + 1) / 2;
if (ni + 1 < n)
ans[ni + 1] += cnt / 2;
else
ans[ni] += cnt / 2;
}
i = ni;
}
rep(i, n) std::cout << ans[i] << (i + 1 < n ? " " : "\n");
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,368 | 758,367 | u700484101 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
for (int i = 0; i < n; i++)
ans[i] = 0;
char left = 'R';
int num = 1;
int i = 1;
int x;
while (i < n) {
if (left == 'R') {
if (s[i] == left)
num++;
else {
ans[i] += num / 2;
if (num % 2 == 0)
ans[i - 1] += num / 2;
else
ans[i - 1] += num / 2 + 1;
if (i == n - 1) {
ans[n - 1] = 1;
}
left = 'L';
num = 1;
x = i;
}
} else {
if (s[i] == left) {
num++;
if (i == n - 1) {
ans[x - 1] += num / 2;
if (num % 2 == 0)
ans[x] += num / 2;
else
ans[x] += num / 2 + 1;
}
} else {
ans[x - 1] += num / 2;
if (num % 2 == 0)
ans[x] += num / 2;
else
ans[x] += num / 2 + 1;
left = 'R';
num = 1;
}
}
i++;
}
for (int i = 0; i < n; i++)
cout << ans[i] << " ";
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
for (int i = 0; i < n; i++)
ans[i] = 0;
char left = 'R';
int num = 1;
int i = 1;
int x;
while (i < n) {
if (left == 'R') {
if (s[i] == left)
num++;
else {
ans[i] += num / 2;
if (num % 2 == 0)
ans[i - 1] += num / 2;
else
ans[i - 1] += num / 2 + 1;
if (i == n - 1) {
ans[n - 1] += 1;
}
left = 'L';
num = 1;
x = i;
}
} else {
if (s[i] == left) {
num++;
if (i == n - 1) {
ans[x - 1] += num / 2;
if (num % 2 == 0)
ans[x] += num / 2;
else
ans[x] += num / 2 + 1;
}
} else {
ans[x - 1] += num / 2;
if (num % 2 == 0)
ans[x] += num / 2;
else
ans[x] += num / 2 + 1;
left = 'R';
num = 1;
}
}
i++;
}
for (int i = 0; i < n; i++)
cout << ans[i] << " ";
}
| [
"assignment.value.change"
] | 758,371 | 758,372 | u105533331 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;
int main() {
ll a, b, c, d, n;
string s;
in(s);
n = s.size();
vector<ll> t(n, 0);
a = 0;
while (a < n) {
c = a;
while (s[c + 1] == 'R')
c++;
b = c;
while (s[b + 1] == 'L')
b++;
if ((b - a + 1) / 2 == 0)
t[c] = t[c + 1] = (b - a + 1) / 2;
else {
if ((c - a) / 2 == 0) {
t[c] = (b - a + 1) / 2 + 1;
t[c + 1] = t[c] - 1;
} else {
t[c] = (b - a + 1) / 2;
t[c + 1] = t[c] + 1;
}
}
a = b + 1;
}
rep(i, n) {
out(t[i]);
hina;
}
memi;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;
int main() {
ll a, b, c, d, n;
string s;
in(s);
n = s.size();
vector<ll> t(n, 0);
a = 0;
while (a < n) {
c = a;
while (s[c + 1] == 'R')
c++;
b = c;
while (s[b + 1] == 'L')
b++;
if ((b - a + 1) % 2 == 0)
t[c] = t[c + 1] = (b - a + 1) / 2;
else {
if ((c - a) % 2 == 0) {
t[c] = (b - a + 1) / 2 + 1;
t[c + 1] = t[c] - 1;
} else {
t[c] = (b - a + 1) / 2;
t[c + 1] = t[c] + 1;
}
}
a = b + 1;
}
rep(i, n) {
out(t[i]);
hina;
}
memi;
}
| [
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change"
] | 758,381 | 758,382 | u917049698 | cpp |
p02954 | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
// #define int long long
// #define double long double
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i < (int)(n); ++i)
#define repeq(i, n) for (int i = 0; i <= (int)(n); ++i)
#define rep1eq(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n)-1; i > 0; --i)
#define rrepeq(i, n) for (int i = (int)(n); i >= 0; --i)
#define rrep1eq(i, n) for (int i = (int)(n); i > 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template <typename T> using Graph = vector<vector<T>>;
template <typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <typename T> struct is_pair : false_type {};
template <typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type {};
template <typename T> struct is_vector : false_type {};
template <typename T> struct is_vector<vector<T>> : true_type {};
template <typename T1, typename T2>
istream &operator>>(istream &istr, pair<T1, T2> &p) {
istr >> p.first >> p.second;
return istr;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &ostr, const pair<T1, T2> &p) {
ostr << p.first << " " << p.second;
return ostr;
}
template <typename T> istream &operator>>(istream &istr, vector<T> &vec) {
for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
istr >> *itr;
}
return istr;
}
template <typename T> ostream &operator<<(ostream &ostr, const vector<T> &vec) {
if (vec.empty())
return ostr;
bool vp = is_vector<T>() || is_pair<T>();
ostr << vec.front();
for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
ostr << (vp ? "\n" : " ") << *itr;
}
return ostr;
}
bool CoutYN(bool a, string y = "Yes", string n = "No") {
cout << (a ? y : n) << "\n";
return a;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
int modpow(int a, long long n, int mod = MOD) {
int ret = 1;
do {
if (n & 1)
ret = 1LL * ret * a % mod;
a = 1LL * a * a % mod;
} while (n >>= 1);
return ret;
}
template <typename T> T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template <typename T> T LCM(T a, T b) { return a / GCD(a, b) * b; }
template <typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template <typename T> bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
if (a.first * b.first < 0)
return a.first < b.first;
if (a.first == 0)
return a.second >= 0 || b.first > 0;
if (b.first == 0)
return b.second < 0 && a.first < 0;
return a.second * b.first < a.first * b.second;
}
/* -------- <templates end> -------- */
void solve() {
string s;
cin >> s;
vi border(1, 0);
rep1(i, s.size()) {
if (s[i] != s[i - 1]) {
border.emplace_back(i);
}
}
border.emplace_back(s.size() - 1);
vi ans(s.size());
rep1(i, border.size()) {
int dist = border[i] - border[i - 1];
int tmp = dist / 2;
if (i & 1) {
ans[border[i]] += tmp;
ans[border[i] - 1] += dist - tmp;
} else {
ans[border[i - 1] - 1] += tmp;
ans[border[i - 1]] += dist - tmp;
}
}
cout << ans << endl;
}
/* -------- <programs end> -------- */
signed main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(12);
solve();
return 0;
}
| #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
// #define int long long
// #define double long double
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i < (int)(n); ++i)
#define repeq(i, n) for (int i = 0; i <= (int)(n); ++i)
#define rep1eq(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n)-1; i > 0; --i)
#define rrepeq(i, n) for (int i = (int)(n); i >= 0; --i)
#define rrep1eq(i, n) for (int i = (int)(n); i > 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template <typename T> using Graph = vector<vector<T>>;
template <typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <typename T> struct is_pair : false_type {};
template <typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type {};
template <typename T> struct is_vector : false_type {};
template <typename T> struct is_vector<vector<T>> : true_type {};
template <typename T1, typename T2>
istream &operator>>(istream &istr, pair<T1, T2> &p) {
istr >> p.first >> p.second;
return istr;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &ostr, const pair<T1, T2> &p) {
ostr << p.first << " " << p.second;
return ostr;
}
template <typename T> istream &operator>>(istream &istr, vector<T> &vec) {
for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
istr >> *itr;
}
return istr;
}
template <typename T> ostream &operator<<(ostream &ostr, const vector<T> &vec) {
if (vec.empty())
return ostr;
bool vp = is_vector<T>() || is_pair<T>();
ostr << vec.front();
for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
ostr << (vp ? "\n" : " ") << *itr;
}
return ostr;
}
bool CoutYN(bool a, string y = "Yes", string n = "No") {
cout << (a ? y : n) << "\n";
return a;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
int modpow(int a, long long n, int mod = MOD) {
int ret = 1;
do {
if (n & 1)
ret = 1LL * ret * a % mod;
a = 1LL * a * a % mod;
} while (n >>= 1);
return ret;
}
template <typename T> T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template <typename T> T LCM(T a, T b) { return a / GCD(a, b) * b; }
template <typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template <typename T> bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
if (a.first * b.first < 0)
return a.first < b.first;
if (a.first == 0)
return a.second >= 0 || b.first > 0;
if (b.first == 0)
return b.second < 0 && a.first < 0;
return a.second * b.first < a.first * b.second;
}
/* -------- <templates end> -------- */
void solve() {
string s;
cin >> s;
vi border(1, 0);
rep1(i, s.size()) {
if (s[i] != s[i - 1]) {
border.emplace_back(i);
}
}
border.emplace_back(s.size());
vi ans(s.size());
rep1(i, border.size()) {
int dist = border[i] - border[i - 1];
int tmp = dist / 2;
if (i & 1) {
ans[border[i]] += tmp;
ans[border[i] - 1] += dist - tmp;
} else {
ans[border[i - 1] - 1] += tmp;
ans[border[i - 1]] += dist - tmp;
}
}
cout << ans << endl;
}
/* -------- <programs end> -------- */
signed main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(12);
solve();
return 0;
}
| [
"expression.operation.binary.remove"
] | 758,390 | 758,391 | u104057163 | cpp |
p02954 | // AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか?
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int n = s.size();
vector<int> ans(n, 0);
int odd = 0, even = 0;
rep(i, n - 1) {
if (s[i] == 'R') {
if (i % 2)
odd++;
else
even++;
} else {
if (i % 2) {
ans[i - 1] += even;
ans[i] += odd;
} else {
ans[i - 1] += odd;
ans[i] += even;
}
odd = even = 0;
}
}
rep(i, n - 1) {
if (s[n - i - 1] == 'L') {
if ((n - i - 1) % 2)
odd++;
else
even++;
} else {
if ((n - i - 1) % 2) {
ans[n - i] += even;
ans[n - i - 1] += odd;
} else {
ans[n - i] += odd;
ans[n - i - 1] += even;
}
odd = even = 0;
}
}
rep(i, n) cout << ans[i] << " ";
} | // AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか?
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int n = s.size();
vector<int> ans(n, 0);
int odd = 0, even = 0;
rep(i, n) {
if (s[i] == 'R') {
if (i % 2)
odd++;
else
even++;
} else {
if (i % 2) {
ans[i - 1] += even;
ans[i] += odd;
} else {
ans[i - 1] += odd;
ans[i] += even;
}
odd = even = 0;
}
}
rep(i, n) {
if (s[n - i - 1] == 'L') {
if ((n - i - 1) % 2)
odd++;
else
even++;
} else {
if ((n - i - 1) % 2) {
ans[n - i] += even;
ans[n - i - 1] += odd;
} else {
ans[n - i] += odd;
ans[n - i - 1] += even;
}
odd = even = 0;
}
}
rep(i, n) cout << ans[i] << " ";
} | [
"expression.operation.binary.remove"
] | 758,394 | 758,395 | u083190434 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 1001001001;
const int MOD = 1e9 + 7;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
string s;
cin >> s;
int n;
n = s.size();
vector<int> ans(n);
rep(ri, 0, 2) {
{
int cnt = 0;
rep(i, 0, n) {
if (s[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i] += (cnt + 1) / 2;
cnt = 0;
}
}
}
reverse(ans.begin(), ans.end());
reverse(s.begin(), s.end());
rep(i, 0, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, 0, n) { printf("%d%c", ans[i], i != n - 1 ? ' ' : '\n'); }
return 0;
} | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 1001001001;
const int MOD = 1e9 + 7;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
string s;
cin >> s;
int n;
n = s.size();
vector<int> ans(n);
rep(ri, 0, 2) {
{
int cnt = 0;
rep(i, 0, n) {
if (s[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
}
reverse(ans.begin(), ans.end());
reverse(s.begin(), s.end());
rep(i, 0, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, 0, n) { printf("%d%c", ans[i], i != n - 1 ? ' ' : '\n'); }
return 0;
} | [
"assignment.change"
] | 758,406 | 758,407 | u748577909 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
for (int i = 0; i < S.size();) {
int x = i;
while (S.at(i + 1) == 'R') {
cout << "0 ";
i++;
}
int y = i;
while (i < S.size() - 1 && S.at(i + 1) == 'L')
i++;
cout << (y - x + 2) / 2 + (i - y) / 2 << " "
<< (y - x + 1) / 2 + (i - y + 1) / 2;
for (; y <= i; y++)
cout << " 0";
if (i != S.size() - 1)
cout << " ";
i++;
}
cout << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
for (int i = 0; i < S.size();) {
int x = i;
while (S.at(i + 1) == 'R') {
cout << "0 ";
i++;
}
int y = i;
while (i < S.size() - 1 && S.at(i + 1) == 'L')
i++;
cout << (y - x + 2) / 2 + (i - y) / 2 << " "
<< (y - x + 1) / 2 + (i - y + 1) / 2;
for (y += 2; y <= i; y++)
cout << " 0";
if (i != S.size() - 1)
cout << " ";
i++;
}
cout << endl;
} | [
"control_flow.loop.for.initializer.change",
"assignment.change"
] | 758,415 | 758,416 | u820224016 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> v;
int count = 0;
char tmp = 'R';
for (int i = 0; i < n; i++) {
if (tmp == s.at(i))
count++;
else {
tmp = s.at(i);
v.push_back(count);
count = 1;
}
}
v.push_back(count);
int t = 0;
vector<int> ans(n + 1);
for (int i = 0; i < v.size(); i += 2) {
int left = v.at(i);
int right = v.at(i + 1);
int sum = left + right;
t += left;
if ((left % 2) == 1)
ans.at(t) = (sum + 1) / 2;
else
ans.at(t) = sum / 2;
if ((right % 2) == 1)
ans.at(t + 1) = (sum + 1) / 2;
else
ans.at(t + 1) = sum / 2;
t += right;
}
for (int i = 1; i < n + 1; i++) {
cout << ans.at(i);
}
cout << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> v;
int count = 0;
char tmp = 'R';
for (int i = 0; i < n; i++) {
if (tmp == s.at(i))
count++;
else {
tmp = s.at(i);
v.push_back(count);
count = 1;
}
}
v.push_back(count);
int t = 0;
vector<int> ans(n + 1);
for (int i = 0; i < v.size(); i += 2) {
int left = v.at(i);
int right = v.at(i + 1);
int sum = left + right;
t += left;
if ((left % 2) == 1)
ans.at(t) = (sum + 1) / 2;
else
ans.at(t) = sum / 2;
if ((right % 2) == 1)
ans.at(t + 1) = (sum + 1) / 2;
else
ans.at(t + 1) = sum / 2;
t += right;
}
for (int i = 1; i < n + 1; i++) {
cout << ans.at(i) << " ";
}
cout << endl;
return 0;
} | [
"io.output.change"
] | 758,422 | 758,423 | u013069672 | cpp |
p02954 | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
typedef long long ll;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> last(n);
int R_count = 1;
int L_count;
int r;
int l;
for (int i = 0; i < n - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'R')
R_count++;
if (s[i] == 'R' && s[i + 1] == 'L') {
L_count = 1;
r = i + 1;
l = i;
}
if (s[i] == 'L' && s[i + 1] == 'L')
L_count++;
if (s[i] == 'L' && s[i + 1] == 'R') {
last[l] = R_count / 2 + (L_count - L_count / 2);
last[r] = L_count / 2 + (R_count - R_count / 2);
R_count = 1;
}
}
last[l] = R_count / 2 + (L_count - L_count / 2);
last[r] = L_count / 2 + (R_count - R_count / 2);
for (int i = 0; i < n - 1; i++)
cout << last[i] << " ";
cout << last[n - 1] << endl;
}
| //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
typedef long long ll;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> last(n);
int R_count = 1;
int L_count;
int r;
int l;
for (int i = 0; i < n - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'R')
R_count++;
if (s[i] == 'R' && s[i + 1] == 'L') {
L_count = 1;
r = i + 1;
l = i;
}
if (s[i] == 'L' && s[i + 1] == 'L')
L_count++;
if (s[i] == 'L' && s[i + 1] == 'R') {
last[r] = R_count / 2 + (L_count - L_count / 2);
last[l] = L_count / 2 + (R_count - R_count / 2);
R_count = 1;
}
}
last[r] = R_count / 2 + (L_count - L_count / 2);
last[l] = L_count / 2 + (R_count - R_count / 2);
for (int i = 0; i < n - 1; i++)
cout << last[i] << " ";
cout << last[n - 1] << endl;
}
| [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 758,428 | 758,429 | u614128939 | cpp |
p02954 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(), greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(), (X).end()
#ifdef __LOCAL
#define DBG(X) cout << #X << " = " << (X) << endl;
#define SAY(X) cout << (X) << endl;
#else
#define DBG(X)
#define SAY(X)
#endif
#ifdef __LOCAL
#include <filesystem>
namespace fs = std::filesystem;
#endif
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int dx[] = {1, 0, -1, 0, 0};
int dy[] = {0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
std::string pad(int num) {
char buffer[4];
std::snprintf(buffer, sizeof(buffer), "%03d", num);
return buffer;
}
inline ll randint(ll a, ll b) {
ll w = (_g() << 31LL) ^ _g();
return a + w % (b - a + 1);
}
inline void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
};
template <typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template <typename T, typename S>
inline ostream &operator<<(ostream &os, const pair<T, S> p) {
cout << "[" << p.first << ";" << p.second << "]";
return os;
}
template <typename T>
inline ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto el : v)
cout << el << " ";
return os;
}
template <typename T> inline T fetch() {
T ret;
cin >> ret;
return ret;
}
template <typename T> inline vector<T> fetch_vec(int sz) {
vector<T> ret(sz);
for (auto &elem : ret)
cin >> elem;
return ret;
}
string S;
void input() {
fast_io();
#ifdef __LOCAL
fs::path p = __FILE__;
fs::path input, output;
input = output = p.parent_path();
input += string("/input/") + string(p.stem()) + string(".txt");
output += string("/output/") + string(p.stem()) + string(".txt");
freopen(input.c_str(), "r", stdin);
freopen(output.c_str(), "w", stdout);
#endif
cin >> S;
}
// 帰納的に答えを算出。
// 最悪O(N^2)なのでNが大きいとTLEになる。
int inductive_solve() {
int N = S.size();
vector<int> X(N, 1);
map<vector<int>, int> C;
C[X]++;
int I;
REP(i, N + 10) {
vector<int> tmp(N, 0);
REP(i, N) {
if (S[i] == 'R')
tmp[i + 1] += X[i];
if (S[i] == 'L')
tmp[i - 1] += X[i];
}
X = tmp;
C[X]++;
if (C[X] > 1) {
I = i + 1;
break;
}
DBG(X)
}
if (I % 2 == 0)
cout << X << endl;
else {
vector<int> tmp(N, 0);
REP(i, N) {
if (S[i] == 'R')
tmp[i + 1] += X[i];
if (S[i] == 'L')
tmp[i - 1] += X[i];
}
X = tmp;
cout << X << endl;
}
return 0;
}
int solve() {
int N = S.size();
vector<int> X(N, 0);
int sum;
sum = 0;
for (int i = 0; i < N; i++) {
if (S[i] == 'R')
sum++;
else {
X[i - 1] += sum;
sum = 0;
}
}
sum = 0;
for (int i = (N - 1); i > 0; i--) {
if (S[i] == 'L')
sum++;
else {
X[i + 1] += sum;
sum = 0;
}
}
DBG(X)
vector<int> Y(N, 0);
REP(i, N - 1) {
if (X[i] == 0)
continue;
else {
Y[i] = (X[i] + 1) / 2 + X[i + 1] / 2;
Y[i + 1] = X[i] / 2 + (X[i + 1] + 1) / 2;
i++;
}
}
DBG(Y)
cout << Y << endl;
return 0;
}
int main() {
input();
solve();
return 0;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(), greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(), (X).end()
#ifdef __LOCAL
#define DBG(X) cout << #X << " = " << (X) << endl;
#define SAY(X) cout << (X) << endl;
#else
#define DBG(X)
#define SAY(X)
#endif
#ifdef __LOCAL
#include <filesystem>
namespace fs = std::filesystem;
#endif
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int dx[] = {1, 0, -1, 0, 0};
int dy[] = {0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
std::string pad(int num) {
char buffer[4];
std::snprintf(buffer, sizeof(buffer), "%03d", num);
return buffer;
}
inline ll randint(ll a, ll b) {
ll w = (_g() << 31LL) ^ _g();
return a + w % (b - a + 1);
}
inline void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
};
template <typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template <typename T, typename S>
inline ostream &operator<<(ostream &os, const pair<T, S> p) {
cout << "[" << p.first << ";" << p.second << "]";
return os;
}
template <typename T>
inline ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto el : v)
cout << el << " ";
return os;
}
template <typename T> inline T fetch() {
T ret;
cin >> ret;
return ret;
}
template <typename T> inline vector<T> fetch_vec(int sz) {
vector<T> ret(sz);
for (auto &elem : ret)
cin >> elem;
return ret;
}
string S;
void input() {
fast_io();
#ifdef __LOCAL
fs::path p = __FILE__;
fs::path input, output;
input = output = p.parent_path();
input += string("/input/") + string(p.stem()) + string(".txt");
output += string("/output/") + string(p.stem()) + string(".txt");
freopen(input.c_str(), "r", stdin);
freopen(output.c_str(), "w", stdout);
#endif
cin >> S;
}
// 帰納的に答えを算出。
// 最悪O(N^2)なのでNが大きいとTLEになる。
int inductive_solve() {
int N = S.size();
vector<int> X(N, 1);
map<vector<int>, int> C;
C[X]++;
int I;
REP(i, N + 10) {
vector<int> tmp(N, 0);
REP(i, N) {
if (S[i] == 'R')
tmp[i + 1] += X[i];
if (S[i] == 'L')
tmp[i - 1] += X[i];
}
X = tmp;
C[X]++;
if (C[X] > 1) {
I = i + 1;
break;
}
DBG(X)
}
if (I % 2 == 0)
cout << X << endl;
else {
vector<int> tmp(N, 0);
REP(i, N) {
if (S[i] == 'R')
tmp[i + 1] += X[i];
if (S[i] == 'L')
tmp[i - 1] += X[i];
}
X = tmp;
cout << X << endl;
}
return 0;
}
int solve() {
int N = S.size();
vector<int> X(N, 0);
int sum;
sum = 0;
for (int i = 0; i < N; i++) {
if (S[i] == 'R')
sum++;
else {
X[i - 1] += sum;
sum = 0;
}
}
sum = 0;
for (int i = (N - 1); i >= 0; i--) {
if (S[i] == 'L')
sum++;
else {
X[i + 1] += sum;
sum = 0;
}
}
DBG(X)
vector<int> Y(N, 0);
REP(i, N - 1) {
if (X[i] == 0)
continue;
else {
Y[i] = (X[i] + 1) / 2 + X[i + 1] / 2;
Y[i + 1] = X[i] / 2 + (X[i + 1] + 1) / 2;
i++;
}
}
DBG(Y)
cout << Y << endl;
return 0;
}
int main() {
input();
solve();
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,430 | 758,431 | u858670323 | cpp |
p02954 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <stdio.h>
#include <vector>
using namespace std;
#define int long long
#define rep(s, i, n) for (int i = s; i < n; i++)
#define c(n) cout << n << endl;
#define ic(n) \
int n; \
cin >> n;
#define sc(s) \
string s; \
cin >> s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c, a, b) *min_element(c + a, c + b)
#define maxi(c, a, b) *max_element(c + a, c + b)
// printf("%.12Lf\n",c);
int keta(int x) {
rep(0, i, 30) {
if (x < 10) {
return i + 1;
}
x = x / 10;
}
}
int gcd(int x, int y) {
int aa = x, bb = y;
rep(0, i, 1000) {
aa = aa % bb;
if (aa == 0) {
return bb;
}
bb = bb % aa;
if (bb == 0) {
return aa;
}
}
}
int lcm(int x, int y) {
int aa = x, bb = y;
rep(0, i, 1000) {
aa = aa % bb;
if (aa == 0) {
return x / bb * y;
}
bb = bb % aa;
if (bb == 0) {
return x / aa * y;
}
}
}
bool p(int x) {
if (x == 1)
return false;
rep(2, i, sqrt(x) + 1) {
if (x % i == 0 && x != i) {
return false;
}
}
return true;
}
int primes[200];
int prime[1000000];
int pr[100000];
int el[314514], wl[314514];
int er[314514], wr[314514];
int a[114514];
string s[214514];
int b[214514], c[214514];
int ans[214514];
signed main() {
sc(s) int n = s.size();
int sum = 1;
rep(0, i, n) {
if (s[i] == s[i + 1])
sum++;
else {
a[i] = sum;
sum = 1;
}
}
sum = 0;
rep(0, i, n) {
if (a[i] > 0) {
b[sum] = i;
c[sum] = a[i];
sum++;
}
}
rep(0, i, sum) {
if (i % 2 == 0) {
if (c[i] % 2 == 0 && c[i + 1] % 2 == 1) {
ans[b[i]] = (c[i] + c[i + 1]) / 2;
ans[b[i + 1]] = (c[i] + c[i + 1] + 1) / 2;
} else {
ans[b[i]] = (c[i] + c[i + 1] + 1) / 2;
ans[b[i] + 1] = (c[i] + c[i + 1]) / 2;
}
}
}
rep(0, i, n) { cout << ans[i] << " "; }
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <stdio.h>
#include <vector>
using namespace std;
#define int long long
#define rep(s, i, n) for (int i = s; i < n; i++)
#define c(n) cout << n << endl;
#define ic(n) \
int n; \
cin >> n;
#define sc(s) \
string s; \
cin >> s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c, a, b) *min_element(c + a, c + b)
#define maxi(c, a, b) *max_element(c + a, c + b)
// printf("%.12Lf\n",c);
int keta(int x) {
rep(0, i, 30) {
if (x < 10) {
return i + 1;
}
x = x / 10;
}
}
int gcd(int x, int y) {
int aa = x, bb = y;
rep(0, i, 1000) {
aa = aa % bb;
if (aa == 0) {
return bb;
}
bb = bb % aa;
if (bb == 0) {
return aa;
}
}
}
int lcm(int x, int y) {
int aa = x, bb = y;
rep(0, i, 1000) {
aa = aa % bb;
if (aa == 0) {
return x / bb * y;
}
bb = bb % aa;
if (bb == 0) {
return x / aa * y;
}
}
}
bool p(int x) {
if (x == 1)
return false;
rep(2, i, sqrt(x) + 1) {
if (x % i == 0 && x != i) {
return false;
}
}
return true;
}
int primes[200];
int prime[1000000];
int pr[100000];
int el[314514], wl[314514];
int er[314514], wr[314514];
int a[114514];
string s[214514];
int b[214514], c[214514];
int ans[214514];
signed main() {
sc(s) int n = s.size();
int sum = 1;
rep(0, i, n) {
if (s[i] == s[i + 1])
sum++;
else {
a[i] = sum;
sum = 1;
}
}
sum = 0;
rep(0, i, n) {
if (a[i] > 0) {
b[sum] = i;
c[sum] = a[i];
sum++;
}
}
rep(0, i, sum) {
if (i % 2 == 0) {
if (c[i] % 2 == 0 && c[i + 1] % 2 == 1) {
ans[b[i]] = (c[i] + c[i + 1]) / 2;
ans[b[i] + 1] = (c[i] + c[i + 1] + 1) / 2;
} else {
ans[b[i]] = (c[i] + c[i + 1] + 1) / 2;
ans[b[i] + 1] = (c[i] + c[i + 1]) / 2;
}
}
}
rep(0, i, n) { cout << ans[i] << " "; }
} | [] | 758,438 | 758,439 | u942393279 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(A) sort(A.begin(), A.end())
#define reverse(A) reverse(A.begin(), A.end())
typedef long long ll;
int main() {
string S;
cin >> S;
int n;
n = S.size();
vector<int> ans(n);
int cnt = 0;
rep(i, n) {
if (S[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
cnt = 0;
for (int i = n - 1; i > 0; i--) {
if (S[i] == 'L')
cnt++;
else {
ans[i] += cnt / 2;
ans[i + 1] += (cnt + 1) / 2;
cnt = 0;
}
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(A) sort(A.begin(), A.end())
#define reverse(A) reverse(A.begin(), A.end())
typedef long long ll;
int main() {
string S;
cin >> S;
int n;
n = S.size();
vector<int> ans(n);
int cnt = 0;
rep(i, n) {
if (S[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
cnt = 0;
for (int i = n - 1; i >= 0; i--) {
if (S[i] == 'L')
cnt++;
else {
ans[i] += cnt / 2;
ans[i + 1] += (cnt + 1) / 2;
cnt = 0;
}
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,451 | 758,452 | u132364782 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(A) sort(A.begin(), A.end())
#define reverse(A) reverse(A.begin(), A.end())
typedef long long ll;
int main() {
string S;
cin >> S;
int n;
n = S.size();
vector<int> ans(n);
int cnt = 0;
rep(i, n) {
if (S[i] == 'R')
cnt++;
else {
ans[i] = cnt / 2;
ans[i - 1] = (cnt + 1) / 2;
cnt = 0;
}
}
cnt = 0;
for (int i = n - 1; i > 0; i--) {
if (S[i] == 'L')
cnt++;
else {
ans[i] += cnt / 2;
ans[i + 1] += (cnt + 1) / 2;
cnt = 0;
}
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(A) sort(A.begin(), A.end())
#define reverse(A) reverse(A.begin(), A.end())
typedef long long ll;
int main() {
string S;
cin >> S;
int n;
n = S.size();
vector<int> ans(n);
int cnt = 0;
rep(i, n) {
if (S[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
cnt = 0;
for (int i = n - 1; i >= 0; i--) {
if (S[i] == 'L')
cnt++;
else {
ans[i] += cnt / 2;
ans[i + 1] += (cnt + 1) / 2;
cnt = 0;
}
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
} | [
"assignment.value.change",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,453 | 758,452 | u132364782 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(A) sort(A.begin(), A.end())
#define reverse(A) reverse(A.begin(), A.end())
typedef long long ll;
int main() {
string S;
cin >> S;
int n;
n = S.size();
vector<int> ans(n);
int cnt = 0;
rep(i, n) {
if (S[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
cnt = 0;
for (int i = n - 1; i > 0; i--) {
if (S[i] == 'L')
cnt++;
else {
ans[i] += cnt / 2;
ans[i + 1] += (cnt + 1) / 2;
cnt = 0;
}
}
rep(i, n) cout << ans[i];
cout << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(A) sort(A.begin(), A.end())
#define reverse(A) reverse(A.begin(), A.end())
typedef long long ll;
int main() {
string S;
cin >> S;
int n;
n = S.size();
vector<int> ans(n);
int cnt = 0;
rep(i, n) {
if (S[i] == 'R')
cnt++;
else {
ans[i] += cnt / 2;
ans[i - 1] += (cnt + 1) / 2;
cnt = 0;
}
}
cnt = 0;
for (int i = n - 1; i >= 0; i--) {
if (S[i] == 'L')
cnt++;
else {
ans[i] += cnt / 2;
ans[i + 1] += (cnt + 1) / 2;
cnt = 0;
}
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,454 | 758,452 | u132364782 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (int i = (int)(j); i < (int)(n); i++)
#define REP(i, j, n) for (int i = (int)(j); i <= (int)(n); i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(), (a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int, int>
#define priq priority_queue<int>
#define disup(A, key) distance(A.begin(), upper_bound(ALL(A), (int)(key)))
#define dislow(A, key) distance(A.begin(), lower_bound(ALL(A), (int)(key)))
#define tii tuple<int, int, int>
signed main() {
string S;
cin >> S;
int N = S.size();
int count = 1;
vi ans(N);
int memoL, memoR;
rep(i, 1, N) {
if (S[i] == 'L') {
if (S[i - 1] == 'L')
count++;
else {
ans[i - 1] += count / 2;
ans[i] += count - count / 2;
count = 1;
memoR = i;
memoL = i - 1;
}
} else {
if (S[i - 1] == 'R')
count++;
else {
ans[memoL] += count / 2;
ans[memoR] += count - count / 2;
count = 1;
}
}
}
ans[memoL] += count / 2;
ans[memoR] += count - count / 2;
rep(i, 0, N) cout << ans[i] << " ";
cout << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (int i = (int)(j); i < (int)(n); i++)
#define REP(i, j, n) for (int i = (int)(j); i <= (int)(n); i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(), (a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int, int>
#define priq priority_queue<int>
#define disup(A, key) distance(A.begin(), upper_bound(ALL(A), (int)(key)))
#define dislow(A, key) distance(A.begin(), lower_bound(ALL(A), (int)(key)))
#define tii tuple<int, int, int>
signed main() {
string S;
cin >> S;
int N = S.size();
int count = 1;
vi ans(N);
int memoL, memoR;
rep(i, 1, N) {
if (S[i] == 'L') {
if (S[i - 1] == 'L')
count++;
else {
ans[i] += count / 2;
ans[i - 1] += count - count / 2;
count = 1;
memoR = i;
memoL = i - 1;
}
} else {
if (S[i - 1] == 'R')
count++;
else {
ans[memoL] += count / 2;
ans[memoR] += count - count / 2;
count = 1;
}
}
}
ans[memoL] += count / 2;
ans[memoR] += count - count / 2;
rep(i, 0, N) cout << ans[i] << " ";
cout << endl;
}
| [
"expression.operation.binary.remove",
"assignment.change"
] | 758,466 | 758,467 | u347057617 | cpp |
p02954 | #define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(), (a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i, j, k) mkp(i, mkp(j, k))
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) \
sort(all((b))); \
(b).erase(unique(all((b))), (b).end())
#define ssp(i, n) (i == n - 1 ? "\n" : " ")
#define tpop(p) \
p.top(); \
p.pop()
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
ll u, k = scanf("%lld", &u);
return u;
}
ll gcd(ll i, ll j) {
if (i > j)
swap(i, j);
if (i == 0)
return j;
return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x % p;
x = x * x % p;
n >>= 1;
}
return res;
}
ll bitcount(ll x) {
int sum = 0;
for (int i = 0; i < 20; i++)
if ((1ll << i) & x)
sum++;
return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
if (!fact_[0]) {
fact_[0] = 1; comp_[0] = 1;
for (int i = 1; i < fn_; i++) {
fact_[i] = fact_[i - 1] * i % Mod;
comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
}
}
if (x < y) return 0;
return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
int n;
string s;
signed main() {
cin >> s;
n = s.size();
for (int i = 0; i < n;) {
if (!(s[i] == 'R' && s[i + 1] == 'L')) {
cout << 0 << ssp(i, n);
i++;
continue;
}
int j = i, x = i + 1;
while (j >= 0 && s[j] == 'R')
j--;
while (x < n && s[x] == 'L')
x++;
cout << ceil((i - j) / 2.) + (x - i - 1) / 2 << ssp(i, n);
cout << ceil((i - j) / 2) + ceil((x - i - 1) / 2.) << ssp(i + 1, n);
i++;
}
} | #define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(), (a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i, j, k) mkp(i, mkp(j, k))
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) \
sort(all((b))); \
(b).erase(unique(all((b))), (b).end())
#define ssp(i, n) (i == n - 1 ? "\n" : " ")
#define tpop(p) \
p.top(); \
p.pop()
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
ll u, k = scanf("%lld", &u);
return u;
}
ll gcd(ll i, ll j) {
if (i > j)
swap(i, j);
if (i == 0)
return j;
return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x % p;
x = x * x % p;
n >>= 1;
}
return res;
}
ll bitcount(ll x) {
int sum = 0;
for (int i = 0; i < 20; i++)
if ((1ll << i) & x)
sum++;
return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
if (!fact_[0]) {
fact_[0] = 1; comp_[0] = 1;
for (int i = 1; i < fn_; i++) {
fact_[i] = fact_[i - 1] * i % Mod;
comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
}
}
if (x < y) return 0;
return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
int n;
string s;
signed main() {
cin >> s;
n = s.size();
for (int i = 0; i < n;) {
if (!(s[i] == 'R' && s[i + 1] == 'L')) {
cout << 0 << ssp(i, n);
i++;
continue;
}
int j = i, x = i + 1;
while (j >= 0 && s[j] == 'R')
j--;
while (x < n && s[x] == 'L')
x++;
cout << ceil((i - j) / 2.) + (x - i - 1) / 2 << ssp(i, n);
cout << ceil((i - j) / 2) + ceil((x - i - 1) / 2.) << ssp(i + 1, n);
i += 2;
}
} | [] | 758,470 | 758,471 | u811004127 | cpp |
p02954 | #define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(), (a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i, j, k) mkp(i, mkp(j, k))
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) \
sort(all((b))); \
(b).erase(unique(all((b))), (b).end())
#define ssp(i, n) (i == n - 1 ? "\n" : " ")
#define tpop(p) \
p.top(); \
p.pop()
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
ll u, k = scanf("%lld", &u);
return u;
}
ll gcd(ll i, ll j) {
if (i > j)
swap(i, j);
if (i == 0)
return j;
return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x % p;
x = x * x % p;
n >>= 1;
}
return res;
}
ll bitcount(ll x) {
int sum = 0;
for (int i = 0; i < 20; i++)
if ((1ll << i) & x)
sum++;
return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
if (!fact_[0]) {
fact_[0] = 1; comp_[0] = 1;
for (int i = 1; i < fn_; i++) {
fact_[i] = fact_[i - 1] * i % Mod;
comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
}
}
if (x < y) return 0;
return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
int n;
string s;
signed main() {
cin >> s;
n = s.size();
for (int i = 0; i < n;) {
if (!(s[i] == 'R' && s[i + 1] == 'L')) {
cout << 0 << ssp(i, n);
i++;
continue;
}
int j = i, x = i + 1;
while (j >= 0 && s[j] == 'R')
j--;
while (x < n && s[x] == 'L')
x++;
cout << ceil((i - j) / 2.) + (x - i - 1) / 2 << ssp(i, n);
cout << ceil((i - j) / 2) + ceil((x - i - 1) / 2.) << ssp(i + 1, n);
i = x;
}
} | #define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(), (a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i, j, k) mkp(i, mkp(j, k))
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) \
sort(all((b))); \
(b).erase(unique(all((b))), (b).end())
#define ssp(i, n) (i == n - 1 ? "\n" : " ")
#define tpop(p) \
p.top(); \
p.pop()
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
ll u, k = scanf("%lld", &u);
return u;
}
ll gcd(ll i, ll j) {
if (i > j)
swap(i, j);
if (i == 0)
return j;
return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x % p;
x = x * x % p;
n >>= 1;
}
return res;
}
ll bitcount(ll x) {
int sum = 0;
for (int i = 0; i < 20; i++)
if ((1ll << i) & x)
sum++;
return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
if (!fact_[0]) {
fact_[0] = 1; comp_[0] = 1;
for (int i = 1; i < fn_; i++) {
fact_[i] = fact_[i - 1] * i % Mod;
comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
}
}
if (x < y) return 0;
return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
int n;
string s;
signed main() {
cin >> s;
n = s.size();
for (int i = 0; i < n;) {
if (!(s[i] == 'R' && s[i + 1] == 'L')) {
cout << 0 << ssp(i, n);
i++;
continue;
}
int j = i, x = i + 1;
while (j >= 0 && s[j] == 'R')
j--;
while (x < n && s[x] == 'L')
x++;
cout << ceil((i - j) / 2.) + (x - i - 1) / 2 << ssp(i, n);
cout << ceil((i - j) / 2) + ceil((x - i - 1) / 2.) << ssp(i + 1, n);
i += 2;
}
} | [
"assignment.change"
] | 758,472 | 758,471 | u811004127 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.