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 |
|---|---|---|---|---|---|---|---|
p02954 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
string S;
cin >> S;
int ans[100010] = {0};
bool lcount = false;
bool rcount = true;
int r = 0;
int l = 0;
int nowR = 0;
for (int i = 0; i < S.length(); i++) {
if (rcount == true && S[i] == 'R')
r++;
else if (rcount == true && S[i] == 'L') {
lcount = true;
rcount = false;
l++;
nowR = i - 1;
} else if (lcount == true && S[i] == 'R') {
if (r % 2 == 1) {
ans[nowR] += r / 2 + 1;
ans[nowR + 1] += r / 2;
} else {
ans[nowR] += r / 2;
ans[nowR + 1] += r / 2;
}
if (l % 2 == 1) {
ans[nowR] += l / 2;
ans[nowR + 1] += l / 2 + 1;
} else {
ans[nowR] += l / 2;
ans[nowR + 1] += l / 2;
}
r = 0;
l = 0;
rcount = true;
lcount = false;
r++;
} else
l++;
}
if (r % 2 == 1) {
ans[nowR] += r / 2 + 1;
ans[nowR + 1] += r / 2;
} else {
ans[nowR] += r / 2;
ans[nowR + 1] += r / 2;
}
if (l % 2 == 1) {
ans[nowR] += l / 2;
ans[nowR + 1] += l / 2 + 1;
} else {
ans[nowR] += l / 2;
ans[nowR + 1] += l / 2;
}
for (int i = 0; i < S.length(); i++) {
cout << ans[i];
}
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
string S;
cin >> S;
int ans[100010] = {0};
bool lcount = false;
bool rcount = true;
int r = 0;
int l = 0;
int nowR = 0;
for (int i = 0; i < S.length(); i++) {
if (rcount == true && S[i] == 'R')
r++;
else if (rcount == true && S[i] == 'L') {
lcount = true;
rcount = false;
l++;
nowR = i - 1;
} else if (lcount == true && S[i] == 'R') {
if (r % 2 == 1) {
ans[nowR] += r / 2 + 1;
ans[nowR + 1] += r / 2;
} else {
ans[nowR] += r / 2;
ans[nowR + 1] += r / 2;
}
if (l % 2 == 1) {
ans[nowR] += l / 2;
ans[nowR + 1] += l / 2 + 1;
} else {
ans[nowR] += l / 2;
ans[nowR + 1] += l / 2;
}
r = 0;
l = 0;
rcount = true;
lcount = false;
r++;
} else
l++;
}
if (r % 2 == 1) {
ans[nowR] += r / 2 + 1;
ans[nowR + 1] += r / 2;
} else {
ans[nowR] += r / 2;
ans[nowR + 1] += r / 2;
}
if (l % 2 == 1) {
ans[nowR] += l / 2;
ans[nowR + 1] += l / 2 + 1;
} else {
ans[nowR] += l / 2;
ans[nowR + 1] += l / 2;
}
for (int i = 0; i < S.length(); i++) {
cout << ans[i] << " ";
}
} | [
"io.output.change"
] | 758,475 | 758,476 | u582357587 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define maxn 200010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
int ans[maxn], arr[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
string str;
cin >> str;
int n = str.length();
int curr = 0;
for (int i = 0; i < n; ++i)
arr[i] = 1;
for (int i = 1; i < n; ++i) {
if (str[i] == 'R')
curr = i;
else {
int dis = i - curr;
if (dis & 1)
ans[curr + 1] += arr[i];
else
ans[curr] += arr[i];
}
}
int curl = 0;
for (int i = n - 2; i >= 0; --i) {
if (str[i] == 'L')
curl = i;
else {
int dis = curl - i;
if (dis & 1)
ans[curl - 1] += arr[i];
else
ans[curl] += arr[i];
}
}
for (int i = 0; i < n; ++i)
cout << ans[i] << " ";
cout << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define maxn 200010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
int ans[maxn], arr[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
string str;
cin >> str;
int n = str.length();
int curr = 0;
for (int i = 0; i < n; ++i)
arr[i] = 1;
for (int i = 1; i < n; ++i) {
if (str[i] == 'R')
curr = i;
else {
int dis = i - curr;
if (dis & 1)
ans[curr + 1] += arr[i];
else
ans[curr] += arr[i];
}
}
int curl = n - 1;
for (int i = n - 2; i >= 0; --i) {
if (str[i] == 'L')
curl = i;
else {
int dis = curl - i;
if (dis & 1)
ans[curl - 1] += arr[i];
else
ans[curl] += arr[i];
}
}
for (int i = 0; i < n; ++i)
cout << ans[i] << " ";
cout << endl;
}
| [
"identifier.replace.add",
"literal.replace.remove"
] | 758,480 | 758,481 | u225649725 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long(i) = 0; (i) < (n); (i)++)
#define ll long long
#define pr_qu priority_queue
#define vec(name, size, common) vector<ll>(name)((size), (common))
int main() {
string s;
cin >> s;
vector<ll> a(s.size(), 0);
char m;
ll mc, co = 0;
for (ll i = 0; i < s.size(); i++) {
if (i == 0) {
m = s.at(i);
mc = i;
co++;
} else {
if (m != s.at(i)) {
if (s.at(i) == 'R') {
a.at(mc) = co;
co = 1;
m = s.at(i);
} else {
a.at(i - 1) = co;
co = 1;
m = s.at(i);
mc = i;
}
} else {
co++;
}
}
if (i == (s.size() - 1)) {
a.at(mc) = co;
}
}
ll l = 0, r = 0, d;
for (ll i = 2; i < s.size(); i++) {
l = 0;
r = 0;
if (d == i) {
continue;
} else {
if (a.at(i - 1) != 0) {
l += a.at(i - 1) - (a.at(i - 1) / 2);
l += a.at(i) / 2;
r += a.at(i - 1) / 2;
r += a.at(i) - (a.at(i) / 2);
a.at(i - 1) = l;
a.at(i) = r;
d = i + 1;
}
}
}
for (ll i = 0; i < s.size(); i++) {
cout << a.at(i) << " ";
}
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long(i) = 0; (i) < (n); (i)++)
#define ll long long
#define pr_qu priority_queue
#define vec(name, size, common) vector<ll>(name)((size), (common))
int main() {
string s;
cin >> s;
vector<ll> a(s.size(), 0);
char m;
ll mc, co = 0;
for (ll i = 0; i < s.size(); i++) {
if (i == 0) {
m = s.at(i);
mc = i;
co++;
} else {
if (m != s.at(i)) {
if (s.at(i) == 'R') {
a.at(mc) = co;
co = 1;
m = s.at(i);
} else {
a.at(i - 1) = co;
co = 1;
m = s.at(i);
mc = i;
}
} else {
co++;
}
}
if (i == (s.size() - 1)) {
a.at(mc) = co;
}
}
ll l = 0, r = 0, d;
for (ll i = 1; i < s.size(); i++) {
l = 0;
r = 0;
if (d == i) {
continue;
} else {
if (a.at(i - 1) != 0) {
l += a.at(i - 1) - (a.at(i - 1) / 2);
l += a.at(i) / 2;
r += a.at(i - 1) / 2;
r += a.at(i) - (a.at(i) / 2);
a.at(i - 1) = l;
a.at(i) = r;
d = i + 1;
}
}
}
for (ll i = 0; i < s.size(); i++) {
cout << a.at(i) << " ";
}
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 758,495 | 758,496 | u830237447 | cpp |
p02954 | #include <iostream>
using namespace std;
int main() {
// 整数の入力
string s;
cin >> s;
int l = s.length();
int *c = new int[l];
int count = 0;
int pointer = 0;
char before = 'R';
bool flush = false;
for (int i = 0; i < l; i++) {
if (before == s[i]) {
count += 1;
} else if (s[i] == 'L') // R to L
{
c[i - 1] = count;
pointer = i;
count = 1;
} else {
flush = true;
}
if (i + 1 == l) {
flush = true;
}
if (flush) {
bool swap = false;
c[pointer] = count;
if (max(c[pointer - 1], c[pointer]) % 2 == 0) {
swap = true;
// cout << "swap";
}
int total = c[pointer - 1] + c[pointer];
// cout << c[pointer-1] << " "<< c[pointer] << endl;
if (total % 2 == 0) {
c[pointer] = total / 2;
c[pointer - 1] = total / 2;
}
if (total % 2 != 0) {
if (c[pointer - 1] < c[pointer]) {
c[pointer] = total / 2;
c[pointer - 1] = total / 2;
c[pointer]++;
} else if (c[pointer - 1] > c[pointer]) {
c[pointer] = total / 2;
c[pointer - 1] = total / 2;
c[pointer - 1]++;
}
if (swap) {
int tmp = c[pointer - 1];
c[pointer - 1] = c[pointer];
c[pointer] = tmp;
}
}
count = 1;
flush = false;
swap = false;
}
before = s[i];
}
for (int i = 0; i < l; i++) {
cout << c[i];
}
cout << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
// 整数の入力
string s;
cin >> s;
int l = s.length();
int *c = new int[l];
int count = 0;
int pointer = 0;
char before = 'R';
bool flush = false;
for (int i = 0; i < l; i++) {
if (before == s[i]) {
count += 1;
} else if (s[i] == 'L') // R to L
{
c[i - 1] = count;
pointer = i;
count = 1;
} else {
flush = true;
}
if (i + 1 == l) {
flush = true;
}
if (flush) {
bool swap = false;
c[pointer] = count;
if (max(c[pointer - 1], c[pointer]) % 2 == 0) {
swap = true;
// cout << "swap";
}
int total = c[pointer - 1] + c[pointer];
// cout << c[pointer-1] << " "<< c[pointer] << endl;
if (total % 2 == 0) {
c[pointer] = total / 2;
c[pointer - 1] = total / 2;
}
if (total % 2 != 0) {
if (c[pointer - 1] < c[pointer]) {
c[pointer] = total / 2;
c[pointer - 1] = total / 2;
c[pointer]++;
} else if (c[pointer - 1] > c[pointer]) {
c[pointer] = total / 2;
c[pointer - 1] = total / 2;
c[pointer - 1]++;
}
if (swap) {
int tmp = c[pointer - 1];
c[pointer - 1] = c[pointer];
c[pointer] = tmp;
}
}
count = 1;
flush = false;
swap = false;
}
before = s[i];
}
for (int i = 0; i < l; i++) {
cout << c[i] << " ";
}
cout << endl;
return 0;
} | [
"io.output.change"
] | 758,518 | 758,519 | u222682687 | cpp |
p02954 | #include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
int main(void) {
std::string s;
std::cin >> s;
auto N = s.size();
int k[100000 + 1];
memset(k, 0, sizeof(k));
int i, r, l, j;
int r_w, l_w, esp;
int c = 0;
r = l = i = 0;
while (i != N) {
r = l = 0;
while (s[i + r] != 'L')
r++;
(r_w = i + r - 1), (l_w = i + r);
while (s[i + r + l] != 'R') {
l++;
if (i + r + l == N)
break;
}
i = i + r + l;
k[r_w] += r / 2;
if (r % 2 == 1)
k[r_w]++;
k[l_w] += r - k[r_w];
esp = k[l_w];
k[l_w] += l / 2;
if (l % 2 == 1)
k[l_w]++;
k[r_w] += l - k[l_w] + esp;
}
for (i = 0; i < N - 1; i++)
printf("%d ", k[i]);
printf("%d\n", k[N] - 1);
return 0;
}
| #include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
int main(void) {
std::string s;
std::cin >> s;
auto N = s.size();
int k[100000 + 1];
memset(k, 0, sizeof(k));
int i, r, l, j;
int r_w, l_w, esp;
int c = 0;
r = l = i = 0;
while (i != N) {
r = l = 0;
while (s[i + r] != 'L')
r++;
(r_w = i + r - 1), (l_w = i + r);
while (s[i + r + l] != 'R') {
l++;
if (i + r + l == N)
break;
}
i = i + r + l;
k[r_w] += r / 2;
if (r % 2 == 1)
k[r_w]++;
k[l_w] += r - k[r_w];
esp = k[l_w];
k[l_w] += l / 2;
if (l % 2 == 1)
k[l_w]++;
k[r_w] += l - k[l_w] + esp;
}
for (i = 0; i < N - 1; i++)
printf("%d ", k[i]);
printf("%d\n", k[N - 1]);
return 0;
}
| [
"call.arguments.change"
] | 758,520 | 758,521 | u787311704 | cpp |
p02954 | #include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
int main(void) {
std::string s;
std::cin >> s;
auto N = s.size();
int k[100000 + 1];
memset(k, 0, sizeof(k));
int i, r, l, j;
int r_w, l_w, esp;
int c = 0;
r = l = i = 0;
while (i != N) {
r = l = 0;
while (s[i + r] != 'L')
r++;
(r_w = i + r - 1), (l_w = i + r);
while (s[i + r + l] != 'R') {
l++;
if (i + r + l == N)
break;
}
i = i + r + l;
k[r_w] += r / 2;
if (r % 2 == 1)
k[r_w]++;
k[l_w] += r - k[r_w];
esp = k[l_w];
k[l_w] += l / 2;
if (l % 2 == 1)
k[l_w]++;
k[r_w] += l - k[l_w] + esp;
}
for (i = 0; i < N - 1; i++)
printf("%d ", k[i]);
printf("%d\n", k[N]);
return 0;
}
| #include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
int main(void) {
std::string s;
std::cin >> s;
auto N = s.size();
int k[100000 + 1];
memset(k, 0, sizeof(k));
int i, r, l, j;
int r_w, l_w, esp;
int c = 0;
r = l = i = 0;
while (i != N) {
r = l = 0;
while (s[i + r] != 'L')
r++;
(r_w = i + r - 1), (l_w = i + r);
while (s[i + r + l] != 'R') {
l++;
if (i + r + l == N)
break;
}
i = i + r + l;
k[r_w] += r / 2;
if (r % 2 == 1)
k[r_w]++;
k[l_w] += r - k[r_w];
esp = k[l_w];
k[l_w] += l / 2;
if (l % 2 == 1)
k[l_w]++;
k[r_w] += l - k[l_w] + esp;
}
for (i = 0; i < N - 1; i++)
printf("%d ", k[i]);
printf("%d\n", k[N - 1]);
return 0;
}
| [
"expression.operation.binary.add"
] | 758,522 | 758,521 | u787311704 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define rp(i, s, e) for (int i = (s); i < (e); ++i)
int main() {
string s;
cin >> s;
int si = s.size();
vector<int> a(si);
int r = 0;
int l = 0;
for (int i = 0; i < si; i++) {
if (s[i] == 'R') {
while (s[i] != 'L') {
r++;
i++;
}
a[i - 1] += (r + 1) / 2;
a[i] += r / 2;
r = 0;
}
}
for (int i = si - 1; i >= 0; i--) {
if (s[i] == 'L') {
while (s[i] != 'R') {
l++;
i--;
}
a[i + 1] += (l + 1) / 2;
a[i] += l / 2;
l = 0;
}
}
for (int i = 0; i < si - 1; i++) {
cout << a[i] << " ";
}
cout << s[si] << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rp(i, s, e) for (int i = (s); i < (e); ++i)
int main() {
string s;
cin >> s;
int si = s.size();
vector<int> a(si);
int r = 0;
int l = 0;
for (int i = 0; i < si; i++) {
if (s[i] == 'R') {
while (s[i] != 'L') {
r++;
i++;
}
a[i - 1] += (r + 1) / 2;
a[i] += r / 2;
r = 0;
}
}
for (int i = si - 1; i >= 0; i--) {
if (s[i] == 'L') {
while (s[i] != 'R') {
l++;
i--;
}
a[i + 1] += (l + 1) / 2;
a[i] += l / 2;
l = 0;
}
}
for (int i = 0; i < si - 1; i++) {
cout << a[i] << " ";
}
cout << a[si - 1] << endl;
}
| [
"identifier.change",
"io.output.change"
] | 758,525 | 758,526 | u103850114 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
rep(ri, 2) {
{
int cnt = 0;
rep(i, 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, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, n) { printf("%d%c", ans[i], i == n - 1 ? '\n' : ' '); }
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
rep(ri, 2) {
{
int cnt = 0;
rep(i, 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, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, n) { printf("%d%c", ans[i], i == n - 1 ? '\n' : ' '); }
}
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.variable.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 758,537 | 758,538 | u006721330 | cpp |
p02954 | #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
string s;
cin >> s;
ll N = s.size();
vector<ll> R(N, 0);
vector<ll> L(N, 0);
vector<ll> ans(N, 0);
for (int i = 0; i < N; i++) {
if (s[i] == 'R' && (i == 0 || R[i - 1] < 2)) {
int tmp = i + 1;
while (s[tmp] == 'R') {
tmp++;
}
R[i] = tmp - i;
} else if (i != 0 && R[i - 1] >= 2) {
R[i] = R[i - 1] - 1;
} else {
R[i] = 0;
}
}
for (int i = N - 1; i > 0; i--) {
if (s[i] == 'L' && (i == 0 || L[i + 1] < 2)) {
int tmp = i - 1;
while (s[tmp] == 'L') {
tmp--;
}
L[i] = i - tmp;
} else if (L[i + 1] >= 2 && i != 0) {
L[i] = L[i + 1] - 1;
} else {
L[i] = 0;
}
}
for (int i = 0; i < N; i++) {
if (R[i] != 0) {
if (R[i] % 2 == 1) {
ans[R[i] + i - 1]++;
} else {
ans[R[i] + i]++;
}
}
}
for (int i = N - 1; i > 0; i--) {
if (L[i] != 0) {
if (L[i] % 2 == 1) {
ans[i - L[i] + 1]++;
} else {
ans[i - L[i]]++;
}
}
}
for (int i = 0; i < N; i++) {
cout << ans[i] << " ";
}
cout << endl;
return 0;
}
| #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
string s;
cin >> s;
ll N = s.size();
vector<ll> R(N, 0);
vector<ll> L(N, 0);
vector<ll> ans(N, 0);
for (int i = 0; i < N; i++) {
if (s[i] == 'R' && (i == 0 || R[i - 1] < 2)) {
int tmp = i + 1;
while (s[tmp] == 'R') {
tmp++;
}
R[i] = tmp - i;
} else if (i != 0 && R[i - 1] >= 2) {
R[i] = R[i - 1] - 1;
} else {
R[i] = 0;
}
}
for (int i = N - 1; i > 0; i--) {
if (s[i] == 'L' && (i == N - 1 || L[i + 1] < 2)) {
int tmp = i - 1;
while (s[tmp] == 'L') {
tmp--;
}
L[i] = i - tmp;
} else if (L[i + 1] >= 2 && i != N - 1) {
L[i] = L[i + 1] - 1;
} else {
L[i] = 0;
}
}
for (int i = 0; i < N; i++) {
if (R[i] != 0) {
if (R[i] % 2 == 1) {
ans[R[i] + i - 1]++;
} else {
ans[R[i] + i]++;
}
}
}
for (int i = N - 1; i > 0; i--) {
if (L[i] != 0) {
if (L[i] % 2 == 1) {
ans[i - L[i] + 1]++;
} else {
ans[i - L[i]]++;
}
}
}
for (int i = 0; i < N; i++) {
cout << ans[i] << " ";
}
cout << endl;
return 0;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 758,542 | 758,543 | u432088501 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
int main() {
int n;
string s;
cin >> s;
n = s.size();
vector<int> ans(n);
rep(ri, 2) {
{ // solve R
int cnt = 0;
rep(i, 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, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, n) { printf("%d5c", ans[i], i == n - 1 ? '\n' : ' '); }
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
int main() {
int n;
string s;
cin >> s;
n = s.size();
vector<int> ans(n);
rep(ri, 2) {
{ // solve R
int cnt = 0;
rep(i, 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, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, n) { printf("%d%c", ans[i], i == n - 1 ? '\n' : ' '); }
return 0;
}
| [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 758,548 | 758,549 | u506858457 | cpp |
p02954 | #include <cstring>
#include <iostream>
using namespace std;
char a[100005];
int b[100005], n, i, sol[100005], nr;
int main() {
cin >> a + 1;
n = strlen(a + 1);
b[1] = 1;
for (i = 2; i <= n; i++) {
if (a[i] == a[i - 1] && a[i] == 'R')
b[i] = b[i - 1] + 1;
if (a[i] != a[i - 1] && a[i] == 'R')
b[i] = 1;
}
b[n] = 1;
for (i = n - 1; i >= 1; i--) {
if (a[i] == a[i + 1] && a[i] == 'L')
b[i] = b[i + 1] + 1;
if (a[i] != a[i - 1] && a[i] == 'L')
b[i] = 1;
}
for (i = 2; i <= n; i++) {
if (a[i] == 'L' && a[i - 1] == 'R') {
nr = 1 + b[i - 1] / 2 + b[i + 1] / 2;
sol[i] = nr;
sol[i - 1] = b[i] + b[i - 1] - nr;
}
}
for (i = 1; i <= n; i++)
cout << sol[i] << ' ';
return 0;
}
| #include <cstring>
#include <iostream>
using namespace std;
char a[100005];
int b[100005], n, i, sol[100005], nr;
int main() {
cin >> a + 1;
n = strlen(a + 1);
b[1] = 1;
for (i = 2; i <= n; i++) {
if (a[i] == a[i - 1] && a[i] == 'R')
b[i] = b[i - 1] + 1;
if (a[i] != a[i - 1] && a[i] == 'R')
b[i] = 1;
}
b[n] = 1;
for (i = n - 1; i >= 1; i--) {
if (a[i] == a[i + 1] && a[i] == 'L')
b[i] = b[i + 1] + 1;
if (a[i] != a[i + 1] && a[i] == 'L')
b[i] = 1;
}
for (i = 2; i <= n; i++) {
if (a[i] == 'L' && a[i - 1] == 'R') {
nr = 1 + b[i - 1] / 2 + b[i + 1] / 2;
sol[i] = nr;
sol[i - 1] = b[i] + b[i - 1] - nr;
}
}
for (i = 1; i <= n; i++)
cout << sol[i] << ' ';
return 0;
}
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 758,552 | 758,553 | u868438411 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
rep(ri, 2) {
{ // solve
int cnt = 0;
rep(i, 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.begin());
rep(i, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, n) { printf("%d%c", ans[i], i == n - 1 ? '\n' : ' '); }
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
rep(ri, 2) {
{ // solve
int cnt = 0;
rep(i, 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, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, n) { printf("%d%c", ans[i], i == n - 1 ? '\n' : ' '); }
return 0;
} | [
"call.function.change",
"call.arguments.change"
] | 758,556 | 758,557 | u106635407 | cpp |
p02954 | #include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n) n.begin(), n.end()
#define rall(n) n.rbegin(), n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1); // 3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll> dij;
struct edge {
ll to, cost;
};
vector<vector<edge>> G;
ll mod_pow(ll a, ll b) {
ll res = 1, mul = a;
for (int i = 0; i < 31; ++i) {
if (b >> i & 1) {
res *= mul;
res %= MOD;
}
mul = (mul * mul) % MOD;
}
return res;
}
void addedge(int from, int to, int cost) {
G[from].push_back({to, cost});
G[to].push_back({from, cost});
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
template <typename T> void outp(vector<T> v) {
for (int i = 0; i < v.size(); ++i) {
cout << v[i];
if (i != v.size() - 1) {
cout << " ";
}
}
}
double add(double a, double b) {
if (abs(a + b) < EPS * (abs(a) + abs(b))) {
return 0;
}
return a + b;
}
int main() {
string h;
cin >> h;
vector<int> v(h.length(), 1);
for (int i = 0; i < h.length() - 1; ++i) {
if (h[i] == h[i + 1] && h[i] == 'R') {
v[i + 2] += v[i];
v[i] = 0;
}
}
for (int i = h.length() - 1; i > 0; --i) {
if (h[i] == h[i - 1] && h[i] == 'L') {
v[i - 1] += v[i];
v[i] = 0;
}
}
outp(v);
} | #include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n) n.begin(), n.end()
#define rall(n) n.rbegin(), n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1); // 3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll> dij;
struct edge {
ll to, cost;
};
vector<vector<edge>> G;
ll mod_pow(ll a, ll b) {
ll res = 1, mul = a;
for (int i = 0; i < 31; ++i) {
if (b >> i & 1) {
res *= mul;
res %= MOD;
}
mul = (mul * mul) % MOD;
}
return res;
}
void addedge(int from, int to, int cost) {
G[from].push_back({to, cost});
G[to].push_back({from, cost});
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
template <typename T> void outp(vector<T> v) {
for (int i = 0; i < v.size(); ++i) {
cout << v[i];
if (i != v.size() - 1) {
cout << " ";
}
}
}
double add(double a, double b) {
if (abs(a + b) < EPS * (abs(a) + abs(b))) {
return 0;
}
return a + b;
}
int main() {
string h;
cin >> h;
vector<int> v(h.length(), 1);
for (int i = 0; i < h.length() - 1; ++i) {
if (h[i] == h[i + 1] && h[i] == 'R') {
v[i + 2] += v[i];
v[i] = 0;
}
}
for (int i = h.length() - 1; i > 0; --i) {
if (h[i] == h[i - 1] && h[i] == 'L') {
v[i - 2] += v[i];
v[i] = 0;
}
}
outp(v);
} | [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 758,558 | 758,559 | u539402331 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int ans[10000000];
int main() {
string s;
cin >> s;
rep(i, s.size()) {
int j = i;
int num = 0;
while (1) {
if (s[i] == 'R') {
if (s[i] != s[j + 1]) {
break;
} else {
j++;
num++;
}
} else {
if (s[i] != s[j - 1]) {
break;
} else {
j--;
num++;
}
}
}
int n = num;
if (s[i] == 'R') {
while (n >= 0) {
if ((n % 2) == 0) {
ans[j] += 1;
} else {
ans[j + 1] += 1;
}
n--;
}
} else {
while (n >= 0) {
if ((n % 2) == 0) {
ans[j] += 1;
} else {
ans[j - 1] += 1;
}
n--;
}
}
i += num;
}
rep(i, s.size()) { cout << ans[i] << " "; }
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int ans[10000000];
int main() {
string s;
cin >> s;
rep(i, s.size()) {
int j = i;
int num = 0;
while (1) {
if (s[i] == 'R') {
if (s[i] != s[j + 1]) {
break;
} else {
j++;
num++;
}
} else {
if (s[i] != s[j + 1]) {
break;
} else {
j++;
num++;
}
}
}
int n = num;
if (s[i] == 'R') {
while (n >= 0) {
if ((n % 2) == 0) {
ans[j] += 1;
} else {
ans[j + 1] += 1;
}
n--;
}
} else {
while (n >= 0) {
if ((n % 2) == 0) {
ans[i] += 1;
} else {
ans[i - 1] += 1;
}
n--;
}
}
i += num;
}
rep(i, s.size()) { cout << ans[i] << " "; }
return 0;
}
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"assignment.variable.change",
"identifier.change",
"expression.operation.binary.change"
] | 758,562 | 758,563 | u905170328 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
ll pre[100001], suff[100001], ans[100001];
int main() {
string s;
cin >> s;
ll n = s.length();
pre[0] = 1;
for (ll i = 1; i < s.length(); i++) {
if (s[i] == 'R')
pre[i] += (pre[i - 1] + 1);
}
suff[n - 1] = 1;
for (ll i = n - 2; i >= 0; i--) {
if (s[i] == 'L')
suff[i] += (suff[i + 1] + 1);
}
for (ll i = 0; i < (n - 1); i++) {
if ((s[i] == 'R') && (s[i + 1] == 'L')) {
ll ss = (pre[i] + suff[i + 1]);
ans[i] = ss / 2;
ans[i + 1] = ss / 2;
if (ss % 2 != 0) {
ans[i] += 1;
if (pre[i] > suff[i + 1]) {
if (pre[i] % 2 == 0)
swap(ans[i], ans[i + 1]);
} else {
if (suff[i] % 2 != 0)
swap(ans[i], ans[i + 1]);
}
}
}
}
for (ll i = 0; i < n; i++)
cout << ans[i] << " ";
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
ll pre[100001], suff[100001], ans[100001];
int main() {
string s;
cin >> s;
ll n = s.length();
pre[0] = 1;
for (ll i = 1; i < s.length(); i++) {
if (s[i] == 'R')
pre[i] += (pre[i - 1] + 1);
}
suff[n - 1] = 1;
for (ll i = n - 2; i >= 0; i--) {
if (s[i] == 'L')
suff[i] += (suff[i + 1] + 1);
}
for (ll i = 0; i < (n - 1); i++) {
if ((s[i] == 'R') && (s[i + 1] == 'L')) {
ll ss = (pre[i] + suff[i + 1]);
ans[i] = ss / 2;
ans[i + 1] = ss / 2;
if (ss % 2 != 0) {
ans[i] += 1;
if (pre[i] > suff[i + 1]) {
if (pre[i] % 2 == 0)
swap(ans[i], ans[i + 1]);
} else {
if (suff[i + 1] % 2 != 0)
swap(ans[i], ans[i + 1]);
}
}
}
}
for (ll i = 0; i < n; i++)
cout << ans[i] << " ";
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 758,578 | 758,579 | u193330108 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n, x) for (int i = (n); i < (x); ++i)
using ll = long long;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
int cntR = 0, cntL = 0;
rep(i, 0, n) {
if (s[i] == 'L') {
while (i <= n - 1 && s[i] == 'L') {
cntL++;
i++;
}
int p = (cntR + cntL) / 2;
int k = i - cntL;
if ((cntR - cntL) % 2 == 0) {
ans[k - 1] = p;
ans[k] = p;
} else {
if (max(cntR, cntL) % 2 == 0) {
ans[k - 1] = p;
ans[k] = p + 1;
} else {
ans[k - 1] = p + 1;
ans[k] = p;
}
}
cntR = 0;
cntL = 0;
i--;
} else
cntR++;
}
rep(i, 0, n) {
if (i > 0)
cout << " ";
cout << ans[i];
}
cout << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n, x) for (int i = (n); i < (x); ++i)
using ll = long long;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
int cntR = 0, cntL = 0;
rep(i, 0, n) {
if (s[i] == 'L') {
while (i <= n - 1 && s[i] == 'L') {
cntL++;
i++;
}
int p = (cntR + cntL) / 2;
int k = i - cntL;
if ((cntR - cntL) % 2 == 0) {
ans[k - 1] = p;
ans[k] = p;
} else {
if (cntL % 2 == 1) {
ans[k - 1] = p;
ans[k] = p + 1;
} else {
ans[k - 1] = p + 1;
ans[k] = p;
}
}
cntR = 0;
cntL = 0;
i--;
} else
cntR++;
}
rep(i, 0, n) {
if (i > 0)
cout << " ";
cout << ans[i];
}
cout << endl;
return 0;
} | [
"call.remove",
"control_flow.branch.if.condition.change",
"literal.number.change"
] | 758,582 | 758,583 | u526854325 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
int rcnt = 0;
int lcnt = 0;
int pos = 0;
int ans[n];
for (int i = 0; i < n; i++) {
ans[i] = 0;
}
for (int i = 0; i < n; i++) {
if (s[i] == 'R') {
if (lcnt != 0) {
if (lcnt % 2 == 0) {
ans[pos] += (lcnt / 2);
ans[pos - 1] += (lcnt / 2);
pos = 0;
lcnt = 0;
} else {
ans[pos] += ((lcnt - 1) / 2);
ans[pos - 1] += 1 + ((lcnt - 1) / 2);
pos = 0;
lcnt = 0;
}
}
rcnt++;
} else {
if (i == n - 1) {
lcnt++;
if (lcnt % 2 == 0) {
ans[pos] += (lcnt / 2);
ans[pos - 1] += (lcnt / 2);
pos = 0;
lcnt = 0;
} else {
ans[pos] += ((lcnt - 1) / 2);
ans[pos - 1] += 1 + ((lcnt - 1) / 2);
pos = 0;
lcnt = 0;
}
}
if (rcnt != 0) {
pos = i;
if (rcnt % 2 == 0) {
ans[i] += 1 + (rcnt / 2);
ans[i - 1] += (rcnt / 2);
rcnt = 0;
} else {
ans[i] += ((rcnt + 1) / 2);
ans[i - 1] += ((rcnt + 1) / 2);
rcnt = 0;
}
} else {
lcnt++;
}
}
}
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();
int rcnt = 0;
int lcnt = 0;
int pos = 0;
int ans[n];
for (int i = 0; i < n; i++) {
ans[i] = 0;
}
for (int i = 0; i < n; i++) {
if (s[i] == 'R') {
if (lcnt != 0) {
if (lcnt % 2 == 0) {
ans[pos] += (lcnt / 2);
ans[pos - 1] += (lcnt / 2);
pos = 0;
lcnt = 0;
} else {
ans[pos] += ((lcnt - 1) / 2);
ans[pos - 1] += 1 + ((lcnt - 1) / 2);
pos = 0;
lcnt = 0;
}
}
rcnt++;
} else {
if (i == n - 1 && rcnt == 0) {
lcnt++;
if (lcnt % 2 == 0) {
ans[pos] += (lcnt / 2);
ans[pos - 1] += (lcnt / 2);
pos = 0;
lcnt = 0;
} else {
ans[pos] += ((lcnt - 1) / 2);
ans[pos - 1] += 1 + ((lcnt - 1) / 2);
pos = 0;
lcnt = 0;
}
}
if (rcnt != 0) {
pos = i;
if (rcnt % 2 == 0) {
ans[i] += 1 + (rcnt / 2);
ans[i - 1] += (rcnt / 2);
rcnt = 0;
} else {
ans[i] += ((rcnt + 1) / 2);
ans[i - 1] += ((rcnt + 1) / 2);
rcnt = 0;
}
} else {
lcnt++;
}
}
}
for (int i = 0; i < n; i++) {
cout << ans[i] << " ";
}
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 758,592 | 758,593 | u262602763 | cpp |
p02954 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
using namespace std;
int main() {
string S;
cin >> S;
int n = S.size();
vector<int> ans(n);
rep(re, 2) {
{
int count = 0;
rep(i, n) {
if (S[i] == 'R')
count++;
else {
ans[i] += count / 2;
ans[i - 1] += (count + 1) / 2;
count = 0;
}
}
}
reverse(ALL(ans));
reverse(ALL(S));
rep(i, n) {
if (S[i] == 'R')
S[i] = 'L';
else
S[i] = 'R';
}
}
rep(i, n) printf("%d%c", ans[i], i == n - 1 ? '/n' : ' ');
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
using namespace std;
int main() {
string S;
cin >> S;
int n;
n = S.size();
vector<int> ans(n);
rep(re, 2) {
{
int count = 0;
rep(i, n) {
if (S[i] == 'R')
count++;
else {
ans[i] += count / 2;
ans[i - 1] += (count + 1) / 2;
count = 0;
}
}
}
reverse(ALL(ans));
reverse(ALL(S));
rep(i, n) {
if (S[i] == 'R')
S[i] = 'L';
else
S[i] = 'R';
}
}
rep(i, n) printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
} | [
"variable_declaration.add",
"literal.string.change",
"call.arguments.change",
"io.output.change",
"io.output.newline.add"
] | 758,594 | 758,595 | u689844566 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
int t0 = 1, renzoku = 0, PRL = 0, RorL = 0, N;
cin >> S;
N = S.size();
vector<int> S2(N, 0);
for (int i = 0; i < N; i++) {
if (S[i] == 'R') {
renzoku++;
if (RorL == 1) {
RorL = 0;
renzoku = 1;
t0 = 1;
}
} else if (S[i] == 'L') {
// RLが来た時の処理
if (RorL == 0) {
RorL = 1;
PRL = i - 1;
S2[i - 1] += (int)((renzoku + 1) / 2);
S2[i] += (int)(renzoku / 2) + 1;
renzoku = 0;
t0++;
} else {
S2[PRL + (t0 % 2)] += 1;
t0++;
}
}
}
for (int j = 0; j < N; j++)
cout << S2[j];
cout << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
int t0 = 1, renzoku = 0, PRL = 0, RorL = 0, N;
cin >> S;
N = S.size();
vector<int> S2(N, 0);
for (int i = 0; i < N; i++) {
if (S[i] == 'R') {
renzoku++;
if (RorL == 1) {
RorL = 0;
renzoku = 1;
t0 = 1;
}
} else if (S[i] == 'L') {
// RLが来た時の処理
if (RorL == 0) {
RorL = 1;
PRL = i - 1;
S2[i - 1] += (int)((renzoku + 1) / 2);
S2[i] += (int)(renzoku / 2) + 1;
renzoku = 0;
t0++;
} else {
S2[PRL + (t0 % 2)] += 1;
t0++;
}
}
}
for (int j = 0; j < N; j++)
cout << S2[j] << " ";
cout << endl;
} | [
"io.output.change"
] | 758,596 | 758,597 | u901446572 | cpp |
p02954 | #include <bits/stdc++.h>
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string s;
cin >> s;
vector<int> arr;
for (int l = 0; l < sz(s);) {
int r = l;
while (r + 1 < sz(s) and s[l] == s[r + 1])
r++;
arr.push_back(r - l + 1);
l = r + 1;
}
vector<int> ans(sz(s));
int cur = 0;
for (int pos = 0; pos < sz(s); pos += 2) {
cur = cur + arr[pos];
int l = cur - 1;
int r = cur;
ans[l] += (arr[pos] + 1) / 2;
ans[r] += arr[pos] / 2;
ans[r] += (arr[pos + 1] + 1) / 2;
ans[l] += arr[pos + 1] / 2;
cur += arr[pos + 1];
}
for (int i = 0; i < sz(s); i++)
cout << ans[i] << " \n"[i == sz(s) - 1];
return (0);
}
| #include <bits/stdc++.h>
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string s;
cin >> s;
vector<int> arr;
for (int l = 0; l < sz(s);) {
int r = l;
while (r + 1 < sz(s) and s[l] == s[r + 1])
r++;
arr.push_back(r - l + 1);
l = r + 1;
}
vector<int> ans(sz(s));
int cur = 0;
for (int pos = 0; pos < sz(arr); pos += 2) {
cur = cur + arr[pos];
int l = cur - 1;
int r = cur;
ans[l] += (arr[pos] + 1) / 2;
ans[r] += arr[pos] / 2;
ans[r] += (arr[pos + 1] + 1) / 2;
ans[l] += arr[pos + 1] / 2;
cur += arr[pos + 1];
}
for (int i = 0; i < sz(s); i++)
cout << ans[i] << " \n"[i == sz(s) - 1];
return (0);
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 758,615 | 758,616 | u472742542 | 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;
int main() {
string s;
cin >> s;
int n = sz(s);
vector<int> ans(n, 0);
int count = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'R') {
count++;
} else if (s[i - 1] != s[i]) {
ans[i - 1] = count;
count = 0;
}
}
// rep(i,n) cout << ans[i];
// cout << endl;
count = 0;
for (int i = n - 1; i > 0; i--) {
if (s[i] == 'L') {
count++;
} else if (s[i + 1] != s[i]) {
ans[i + 1] = count;
count = 0;
}
}
// rep(i,n) cout << ans[i];
// cout << endl;
int l, r;
rep(i, n - 1) {
if (s[i] == 'R' && s[i + 1] == 'L') {
l = ans[i];
r = ans[i + 1];
ans[i] = l / 2 + l % 2 + r / 2;
ans[i + 1] = r / 2 + r % 2 + l / 2;
}
}
rep(i, n) cout << ans[i] << ' ';
cout << endl;
return 0;
}
| #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;
int main() {
string s;
cin >> s;
int n = sz(s);
vector<int> ans(n, 0);
int count = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'R') {
count++;
} else if (s[i - 1] != s[i]) {
ans[i - 1] = count;
count = 0;
}
}
// rep(i,n) cout << ans[i];
// cout << endl;
count = 0;
for (int i = n - 1; i >= 0; i--) {
if (s[i] == 'L') {
count++;
} else if (s[i + 1] != s[i]) {
ans[i + 1] = count;
count = 0;
}
}
// rep(i,n) cout << ans[i];
// cout << endl;
int l, r;
rep(i, n - 1) {
if (s[i] == 'R' && s[i + 1] == 'L') {
l = ans[i];
r = ans[i + 1];
ans[i] = l / 2 + l % 2 + r / 2;
ans[i + 1] = r / 2 + r % 2 + l / 2;
}
}
rep(i, n) cout << ans[i] << ' ';
cout << endl;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,617 | 758,618 | u044459372 | 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;
int main() {
string s;
cin >> s;
int sl = sz(s);
vector<pair<char, int>> a;
vector<int> ans(sl);
char tmp = 'R';
int cnt = 1;
for (int i = 0; i <= sl; i++) {
if (i == sl)
a.push_back(make_pair(tmp, cnt));
else if (tmp == s.at(i))
cnt++;
else {
a.push_back(make_pair(tmp, cnt));
tmp = s.at(i);
cnt = 1;
}
}
int ind = -1, i = 0, bl = sz(a);
while (i < bl) {
cnt = a[i].second + a[i + 1].second;
ind += a[i].second;
ans.at(ind) = (a[i].second - 1) / 2 + 1;
ans.at(ind) += (a[i + 1].second) / 2;
ans.at(ind + 1) = cnt - ans.at(ind);
ind += a[i + 1].second;
i = i + 2;
}
rep(j, sl) cout << ans.at(j) << " ";
}
| #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;
int main() {
string s;
cin >> s;
int sl = sz(s);
vector<pair<char, int>> a;
vector<int> ans(sl);
char tmp = 'R';
int cnt = 1;
for (int i = 1; i <= sl; i++) {
if (i == sl)
a.push_back(make_pair(tmp, cnt));
else if (tmp == s.at(i))
cnt++;
else {
a.push_back(make_pair(tmp, cnt));
tmp = s.at(i);
cnt = 1;
}
}
int ind = -1, i = 0, bl = sz(a);
while (i < bl) {
cnt = a[i].second + a[i + 1].second;
ind += a[i].second;
ans.at(ind) = (a[i].second - 1) / 2 + 1;
ans.at(ind) += (a[i + 1].second) / 2;
ans.at(ind + 1) = cnt - ans.at(ind);
ind += a[i + 1].second;
i = i + 2;
}
rep(j, sl) cout << ans.at(j) << " ";
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 758,631 | 758,632 | u059207724 | cpp |
p02954 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
string S;
cin >> S;
vector<LL> members(S.length());
LL i = 0;
while (i < S.length()) {
LL cnt_r = 0;
LL cnt_l = 0;
while (S[i] == 'R') {
cnt_r++;
i++;
}
while (S[i] == 'L') {
cnt_l++;
i++;
}
if ((cnt_r - cnt_l) % 2 == 0) {
members[i - cnt_l - 1] = (cnt_r + cnt_l) / 2;
members[i - cnt_l] = (cnt_r + cnt_l) / 2;
} else {
members[i - cnt_l - 1] = (cnt_r - 1) / 2 + cnt_l / 2;
members[i - cnt_l] = (cnt_r) / 2 + (cnt_l - 1) / 2;
}
}
rep(i, S.length()) { cout << members[i] << " "; }
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
string S;
cin >> S;
vector<LL> members(S.length());
LL i = 0;
while (i < S.length()) {
LL cnt_r = 0;
LL cnt_l = 0;
while (S[i] == 'R') {
cnt_r++;
i++;
}
while (S[i] == 'L') {
cnt_l++;
i++;
}
if ((cnt_r - cnt_l) % 2 == 0) {
members[i - cnt_l - 1] = (cnt_r + cnt_l) / 2;
members[i - cnt_l] = (cnt_r + cnt_l) / 2;
} else {
members[i - cnt_l - 1] = (cnt_r - 1) / 2 + cnt_l / 2 + 1;
members[i - cnt_l] = (cnt_r) / 2 + (cnt_l - 1) / 2 + 1;
}
}
rep(i, S.length()) { cout << members[i] << " "; }
return 0;
} | [
"assignment.change"
] | 758,648 | 758,649 | u758765597 | cpp |
p02954 | #include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
const int N = 1e5 + 1;
char buf[N];
int main() {
scanf("%s", buf);
char *p = buf;
while (*p) {
int a = 0, b = 0;
while (*p == 'R')
++a, ++p;
while (*p && *p == 'L')
++b, ++p;
for (int i = 1; i < a; ++i)
printf("0 ");
printf("%d %d", (a + 1) / 2 + b / 2, (b + 1) / 2 + a / 2);
for (int i = 1; i < b; ++i)
printf(" 0 ");
}
printf("\n");
return 0;
} | #include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
const int N = 1e5 + 1;
char buf[N];
int main() {
scanf("%s", buf);
char *p = buf;
while (*p) {
int a = 0, b = 0;
while (*p == 'R')
++a, ++p;
while (*p && *p == 'L')
++b, ++p;
for (int i = 1; i < a; ++i)
printf("0 ");
printf("%d %d ", (a + 1) / 2 + b / 2, (b + 1) / 2 + a / 2);
for (int i = 1; i < b; ++i)
printf("0 ");
}
printf("\n");
return 0;
} | [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 758,681 | 758,682 | u919923389 | cpp |
p02954 | #include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
const int N = 1e5 + 1;
char buf[N];
int main() {
scanf("%s", buf);
char *p = buf;
while (*p) {
int a = 0, b = 0;
while (*p == 'R')
++a, ++p;
while (*p && *p == 'L')
++b, ++p;
for (int i = 1; i < a; ++i)
printf("0 ");
printf("%d %d", (a + 1) / 2 + b / 2, (b + 1) / 2 + a / 2);
for (int i = 1; i < b; ++i)
printf(" 0");
}
printf("\n");
return 0;
} | #include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
const int N = 1e5 + 1;
char buf[N];
int main() {
scanf("%s", buf);
char *p = buf;
while (*p) {
int a = 0, b = 0;
while (*p == 'R')
++a, ++p;
while (*p && *p == 'L')
++b, ++p;
for (int i = 1; i < a; ++i)
printf("0 ");
printf("%d %d ", (a + 1) / 2 + b / 2, (b + 1) / 2 + a / 2);
for (int i = 1; i < b; ++i)
printf("0 ");
}
printf("\n");
return 0;
} | [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 758,683 | 758,682 | u919923389 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
char switcher(char status) {
if (status == 'R')
return 'L';
else
return 'R';
}
int main() {
string s;
cin >> s;
char status = 'R';
vector<int> ans(s.length(), 0);
for (int i = 0; i < s.length() - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
int r_cnt = 0;
int l_cnt = 0;
for (int l = i; l >= 0 && s[l] == 'R'; l--) {
r_cnt++;
}
for (int r = i + 1; r < s.length() && s[r] == 'L'; r++) {
l_cnt++;
}
ans[i] = ans[i + 1] = (r_cnt + l_cnt) / 2;
if ((r_cnt + l_cnt) % 2 != 0) {
if (r_cnt % 2 != 0)
ans[i] += 1;
else
ans[i + 1] += 1;
}
}
}
for (int i = 0; i < s.length(); i++) {
cout << ans[i] + ' ';
}
} | #include <bits/stdc++.h>
using namespace std;
char switcher(char status) {
if (status == 'R')
return 'L';
else
return 'R';
}
int main() {
string s;
cin >> s;
char status = 'R';
vector<int> ans(s.length(), 0);
for (int i = 0; i < s.length() - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
int r_cnt = 0;
int l_cnt = 0;
for (int l = i; l >= 0 && s[l] == 'R'; l--) {
r_cnt++;
}
for (int r = i + 1; r < s.length() && s[r] == 'L'; r++) {
l_cnt++;
}
ans[i] = ans[i + 1] = (r_cnt + l_cnt) / 2;
if ((r_cnt + l_cnt) % 2 != 0) {
if (r_cnt % 2 != 0)
ans[i] += 1;
else
ans[i + 1] += 1;
}
}
}
for (int i = 0; i < s.length(); i++) {
cout << ans[i] << ' ';
}
} | [
"io.output.change"
] | 758,684 | 758,685 | u772690052 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
char switcher(char status) {
if (status == 'R')
return 'L';
else
return 'R';
}
int main() {
string s;
cin >> s;
char status = 'R';
vector<int> ans(s.length(), 0);
for (int i = 0; i < s.length() - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
int r_cnt = 0;
int l_cnt = 0;
for (int l = i; l >= 0 && s[l] == 'R'; l--) {
r_cnt++;
}
for (int r = i + 1; r < s.length() && s[r] == 'L'; r++) {
l_cnt++;
}
ans[i] = ans[i + 1] = (r_cnt + l_cnt) / 2;
if ((r_cnt + l_cnt) % 2 != 0) {
if (r_cnt % 2 != 0)
ans[i] += 1;
else
ans[i + 1] += 1;
}
}
}
for (int i = 0; i < s.length(); i++) {
cout << ans[i];
}
} | #include <bits/stdc++.h>
using namespace std;
char switcher(char status) {
if (status == 'R')
return 'L';
else
return 'R';
}
int main() {
string s;
cin >> s;
char status = 'R';
vector<int> ans(s.length(), 0);
for (int i = 0; i < s.length() - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
int r_cnt = 0;
int l_cnt = 0;
for (int l = i; l >= 0 && s[l] == 'R'; l--) {
r_cnt++;
}
for (int r = i + 1; r < s.length() && s[r] == 'L'; r++) {
l_cnt++;
}
ans[i] = ans[i + 1] = (r_cnt + l_cnt) / 2;
if ((r_cnt + l_cnt) % 2 != 0) {
if (r_cnt % 2 != 0)
ans[i] += 1;
else
ans[i + 1] += 1;
}
}
}
for (int i = 0; i < s.length(); i++) {
cout << ans[i] << ' ';
}
} | [
"io.output.change"
] | 758,686 | 758,685 | u772690052 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
char s[maxn];
int main() {
scanf("%s", s);
int R = 0, L = 0, Ln, Rn;
while (s[R]) {
while (s[R] == 'R')
R++;
Ln = R - L;
L = R + 1;
while (s[L] == 'L')
L++;
Rn = L - R;
a[R] = a[R - 1] = (Ln + Rn) / 2;
if ((Ln + Rn) & 1)
if (Ln > Rn && Ln & 1 || Ln < Rn && !(Rn & 12))
a[R - 1]++;
else
a[R]++;
R = L;
}
for (int i = 0; s[i]; i++)
printf("%d ", a[i]);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
char s[maxn];
int main() {
scanf("%s", s);
int R = 0, L = 0, Ln, Rn;
while (s[R]) {
while (s[R] == 'R')
R++;
Ln = R - L;
L = R + 1;
while (s[L] == 'L')
L++;
Rn = L - R;
a[R] = a[R - 1] = (Ln + Rn) / 2;
if ((Ln + Rn) & 1)
if (Ln > Rn && Ln & 1 || Ln < Rn && !(Rn & 1))
a[R - 1]++;
else
a[R]++;
R = L;
}
for (int i = 0; s[i]; i++)
printf("%d ", a[i]);
return 0;
} | [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 758,687 | 758,688 | u098251832 | cpp |
p02954 | #include <iostream>
#include <string>
using namespace std;
int len[100005];
int ans[100005];
int main() {
for (int i = 0; i < 100005; ++i) {
ans[i] = 0;
}
string S;
cin >> S;
int cnt = 0;
int index = 0;
bool flag = true; // true -> R false -> L
for (int i = 0; i < S.size(); ++i) {
if ((flag) && (S[i] == 'L')) {
len[index] = cnt;
index++;
cnt = 1;
flag = false;
} else if ((!flag) && (S[i] == 'R')) {
len[index] = cnt;
index++;
cnt = 1;
flag = true;
} else {
cnt++;
}
}
len[index] = cnt;
index++;
cnt = 1;
flag = true;
/*
for (int i = 0; i < index; ++i)
{
cout << len[i] << " ";
}
cout << endl;
*/
int temp = 0;
for (int i = 0; i <= index; i += 2) {
if (len[i] % 2 == 0) {
ans[temp + len[i] - 1] = (len[i] + len[i + 1]) / 2;
ans[temp + len[i]] = (len[i] + len[i + 1] + 1) / 2;
temp += len[i] + len[i + 1];
} else {
ans[temp + len[i]] = (len[i] + len[i + 1]) / 2;
ans[temp + len[i] - 1] = (len[i] + len[i + 1] + 1) / 2;
temp += len[i] + len[i + 1];
}
}
for (int i = 0; i < S.size(); ++i) {
if (i != 0) {
cout << " ";
}
cout << ans[i];
}
cout << endl;
return 0;
} | #include <iostream>
#include <string>
using namespace std;
int len[100005];
int ans[100005];
int main() {
for (int i = 0; i < 100005; ++i) {
ans[i] = 0;
}
string S;
cin >> S;
int cnt = 0;
int index = 0;
bool flag = true; // true -> R false -> L
for (int i = 0; i < S.size(); ++i) {
if ((flag) && (S[i] == 'L')) {
len[index] = cnt;
index++;
cnt = 1;
flag = false;
} else if ((!flag) && (S[i] == 'R')) {
len[index] = cnt;
index++;
cnt = 1;
flag = true;
} else {
cnt++;
}
}
len[index] = cnt;
index++;
cnt = 1;
flag = true;
/*
for (int i = 0; i < index; ++i)
{
cout << len[i] << " ";
}
cout << endl;
*/
int temp = 0;
for (int i = 0; i < index; i += 2) {
if (len[i] % 2 == 0) {
ans[temp + len[i] - 1] = (len[i] + len[i + 1]) / 2;
ans[temp + len[i]] = (len[i] + len[i + 1] + 1) / 2;
temp += len[i] + len[i + 1];
} else {
ans[temp + len[i]] = (len[i] + len[i + 1]) / 2;
ans[temp + len[i] - 1] = (len[i] + len[i + 1] + 1) / 2;
temp += len[i] + len[i + 1];
}
}
for (int i = 0; i < S.size(); ++i) {
if (i != 0) {
cout << " ";
}
cout << ans[i];
}
cout << endl;
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 758,694 | 758,695 | u352969025 | cpp |
p02954 | //萌新看过(膜拜)大佬后写出(逃)
#pragma GCC optimize("Ofast", 3, "inline")
#include <bits/stdc++.h>
using namespace std;
string s;
int ans[100000], turn[2];
int main() {
ios_base::sync_with_stdio(false);
cin >> s;
for (int i = 0; i < s.size() - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
memset(turn, 0, sizeof(turn));
for (int j = i; j >= 0; j++) {
if (s[j] == 'R')
turn[(i - j) % 2]++;
else
break;
}
for (int j = i + 1; j < s.size(); j++) {
if (s[j] == 'L')
turn[(j - i) % 2]++;
else
break;
}
ans[i] = turn[0];
ans[i + 1] = turn[1];
}
}
for (int i = 0; i < s.size(); i++)
cout << ans[i] << ' ';
return 0;
}
| //萌新看过(膜拜)大佬后写出(逃)
#pragma GCC optimize("Ofast", 3, "inline")
#include <bits/stdc++.h>
using namespace std;
string s;
int ans[100000], turn[2];
int main() {
ios_base::sync_with_stdio(false);
cin >> s;
for (int i = 0; i < s.size() - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
memset(turn, 0, sizeof(turn));
for (int j = i; j >= 0; j--) {
if (s[j] == 'R')
turn[(i - j) % 2]++;
else
break;
}
for (int j = i + 1; j < s.size(); j++) {
if (s[j] == 'L')
turn[(j - i) % 2]++;
else
break;
}
ans[i] = turn[0];
ans[i + 1] = turn[1];
}
}
for (int i = 0; i < s.size(); i++)
cout << ans[i] << ' ';
return 0;
}
| [] | 758,718 | 758,719 | u083499110 | cpp |
p02954 | #include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int i, j;
string s;
int n;
ll dp[100001][13] = {0};
const ll mod = 1e9 + 7;
void solve() {
string s;
cin >> s;
int l = s.size();
int st = 0;
int circle_pos = -1;
bool has_r = false;
for (i = 0; i < l; ++i) {
if (s[i] == 'R') {
if (circle_pos != -1) {
for (j = st; j < circle_pos; ++j)
cout << 0 << " ";
int x = (i - st) / 2, y = (i - st - x);
if ((circle_pos - st) % 2 == 1) {
cout << x << " " << y << " ";
} else {
cout << y << " " << x << " ";
}
for (j = circle_pos + 2; j < i; ++j)
cout << 0 << " ";
}
if (!has_r) {
st = i;
circle_pos = -1;
has_r = true;
}
} else {
has_r = false;
if (circle_pos == -1)
circle_pos = i - 1;
}
}
for (j = st; j < circle_pos; ++j)
cout << 0 << " ";
int x = (l - st) / 2, y = (l - st - x);
if ((circle_pos - st) % 2 == 1) {
cout << x << " " << y << " ";
} else {
cout << y << " " << x << " ";
}
for (j = circle_pos + 2; j < l - 1; ++j)
cout << 0 << " ";
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
solve();
return 0;
}
| #include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int i, j;
string s;
int n;
ll dp[100001][13] = {0};
const ll mod = 1e9 + 7;
void solve() {
string s;
cin >> s;
int l = s.size();
int st = 0;
int circle_pos = -1;
bool has_r = false;
for (i = 0; i < l; ++i) {
if (s[i] == 'R') {
if (circle_pos != -1) {
for (j = st; j < circle_pos; ++j)
cout << 0 << " ";
int x = (i - st) / 2, y = (i - st - x);
if ((circle_pos - st) % 2 == 1) {
cout << x << " " << y << " ";
} else {
cout << y << " " << x << " ";
}
for (j = circle_pos + 2; j < i; ++j)
cout << 0 << " ";
}
if (!has_r) {
st = i;
circle_pos = -1;
has_r = true;
}
} else {
has_r = false;
if (circle_pos == -1)
circle_pos = i - 1;
}
}
for (j = st; j < circle_pos; ++j)
cout << 0 << " ";
int x = (l - st) / 2, y = (l - st - x);
if ((circle_pos - st) % 2 == 1) {
cout << x << " " << y << " ";
} else {
cout << y << " " << x << " ";
}
for (j = circle_pos + 2; j < l; ++j)
cout << 0 << " ";
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
solve();
return 0;
}
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 758,724 | 758,725 | u778594851 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i, j, k) for (int i = j; i < k; i++)
#define f(n) fr(i, 0, n)
#define f1(n) fr(i, 1, n + 1)
#define ms(i) memset(i, 0, sizeof(i));
#define ms1(i) memset(i, -1, sizeof(i));
#define F first
#define S second
const ll mod = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
// while(cin >> n){
string s;
cin >> s;
n = s.size();
vector<int> l, r;
f(n) {
if (s[i] == 'L')
l.pb(i);
else
r.pb(i);
}
int cnt[n + 5] = {};
f(n) {
if (s[i] == 'L') {
int idx = lower_bound(r.begin(), r.end(), i) - r.begin() - 1;
if ((i - r[idx]) % 2) {
cnt[r[idx] + 1]++;
} else {
cnt[r[idx]]++;
}
} else {
int num = *lower_bound(l.begin(), l.end(), i);
if ((num - i) % 2) {
cnt[num]++;
} else {
cnt[num - 1]++;
}
}
}
f(n) { cout << cnt[i] << ' '; }
cout << endl;
//}
} | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i, j, k) for (int i = j; i < k; i++)
#define f(n) fr(i, 0, n)
#define f1(n) fr(i, 1, n + 1)
#define ms(i) memset(i, 0, sizeof(i));
#define ms1(i) memset(i, -1, sizeof(i));
#define F first
#define S second
const ll mod = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
// while(cin >> n){
string s;
cin >> s;
n = s.size();
vector<int> l, r;
f(n) {
if (s[i] == 'L')
l.pb(i);
else
r.pb(i);
}
int cnt[n + 5] = {};
f(n) {
if (s[i] == 'L') {
int idx = lower_bound(r.begin(), r.end(), i) - r.begin() - 1;
if ((i - r[idx]) % 2) {
cnt[r[idx] + 1]++;
} else {
cnt[r[idx]]++;
}
} else {
int num = *lower_bound(l.begin(), l.end(), i);
if ((num - i) % 2) {
cnt[num - 1]++;
} else {
cnt[num]++;
}
}
}
f(n) { cout << cnt[i] << ' '; }
cout << endl;
//}
} | [
"expression.operation.binary.remove"
] | 758,738 | 758,739 | u308590217 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef vector<V> VV;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 2505
const ll LINF = (ll)1e18 + 7; //
const int INF = 1e9 + 7; // 2,147,483,647 (Max int)
const int MOD = 1e9 + 7;
// テンプレ終了
//====================================================================//
//
int main() {
string S;
cin >> S;
int N = S.size();
V u(N, 1), d(N, 0);
REP(i, N - 1) {
if (S[i] == 'R' && S[i + 1] == 'R') {
u[i + 1] += d[i];
d[i + 1] += u[i];
}
}
for (int i = N - 1; i > 0; --i) {
if (S[i] == 'L' && S[i - 1] == 'L') {
u[i - 1] += d[i];
d[i - 1] += u[i];
}
}
REP(i, N - 1) {
if (S[i] == 'R' && S[i + 1] == 'L') {
cout << (u[i] + d[i + 1]) << " ";
cout << (d[i] + u[i + 1]) << " ";
++i;
} else
cout << '0' << " ";
}
cout << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef vector<V> VV;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 2505
const ll LINF = (ll)1e18 + 7; //
const int INF = 1e9 + 7; // 2,147,483,647 (Max int)
const int MOD = 1e9 + 7;
// テンプレ終了
//====================================================================//
//
int main() {
string S;
cin >> S;
int N = S.size();
V u(N, 1), d(N, 0);
REP(i, N - 1) {
if (S[i] == 'R' && S[i + 1] == 'R') {
u[i + 1] += d[i];
d[i + 1] += u[i];
}
}
for (int i = N - 1; i > 0; --i) {
if (S[i] == 'L' && S[i - 1] == 'L') {
u[i - 1] += d[i];
d[i - 1] += u[i];
}
}
REP(i, N) {
if (S[i] == 'R' && S[i + 1] == 'L') {
cout << (u[i] + d[i + 1]) << " ";
cout << (d[i] + u[i + 1]) << " ";
++i;
} else
cout << '0' << " ";
}
cout << endl;
return 0;
}
| [
"expression.operation.binary.remove"
] | 758,740 | 758,741 | u090325904 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
string S;
cin >> S;
vector<int> ans(S.size());
int from = 0;
int to = 0;
int point = 0;
for (int i = 0; i < S.size() - 1; i++) {
if (S.at(i) == 'R' && S.at(i + 1) == 'L') {
point = i;
}
if (S.at(i) == 'L' && S.at(i + 1) == 'R') {
to = i;
for (int j = from; j <= to; j++) {
if (abs(point - j) % 2 == 0) {
ans[point]++;
} else {
ans[point + 1]++;
}
}
from = i + 1;
}
if (S.size() == i + 2) {
to = i + 1;
for (int j = from; j <= to; j++) {
if (abs(point - j) % 2 == 0) {
ans[point]++;
} else {
ans[point + 1]++;
}
}
}
}
for (auto n : ans)
cout << n;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
string S;
cin >> S;
vector<int> ans(S.size());
int from = 0;
int to = 0;
int point = 0;
for (int i = 0; i < S.size() - 1; i++) {
if (S.at(i) == 'R' && S.at(i + 1) == 'L') {
point = i;
}
if (S.at(i) == 'L' && S.at(i + 1) == 'R') {
to = i;
for (int j = from; j <= to; j++) {
if (abs(point - j) % 2 == 0) {
ans[point]++;
} else {
ans[point + 1]++;
}
}
from = i + 1;
}
if (S.size() == i + 2) {
to = i + 1;
for (int j = from; j <= to; j++) {
if (abs(point - j) % 2 == 0) {
ans[point]++;
} else {
ans[point + 1]++;
}
}
}
}
for (auto n : ans)
cout << n << " ";
} | [
"io.output.change"
] | 758,762 | 758,763 | u598710706 | cpp |
p02954 | #include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
using namespace std;
// using namespace __gnu_cxx;
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 400005, MAXM = 102, Mod = 1000000007, MAXLog = 20;
int main() {
#ifndef ONLINE_JUDGE
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9),
cout << fixed;
string s;
cin >> s;
vector<int> lft(s.size());
vector<int> right(s.size());
int lst = 0;
for (int i = 0; i < s.size(); ++i) {
lst = (s[i] == 'R' ? i : lst);
lft[i] = lst;
}
lst = s.size() - 1;
for (int i = s.size() - 1; i >= 0; --i) {
lst = (s[i] == 'L' ? i : lst);
right[i] = lst;
}
vector<int> ans(s.size(), 0);
for (int i = 0; i < s.size(); ++i) {
if (s[i] == 'R') {
ans[right[i] - ((right[i] - i) & 1)]++;
} else {
ans[lft[i] - ((i - lft[i]) & 1)]++;
}
}
for (int i = 0; i < s.size(); ++i) {
cout << ans[i] << ' ';
}
cout << '\n';
return 0;
}
| #include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
using namespace std;
// using namespace __gnu_cxx;
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 400005, MAXM = 102, Mod = 1000000007, MAXLog = 20;
int main() {
#ifndef ONLINE_JUDGE
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9),
cout << fixed;
string s;
cin >> s;
vector<int> lft(s.size());
vector<int> right(s.size());
int lst = 0;
for (int i = 0; i < s.size(); ++i) {
lst = (s[i] == 'R' ? i : lst);
lft[i] = lst;
}
lst = s.size() - 1;
for (int i = s.size() - 1; i >= 0; --i) {
lst = (s[i] == 'L' ? i : lst);
right[i] = lst;
}
vector<int> ans(s.size(), 0);
for (int i = 0; i < s.size(); ++i) {
if (s[i] == 'R') {
ans[right[i] - ((right[i] - i) & 1)]++;
} else {
ans[lft[i] + ((i - lft[i]) & 1)]++;
}
}
for (int i = 0; i < s.size(); ++i) {
cout << ans[i] << ' ';
}
cout << '\n';
return 0;
}
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 758,764 | 758,765 | u381626581 | cpp |
p02954 | // LRが連続している分だけ繰り返せば十分
//その後は、偶奇で繰り返すだけ
//
//実際は偶奇に分ければ、繰り返さなくても答えは出る
// RRRRL -> Rの端に集まるのは、Rの端から左に見て、2個目と4個目のR
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
int main() {
string s;
cin >> s;
int s_size = s.size();
vector<int> result(s_size, 0);
// Rを計算する
vector<int> r_count(2, 0);
int count = 0;
for (int i = 0; i < s_size; i++) {
if (s[i] == 'R') {
r_count[i % 2]++;
count++;
} else {
if (count > 0) {
// RからLに切り替わったら
result[i] += r_count[i % 2]; // Lの方には、Lと偶奇が同じR
result[i - 1] += r_count[(i + 1) % 2];
r_count[0] = r_count[1] = count = 0;
}
}
}
// Lを計算する
count = 0;
vector<int> l_count(2, 0);
for (int i = s_size - 1; i > 0; i--) {
if (s[i] == 'L') {
l_count[i % 2]++;
count++;
} else {
if (count > 0) {
result[i] += l_count[i % 2]; // Rの方には、Rと偶奇が同じL
result[i + 1] += l_count[(i + 1) % 2];
l_count[0] = l_count[1] = count = 0;
}
}
}
bool is_first = true;
for (int i = 0; i < s_size; i++) {
if (is_first) {
is_first = false;
} else {
cout << " ";
}
cout << result[i];
}
cout << endl;
return 0;
}
| // LRが連続している分だけ繰り返せば十分
//その後は、偶奇で繰り返すだけ
//
//実際は偶奇に分ければ、繰り返さなくても答えは出る
// RRRRL -> Rの端に集まるのは、Rの端から左に見て、2個目と4個目のR
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
int main() {
string s;
cin >> s;
int s_size = s.size();
vector<int> result(s_size, 0);
// Rを計算する
vector<int> r_count(2, 0);
int count = 0;
for (int i = 0; i < s_size; i++) {
if (s[i] == 'R') {
r_count[i % 2]++;
count++;
} else {
if (count > 0) {
// RからLに切り替わったら
result[i] += r_count[i % 2]; // Lの方には、Lと偶奇が同じR
result[i - 1] += r_count[(i + 1) % 2];
r_count[0] = r_count[1] = count = 0;
}
}
}
// Lを計算する
count = 0;
vector<int> l_count(2, 0);
for (int i = s_size - 1; i >= 0; i--) {
if (s[i] == 'L') {
l_count[i % 2]++;
count++;
} else {
if (count > 0) {
result[i] += l_count[i % 2]; // Rの方には、Rと偶奇が同じL
result[i + 1] += l_count[(i + 1) % 2];
l_count[0] = l_count[1] = count = 0;
}
}
}
bool is_first = true;
for (int i = 0; i < s_size; i++) {
if (is_first) {
is_first = false;
} else {
cout << " ";
}
cout << result[i];
}
cout << endl;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,766 | 758,767 | u538188080 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;
const int MAX_N = 1e5 + 5;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
rep(ri, 2) {
int cnt = 0;
rep(i, n) {
if (s[i] == 'R') {
cnt++;
} else {
ans[i - 1] += (cnt + 1) / 2;
ans[i] += cnt / 2;
cnt = 0;
}
}
reverse(ans.begin(), ans.end());
reverse(s.begin(), s.end());
rep(i, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] == 'L';
}
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
}
| #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;
const int MAX_N = 1e5 + 5;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
rep(ri, 2) {
int cnt = 0;
rep(i, n) {
if (s[i] == 'R') {
cnt++;
} else {
ans[i - 1] += (cnt + 1) / 2;
ans[i] += cnt / 2;
cnt = 0;
}
}
reverse(ans.begin(), ans.end());
reverse(s.begin(), s.end());
rep(i, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
}
| [
"expression.operation.compare.replace.remove",
"assignment.replace.add",
"misc.typo"
] | 758,772 | 758,773 | u765690804 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;
const int MAX_N = 1e5 + 5;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
rep(ri, 2) {
int cnt = 0;
rep(i, n) {
if (s[i] == 'R') {
cnt++;
} else {
ans[i - 1] += (cnt + 1) / 2;
ans[i] += cnt / 2;
cnt = 0;
}
}
reverse(ans.begin(), ans.end());
reverse(s.begin(), s.end());
rep(i, n) {
if (s[i] == 'L')
s[i] == 'R';
else
s[i] == 'L';
}
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
}
| #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;
const int MAX_N = 1e5 + 5;
int main() {
string s;
cin >> s;
int n = s.size();
vector<int> ans(n);
rep(ri, 2) {
int cnt = 0;
rep(i, n) {
if (s[i] == 'R') {
cnt++;
} else {
ans[i - 1] += (cnt + 1) / 2;
ans[i] += cnt / 2;
cnt = 0;
}
}
reverse(ans.begin(), ans.end());
reverse(s.begin(), s.end());
rep(i, n) {
if (s[i] == 'L')
s[i] = 'R';
else
s[i] = 'L';
}
}
rep(i, n) cout << ans[i] << " ";
cout << endl;
}
| [
"expression.operation.compare.replace.remove",
"assignment.replace.add",
"misc.typo"
] | 758,774 | 758,773 | u765690804 | cpp |
p02954 | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <math.h>
#include <queue>
#include <sstream>
#include <stdexcept>
#include <stdio.h>
#include <string>
#include <vector>
// for(int i=0;i<n;i++)
#define cinf(n, x) \
for (int i = 0; i < n; i++) \
cin >> x[i];
#define pi pair<int, int>
using namespace std;
using ll = long long;
int main() {
string h;
cin >> h;
int r[100002] = {}, l[100002] = {};
int k = 0;
for (int i = 0; i < h.size() - 1; i++) {
if (h[i] == 'R' && h[i + 1] == 'R')
r[k]++;
else if (h[i] == 'L' && h[i + 1] == 'L')
l[k]++;
else if (h[i] == 'L' && h[i + 1] == 'R')
k++;
}
for (int p = 0; p <= k; p++) {
for (int i = 0; i < r[p]; i++)
cout << '0' << ' ';
if ((r[p] + l[p]) % 2 == 0) {
cout << (r[p] + l[p] + 2) / 2 << ' ' << (r[p] + l[p] + 2) / 2 << ' ';
} else if ((r[p] + l[p]) % 2 != 0 && l[p] % 2 == 0) {
cout << (r[p] + l[p] + 3) / 2 << ' ' << (r[p] + l[p] + 1) / 2 << ' ';
} else {
cout << (r[p] + l[p] + 1) / 2 << ' ' << (r[p] + l[p] + 3) / 2 << ' ';
}
for (int i = 0; i < l[p]; i++)
cout << '0' << ' ';
}
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <math.h>
#include <queue>
#include <sstream>
#include <stdexcept>
#include <stdio.h>
#include <string>
#include <vector>
// for(int i=0;i<n;i++)
#define cinf(n, x) \
for (int i = 0; i < n; i++) \
cin >> x[i];
#define pi pair<int, int>
using namespace std;
using ll = long long;
int main() {
string h;
cin >> h;
int r[100002] = {}, l[100002] = {};
int k = 0;
for (int i = 0; i < h.size() - 1; i++) {
if (h[i] == 'R' && h[i + 1] == 'R')
r[k]++;
else if (h[i] == 'L' && h[i + 1] == 'L')
l[k]++;
else if (h[i] == 'L' && h[i + 1] == 'R')
k++;
}
for (int p = 0; p <= k; p++) {
for (int i = 0; i < r[p]; i++)
cout << '0' << ' ';
if ((r[p] + l[p]) % 2 == 0) {
cout << (r[p] + l[p] + 2) / 2 << ' ' << (r[p] + l[p] + 2) / 2 << ' ';
} else if ((r[p] + l[p]) % 2 != 0 && l[p] % 2 != 0) {
cout << (r[p] + l[p] + 3) / 2 << ' ' << (r[p] + l[p] + 1) / 2 << ' ';
} else {
cout << (r[p] + l[p] + 1) / 2 << ' ' << (r[p] + l[p] + 3) / 2 << ' ';
}
for (int i = 0; i < l[p]; i++)
cout << '0' << ' ';
}
} | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,787 | 758,788 | u139300044 | cpp |
p02954 | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.length(), k = 0;
vector<int> n = {0};
char prev = 'R';
for (int i = 0; i < N; i++) {
if (prev == S[i]) {
n[k] += 1;
} else {
n.push_back(1);
prev = S[i];
k += 1;
}
}
for (int i = 0; i < n.size(); i++) {
for (int k = 1; k < n[i]; k++) {
cout << 0 << ' ';
}
if ((n[i] + n[i + 1]) % 2 == 0) {
cout << (n[i] + n[i + 1]) / 2 << ' ' << (n[i] + n[i + 1]) / 2;
} else {
if (n[i] % 2 == 0) {
cout << (n[i] + n[i + 1]) / 2 << ' ' << (n[i] + n[i + 1]) / 2 + 1
<< ' ';
} else {
cout << (n[i] + n[i + 1]) / 2 + 1 << ' ' << (n[i] + n[i + 1]) / 2
<< ' ';
}
}
i += 1;
for (int k = 1; k < n[i]; k++) {
cout << 0 << ' ';
}
}
return 0;
} | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.length(), k = 0;
vector<int> n = {0};
char prev = 'R';
for (int i = 0; i < N; i++) {
if (prev == S[i]) {
n[k] += 1;
} else {
n.push_back(1);
prev = S[i];
k += 1;
}
}
for (int i = 0; i < n.size(); i++) {
for (int k = 1; k < n[i]; k++) {
cout << 0 << ' ';
}
if ((n[i] + n[i + 1]) % 2 == 0) {
cout << (n[i] + n[i + 1]) / 2 << ' ' << (n[i] + n[i + 1]) / 2 << ' ';
} else {
if (n[i] % 2 == 0) {
cout << (n[i] + n[i + 1]) / 2 << ' ' << (n[i] + n[i + 1]) / 2 + 1
<< ' ';
} else {
cout << (n[i] + n[i + 1]) / 2 + 1 << ' ' << (n[i] + n[i + 1]) / 2
<< ' ';
}
}
i += 1;
for (int k = 1; k < n[i]; k++) {
cout << 0 << ' ';
}
}
return 0;
} | [
"io.output.change"
] | 758,793 | 758,794 | u775643066 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout \
if (false) \
cout
#define debug() if (false)
#define dvout \
if (false) \
cout
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v) \
for (auto &i : v) { \
cout << i << " "; \
} \
cout << "\n"; //配列出力
#define vin(v) \
for (auto &i : v) \
cin >> i; //配列入力
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9 + 7)
typedef long long ll;
typedef unsigned long long ull;
void Main() {
string S;
cin >> S;
bool prev = false;
vector<int> ans(S.size(), 0);
int cnt = 0;
S.push_back('R');
dout << S.size() << endl;
for (int i = 1; i < S.size(); i++) {
if (prev == (S[i] == 'L')) {
cnt++;
} else {
cnt++;
dout << cnt << "\t";
if (prev) {
ans[i - cnt] += (cnt) / 2;
ans[i - cnt - 1] += (cnt + 1) / 2;
} else {
ans[i] += (cnt) / 2;
ans[i - 1] += (cnt + 1) / 2;
}
prev = (S[i] == 'L');
cnt = 0;
}
}
dout << endl << endl;
vout(ans);
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << std::fixed << std::setprecision(15);
Main();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout \
if (false) \
cout
#define debug() if (false)
#define dvout \
if (false) \
cout
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v) \
for (auto &i : v) { \
cout << i << " "; \
} \
cout << "\n"; //配列出力
#define vin(v) \
for (auto &i : v) \
cin >> i; //配列入力
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9 + 7)
typedef long long ll;
typedef unsigned long long ull;
void Main() {
string S;
cin >> S;
bool prev = false;
vector<int> ans(S.size(), 0);
int cnt = 0;
S.push_back('R');
dout << S.size() << endl;
for (int i = 1; i < S.size(); i++) {
if (prev == (S[i] == 'L')) {
cnt++;
} else {
cnt++;
dout << cnt << "\t";
if (prev) {
ans[i - cnt] += (cnt + 1) / 2;
ans[i - cnt - 1] += (cnt) / 2;
} else {
ans[i] += (cnt) / 2;
ans[i - 1] += (cnt + 1) / 2;
}
prev = (S[i] == 'L');
cnt = 0;
}
}
dout << endl << endl;
vout(ans);
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << std::fixed << std::setprecision(15);
Main();
return 0;
} | [
"assignment.change",
"expression.operation.binary.remove"
] | 758,831 | 758,832 | u111937495 | cpp |
p02954 | #include <iostream>
using namespace std;
int main() {
string s;
char bloc1, bloc2, dir;
int num_f, num_s, rnum, lnum, lcount, i, count, len;
cin >> s;
len = (int)(s.length());
if (len == 2)
cout << 1 << " " << 1;
else {
bloc1 = s[0];
bloc2 = s[1];
num_f = 0;
num_s = 0;
rnum = 0;
lnum = 0;
lcount = 0;
dir = 'f';
for (count = 0; count < (len - 1); count++) {
if (bloc1 == 'R' && bloc2 == 'L') {
if (dir = 's') {
rnum = num_s + 1;
lnum = num_f + 1;
} else {
rnum = num_f + 1;
lnum = num_s + 1;
}
dir = 'f';
num_f = 0;
num_s = 0;
}
if (bloc1 == 'L' && bloc2 == 'L') {
if (dir == 'f') {
rnum++;
dir = 's';
} else {
lnum++;
dir = 'f';
}
lcount++;
}
if (bloc1 == 'L' && bloc2 == 'R') {
cout << rnum << " " << lnum << " ";
if (lcount > 0) {
for (i = 0; i < lcount; i++)
cout << 0 << " ";
}
lcount = 0;
dir = 'f';
}
if (bloc1 == 'R' && bloc2 == 'R') {
if (dir == 'f') {
num_f++;
dir = 's';
} else {
num_s++;
dir = 'f';
}
cout << 0 << " ";
}
bloc1 = bloc2;
bloc2 = s[(count + 2)];
}
cout << rnum << " " << lnum << " ";
if (lcount > 0) {
for (i = 0; i < (lcount - 1); i++)
cout << 0 << " ";
}
cout << 0;
}
return 0;
} | #include <iostream>
using namespace std;
int main() {
string s;
char bloc1, bloc2, dir;
int num_f, num_s, rnum, lnum, lcount, i, count, len;
cin >> s;
len = (int)(s.length());
if (len == 2)
cout << 1 << " " << 1;
else {
bloc1 = s[0];
bloc2 = s[1];
num_f = 0;
num_s = 0;
rnum = 0;
lnum = 0;
lcount = 0;
dir = 'f';
for (count = 0; count < (len - 1); count++) {
if (bloc1 == 'R' && bloc2 == 'L') {
if (dir = 's') {
rnum = num_s + 1;
lnum = num_f + 1;
} else {
rnum = num_f + 1;
lnum = num_s + 1;
}
dir = 'f';
num_f = 0;
num_s = 0;
}
if (bloc1 == 'L' && bloc2 == 'L') {
if (dir == 'f') {
rnum++;
dir = 's';
} else {
lnum++;
dir = 'f';
}
lcount++;
}
if (bloc1 == 'L' && bloc2 == 'R') {
cout << rnum << " " << lnum << " ";
if (lcount > 0) {
for (i = 0; i < lcount; i++)
cout << 0 << " ";
}
lcount = 0;
dir = 'f';
}
if (bloc1 == 'R' && bloc2 == 'R') {
if (dir == 'f') {
num_f++;
dir = 's';
} else {
num_s++;
dir = 'f';
}
cout << 0 << " ";
}
bloc1 = bloc2;
bloc2 = s[(count + 2)];
}
cout << rnum << " " << lnum << " ";
if (lcount > 0) {
for (i = 0; i < (lcount - 1); i++)
cout << 0 << " ";
cout << 0;
}
}
return 0;
} | [] | 758,837 | 758,838 | u736278528 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define sachin \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
int main() {
sachin long long n, count1 = 1;
string s;
cin >> s;
n = s.size();
vector<long long> vect, vect2(n, 0);
char a = 'R';
for (int i = 1; i < n; i++) {
while (i < n && s[i] == a)
i++, count1++;
// vect2[i-1]=1;vect2[i]=1;
vect.push_back(count1);
if (i == n - 1 && a != 'L')
vect.push_back(1);
if (a == 'R')
a = 'L';
else
a = 'R';
count1 = 1;
}
long long k = 0;
for (int i = 0; i < n - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
long long mid = (vect[0] + vect[1]) / 2;
if ((vect[k] + vect[k + 1]) % 2 == 0)
vect2[i] = mid, vect2[i + 1] = mid;
else if (vect[k] > vect[k + 1]) {
if ((vect[k] - 1) % 2 == 0)
vect2[i] = 1 + mid, vect2[i + 1] = mid;
else
vect2[i] = mid, vect2[i + 1] = mid + 1;
} else {
if ((vect[k + 1] - 1) % 2 == 0)
vect2[i + 1] = 1 + mid, vect2[i] = mid;
else
vect2[i + 1] = mid, vect2[i] = mid + 1;
}
k += 2;
}
}
for (int i = 0; i < n; i++)
cout << vect2[i] << " ";
cout << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define sachin \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
int main() {
sachin long long n, count1 = 1;
string s;
cin >> s;
n = s.size();
vector<long long> vect, vect2(n, 0);
char a = 'R';
for (int i = 1; i < n; i++) {
while (i < n && s[i] == a)
i++, count1++;
// vect2[i-1]=1;vect2[i]=1;
vect.push_back(count1);
if (i == n - 1 && a != 'L')
vect.push_back(1);
if (a == 'R')
a = 'L';
else
a = 'R';
count1 = 1;
}
long long k = 0;
for (int i = 0; i < n - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
long long mid = (vect[k] + vect[k + 1]) / 2;
if ((vect[k] + vect[k + 1]) % 2 == 0)
vect2[i] = mid, vect2[i + 1] = mid;
else if (vect[k] > vect[k + 1]) {
if ((vect[k] - 1) % 2 == 0)
vect2[i] = 1 + mid, vect2[i + 1] = mid;
else
vect2[i] = mid, vect2[i + 1] = mid + 1;
} else {
if ((vect[k + 1] - 1) % 2 == 0)
vect2[i + 1] = 1 + mid, vect2[i] = mid;
else
vect2[i + 1] = mid, vect2[i] = mid + 1;
}
k += 2;
}
}
for (int i = 0; i < n; i++)
cout << vect2[i] << " ";
cout << endl;
return 0;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 758,839 | 758,840 | u760783140 | cpp |
p02954 | #include <iostream>
#include <string>
int main() {
int s, i, rlPlace;
std::string d;
std::cin >> d;
s = d.length();
bool k;
int ans[100000];
for (i = 0; i < s; i++) {
ans[i] = 0;
}
for (i = 1; i < s; i++) {
k = 0;
while (d[i] == 'R')
++i;
rlPlace = i;
while (d[i] == 'L' && i < s) {
ans[rlPlace + k]++;
k = !k;
i++;
}
}
for (i = s - 2; i >= 0; --i) {
k = 0;
while (d[i] == 'L')
--i;
rlPlace = i;
while (d[i] == 'R' && i >= 0) {
ans[rlPlace - k]++;
k = !k;
--i;
}
}
for (i = 0; i < s; i++) {
if (i != 0)
std::cout << " ";
std::cout << ans[i];
}
std::cout << '\n';
}
| #include <iostream>
#include <string>
int main() {
int s, i, rlPlace;
std::string d;
std::cin >> d;
s = d.length();
bool k;
int ans[100000];
for (i = 0; i < s; i++) {
ans[i] = 0;
}
for (i = 1; i < s; i++) {
k = 0;
while (d[i] == 'R')
++i;
rlPlace = i;
while (d[i] == 'L' && i < s) {
ans[rlPlace - k]++;
k = !k;
i++;
}
}
for (i = s - 2; i >= 0; --i) {
k = 0;
while (d[i] == 'L')
--i;
rlPlace = i;
while (d[i] == 'R' && i >= 0) {
ans[rlPlace + k]++;
k = !k;
--i;
}
}
for (i = 0; i < s; i++) {
if (i != 0)
std::cout << " ";
std::cout << ans[i];
}
std::cout << '\n';
}
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 758,843 | 758,844 | u623601489 | cpp |
p02954 | #include <iostream>
#include <string>
int main() {
int s, i, rlPlace;
std::string d;
std::cin >> d;
s = d.length();
bool k;
int ans[100000];
for (i = 0; i < s; i++) {
ans[i] = 0;
}
for (i = 1; i < s; i++) {
k = 1;
while (d[i] == 'R')
++i;
rlPlace = i;
while (d[i] == 'L' && i < s) {
ans[rlPlace + k]++;
k = !k;
i++;
}
}
for (i = s - 2; i >= 0; --i) {
k = 1;
while (d[i] == 'L')
--i;
rlPlace = i;
while (d[i] == 'R' && i >= 0) {
ans[rlPlace - k]++;
k = !k;
--i;
}
}
for (i = 0; i < s; i++) {
if (i != 0)
std::cout << " ";
std::cout << ans[i];
}
std::cout << '\n';
}
| #include <iostream>
#include <string>
int main() {
int s, i, rlPlace;
std::string d;
std::cin >> d;
s = d.length();
bool k;
int ans[100000];
for (i = 0; i < s; i++) {
ans[i] = 0;
}
for (i = 1; i < s; i++) {
k = 0;
while (d[i] == 'R')
++i;
rlPlace = i;
while (d[i] == 'L' && i < s) {
ans[rlPlace - k]++;
k = !k;
i++;
}
}
for (i = s - 2; i >= 0; --i) {
k = 0;
while (d[i] == 'L')
--i;
rlPlace = i;
while (d[i] == 'R' && i >= 0) {
ans[rlPlace + k]++;
k = !k;
--i;
}
}
for (i = 0; i < s; i++) {
if (i != 0)
std::cout << " ";
std::cout << ans[i];
}
std::cout << '\n';
}
| [
"literal.number.change",
"assignment.value.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 758,845 | 758,844 | u623601489 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> ans((int)s.size()), childR((int)s.size()), childL((int)s.size());
for (int i = 0; i < (int)s.size(); i++) {
if (s[i] == 'L')
continue;
char moto = s[i];
int j = i, cnt = 0;
while (moto == s[j]) {
j++;
cnt++;
if (j > (int)s.size() - 1)
break;
}
int tmp = cnt;
for (int j = i; j < i + cnt; j++) {
childR[j] = cnt;
cnt--;
}
if (tmp > 2)
i += tmp - 2;
}
for (int i = (int)s.size() - 1; i >= 0; i--) {
if (s[i] == 'R')
continue;
char moto = s[i];
int j = i, cnt = 0;
while (moto == s[j]) {
j--;
cnt++;
if (j < 0)
break;
}
int tmp = cnt;
for (int j = i; j > i - tmp; j--) {
childL[j] = cnt;
cnt--;
}
if (tmp > 2)
i -= tmp - 2;
}
for (int i = 0; i < (int)s.size(); i++) {
if (childR[i] == 0)
continue;
if (childR[i] % 2 == 0)
ans[childR[i] + i]++;
else
ans[childR[i] + i - 1]++;
}
for (int i = (int)s.size(); i >= 0; i--) {
if (childL[i] == 0)
continue;
if (childL[i] % 2 == 0)
ans[i - childL[i]]++;
else
ans[i - childL[i] + 1]++;
}
for (int i = 0; i < (int)s.size(); i++)
cout << ans[i] << " ";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> ans((int)s.size()), childR((int)s.size()), childL((int)s.size());
for (int i = 0; i < (int)s.size(); i++) {
if (s[i] == 'L')
continue;
char moto = s[i];
int j = i, cnt = 0;
while (moto == s[j]) {
j++;
cnt++;
if (j > (int)s.size() - 1)
break;
}
int tmp = cnt;
for (int j = i; j < i + tmp; j++) {
childR[j] = cnt;
cnt--;
}
if (tmp > 2)
i += tmp - 2;
}
for (int i = (int)s.size() - 1; i >= 0; i--) {
if (s[i] == 'R')
continue;
char moto = s[i];
int j = i, cnt = 0;
while (moto == s[j]) {
j--;
cnt++;
if (j < 0)
break;
}
int tmp = cnt;
for (int j = i; j > i - tmp; j--) {
childL[j] = cnt;
cnt--;
}
if (tmp > 2)
i -= tmp - 2;
}
for (int i = 0; i < (int)s.size(); i++) {
if (childR[i] == 0)
continue;
if (childR[i] % 2 == 0)
ans[childR[i] + i]++;
else
ans[childR[i] + i - 1]++;
}
for (int i = (int)s.size(); i >= 0; i--) {
if (childL[i] == 0)
continue;
if (childL[i] % 2 == 0)
ans[i - childL[i]]++;
else
ans[i - childL[i] + 1]++;
}
for (int i = 0; i < (int)s.size(); i++)
cout << ans[i] << " ";
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,862 | 758,863 | u018586085 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> ans((int)s.size()), childR((int)s.size()), childL((int)s.size());
for (int i = 0; i < (int)s.size(); i++) {
if (s[i] == 'L')
continue;
char moto = s[i];
int j = i, cnt = 0;
while (moto == s[j]) {
j++;
cnt++;
if (j >= (int)s.size() - 1)
break;
}
int tmp = cnt;
for (int j = i; j < i + cnt; j++) {
childR[j] = cnt;
cnt--;
}
if (tmp > 2)
i += tmp - 2;
}
for (int i = (int)s.size() - 1; i >= 0; i--) {
if (s[i] == 'R')
continue;
char moto = s[i];
int j = i, cnt = 0;
while (moto == s[j]) {
j--;
cnt++;
if (j <= 0)
break;
}
int tmp = cnt;
for (int j = i; j > i - tmp; j--) {
childL[j] = cnt;
cnt--;
}
if (tmp > 2)
i -= tmp - 2;
}
for (int i = 0; i < (int)s.size(); i++) {
if (childR[i] == 0)
continue;
if (childR[i] % 2 == 0)
ans[childR[i] + i]++;
else
ans[childR[i] + i - 1]++;
}
for (int i = (int)s.size(); i >= 0; i--) {
if (childL[i] == 0)
continue;
if (childL[i] % 2 == 0)
ans[i - childL[i]]++;
else
ans[i - childL[i] + 1]++;
}
for (int i = 0; i < (int)s.size(); i++)
cout << ans[i] << " ";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> ans((int)s.size()), childR((int)s.size()), childL((int)s.size());
for (int i = 0; i < (int)s.size(); i++) {
if (s[i] == 'L')
continue;
char moto = s[i];
int j = i, cnt = 0;
while (moto == s[j]) {
j++;
cnt++;
if (j > (int)s.size() - 1)
break;
}
int tmp = cnt;
for (int j = i; j < i + tmp; j++) {
childR[j] = cnt;
cnt--;
}
if (tmp > 2)
i += tmp - 2;
}
for (int i = (int)s.size() - 1; i >= 0; i--) {
if (s[i] == 'R')
continue;
char moto = s[i];
int j = i, cnt = 0;
while (moto == s[j]) {
j--;
cnt++;
if (j < 0)
break;
}
int tmp = cnt;
for (int j = i; j > i - tmp; j--) {
childL[j] = cnt;
cnt--;
}
if (tmp > 2)
i -= tmp - 2;
}
for (int i = 0; i < (int)s.size(); i++) {
if (childR[i] == 0)
continue;
if (childR[i] % 2 == 0)
ans[childR[i] + i]++;
else
ans[childR[i] + i - 1]++;
}
for (int i = (int)s.size(); i >= 0; i--) {
if (childL[i] == 0)
continue;
if (childL[i] % 2 == 0)
ans[i - childL[i]]++;
else
ans[i - childL[i] + 1]++;
}
for (int i = 0; i < (int)s.size(); i++)
cout << ans[i] << " ";
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,864 | 758,863 | u018586085 | cpp |
p02954 | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
string s;
cin >> s;
int si = s.length();
vector<int> hint;
vector<int> hint2;
vector<int> ans;
int l = 0, r = 0;
for (int i = 0; i < si; i++) {
if (i > 0) {
if (s[i] == 'L' && s[i - 1] == 'R') {
hint.push_back(r);
r = 0;
} else if (s[i] == 'R' && s[i - 1] == 'L') {
hint.push_back(l);
l = 0;
}
}
if (s[i] == 'R') {
r++;
}
if (s[i] == 'L') {
l++;
}
if (i == si - 1) {
hint.push_back(l);
}
}
for (int i = 0; i < si; i++) {
ans.push_back(0);
}
for (int i = 0; i < hint.size() / 2; i++) {
r = 0, l = 0;
r += hint[i * 2] / 2;
l += hint[i * 2] - hint[i * 2] / 2;
l += hint[i * 2 + 1] / 2;
r += hint[i * 2 + 1] - hint[i * 2 + 1] / 2;
hint2.push_back(l);
hint2.push_back(r);
}
int basyo;
for (int i = 0; i < hint.size() / 2; i++) {
basyo = 0;
for (int j = 0; j <= i * 2; j++) {
basyo += hint[j];
}
ans[basyo - 1] = hint2[i * 2];
ans[basyo] = hint2[i * 2 + 1];
}
for (int i = 0; i < ans.size(); i++) {
cout << ans[i];
}
return 0;
} | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
string s;
cin >> s;
int si = s.length();
vector<int> hint;
vector<int> hint2;
vector<int> ans;
int l = 0, r = 0;
for (int i = 0; i < si; i++) {
if (i > 0) {
if (s[i] == 'L' && s[i - 1] == 'R') {
hint.push_back(r);
r = 0;
} else if (s[i] == 'R' && s[i - 1] == 'L') {
hint.push_back(l);
l = 0;
}
}
if (s[i] == 'R') {
r++;
}
if (s[i] == 'L') {
l++;
}
if (i == si - 1) {
hint.push_back(l);
}
}
for (int i = 0; i < si; i++) {
ans.push_back(0);
}
for (int i = 0; i < hint.size() / 2; i++) {
r = 0, l = 0;
r += hint[i * 2] / 2;
l += hint[i * 2] - hint[i * 2] / 2;
l += hint[i * 2 + 1] / 2;
r += hint[i * 2 + 1] - hint[i * 2 + 1] / 2;
hint2.push_back(l);
hint2.push_back(r);
}
int basyo;
for (int i = 0; i < hint.size() / 2; i++) {
basyo = 0;
for (int j = 0; j <= i * 2; j++) {
basyo += hint[j];
}
ans[basyo - 1] = hint2[i * 2];
ans[basyo] = hint2[i * 2 + 1];
}
for (int i = 0; i < ans.size(); i++) {
cout << ans[i] << " ";
}
return 0;
} | [
"io.output.change"
] | 758,875 | 758,876 | u135203576 | cpp |
p02954 | //
// Created by kuroneko on 2019-08-04.
//
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define INF 1000000000000009LL
#define MOD 1000000007LL
typedef int Weight;
struct Edge {
int src, dst;
Weight weight;
Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
int main() {
string s;
cin >> s;
vector<int> ans(int(s.size()));
vector<int> ch;
for (int i = 1; i < s.size(); i++) {
if (s[i] == 'L' && s[i - 1] == 'R')
ch.push_back(i);
}
int tmp = 0, i = 0;
while (i != ch.size()) {
while (tmp != s.size()) {
if (s[tmp] == 'R' && tmp < ch[i]) {
if ((ch[i] - tmp) % 2 == 0)
ans[ch[i]]++;
else
ans[ch[i] - 1]++;
} else if (s[tmp] == 'L' && tmp >= ch[i]) {
if ((tmp - ch[i]) % 2 == 0)
ans[ch[i]]++;
else
ans[ch[i] - 1]++;
} else {
i++;
break;
}
tmp++;
}
if (tmp == int(s.size()))
break;
}
for (int i = 0; i < s.size(); i++) {
cout << ans[i];
if (i == int(s.size()) - 1)
cout << " ";
}
cout << endl;
return 0;
}
| //
// Created by kuroneko on 2019-08-04.
//
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define INF 1000000000000009LL
#define MOD 1000000007LL
typedef int Weight;
struct Edge {
int src, dst;
Weight weight;
Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
int main() {
string s;
cin >> s;
vector<int> ans(int(s.size()));
vector<int> ch;
for (int i = 1; i < s.size(); i++) {
if (s[i] == 'L' && s[i - 1] == 'R')
ch.push_back(i);
}
int tmp = 0, i = 0;
while (i != ch.size()) {
while (tmp != s.size()) {
if (s[tmp] == 'R' && tmp < ch[i]) {
if ((ch[i] - tmp) % 2 == 0)
ans[ch[i]]++;
else
ans[ch[i] - 1]++;
} else if (s[tmp] == 'L' && tmp >= ch[i]) {
if ((tmp - ch[i]) % 2 == 0)
ans[ch[i]]++;
else
ans[ch[i] - 1]++;
} else {
i++;
break;
}
tmp++;
}
if (tmp == int(s.size()))
break;
}
for (int i = 0; i < s.size(); i++) {
cout << ans[i];
if (i != int(s.size()) - 1)
cout << " ";
}
cout << endl;
return 0;
}
| [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 758,882 | 758,883 | u492352831 | cpp |
p02954 | #include <algorithm>
#include <cmath>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
int main(void) {
std::string S;
std::cin >> S;
std::vector<int64_t> R(S.size(), 0);
std::vector<int64_t> L(S.size(), 0);
for (int64_t i = 0; i < S.size(); ++i) {
if (S.at(i) == 'R')
R.at(i) = 1;
else
L.at(i) = 1;
}
for (int64_t i = 0; i < S.size() - 1; ++i) {
if (S.at(i) == 'L')
continue;
if (i + 2 >= S.size()) {
if (S.at(i + 1) == 'R') {
R.at(i + 1) += R.at(i);
R.at(i) = 0;
}
} else if (S.at(i + 1) == 'R') {
R.at(i + 2) += R.at(i);
R.at(i) = 0;
}
}
for (int64_t i = S.size() - 1; i >= 1; --i) {
if (S.at(i) == 'R')
continue;
if (i - 2 < 0) {
if (S.at(i - 1) == 'L') {
L.at(i - 1) += L.at(i);
L.at(i) = 0;
}
} else if (S.at(i - 1) == 'L') {
L.at(i - 2) += L.at(i);
L.at(i) = 0;
}
}
for (int64_t i = 0; i < S.size(); ++i) {
std::cout << (R.at(i) + L.at(i));
}
std::cout << std::endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
int main(void) {
std::string S;
std::cin >> S;
std::vector<int64_t> R(S.size(), 0);
std::vector<int64_t> L(S.size(), 0);
for (int64_t i = 0; i < S.size(); ++i) {
if (S.at(i) == 'R')
R.at(i) = 1;
else
L.at(i) = 1;
}
for (int64_t i = 0; i < S.size() - 1; ++i) {
if (S.at(i) == 'L')
continue;
if (i + 2 >= S.size()) {
if (S.at(i + 1) == 'R') {
R.at(i + 1) += R.at(i);
R.at(i) = 0;
}
} else if (S.at(i + 1) == 'R') {
R.at(i + 2) += R.at(i);
R.at(i) = 0;
}
}
for (int64_t i = S.size() - 1; i >= 1; --i) {
if (S.at(i) == 'R')
continue;
if (i - 2 < 0) {
if (S.at(i - 1) == 'L') {
L.at(i - 1) += L.at(i);
L.at(i) = 0;
}
} else if (S.at(i - 1) == 'L') {
L.at(i - 2) += L.at(i);
L.at(i) = 0;
}
}
for (int64_t i = 0; i < S.size(); ++i) {
std::cout << (R.at(i) + L.at(i)) << " ";
}
std::cout << std::endl;
return 0;
} | [
"expression.operation.binary.add"
] | 758,892 | 758,893 | u100280611 | cpp |
p02954 | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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 print(const std::vector<int> &v) {
std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
std::cout << std::endl;
}
int main() {
string S;
cin >> S;
int N = S.length() - 1;
//連続しているRとLを探す周期は2であることは確か
vector<int> C;
for (int i = 0; i < S.length() - 1; i++) {
if (S[i] != S[i + 1]) {
C.push_back(i);
}
}
// Rが始まる座標と偶数回目でのRとLの数
vector<tuple<int, int, int>> res;
for (int i = 0; i < C.size(); i++) {
if (i == 0 and i == C.size() - 1) {
int left = C[i];
int right = N - C[i];
int lc = 1 + left / 2 + (right - right / 2);
int rc = 1 + (left - left / 2) + right / 2;
res.emplace_back(C[i], rc, lc);
} else if (i == 0) {
int left = C[i];
int right = C[i + 1] - C[i] - 1;
int lc = 1 + left / 2 + (right - right / 2);
int rc = 1 + (left - left / 2) + right / 2;
res.emplace_back(C[i], rc, lc);
} else if (i % 2 == 0 and i == C.size() - 1) {
int left = C[i] - C[i - 1] - 1;
int right = N - C[i];
int lc = 1 + left / 2 + (right - right / 2);
int rc = 1 + (left - left / 2) + right / 2;
res.emplace_back(C[i], rc, lc);
} else if (i % 2 == 0) {
int left = C[i] - C[i - 1] - 1;
int right = C[i + 1] - C[i] - 1;
int lc = 1 + left / 2 + (right - right / 2);
int rc = 1 + (left - left / 2) + right / 2;
res.emplace_back(C[i], rc, lc);
}
}
vector<long long> ans(N + 1, 0);
for (int i = 0; i < res.size(); i++) {
ans[get<0>(res[i])] = get<2>(res[i]);
ans[get<0>(res[i]) + 1] = get<1>(res[i]);
}
REP(i, N + 1) { cout << ans[i] << " "; }
cout << endl;
} | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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 print(const std::vector<int> &v) {
std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
std::cout << std::endl;
}
int main() {
string S;
cin >> S;
int N = S.length() - 1;
//連続しているRとLを探す周期は2であることは確か
vector<int> C;
for (int i = 0; i < S.length() - 1; i++) {
if (S[i] != S[i + 1]) {
C.push_back(i);
}
}
// Rが始まる座標と偶数回目でのRとLの数
vector<tuple<int, int, int>> res;
for (int i = 0; i < C.size(); i++) {
if (i == 0 and i == C.size() - 1) {
int left = C[i];
int right = N - C[i] - 1;
int lc = 1 + left / 2 + (right - right / 2);
int rc = 1 + (left - left / 2) + right / 2;
res.emplace_back(C[i], rc, lc);
} else if (i == 0) {
int left = C[i];
int right = C[i + 1] - C[i] - 1;
int lc = 1 + left / 2 + (right - right / 2);
int rc = 1 + (left - left / 2) + right / 2;
res.emplace_back(C[i], rc, lc);
} else if (i % 2 == 0 and i == C.size() - 1) {
int left = C[i] - C[i - 1] - 1;
int right = N - C[i] - 1;
int lc = 1 + left / 2 + (right - right / 2);
int rc = 1 + (left - left / 2) + right / 2;
res.emplace_back(C[i], rc, lc);
} else if (i % 2 == 0) {
int left = C[i] - C[i - 1] - 1;
int right = C[i + 1] - C[i] - 1;
int lc = 1 + left / 2 + (right - right / 2);
int rc = 1 + (left - left / 2) + right / 2;
res.emplace_back(C[i], rc, lc);
}
}
vector<long long> ans(N + 1, 0);
for (int i = 0; i < res.size(); i++) {
ans[get<0>(res[i])] = get<2>(res[i]);
ans[get<0>(res[i]) + 1] = get<1>(res[i]);
}
REP(i, N + 1) { cout << ans[i] << " "; }
cout << endl;
} | [
"assignment.change"
] | 758,904 | 758,905 | u824337972 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
string s;
int e[100100];
int n;
int tot;
int stopR[100100];
int stopL[100100];
int go(int pos) {
if (s[pos] == 'R') {
if ((stopR[pos] - pos) % 2 == 0)
return stopR[pos];
return stopR[pos] + 1;
}
if (s[pos] == 'L') {
if ((pos - stopL[pos] + 1) % 2 == 0)
return stopL[pos - 1];
return stopL[pos];
}
}
char a = 'L';
int ans;
int main() {
cin >> s;
n = s.length();
ans = n - 1;
for (int i = n - 1; i >= 0; --i) {
if (s[i] != a) {
ans = i;
a = s[i];
}
stopR[i] = ans;
}
ans = 0;
a = 'R';
for (int i = 0; i < n; ++i) {
if (s[i] != a) {
ans = i;
a = s[i];
}
stopL[i] = ans;
}
for (int i = 0; i < n; ++i) {
e[go(i)]++;
}
for (int i = 0; i < n; ++i) {
cout << e[i] << " ";
}
cout << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
string s;
int e[100100];
int n;
int tot;
int stopR[100100];
int stopL[100100];
int go(int pos) {
if (s[pos] == 'R') {
if ((stopR[pos] - pos) % 2 == 0)
return stopR[pos];
return stopR[pos] + 1;
}
if (s[pos] == 'L') {
if ((pos - stopL[pos] + 1) % 2 == 0)
return stopL[pos] - 1;
return stopL[pos];
}
}
char a = 'L';
int ans;
int main() {
cin >> s;
n = s.length();
ans = n - 1;
for (int i = n - 1; i >= 0; --i) {
if (s[i] != a) {
ans = i;
a = s[i];
}
stopR[i] = ans;
}
ans = 0;
a = 'R';
for (int i = 0; i < n; ++i) {
if (s[i] != a) {
ans = i;
a = s[i];
}
stopL[i] = ans;
}
for (int i = 0; i < n; ++i) {
e[go(i)]++;
}
for (int i = 0; i < n; ++i) {
cout << e[i] << " ";
}
cout << endl;
return 0;
} | [
"function.return_value.change"
] | 758,907 | 758,908 | u798941584 | cpp |
p02954 | #include <iostream>
#include <string>
#include <vector>
int main() {
std::string S;
std::cin >> S;
int length = S.length();
std::vector<int> children(length, 0);
int comparison = 0;
std::vector<int> components;
for (int i = 0; i < length; i += 1) {
if (S[i] == S[comparison]) {
continue;
}
components.push_back(i - comparison);
comparison = i;
}
components.push_back(length - comparison);
int size = components.size();
int count = 0;
for (int i = 0; i < size; i += 1) {
if (i % 2 == 0) {
if (components[i] % 2 == 0) {
children[count + components[i]] += components[i] / 2;
children[count + components[i] - 1] += components[i] / 2;
} else {
children[count + components[i]] += components[i] / 2;
children[count + components[i] - 1] += components[i] / 2 + 1;
}
} else {
if (components[i] % 2 == 0) {
children[count] += components[i] / 2;
children[count - 1] += components[i] / 2;
} else {
children[count] += components[i] / 2 + 1;
children[count] += components[i] / 2;
}
}
count += components[i];
}
for (int i = 0; i < length; i += 1) {
if (i != 0) {
std::cout << " ";
}
std::cout << children[i];
}
std::cout << std::endl;
return 0;
}
| #include <iostream>
#include <string>
#include <vector>
int main() {
std::string S;
std::cin >> S;
int length = S.length();
std::vector<int> children(length, 0);
int comparison = 0;
std::vector<int> components;
for (int i = 0; i < length; i += 1) {
if (S[i] == S[comparison]) {
continue;
}
components.push_back(i - comparison);
comparison = i;
}
components.push_back(length - comparison);
int size = components.size();
int count = 0;
for (int i = 0; i < size; i += 1) {
if (i % 2 == 0) {
if (components[i] % 2 == 0) {
children[count + components[i]] += components[i] / 2;
children[count + components[i] - 1] += components[i] / 2;
} else {
children[count + components[i]] += components[i] / 2;
children[count + components[i] - 1] += components[i] / 2 + 1;
}
} else {
if (components[i] % 2 == 0) {
children[count] += components[i] / 2;
children[count - 1] += components[i] / 2;
} else {
children[count] += components[i] / 2 + 1;
children[count - 1] += components[i] / 2;
}
}
count += components[i];
}
for (int i = 0; i < length; i += 1) {
if (i != 0) {
std::cout << " ";
}
std::cout << children[i];
}
std::cout << std::endl;
return 0;
}
| [
"assignment.change"
] | 758,909 | 758,910 | u785465309 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main() {
string S;
cin >> S;
int N = S.size();
vector<int> ans(N, 0), point(N, 0);
for (int i = 0; i < N - 1; i++) {
if (S.at(i) == 'R' && S.at(i + 1) == 'L') {
point.push_back(i);
}
}
for (int i = 0; i < N; i++) {
vector<int>::iterator it;
if (S.at(i) == 'L') {
it = upper_bound(point.begin(), point.end(), i);
int loop = *(--it);
int dis = i - loop;
if (dis % 2 == 0) {
ans.at(loop)++;
} else {
ans.at(loop + 1)++;
}
} else {
it = lower_bound(point.begin(), point.end(), i);
int loop = *it;
int dis = loop - i;
if (dis % 2 == 0) {
ans.at(loop)++;
} else {
ans.at(loop + 1)++;
}
}
}
for (int i = 0; i < N; i++) {
cout << ans.at(i) << " ";
}
cout << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main() {
string S;
cin >> S;
int N = S.size();
vector<int> ans(N, 0), point(0);
for (int i = 0; i < N - 1; i++) {
if (S.at(i) == 'R' && S.at(i + 1) == 'L') {
point.push_back(i);
}
}
for (int i = 0; i < N; i++) {
vector<int>::iterator it;
if (S.at(i) == 'L') {
it = upper_bound(point.begin(), point.end(), i);
int loop = *(--it);
int dis = i - loop;
if (dis % 2 == 0) {
ans.at(loop)++;
} else {
ans.at(loop + 1)++;
}
} else {
it = lower_bound(point.begin(), point.end(), i);
int loop = *it;
int dis = loop - i;
if (dis % 2 == 0) {
ans.at(loop)++;
} else {
ans.at(loop + 1)++;
}
}
}
for (int i = 0; i < N; i++) {
cout << ans.at(i) << " ";
}
// cout << endl;
// for(int i = 0;i < point.size();i++) {
// cout << point.at(i) << " ";
// }
cout << endl;
}
| [
"call.arguments.change"
] | 758,919 | 758,920 | u372299304 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int len = s.size();
vector<int> ans(len, 0);
// R->L
for (int i = 0; i < len - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
for (int j = 1; (i + j) < len && s[i + j] == 'L'; j++) {
ans[i + (j % 2)]++;
}
}
}
// L->R
for (int ri = 0; ri < len - 1; ri++) {
int i = len - ri;
if (s[i] == 'L' && s[i - 1] == 'R') {
for (int j = 1; (i - j) > -1 && s[i - j] == 'R'; j++) {
ans[i - (j % 2)]++;
}
}
}
for (int i = 0; i < len; i++)
cout << ans[i] << ((i != len - 1) ? " " : "\n");
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int len = s.size();
vector<int> ans(len, 0);
// R->L
for (int i = 0; i < len - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
for (int j = 1; (i + j) < len && s[i + j] == 'L'; j++) {
ans[i + (j % 2)]++;
}
}
}
// L->R
for (int ri = 0; ri < len - 1; ri++) {
int i = len - ri - 1;
if (s[i] == 'L' && s[i - 1] == 'R') {
for (int j = 1; (i - j) > -1 && s[i - j] == 'R'; j++) {
ans[i - (j % 2)]++;
}
}
}
for (int i = 0; i < len; i++)
cout << ans[i] << ((i != len - 1) ? " " : "\n");
return 0;
}
| [
"assignment.change"
] | 758,921 | 758,922 | u905270643 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
vector<ll> G1[500005];
vector<ll> G2[500005];
// vector<P> tree[500010];
priority_queue<ll> pql;
priority_queue<P> pqp;
// big priority queue
priority_queue<ll, vector<ll>, greater<ll>> pqls;
priority_queue<P, vector<P>, greater<P>> pqps;
// small priority queue
// top pop
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
// ll bit[500005];
//↓,→,↑,←
#define p(x) cout << x << endl;
#define el cout << endl;
#define pe(x) cout << (x) << " ";
#define ps(x) cout << fixed << setprecision(25) << x << endl;
#define pu(x) cout << (x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
ll mod = 1000000007;
ll rui(ll number1, ll number2) {
if (number2 == 0) {
return 1;
} else {
ll number3 = rui(number1, number2 / 2);
number3 *= number3;
number3 %= mod;
if (number2 % 2 == 1) {
number3 *= number1;
number3 %= mod;
}
return number3;
}
}
ll gcd(ll number1, ll number2) {
if (number1 > number2) {
swap(number1, number2);
}
if (number1 == 0 || number1 == number2) {
return number2;
} else {
return gcd(number2 % number1, number1);
}
}
void YES(bool condition) {
if (condition) {
p("YES");
} else {
p("NO");
}
return;
}
void Yes(bool condition) {
if (condition) {
p("Yes");
} else {
p("No");
}
return;
}
// ll fact[800005],rfact[800005];
/*
void c3_init(){
fact[0] = rfact[0] = 1;
for(ll i=1; i<=800000; i++){
fact[i] = (fact[i-1]*i) % mod;
}
rfact[800000] = rui(fact[800000],mod - 2);
for(ll i=800000; i>=1; i--){
rfact[i-1] = rfact[i] * i;
rfact[i-1] %= mod;
}
return;}
ll c3(ll n,ll r){
return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
ll n, m, sum, ans, a, b, c, e, g, h, w, i, j, k, q;
ll x[500005], y[500005], z[500005];
char s[500005];
bool dame;
ll num = 0;
void solve(ll r, ll l) {
ll ans_r = 0, ans_l = 0;
if ((r + l) % 2 == 0) {
ans_r = (r + l) / 2;
ans_l = (r + l) / 2;
} else {
if (r > l) {
ans_l = (r + l) / 2 + 1;
ans_r = (r + l) / 2;
if (r % 2 == 1) {
swap(ans_l, ans_r);
}
} else {
ans_l = (r + l) / 2 + 1;
ans_r = (r + l) / 2;
if (r % 2 == 0) {
swap(ans_l, ans_r);
}
}
}
for (ll i = num; i < num + r - 1; i++) {
x[i] = 0;
}
x[num + r - 1] = ans_r;
x[num + r] = ans_l;
for (ll i = num + r + 1; i < num + r + l; i++) {
x[i] = 0;
}
num += r + l;
return;
}
int main() {
cin >> s;
n = strlen(s);
int now = 0;
ll r = 0, l = 0;
for (ll i = 0; i < n; i++) {
if (s[i] == 'L') {
l++;
now = 1;
} else {
if (now == 1) {
// L to R
solve(r, l);
r = 0;
l = 0;
}
r++;
now = 2;
}
}
if (now == 1) {
solve(r, l);
} else {
solve(r, l);
}
for (i = 0; i < n; i++) {
pe(x[i]);
}
el;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
vector<ll> G1[500005];
vector<ll> G2[500005];
// vector<P> tree[500010];
priority_queue<ll> pql;
priority_queue<P> pqp;
// big priority queue
priority_queue<ll, vector<ll>, greater<ll>> pqls;
priority_queue<P, vector<P>, greater<P>> pqps;
// small priority queue
// top pop
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
// ll bit[500005];
//↓,→,↑,←
#define p(x) cout << x << endl;
#define el cout << endl;
#define pe(x) cout << (x) << " ";
#define ps(x) cout << fixed << setprecision(25) << x << endl;
#define pu(x) cout << (x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
ll mod = 1000000007;
ll rui(ll number1, ll number2) {
if (number2 == 0) {
return 1;
} else {
ll number3 = rui(number1, number2 / 2);
number3 *= number3;
number3 %= mod;
if (number2 % 2 == 1) {
number3 *= number1;
number3 %= mod;
}
return number3;
}
}
ll gcd(ll number1, ll number2) {
if (number1 > number2) {
swap(number1, number2);
}
if (number1 == 0 || number1 == number2) {
return number2;
} else {
return gcd(number2 % number1, number1);
}
}
void YES(bool condition) {
if (condition) {
p("YES");
} else {
p("NO");
}
return;
}
void Yes(bool condition) {
if (condition) {
p("Yes");
} else {
p("No");
}
return;
}
// ll fact[800005],rfact[800005];
/*
void c3_init(){
fact[0] = rfact[0] = 1;
for(ll i=1; i<=800000; i++){
fact[i] = (fact[i-1]*i) % mod;
}
rfact[800000] = rui(fact[800000],mod - 2);
for(ll i=800000; i>=1; i--){
rfact[i-1] = rfact[i] * i;
rfact[i-1] %= mod;
}
return;}
ll c3(ll n,ll r){
return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
ll n, m, sum, ans, a, b, c, e, g, h, w, i, j, k, q;
ll x[500005], y[500005], z[500005];
char s[500005];
bool dame;
ll num = 0;
void solve(ll r, ll l) {
// pe(r);p(l);
ll ans_r = 0, ans_l = 0;
if ((r + l) % 2 == 0) {
ans_r = (r + l) / 2;
ans_l = (r + l) / 2;
} else {
if (r > l) {
ans_l = (r + l) / 2 + 1;
ans_r = (r + l) / 2;
if (r % 2 == 1) {
swap(ans_l, ans_r);
}
} else {
ans_l = (r + l) / 2 + 1;
ans_r = (r + l) / 2;
if (l % 2 == 0) {
swap(ans_l, ans_r);
}
}
}
for (ll i = num; i < num + r - 1; i++) {
x[i] = 0;
}
x[num + r - 1] = ans_r;
x[num + r] = ans_l;
for (ll i = num + r + 1; i < num + r + l; i++) {
x[i] = 0;
}
num += r + l;
return;
}
int main() {
cin >> s;
n = strlen(s);
int now = 0;
ll r = 0, l = 0;
for (ll i = 0; i < n; i++) {
if (s[i] == 'L') {
l++;
now = 1;
} else {
if (now == 1) {
// L to R
solve(r, l);
r = 0;
l = 0;
}
r++;
now = 2;
}
}
if (now == 1) {
solve(r, l);
} else {
solve(r, l);
}
for (i = 0; i < n; i++) {
pe(x[i]);
}
el;
return 0;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 758,923 | 758,924 | u399527088 | cpp |
p02954 | #include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define rep(a, b, c) for (ll a = b; a <= c; a++)
#define per(a, b, c) for (ll a = b; a >= c; a--)
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 5;
const int M = 2e5 + 5;
int n;
char s[N];
int a[N];
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
// printf("n=%d\n", n);
rep(i, 1, n) a[i] = 1;
rep(i, 1, n) {
if (s[i] == 'R' && s[i - 1] == 'R') {
a[i] += a[i - 1];
a[i - 1] = 0;
}
}
per(i, n, 1) {
if (s[i] == 'L' && s[i + 1] == 'L') {
a[i] += a[i + 1];
a[i + 1] = 0;
}
}
rep(i, 2, n - 1) {
if (s[i] == 'R' && s[i + 1] == 'L') {
int tmp = a[i] / 2;
int tmp2 = a[i + 1] / 2;
a[i] = a[i] - tmp + tmp2;
a[i + 1] = a[i + 1] - tmp2 + tmp;
}
}
printf("%d", a[1]);
rep(i, 2, n) printf(" %d", a[i]);
puts("");
return 0;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define rep(a, b, c) for (ll a = b; a <= c; a++)
#define per(a, b, c) for (ll a = b; a >= c; a--)
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 5;
const int M = 2e5 + 5;
int n;
char s[N];
int a[N];
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
// printf("n=%d\n", n);
rep(i, 1, n) a[i] = 1;
rep(i, 1, n) {
if (s[i] == 'R' && s[i - 1] == 'R') {
a[i] += a[i - 1];
a[i - 1] = 0;
}
}
per(i, n, 1) {
if (s[i] == 'L' && s[i + 1] == 'L') {
a[i] += a[i + 1];
a[i + 1] = 0;
}
}
rep(i, 1, n - 1) {
if (s[i] == 'R' && s[i + 1] == 'L') {
int tmp = a[i] / 2;
int tmp2 = a[i + 1] / 2;
a[i] = a[i] - tmp + tmp2;
a[i + 1] = a[i + 1] - tmp2 + tmp;
}
}
printf("%d", a[1]);
rep(i, 2, n) printf(" %d", a[i]);
puts("");
return 0;
}
| [
"literal.number.change",
"call.arguments.change"
] | 758,925 | 758,926 | u493249745 | cpp |
p02954 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
/*
||||||||||||||||||||||||||||||||||||||||||||||||
| ||| | |||| |||| | |
| | | | | | | | | | |
| | | | | | | | | | |
||||||| | | ||||||| ||| ||| |||||
| | | | | | | | | | |
| | ||| | | | || |||| | |
||||||||||||||||||||||||||||||||||||||||||||||||
*/
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define mp make_pair
#define all(v) v.begin(), v.end()
#define int long long
#define ll long long
#define M 1000000007
#define inputarr(a, n) \
for (int i = 0; i < n; ++i) \
cin >> a[i]
#define GCD(m, n) __gcd(m, n)
#define LCM(m, n) m *(n / GCD(m, n))
#define mii map<ll, ll>
#define msi map<string, ll>
#define mis map<ll int, string>
#define rep(a, b) for (ll i = a; i < b; i++)
#define rep0(n) for (ll i = 0; i < n; i++)
#define repi(i, a, b) for (ll i = a; i < b; i++)
#define pb push_back
#define vi vector<ll>
#define mp make_pair
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define FORE(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define inputoutput \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define input freopen("input.txt", "r", stdin);
#define Set(a, s) 4(a, s, sizeof(a))
#define FOR repi
#define pii pair<int, int>
//#define float long double
ll max(ll a, ll b) { return (a > b) ? a : b; }
int min(int a, int b) { return (a < b) ? a : b; }
int solve() {
string s;
cin >> s;
int n = s.size();
vi r, l;
rep0(n) if (s[i] == 'L') l.pb(i);
else r.pb(-i);
// FORE(it,l) cout<<*it<<" ";cout<<endl;
// FORE(it,r) cout<<*it<<" ";
sort(all(r));
vi ans(n + 1, 0);
rep0(n) {
if (s[i] == 'R') {
int k = upper_bound(all(l), i) - l.begin();
// cout<<k<<" ";
if ((l[k] - i) % 2)
ans[l[k] - 1]++;
else
ans[l[k]]++;
} else {
int k = upper_bound(all(r), -i) - r.begin();
if ((-r[k] - i) % 2)
ans[-r[k] + 1]++;
else
ans[-r[k]]++;
}
}
rep0(n) cout << ans[i] << " ";
r0
}
signed main() {
inputoutput asdf int t = 1;
// cin>>t;
while (t--) {
solve();
}
} |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
/*
||||||||||||||||||||||||||||||||||||||||||||||||
| ||| | |||| |||| | |
| | | | | | | | | | |
| | | | | | | | | | |
||||||| | | ||||||| ||| ||| |||||
| | | | | | | | | | |
| | ||| | | | || |||| | |
||||||||||||||||||||||||||||||||||||||||||||||||
*/
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define mp make_pair
#define all(v) v.begin(), v.end()
#define int long long
#define ll long long
#define M 1000000007
#define inputarr(a, n) \
for (int i = 0; i < n; ++i) \
cin >> a[i]
#define GCD(m, n) __gcd(m, n)
#define LCM(m, n) m *(n / GCD(m, n))
#define mii map<ll, ll>
#define msi map<string, ll>
#define mis map<ll int, string>
#define rep(a, b) for (ll i = a; i < b; i++)
#define rep0(n) for (ll i = 0; i < n; i++)
#define repi(i, a, b) for (ll i = a; i < b; i++)
#define pb push_back
#define vi vector<ll>
#define mp make_pair
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define FORE(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define inputoutput \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define input freopen("input.txt", "r", stdin);
#define Set(a, s) 4(a, s, sizeof(a))
#define FOR repi
#define pii pair<int, int>
//#define float long double
ll max(ll a, ll b) { return (a > b) ? a : b; }
int min(int a, int b) { return (a < b) ? a : b; }
int solve() {
string s;
cin >> s;
int n = s.size();
vi r, l;
rep0(n) if (s[i] == 'L') l.pb(i);
else r.pb(-i);
// FORE(it,l) cout<<*it<<" ";cout<<endl;
// FORE(it,r) cout<<*it<<" ";
sort(all(r));
vi ans(n + 1, 0);
rep0(n) {
if (s[i] == 'R') {
int k = upper_bound(all(l), i) - l.begin();
// cout<<k<<" ";
if ((l[k] - i) % 2)
ans[l[k] - 1]++;
else
ans[l[k]]++;
} else {
int k = upper_bound(all(r), -i) - r.begin();
if ((-r[k] - i) % 2)
ans[-r[k] + 1]++;
else
ans[-r[k]]++;
}
}
rep0(n) cout << ans[i] << " ";
r0
}
signed main() { // inputoutput
asdf int t = 1;
// cin>>t;
while (t--) {
solve();
}
} | [] | 758,939 | 758,940 | u980932400 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a, b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>
#define o_set \
tree<int, null_type, less<int>, rb_tree_tag, \
tree_order_statistics_node_update>
#define o_setll \
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
// member functions :
// 1. order_of_key(k) : number of elements strictly lesser than k
// 2. find_by_order(k) : k-th element in the set
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[], ll b[], ll n);
ll logint(ll x, ll y);
ll gcd(ll x, ll y) {
if (x == 0)
return y;
return gcd(y % x, x);
}
ll powM(ll x, ll y, ll m) {
if (y == 0)
return 1;
ll p = powM(x, y / 2, m) % m;
p = (p * p) % m;
return (y % 2 == 0) ? p : (x * p) % m;
}
ll modI(ll a, ll m) {
ll m0 = m, y = 0, x = 1;
if (m == 1)
return 0;
while (a > 1) {
ll q = a / m;
ll t = m;
m = a % m;
a = t;
t = y;
y = x - q * y;
x = t;
}
if (x < 0)
x += m0;
return x;
}
void pairsort(int a[], int b[], int n) {
pair<int, int> v[n];
REP(i, 0, n) {
v[i].F = a[i];
v[i].S = b[i];
}
sort(v, v + n);
REP(i, 0, n) {
a[i] = v[i].F;
b[i] = v[i].S;
}
}
void pairsortll(ll a[], ll b[], ll n) {
pair<ll, ll> v[n];
REP(i, 0, n) {
v[i].F = a[i];
v[i].S = b[i];
}
sort(v, v + n);
REP(i, 0, n) {
a[i] = v[i].F;
b[i] = v[i].S;
}
}
ll logint(ll x, ll y) {
ll ans = 0;
ll a = 1;
for (ll i = 0; i <= x; i++) {
if (x < a) {
return ans;
}
ans++;
a *= y;
}
return -1;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
*/
ll q = 1;
// cin>>q;
while (q--) {
string s;
cin >> s;
ll n = s.size();
vector<tuple<ll, ll, ll>> v;
REP(i, 0, n) {
v.PB(MT(0, 0, 0));
ll i0 = i;
while (s[i0] == 'L')
i0++;
G(0, v[v.size() - 1]) = i0 - i;
G(2, v[v.size() - 1]) = i0;
i = i0;
while (s[i0] == 'R') {
i0++;
if (i0 == n)
break;
}
G(1, v[v.size() - 1]) = i0 - i;
i = i0 - 1;
}
ll nv = v.size();
ll ans[n] = {};
REP(i, 0, nv) {
ans[G(2, v[i]) - 1] += G(0, v[i]) - G(0, v[i]) / 2 + G(1, v[i]) / 2;
ans[G(2, v[i])] += G(1, v[i]) - G(1, v[i]) / 2 + G(0, v[i]) / 2;
}
REP(i, 0, n) { cout << ans[i] << ' '; }
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a, b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>
#define o_set \
tree<int, null_type, less<int>, rb_tree_tag, \
tree_order_statistics_node_update>
#define o_setll \
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
// member functions :
// 1. order_of_key(k) : number of elements strictly lesser than k
// 2. find_by_order(k) : k-th element in the set
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[], ll b[], ll n);
ll logint(ll x, ll y);
ll gcd(ll x, ll y) {
if (x == 0)
return y;
return gcd(y % x, x);
}
ll powM(ll x, ll y, ll m) {
if (y == 0)
return 1;
ll p = powM(x, y / 2, m) % m;
p = (p * p) % m;
return (y % 2 == 0) ? p : (x * p) % m;
}
ll modI(ll a, ll m) {
ll m0 = m, y = 0, x = 1;
if (m == 1)
return 0;
while (a > 1) {
ll q = a / m;
ll t = m;
m = a % m;
a = t;
t = y;
y = x - q * y;
x = t;
}
if (x < 0)
x += m0;
return x;
}
void pairsort(int a[], int b[], int n) {
pair<int, int> v[n];
REP(i, 0, n) {
v[i].F = a[i];
v[i].S = b[i];
}
sort(v, v + n);
REP(i, 0, n) {
a[i] = v[i].F;
b[i] = v[i].S;
}
}
void pairsortll(ll a[], ll b[], ll n) {
pair<ll, ll> v[n];
REP(i, 0, n) {
v[i].F = a[i];
v[i].S = b[i];
}
sort(v, v + n);
REP(i, 0, n) {
a[i] = v[i].F;
b[i] = v[i].S;
}
}
ll logint(ll x, ll y) {
ll ans = 0;
ll a = 1;
for (ll i = 0; i <= x; i++) {
if (x < a) {
return ans;
}
ans++;
a *= y;
}
return -1;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
*/
ll q = 1;
// cin>>q;
while (q--) {
string s;
cin >> s;
ll n = s.size();
vector<tuple<ll, ll, ll>> v;
REP(i, 0, n) {
v.PB(MT(0, 0, 0));
ll i0 = i;
while (s[i0] == 'R')
i0++;
G(0, v[v.size() - 1]) = i0 - i;
G(2, v[v.size() - 1]) = i0;
i = i0;
while (s[i0] == 'L') {
i0++;
if (i0 == n)
break;
}
G(1, v[v.size() - 1]) = i0 - i;
i = i0 - 1;
}
ll nv = v.size();
ll ans[n] = {};
REP(i, 0, nv) {
ans[G(2, v[i]) - 1] += G(0, v[i]) - G(0, v[i]) / 2 + G(1, v[i]) / 2;
ans[G(2, v[i])] += G(1, v[i]) - G(1, v[i]) / 2 + G(0, v[i]) / 2;
}
REP(i, 0, n) { cout << ans[i] << ' '; }
}
return 0;
} | [
"literal.string.change",
"control_flow.loop.condition.change"
] | 758,945 | 758,946 | u130804410 | cpp |
p02954 | #include <iostream>
#include <string>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int n = s.size();
int ans[n];
int status = 0;
int r = 0;
for (int i = 0; i < n; i++) {
if (status == 0) {
if (s[i] == 'R') {
ans[i] = 0;
r++;
} else {
if (r % 2 == 0) {
ans[i] = r / 2;
ans[i - 1] = r / 2;
} else {
ans[i] = (r - 1) / 2;
ans[i - 1] = (r + 1) / 2;
}
status = 1;
r = 1;
}
} else /*status==1*/ {
if (s[i] == 'L') {
ans[i] = 0;
r++;
} else {
if (r % 2 == 0) {
ans[i - r - 1] += r / 2;
ans[i - r] += r / 2;
} else {
ans[i - r - 1] += (r - 1) / 2;
ans[i - r] += (r + 1) / 2;
}
ans[i] = 0;
status = 0;
r = 1;
}
}
}
if (r > 1) {
if (r % 2 == 0) {
ans[n - r - 1] += r / 2;
ans[n - r] += r / 2;
} else {
ans[n - r - 1] += (r - 1) / 2;
ans[n - r] += (r + 1) / 2;
}
} else
ans[n - 1] = 1;
for (int i = 0; i < n - 1; i++)
cout << ans[i] << " ";
cout << ans[n - 1] << endl;
return 0;
}
| #include <iostream>
#include <string>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int n = s.size();
int ans[n];
int status = 0;
int r = 0;
for (int i = 0; i < n; i++) {
if (status == 0) {
if (s[i] == 'R') {
ans[i] = 0;
r++;
} else {
if (r % 2 == 0) {
ans[i] = r / 2;
ans[i - 1] = r / 2;
} else {
ans[i] = (r - 1) / 2;
ans[i - 1] = (r + 1) / 2;
}
status = 1;
r = 1;
}
} else /*status==1*/ {
if (s[i] == 'L') {
ans[i] = 0;
r++;
} else {
if (r % 2 == 0) {
ans[i - r - 1] += r / 2;
ans[i - r] += r / 2;
} else {
ans[i - r - 1] += (r - 1) / 2;
ans[i - r] += (r + 1) / 2;
}
ans[i] = 0;
status = 0;
r = 1;
}
}
}
if (r > 1) {
if (r % 2 == 0) {
ans[n - r - 1] += r / 2;
ans[n - r] += r / 2;
} else {
ans[n - r - 1] += (r - 1) / 2;
ans[n - r] += (r + 1) / 2;
}
} else
ans[n - 1]++;
for (int i = 0; i < n - 1; i++)
cout << ans[i] << " ";
cout << ans[n - 1] << endl;
return 0;
}
| [] | 758,949 | 758,950 | u464190313 | cpp |
p02954 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
string s;
cin >> s;
ll N = s.size();
ll i;
char cb, cn;
ll Rpos, Lpos;
ll even, odd;
ll ans[N];
cb = 'R';
even = 1;
odd = 0;
for (i = 1; i < N; i++) {
cn = s[i];
if (cb == 'R') {
even += (i + 1) % 2;
odd += i % 2;
if (cn == 'R') {
ans[i - 1] = 0;
}
if (cn == 'L') {
Rpos = i - 1;
Lpos = i;
}
}
if (cb == 'L') {
if (cn == 'L') {
ans[i] = 0;
even += (i + 1) % 2;
odd += i % 2;
}
if (cn == 'R') {
if (Rpos % 2 == 0) {
ans[Rpos] = even;
ans[Lpos] = odd;
} else {
ans[Rpos] = odd;
ans[Lpos] = even;
}
even = (i + 1) % 2;
odd = i % 2;
}
}
if (i == N - 1) {
if (even % 2 == Rpos % 2) {
ans[Rpos] = even;
ans[Lpos] = odd;
} else {
ans[Rpos] = odd;
ans[Lpos] = even;
}
}
cb = cn;
}
for (i = 0; i < N - 1; i++) {
cout << ans[i] << " ";
}
cout << ans[N - 1];
return 0;
}
| #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
string s;
cin >> s;
ll N = s.size();
ll i;
char cb, cn;
ll Rpos, Lpos;
ll even, odd;
ll ans[N];
cb = 'R';
even = 1;
odd = 0;
for (i = 1; i < N; i++) {
cn = s[i];
if (cb == 'R') {
even += (i + 1) % 2;
odd += i % 2;
if (cn == 'R') {
ans[i - 1] = 0;
}
if (cn == 'L') {
Rpos = i - 1;
Lpos = i;
}
}
if (cb == 'L') {
if (cn == 'L') {
ans[i] = 0;
even += (i + 1) % 2;
odd += i % 2;
}
if (cn == 'R') {
if (Rpos % 2 == 0) {
ans[Rpos] = even;
ans[Lpos] = odd;
} else {
ans[Rpos] = odd;
ans[Lpos] = even;
}
even = (i + 1) % 2;
odd = i % 2;
}
}
if (i == N - 1) {
if (Rpos % 2 == 0) {
ans[Rpos] = even;
ans[Lpos] = odd;
} else {
ans[Rpos] = odd;
ans[Lpos] = even;
}
}
cb = cn;
}
for (i = 0; i < N - 1; i++) {
cout << ans[i] << " ";
}
cout << ans[N - 1];
return 0;
}
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 758,953 | 758,954 | u770161743 | cpp |
p02954 | #include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define double long double
#define INF LLONG_MAX / 10
#define P pair<int, int>
#define prique priority_queue
using namespace std;
string s;
int memo[100010], ans[100010];
signed main() {
cin >> s;
int rr = 0;
rep(i, s.size() - 1) {
if (s[i] == 'R')
rr++;
else if (i && s[i - 1] == 'R') {
memo[i - 1] = rr;
rr = 0;
}
}
if (s.back() == 'L')
memo[s.size() - 2] = rr;
rr = 0;
for (int i = s.size() - 1; i > 0; i--) {
if (s[i] == 'L')
rr++;
else if (i != s.size() - 1 && s[i + 1] == 'L') {
memo[i + 1] = rr;
rr = 0;
}
}
if (s[0] == 'R' && s[1] == 'L')
memo[0] = rr;
rep(i, s.size() - 1) {
if (s[i] == 'R' && s[i + 1] == 'L') {
ans[i] = (memo[i] + 1) / 2 + memo[i + 1] / 2;
;
ans[i + 1] = memo[i] / 2 + (memo[i + 1] + 1) / 2;
}
}
cout << ans[0];
REP(i, s.size() - 1) cout << " " << ans[i];
cout << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define double long double
#define INF LLONG_MAX / 10
#define P pair<int, int>
#define prique priority_queue
using namespace std;
string s;
int memo[100010], ans[100010];
signed main() {
cin >> s;
int rr = 0;
rep(i, s.size() - 1) {
if (s[i] == 'R')
rr++;
else if (i && s[i - 1] == 'R') {
memo[i - 1] = rr;
rr = 0;
}
}
if (s.back() == 'L')
memo[s.size() - 2] = rr;
rr = 0;
for (int i = s.size() - 1; i > 0; i--) {
if (s[i] == 'L')
rr++;
else if (i != s.size() - 1 && s[i + 1] == 'L') {
memo[i + 1] = rr;
rr = 0;
}
}
if (s[0] == 'R' && s[1] == 'L')
memo[1] = rr;
rep(i, s.size() - 1) {
if (s[i] == 'R' && s[i + 1] == 'L') {
ans[i] = (memo[i] + 1) / 2 + memo[i + 1] / 2;
;
ans[i + 1] = memo[i] / 2 + (memo[i + 1] + 1) / 2;
}
}
cout << ans[0];
REP(i, s.size() - 1) cout << " " << ans[i];
cout << endl;
return 0;
} | [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change"
] | 758,955 | 758,956 | u379822620 | cpp |
p02954 | #include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FFOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FFOR(i, 0, n)
#define SORT(V) sort((V).begin(), (V).end())
#define INF ((1LL << 62) - (1LL << 31))
#define MOD 1000000007
using namespace std;
int main() {
string S;
cin >> S;
vector<pair<int, int>> A;
int a = 1, b = 0;
FOR(i, 1, S.size()) {
if (S.at(i - 1) == 'L' && S.at(i) == 'R') {
A.push_back(make_pair(a, b));
a = 0;
b = 0;
}
if (S.at(i) == 'R')
a++;
if (S.at(i) == 'L')
b++;
if (i == S.size() - 1)
A.push_back(make_pair(a, b));
}
vector<int> B;
REP(i, A.size()) {
for (int j = 1; j < A[i].first; j++)
B.push_back(0);
int p = (A[i].first + 1) / 2 + A[i].second / 2;
B.push_back(p);
B.push_back(A[i].first + A[i].second - p);
for (int j = 1; j < A[i].second; j++)
B.push_back(0);
}
REP(i, B.size()) cout << B.at(i);
cout << endl;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FFOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FFOR(i, 0, n)
#define SORT(V) sort((V).begin(), (V).end())
#define INF ((1LL << 62) - (1LL << 31))
#define MOD 1000000007
using namespace std;
int main() {
string S;
cin >> S;
vector<pair<int, int>> A;
int a = 1, b = 0;
FOR(i, 1, S.size()) {
if (S.at(i - 1) == 'L' && S.at(i) == 'R') {
A.push_back(make_pair(a, b));
a = 0;
b = 0;
}
if (S.at(i) == 'R')
a++;
if (S.at(i) == 'L')
b++;
if (i == S.size() - 1)
A.push_back(make_pair(a, b));
}
vector<int> B;
REP(i, A.size()) {
for (int j = 1; j < A[i].first; j++)
B.push_back(0);
int p = (A[i].first + 1) / 2 + A[i].second / 2;
B.push_back(p);
B.push_back(A[i].first + A[i].second - p);
for (int j = 1; j < A[i].second; j++)
B.push_back(0);
}
REP(i, B.size()) cout << B.at(i) << " ";
cout << endl;
}
| [
"expression.operation.binary.add"
] | 758,957 | 758,958 | u041282550 | cpp |
p02954 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <time.h>
#include <tuple>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
// using namespace std::vector;
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
//#define M_PI 3.1415926535
#define huge 1000000007
typedef long long int ll;
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);
ll bur(ll N, ll X);
long long comb(int n, int r);
bool IsPrime(int num);
bool dp[110][10010];
class UnionFind;
// UF木
class UnionFind {
public:
//親
vector<int> Parent;
//初期状態
UnionFind(int N) { Parent = vector<int>(N, -1); }
int root(int A) {
if (Parent[A] < 0)
return A;
return Parent[A] = root(Parent[A]);
}
//サイズ確認
int size(int A) { return -Parent[root(A)]; }
int connect(int A, int B) {
// root同氏をくっつける
A = root(A);
B = root(B);
//結合済み
if (A == B) {
return false;
}
//大きいほうに小さいほうをくっつける
if (size(A) < size(B))
swap(A, B);
// Aのサイズ更新
Parent[A] += Parent[B];
// Bの親をAに
Parent[B] = A;
return true;
}
};
int main(void) {
ll N = 0;
ll A = 0;
ll B = 0;
ll C = 0;
ll D = 0;
ll E = 0;
ll W = 0;
ll H = 0;
// ll T = 0;
// ll M = 0;
// ll h[400][400] = {};
ll b[9] = {1, 7, 4, 5, 3, 2, 9, 6, 8}; //順番の配列
// ll b2[9] = { 2,3,4,5,5,5,6,6,7 };//順番の配列
// ll aa[20][20] = {};//sortaf
// ll c2[9] = {};
ll d[10] = {}; //要素数
// ll v[3] = {};
// ll *c, *s, *n;
string S, T, U[52];
char fi[50], fv[50];
ll count = 0;
double count2 = 0;
ll min = 3000;
ll max = 1;
ll dist1 = 0;
ll dist2 = 0;
ll dist3 = 0;
ll now = 0;
int tmax = 10000;
int tmax2 = 0;
// int flag = 0;
// char temp, head, state;
// int is = 0;
bool start = false;
// char p;
ll all = 0, all2 = 0, all3 = 0;
ll amr = 0;
ll first = 0;
ll second = 0;
ll keep = 0;
// ll head = 0;
// ll tail = 0;
// ll lgh = 10000;
// ll state = 0;
char col = NULL;
// ll aa[3] = {10000,10000,10000}, bb[3] = { 10000,10000,10000 }, cc[3] = {
// 10000,10000,10000 }; ll an[3] = { 10000,10000,10000 }, bn[3] = {
// 10000,10000,10000 }, cn[3] = { 10000,10000,10000 };
cin >> S;
// vector<ll> mo(A+1);
vector<ll> damA(S.length());
vector<ll> damB(N);
rep(i, 0, S.length() - 1) {
if (S[i] == 'R' && S[i + 1] == 'R') {
first++;
} else if (S[i] == 'R' && S[i + 1] == 'L') {
damA[i]++;
damA[i + 1]++;
if (first % 2 == 0) {
damA[i] += first / 2;
damA[i + 1] += first / 2;
} else {
damA[i] += first / 2;
damA[i + 1] += first / 2;
damA[i + 1]++;
}
first = 0;
keep = i;
} else if (S[i] == 'L' && S[i + 1] == 'L') {
second++;
} else if (S[i] == 'L' && S[i + 1] == 'R') {
if (second % 2 == 0) {
damA[keep] += second / 2;
damA[keep + 1] += second / 2;
} else {
damA[keep] += second / 2;
damA[keep + 1] += second / 2;
damA[keep]++;
}
second = 0;
}
}
if (second > 0) {
if (second % 2 == 0) {
damA[keep] += second / 2;
damA[keep + 1] += second / 2;
} else {
damA[keep] += second / 2;
damA[keep + 1] += second / 2;
damA[keep]++;
}
}
rep(i, 0, S.length()) { cout << damA[i]; }
cout << endl;
return 0;
}
ll bur(ll N, ll X) {
ll pan = 1;
ll pat = 1;
ll burg = 0;
if (X > burg) {
if (N == 0)
return pat;
burg += pan;
burg += bur(N - 1, X);
burg += pat;
burg += bur(N - 1, X);
burg += pan;
}
return burg;
}
ll gcd(ll a, ll b) {
/* 自然数 a > b を確認・入替 */
if (a < b) {
ll tmp = a;
a = b;
b = tmp;
}
ll x = b;
ll y = a;
/* ユークリッドの互除法 */
ll r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return y / b * x;
}
bool IsPrime(int num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false; // 偶数はあらかじめ除く
double sqrtNum = sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
// 素数ではない
return false;
}
}
// 素数である
return true;
}
// 最大公約数を求める関数
ll lcm(ll x, ll y) {
if (x == 0 || y == 0) // 引数チェック
{
// fprintf(stderr, "引数エラーです。\n");
return 0;
}
return (x * y / gcd(x, y));
}
// combination
long long comb(int n, int r) {
std::vector<std::vector<long long>> v(n + 1,
std::vector<long long>(n + 1, 0));
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}
return v[n][r];
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <time.h>
#include <tuple>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
// using namespace std::vector;
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
//#define M_PI 3.1415926535
#define huge 1000000007
typedef long long int ll;
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);
ll bur(ll N, ll X);
long long comb(int n, int r);
bool IsPrime(int num);
bool dp[110][10010];
class UnionFind;
// UF木
class UnionFind {
public:
//親
vector<int> Parent;
//初期状態
UnionFind(int N) { Parent = vector<int>(N, -1); }
int root(int A) {
if (Parent[A] < 0)
return A;
return Parent[A] = root(Parent[A]);
}
//サイズ確認
int size(int A) { return -Parent[root(A)]; }
int connect(int A, int B) {
// root同氏をくっつける
A = root(A);
B = root(B);
//結合済み
if (A == B) {
return false;
}
//大きいほうに小さいほうをくっつける
if (size(A) < size(B))
swap(A, B);
// Aのサイズ更新
Parent[A] += Parent[B];
// Bの親をAに
Parent[B] = A;
return true;
}
};
int main(void) {
ll N = 0;
ll A = 0;
ll B = 0;
ll C = 0;
ll D = 0;
ll E = 0;
ll W = 0;
ll H = 0;
// ll T = 0;
// ll M = 0;
// ll h[400][400] = {};
ll b[9] = {1, 7, 4, 5, 3, 2, 9, 6, 8}; //順番の配列
// ll b2[9] = { 2,3,4,5,5,5,6,6,7 };//順番の配列
// ll aa[20][20] = {};//sortaf
// ll c2[9] = {};
ll d[10] = {}; //要素数
// ll v[3] = {};
// ll *c, *s, *n;
string S, T, U[52];
char fi[50], fv[50];
ll count = 0;
double count2 = 0;
ll min = 3000;
ll max = 1;
ll dist1 = 0;
ll dist2 = 0;
ll dist3 = 0;
ll now = 0;
int tmax = 10000;
int tmax2 = 0;
// int flag = 0;
// char temp, head, state;
// int is = 0;
bool start = false;
// char p;
ll all = 0, all2 = 0, all3 = 0;
ll amr = 0;
ll first = 0;
ll second = 0;
ll keep = 0;
// ll head = 0;
// ll tail = 0;
// ll lgh = 10000;
// ll state = 0;
char col = NULL;
// ll aa[3] = {10000,10000,10000}, bb[3] = { 10000,10000,10000 }, cc[3] = {
// 10000,10000,10000 }; ll an[3] = { 10000,10000,10000 }, bn[3] = {
// 10000,10000,10000 }, cn[3] = { 10000,10000,10000 };
cin >> S;
// vector<ll> mo(A+1);
vector<ll> damA(S.length());
vector<ll> damB(N);
rep(i, 0, S.length() - 1) {
if (S[i] == 'R' && S[i + 1] == 'R') {
first++;
} else if (S[i] == 'R' && S[i + 1] == 'L') {
damA[i]++;
damA[i + 1]++;
if (first % 2 == 0) {
damA[i] += first / 2;
damA[i + 1] += first / 2;
} else {
damA[i] += first / 2;
damA[i + 1] += first / 2;
damA[i + 1]++;
}
first = 0;
keep = i;
} else if (S[i] == 'L' && S[i + 1] == 'L') {
second++;
} else if (S[i] == 'L' && S[i + 1] == 'R') {
if (second % 2 == 0) {
damA[keep] += second / 2;
damA[keep + 1] += second / 2;
} else {
damA[keep] += second / 2;
damA[keep + 1] += second / 2;
damA[keep]++;
}
second = 0;
}
}
if (second > 0) {
if (second % 2 == 0) {
damA[keep] += second / 2;
damA[keep + 1] += second / 2;
} else {
damA[keep] += second / 2;
damA[keep + 1] += second / 2;
damA[keep]++;
}
}
rep(i, 0, S.length()) { cout << damA[i] << " "; }
cout << endl;
return 0;
}
ll bur(ll N, ll X) {
ll pan = 1;
ll pat = 1;
ll burg = 0;
if (X > burg) {
if (N == 0)
return pat;
burg += pan;
burg += bur(N - 1, X);
burg += pat;
burg += bur(N - 1, X);
burg += pan;
}
return burg;
}
ll gcd(ll a, ll b) {
/* 自然数 a > b を確認・入替 */
if (a < b) {
ll tmp = a;
a = b;
b = tmp;
}
ll x = b;
ll y = a;
/* ユークリッドの互除法 */
ll r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return y / b * x;
}
bool IsPrime(int num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false; // 偶数はあらかじめ除く
double sqrtNum = sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
// 素数ではない
return false;
}
}
// 素数である
return true;
}
// 最大公約数を求める関数
ll lcm(ll x, ll y) {
if (x == 0 || y == 0) // 引数チェック
{
// fprintf(stderr, "引数エラーです。\n");
return 0;
}
return (x * y / gcd(x, y));
}
// combination
long long comb(int n, int r) {
std::vector<std::vector<long long>> v(n + 1,
std::vector<long long>(n + 1, 0));
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}
return v[n][r];
} | [
"io.output.change"
] | 758,960 | 758,961 | u301409936 | cpp |
p02954 | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
// RRLLLLRLRRLL 0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0
int h[100005][2] = {0};
int main() {
int n = 1;
char c;
while (cin >> c) {
if (c == 'R')
h[n][0] = 1;
if (c == 'L')
h[n][0] = -1;
n++;
}
int pe = 0;
for (int i = 1; i <= n; i++) {
if (h[i][0] == 1)
pe++;
if (h[i][0] == -1 && h[i - 1][0] == 1) {
h[i][1] += (pe / 2);
h[i - 1][1] += (pe - pe / 2);
pe = 0;
}
}
pe = 0;
for (int i = n; i > 0; i--) {
if (h[i][0] == -1)
pe++;
if (h[i][0] == 1 && h[i + 1][0] == -1) {
h[i][1] += (pe / 2);
h[i + 1][1] += (pe - pe / 2);
pe = 0;
}
}
for (int i = 1; i <= n; i++) {
cout << h[i][1] << " ";
}
cout << endl;
}
| #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
// RRLLLLRLRRLL 0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0
int h[100005][2] = {0};
int main() {
int n = 1;
char c;
while (cin >> c) {
if (c == 'R')
h[n][0] = 1;
if (c == 'L')
h[n][0] = -1;
n++;
}
n--;
int pe = 0;
for (int i = 1; i <= n; i++) {
if (h[i][0] == 1)
pe++;
if (h[i][0] == -1 && h[i - 1][0] == 1) {
h[i][1] += (pe / 2);
h[i - 1][1] += (pe - pe / 2);
pe = 0;
}
}
pe = 0;
for (int i = n; i > 0; i--) {
if (h[i][0] == -1)
pe++;
if (h[i][0] == 1 && h[i + 1][0] == -1) {
h[i][1] += (pe / 2);
h[i + 1][1] += (pe - pe / 2);
pe = 0;
}
}
for (int i = 1; i <= n; i++) {
cout << h[i][1] << " ";
}
cout << endl;
}
| [
"expression.unary.arithmetic.add"
] | 758,966 | 758,967 | u791146764 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;
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;
}
string s;
void solve() {
cin >> s;
int rnum = 0, lnum = 0, rin, lin;
int n = s.length();
vi ans(n, 0);
rep(i, 0, n) {
if (i == n - 1) {
lnum++;
int num = rnum + lnum;
if (num % 2 == 0) {
ans[lin] = num / 2;
ans[rin] = num / 2;
rnum = 0;
lnum = 0;
} else {
if (rnum > lnum) {
if (rnum % 2 == 0) {
ans[rin] = (rnum + lnum - 1) / 2;
ans[lin] = (rnum + lnum + 1) / 2;
} else {
ans[rin] = (rnum + lnum + 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
}
} else {
if (lnum % 2 == 0) {
ans[rin] = (rnum + lnum + 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
} else {
ans[rin] = (rnum + lnum - 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
}
}
rnum = 0;
lnum = 0;
}
continue;
}
if (s[i] == 'R') {
if (s[i + 1] == 'R') {
rnum++;
} else {
rin = i;
lin = i + 1;
rnum++;
}
} else {
if (s[i + 1] == 'L') {
lnum++;
} else {
lnum++;
int num = rnum + lnum;
if (num % 2 == 0) {
ans[lin] = num / 2;
ans[rin] = num / 2;
rnum = 0;
lnum = 0;
} else {
if (rnum > lnum) {
if (rnum % 2 == 0) {
ans[rin] = (rnum + lnum - 1) / 2;
ans[lin] = (rnum + lnum + 1) / 2;
} else {
ans[rin] = (rnum + lnum + 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
}
} else {
if (lnum % 2 == 0) {
ans[rin] = (rnum + lnum + 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
} else {
ans[rin] = (rnum + lnum - 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
}
}
rnum = 0;
lnum = 0;
}
}
}
}
rep(i, 0, n) { cout << ans[i] << ' '; }
cout << endl;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
// cout << fixed << setprecision(10);
solve();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;
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;
}
string s;
void solve() {
cin >> s;
int rnum = 0, lnum = 0, rin, lin;
int n = s.length();
vi ans(n, 0);
rep(i, 0, n) {
if (i == n - 1) {
lnum++;
int num = rnum + lnum;
if (num % 2 == 0) {
ans[lin] = num / 2;
ans[rin] = num / 2;
rnum = 0;
lnum = 0;
} else {
if (rnum > lnum) {
if (rnum % 2 == 0) {
ans[rin] = (rnum + lnum - 1) / 2;
ans[lin] = (rnum + lnum + 1) / 2;
} else {
ans[rin] = (rnum + lnum + 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
}
} else {
if (lnum % 2 == 0) {
ans[rin] = (rnum + lnum + 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
} else {
ans[rin] = (rnum + lnum - 1) / 2;
ans[lin] = (rnum + lnum + 1) / 2;
}
}
rnum = 0;
lnum = 0;
}
continue;
}
if (s[i] == 'R') {
if (s[i + 1] == 'R') {
rnum++;
} else {
rin = i;
lin = i + 1;
rnum++;
}
} else {
if (s[i + 1] == 'L') {
lnum++;
} else {
lnum++;
int num = rnum + lnum;
if (num % 2 == 0) {
ans[lin] = num / 2;
ans[rin] = num / 2;
rnum = 0;
lnum = 0;
} else {
if (rnum > lnum) {
if (rnum % 2 == 0) {
ans[rin] = (rnum + lnum - 1) / 2;
ans[lin] = (rnum + lnum + 1) / 2;
} else {
ans[rin] = (rnum + lnum + 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
}
} else {
if (lnum % 2 == 0) {
ans[rin] = (rnum + lnum + 1) / 2;
ans[lin] = (rnum + lnum - 1) / 2;
} else {
ans[rin] = (rnum + lnum - 1) / 2;
ans[lin] = (rnum + lnum + 1) / 2;
}
}
rnum = 0;
lnum = 0;
}
}
}
}
rep(i, 0, n) { cout << ans[i] << ' '; }
cout << endl;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
// cout << fixed << setprecision(10);
solve();
return 0;
}
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change",
"assignment.variable.change"
] | 758,972 | 758,973 | u961528573 | cpp |
p02954 | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
string s;
cin >> s;
int size = s.size();
int arr[size];
for (int i = 0; i < size; i++) {
arr[i] = 0;
}
int cnt = 0;
int ans;
for (int i = 0; i < size; i++) {
if (s[i] == 'R')
cnt++;
else {
arr[i - 1] += cnt / 2 + cnt % 2;
arr[i] += cnt / 2;
cnt = 0;
}
}
for (int i = size - 1; i > 0; i--) {
if (s[i] == 'L')
cnt++;
else {
arr[i + 1] += cnt / 2 + cnt % 2;
arr[i] += cnt / 2;
cnt = 0;
}
}
cout << arr[0];
for (int i = 1; i < size; i++) {
cout << " " << arr[i];
}
return 0;
} | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
string s;
cin >> s;
int size = s.size();
int arr[size];
for (int i = 0; i < size; i++) {
arr[i] = 0;
}
int cnt = 0;
for (int i = 0; i < size; i++) {
if (s[i] == 'R')
cnt++;
else {
arr[i - 1] += cnt / 2 + cnt % 2;
arr[i] += cnt / 2;
cnt = 0;
}
}
for (int i = size - 1; i >= 0; i--) {
if (s[i] == 'L')
cnt++;
else {
arr[i + 1] += cnt / 2 + cnt % 2;
arr[i] += cnt / 2;
cnt = 0;
}
}
cout << arr[0];
for (int i = 1; i < size; i++) {
cout << " " << arr[i];
}
return 0;
} | [
"variable_declaration.remove",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 758,974 | 758,975 | u778347695 | cpp |
p02954 | #include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
string S;
cin >> S;
int l = S.size(), count = 0, left = 0, hajime = 0;
vector<int> c(l, 0);
for (int i = 0; i < l; i++) {
if (S[i] == 'R') {
if (i != l - 1 && S[i + 1] == 'R') {
c[i] = 0;
count++;
} else if (i != l - 1 && S[i + 1] == 'L') {
left = i;
count++;
}
} else {
if (i != l - 1 && S[i + 1] == 'R') {
count++;
if (count % 2 && !(left - hajime) % 2) {
c[left] = (count + 1) / 2;
c[left + 1] = count / 2;
} else if (count % 2) {
c[left + 1] = (count + 1) / 2;
c[left] = count / 2;
} else {
c[left + 1] = count / 2;
c[left] = count / 2;
}
hajime = i + 1;
count = 0;
} else if (i != l - 1 && S[i + 1] == 'L') {
c[i + 1] = 0;
count++;
}
}
if (i == l - 1 && count != 0) {
count++;
if (count % 2 && !(left - hajime) % 2) {
c[left] = (count + 1) / 2;
c[left + 1] = count / 2;
} else if (count % 2) {
c[left + 1] = (count + 1) / 2;
c[left] = count / 2;
} else {
c[left + 1] = count / 2;
c[left] = count / 2;
}
}
}
for (int i = 0; i < l; i++) {
cout << c[i] << " ";
}
} | #include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
string S;
cin >> S;
int l = S.size(), count = 0, left = 0, hajime = 0;
vector<int> c(l, 0);
for (int i = 0; i < l; i++) {
if (S[i] == 'R') {
if (i != l - 1 && S[i + 1] == 'R') {
c[i] = 0;
count++;
} else if (i != l - 1 && S[i + 1] == 'L') {
left = i;
count++;
}
} else {
if (i != l - 1 && S[i + 1] == 'R') {
count++;
if (count % 2 && !((left - hajime) % 2)) {
c[left] = (count + 1) / 2;
c[left + 1] = count / 2;
} else if (count % 2) {
c[left + 1] = (count + 1) / 2;
c[left] = count / 2;
} else {
c[left + 1] = count / 2;
c[left] = count / 2;
}
hajime = i + 1;
count = 0;
} else if (i != l - 1 && S[i + 1] == 'L') {
c[i + 1] = 0;
count++;
}
}
if (i == l - 1 && count != 0) {
count++;
if (count % 2 && !((left - hajime) % 2)) {
c[left] = (count + 1) / 2;
c[left + 1] = count / 2;
} else if (count % 2) {
c[left + 1] = (count + 1) / 2;
c[left] = count / 2;
} else {
c[left + 1] = count / 2;
c[left] = count / 2;
}
}
}
for (int i = 0; i < l; i++) {
cout << c[i] << " ";
}
} | [
"control_flow.branch.if.condition.change"
] | 758,982 | 758,983 | u444349080 | cpp |
p02954 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define INF 10e17
#define rep(i, n) for (long long i = 0; i < n; i++)
#define repr(i, n, m) for (long long i = m; i < n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) \
for (auto &&itr : x) { \
debug(itr); \
}
template <class T> inline void chmax(T &ans, T t) {
if (t > ans)
ans = t;
}
template <class T> inline void chmin(T &ans, T t) {
if (t < ans)
ans = t;
}
int main() {
string s;
cin >> s;
s += "T";
vector<ll> ans(s.size(), 0);
int rsum = 0, lsum = 0;
bool flag = false;
pair<int, int> p;
for (int i = 0; i <= s.size(); ++i) {
if (s[i] == 'R')
rsum += 1;
else if (s[i] == 'L')
lsum += 1;
if (i > 0 and i < s.size()) {
if ((flag and (s[i] == 'L' and s[i + 1] == 'R')) or s[i] == 'T') {
flag = false;
if ((rsum + lsum) % 2 == 0) {
ans[p.first] = (rsum + lsum) / 2;
ans[p.second] = (rsum + lsum) / 2;
} else {
ans[p.first] = (rsum + lsum) / 2;
ans[p.second] = (rsum + lsum) / 2;
lsum -= 1;
rsum -= 1;
if (rsum > lsum) {
if (rsum % 2 == 0) {
ans[p.first] += 1;
} else {
ans[p.second] += 1;
}
} else if (lsum > rsum) {
if (lsum % 2 == 0) {
ans[p.second] += 1;
} else {
ans[p.first] += 1;
}
}
}
rsum = 0;
lsum = 0;
} else if (s[i] == 'R' and s[i + 1] == 'L') {
flag = true;
p.first = i, p.second = i + 1;
}
}
}
for (int i = 0; i < s.size() - 1; ++i) {
cout << ans[i] << " ";
}
END;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define INF 10e17
#define rep(i, n) for (long long i = 0; i < n; i++)
#define repr(i, n, m) for (long long i = m; i < n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) \
for (auto &&itr : x) { \
debug(itr); \
}
template <class T> inline void chmax(T &ans, T t) {
if (t > ans)
ans = t;
}
template <class T> inline void chmin(T &ans, T t) {
if (t < ans)
ans = t;
}
int main() {
string s;
cin >> s;
s += "T";
vector<ll> ans(s.size(), 0);
int rsum = 0, lsum = 0;
bool flag = false;
pair<int, int> p;
for (int i = 0; i <= s.size(); ++i) {
if (s[i] == 'R')
rsum += 1;
else if (s[i] == 'L')
lsum += 1;
if (i >= 0 and i < s.size()) {
if ((s[i] == 'L' and s[i + 1] == 'R') or s[i] == 'T') {
flag = false;
if ((rsum + lsum) % 2 == 0) {
ans[p.first] = (rsum + lsum) / 2;
ans[p.second] = (rsum + lsum) / 2;
} else {
ans[p.first] = (rsum + lsum) / 2;
ans[p.second] = (rsum + lsum) / 2;
lsum -= 1;
rsum -= 1;
if (rsum > lsum) {
if (rsum % 2 == 0) {
ans[p.first] += 1;
} else {
ans[p.second] += 1;
}
} else if (lsum > rsum) {
if (lsum % 2 == 0) {
ans[p.second] += 1;
} else {
ans[p.first] += 1;
}
}
}
rsum = 0;
lsum = 0;
} else if (s[i] == 'R' and s[i + 1] == 'L') {
flag = true;
p.first = i, p.second = i + 1;
}
}
}
for (int i = 0; i < s.size() - 1; ++i) {
cout << ans[i] << " ";
}
END;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 758,984 | 758,985 | u898749314 | cpp |
p02954 | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
string s;
cin >> s;
int n = s.size();
vector<int> v(n);
vector<int> w(n, 0), w2(n, 0);
for (int i = 0; i < n; i++) {
v[i] = (s[i] == 'R' ? 1 : -1);
}
int cnt = 1;
for (int i = 0; i < n - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
w[i] = cnt;
cnt = 1;
} else if (s[i] == 'R') {
cnt++;
}
}
cnt = 1;
for (int i = n - 1; i >= 1; i--) {
if (s[i] == 'L' && s[i - 1] == 'R') {
w[i] = cnt;
cnt = 1;
} else if (s[i] == 'L') {
cnt++;
}
}
for (int i = 0; i < n - 1; i++) {
if (w[i] * w[i + 1] > 0) {
int t = w[i] + w[i + 1];
if (t % 2 == 0) {
w2[i] = t / 2;
w2[i + 1] = t / 2;
} else {
w2[i] = t / 2;
w2[i + 1] = t / 2;
if (w[i] % 2 == 0) {
w2[i + 1]++;
} else {
w2[i]++;
}
}
}
}
for (int i = 0; i < n; i++) {
cout << w2[i] << " ";
}
cout << endl;
}
| #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
string s;
cin >> s;
int n = s.size();
vector<int> v(n);
vector<int> w(n, 0), w2(n, 0);
for (int i = 0; i < n; i++) {
v[i] = (s[i] == 'R' ? 1 : -1);
}
int cnt = 1;
for (int i = 0; i < n - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
w[i] = cnt;
cnt = 1;
} else if (s[i] == 'R') {
cnt++;
}
}
cnt = 1;
for (int i = n - 1; i >= 1; i--) {
if (s[i] == 'L' && s[i - 1] == 'R') {
w[i] = cnt;
cnt = 1;
} else if (s[i] == 'L') {
cnt++;
}
}
for (int i = 0; i < n - 1; i++) {
if (w[i] * w[i + 1] > 0) {
int t = w[i] + w[i + 1];
if (t % 2 == 0) {
w2[i] = t / 2;
w2[i + 1] = t / 2;
} else {
w2[i] = t / 2;
w2[i + 1] = t / 2;
if (w[i] % 2 == 0) {
w2[i + 1]++;
} else {
w2[i]++;
}
}
i++;
}
}
for (int i = 0; i < n; i++) {
cout << w2[i] << " ";
}
cout << endl;
}
| [
"expression.unary.arithmetic.add"
] | 758,986 | 758,987 | u550444782 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
char s[maxn];
int sum[maxn];
int L[maxn], R[maxn];
int l[maxn], r[maxn];
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
for (register int i = 1; i <= n; i++) {
if (s[i] == 'L') {
int x = i;
L[i] = i;
while (s[i] == 'L') {
l[i] = l[i - 1] + 1;
L[i] = x;
i++;
}
i--;
}
}
for (register int i = n; i >= 1; i--) {
if (s[i] == 'R') {
int x = i;
R[i] = i;
while (s[i] == 'R') {
r[i] = r[i + 1] + 1;
R[i] = x;
i--;
}
i++;
}
}
for (register int i = 1; i <= n; i++) {
if (l[i]) {
if (l[i] % 2)
sum[L[i]++];
else
sum[L[i] - 1]++;
}
if (r[i]) {
if (r[i] % 2)
sum[R[i]]++;
else
sum[R[i] + 1]++;
}
}
for (register int i = 1; i <= n; i++)
printf("%d ", sum[i]);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
char s[maxn];
int sum[maxn];
int L[maxn], R[maxn];
int l[maxn], r[maxn];
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
for (register int i = 1; i <= n; i++) {
if (s[i] == 'L') {
int x = i;
L[i] = i;
while (s[i] == 'L') {
l[i] = l[i - 1] + 1;
L[i] = x;
i++;
}
i--;
}
}
for (register int i = n; i >= 1; i--) {
if (s[i] == 'R') {
int x = i;
R[i] = i;
while (s[i] == 'R') {
r[i] = r[i + 1] + 1;
R[i] = x;
i--;
}
i++;
}
}
for (register int i = 1; i <= n; i++) {
if (l[i]) {
if (l[i] % 2)
sum[L[i]]++;
else
sum[L[i] - 1]++;
}
if (r[i]) {
if (r[i] % 2)
sum[R[i]]++;
else
sum[R[i] + 1]++;
}
}
for (register int i = 1; i <= n; i++)
printf("%d ", sum[i]);
return 0;
}
| [] | 758,988 | 758,989 | u088044957 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
char s[maxn];
int sum[maxn];
int L[maxn], R[maxn];
int l[maxn], r[maxn];
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
for (register int i = 1; i <= n; i++) {
if (s[i] == 'L') {
int x = i;
L[i] = i;
while (s[i] == 'L') {
l[i] = l[i - 1] + 1;
l[i] = x;
i++;
}
i--;
}
}
for (register int i = n; i >= 1; i--) {
if (s[i] == 'R') {
int x = i;
R[i] = i;
while (s[i] == 'R') {
r[i] = r[i + 1] + 1;
r[i] = x;
i--;
}
i++;
}
}
for (register int i = 1; i <= n; i++) {
if (l[i]) {
if (l[i] % 2)
sum[L[i]++];
else
sum[L[i] - 1]++;
}
if (r[i]) {
if (r[i] % 2)
sum[R[i]]++;
else
sum[R[i] + 1]++;
}
}
for (register int i = 1; i <= n; i++)
printf("%d ", sum[i]);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
char s[maxn];
int sum[maxn];
int L[maxn], R[maxn];
int l[maxn], r[maxn];
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
for (register int i = 1; i <= n; i++) {
if (s[i] == 'L') {
int x = i;
L[i] = i;
while (s[i] == 'L') {
l[i] = l[i - 1] + 1;
L[i] = x;
i++;
}
i--;
}
}
for (register int i = n; i >= 1; i--) {
if (s[i] == 'R') {
int x = i;
R[i] = i;
while (s[i] == 'R') {
r[i] = r[i + 1] + 1;
R[i] = x;
i--;
}
i++;
}
}
for (register int i = 1; i <= n; i++) {
if (l[i]) {
if (l[i] % 2)
sum[L[i]]++;
else
sum[L[i] - 1]++;
}
if (r[i]) {
if (r[i] % 2)
sum[R[i]]++;
else
sum[R[i] + 1]++;
}
}
for (register int i = 1; i <= n; i++)
printf("%d ", sum[i]);
return 0;
}
| [
"assignment.variable.change",
"identifier.change"
] | 758,990 | 758,989 | u088044957 | cpp |
p02948 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
int main() {
int n, m;
cin >> n >> m;
vector<P> ab;
for (int i = 0; i < n; i++) {
ll a, b;
cin >> a >> b;
ab.push_back(P(a, b));
}
sort(ab.begin(), ab.end());
priority_queue<ll> pq;
ll j = 0;
ll ans = 0;
for (int i = 1; i <= m; i++) {
for (; ab[j].first <= i; j++) {
pq.push(ab[j].second);
}
if (!pq.empty()) {
ans += pq.top();
pq.pop();
}
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
int main() {
int n, m;
cin >> n >> m;
vector<P> ab;
for (int i = 0; i < n; i++) {
ll a, b;
cin >> a >> b;
ab.push_back(P(a, b));
}
sort(ab.begin(), ab.end());
priority_queue<ll> pq;
ll j = 0;
ll ans = 0;
for (int i = 1; i <= m; i++) {
for (; j < n && ab[j].first <= i; j++) {
pq.push(ab[j].second);
}
if (!pq.empty()) {
ans += pq.top();
pq.pop();
}
}
cout << ans;
return 0;
} | [
"control_flow.loop.for.condition.change"
] | 759,008 | 759,009 | u129667379 | cpp |
p02948 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
int n, m, a, b, ans = 0;
cin >> n >> m;
priority_queue<int> A;
set<int> B[100001];
rep(i, n) cin >> a >> b, B[a].insert(b);
rep(i, m) {
for (auto j : B[i + 1])
A.push(j);
if (!A.empty())
ans += A.top(), A.pop();
}
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
int n, m, a, b, ans = 0;
cin >> n >> m;
priority_queue<int> A;
vector<int> B[100001];
rep(i, n) cin >> a >> b, B[a].push_back(b);
rep(i, m) {
for (auto j : B[i + 1])
A.push(j);
if (!A.empty())
ans += A.top(), A.pop();
}
cout << ans;
} | [
"variable_declaration.type.change",
"call.function.change"
] | 759,012 | 759,013 | u441296840 | cpp |
p02948 | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
const int N = 1e6;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
map<int, vi> tasks;
forn(i, n) {
int a, b;
cin >> a >> b;
tasks[a].pb(b);
}
set<int> q;
ll ans = 0;
forn(i, m) {
if (tasks.count(i + 1))
for (int x : tasks[i + 1])
q.insert(-x);
if (!q.empty())
ans -= *q.begin(), q.erase(q.begin());
}
cout << ans << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
const int N = 1e6;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
map<int, vi> tasks;
forn(i, n) {
int a, b;
cin >> a >> b;
tasks[a].pb(b);
}
multiset<int> q;
ll ans = 0;
forn(i, m) {
if (tasks.count(i + 1))
for (int x : tasks[i + 1])
q.insert(-x);
if (!q.empty())
ans -= *q.begin(), q.erase(q.begin());
}
cout << ans << "\n";
return 0;
} | [
"variable_declaration.type.change"
] | 759,014 | 759,015 | u711540245 | cpp |
p02948 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int N, M;
cin >> N >> M;
vector<pair<int, int>> v;
for (int i = 0; i < N; ++i) {
int A, B;
cin >> A >> B;
v.push_back(make_pair(A, B));
}
sort(v.begin(), v.end());
long long int ans = 0;
priority_queue<int> q;
int k = 0;
for (int i = 1; i <= M; ++i) {
while (v[k].first == i && k < M) {
q.push(v[k].second);
++k;
}
if (!q.empty()) {
ans += q.top();
q.pop();
}
}
cout << ans << '\n';
} | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int N, M;
cin >> N >> M;
vector<pair<int, int>> v;
for (int i = 0; i < N; ++i) {
int A, B;
cin >> A >> B;
v.push_back(make_pair(A, B));
}
sort(v.begin(), v.end());
long long int ans = 0;
priority_queue<int> q;
int k = 0;
for (int i = 1; i <= M; ++i) {
while (v[k].first == i && k < N) {
q.push(v[k].second);
++k;
}
if (!q.empty()) {
ans += q.top();
q.pop();
}
}
cout << ans << '\n';
} | [
"identifier.change",
"control_flow.loop.condition.change"
] | 759,022 | 759,023 | u596101798 | cpp |
p02948 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPP(i, n) for (int i = 1; i <= n; i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF = (long long)1E17;
#define i_7 (long long)(1E9 + 7)
long mod(long a) {
long long c = a % i_7;
if (c >= 0)
return c;
return c + i_7;
}
using namespace std;
bool prime_(int n) {
if (n == 1) {
return false;
} else if (n == 2) {
return true;
} else {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
long long gcd_(long long a, long long b) {
if (a < b) {
swap(a, b);
}
if (a % b == 0) {
return b;
} else {
return gcd_(b, a % b);
}
}
long long lcm_(long long x, long long y) { return (x / gcd_(x, y)) * y; }
class UnionFind {
public:
//各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
vector<int> Parent;
//クラスを作るときは、Parentの値を全て-1にする。
//以下のようにすると全てバラバラの頂点として解釈できる。
UnionFind(int N) { Parent = vector<int>(N, -1); }
// Aがどのグループに属しているか調べる
int root(int A) {
if (Parent[A] < 0)
return A;
return Parent[A] = root(Parent[A]);
}
//自分のいるグループの頂点数を調べる
int size(int A) {
return -Parent[root(A)]; //先祖をrootで取っておきたい。
}
// AとBをくっ付ける
bool connect(int A, int B) {
// AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
A = root(A);
B = root(B);
if (A == B) {
//すでにくっついてるからくっ付けない
return false;
}
//大きい方(A)に小さいほう(B)をくっ付けたい
//大小が逆だったらAとBをひっくり返す。
if (size(A) < size(B))
swap(A, B);
// Aのサイズを更新する
Parent[A] += Parent[B];
// Bの親をAに変更する
Parent[B] = A;
return true;
}
};
int main() {
int n, m;
cin >> n >> m;
int a, b;
vector<pair<int, int>> ab;
REP(i, n) {
cin >> a >> b;
ab.push_back(make_pair(a, b));
}
sort(ab.begin(), ab.end());
priority_queue<int> q;
int index = 0;
int ans = 0;
for (int i = m; i >= 0; i--) {
while (index < n) {
if (i + ab[index].first > m) {
break;
} else {
q.push(ab[index].second);
index++;
}
}
if (!q.empty()) {
ans = q.top();
q.pop();
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPP(i, n) for (int i = 1; i <= n; i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF = (long long)1E17;
#define i_7 (long long)(1E9 + 7)
long mod(long a) {
long long c = a % i_7;
if (c >= 0)
return c;
return c + i_7;
}
using namespace std;
bool prime_(int n) {
if (n == 1) {
return false;
} else if (n == 2) {
return true;
} else {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
long long gcd_(long long a, long long b) {
if (a < b) {
swap(a, b);
}
if (a % b == 0) {
return b;
} else {
return gcd_(b, a % b);
}
}
long long lcm_(long long x, long long y) { return (x / gcd_(x, y)) * y; }
class UnionFind {
public:
//各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
vector<int> Parent;
//クラスを作るときは、Parentの値を全て-1にする。
//以下のようにすると全てバラバラの頂点として解釈できる。
UnionFind(int N) { Parent = vector<int>(N, -1); }
// Aがどのグループに属しているか調べる
int root(int A) {
if (Parent[A] < 0)
return A;
return Parent[A] = root(Parent[A]);
}
//自分のいるグループの頂点数を調べる
int size(int A) {
return -Parent[root(A)]; //先祖をrootで取っておきたい。
}
// AとBをくっ付ける
bool connect(int A, int B) {
// AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
A = root(A);
B = root(B);
if (A == B) {
//すでにくっついてるからくっ付けない
return false;
}
//大きい方(A)に小さいほう(B)をくっ付けたい
//大小が逆だったらAとBをひっくり返す。
if (size(A) < size(B))
swap(A, B);
// Aのサイズを更新する
Parent[A] += Parent[B];
// Bの親をAに変更する
Parent[B] = A;
return true;
}
};
int main() {
int n, m;
cin >> n >> m;
int a, b;
vector<pair<int, int>> ab;
REP(i, n) {
cin >> a >> b;
ab.push_back(make_pair(a, b));
}
sort(ab.begin(), ab.end());
priority_queue<int> q;
int index = 0;
int ans = 0;
for (int i = m; i >= 0; i--) {
while (index < n) {
if (i + ab[index].first > m) {
break;
} else {
q.push(ab[index].second);
index++;
}
}
if (!q.empty()) {
ans += q.top();
q.pop();
}
}
cout << ans << endl;
return 0;
}
| [
"assignment.value.change"
] | 759,026 | 759,027 | u222293734 | cpp |
p02948 | #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
set<pair<int, int>> W;
priority_queue<int> B;
int N, M, a, b;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> a >> b;
W.insert({a, b});
}
int ans = 0;
auto it = W.begin();
for (int i = 0; i < M; i++) {
while (it != W.end()) {
if ((*it).first > i + 1)
break;
B.push((*it).second);
it++;
}
if (!B.empty()) {
ans += B.top();
// cout << i<<" "<<B.top() << endl;
B.pop();
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
multiset<pair<int, int>> W;
priority_queue<int> B;
int N, M, a, b;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> a >> b;
W.insert({a, b});
}
int ans = 0;
auto it = W.begin();
for (int i = 0; i < M; i++) {
while (it != W.end()) {
if ((*it).first > i + 1)
break;
B.push((*it).second);
it++;
}
if (!B.empty()) {
ans += B.top();
// cout << i<<" "<<B.top() << endl;
B.pop();
}
}
cout << ans << endl;
} | [
"variable_declaration.type.narrow.change",
"variable_declaration.type.change"
] | 759,030 | 759,031 | u045811375 | cpp |
p02948 | #include <bits/stdc++.h>
using namespace std;
int main() {
set<pair<int, int>> W;
priority_queue<int> B;
int N, M, a, b;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> a >> b;
W.insert({a, b});
}
int ans = 0;
auto it = W.begin();
for (int i = 0; i < M; i++) {
while (it != W.end()) {
if ((*it).first > i + 1)
break;
B.push((*it).second);
it++;
}
if (!B.empty()) {
ans += B.top();
// cout << i<<" "<<B.top() << endl;
B.pop();
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
multiset<pair<int, int>> W;
priority_queue<int> B;
int N, M, a, b;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> a >> b;
W.insert({a, b});
}
int ans = 0;
auto it = W.begin();
for (int i = 0; i < M; i++) {
while (it != W.end()) {
if ((*it).first > i + 1)
break;
B.push((*it).second);
it++;
}
if (!B.empty()) {
ans += B.top();
// cout << i<<" "<<B.top() << endl;
B.pop();
}
}
cout << ans << endl;
} | [
"variable_declaration.type.change"
] | 759,032 | 759,031 | u045811375 | cpp |
p02948 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
priority_queue<pair<int, int>> v;
priority_queue<int> pq;
for (int i = 0; i < n; i++) {
int first, second;
cin >> first >> second;
v.push(pair<int, int>(-first, second));
}
int result = 0;
for (int i = 1; i <= m; i++) {
while (!v.empty() && abs(v.top().first) <= i) {
pq.push(v.top().second);
v.pop();
}
if (!pq.empty()) {
result += pq.top();
pq.pop();
} else {
break;
}
}
cout << result << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
priority_queue<pair<int, int>> v;
priority_queue<int> pq;
for (int i = 0; i < n; i++) {
int first, second;
cin >> first >> second;
v.push(pair<int, int>(-first, second));
}
int result = 0;
for (int i = 1; i <= m; i++) {
while (!v.empty() && abs(v.top().first) <= i) {
pq.push(v.top().second);
v.pop();
}
if (!pq.empty()) {
result += pq.top();
pq.pop();
}
}
cout << result << endl;
}
| [] | 759,036 | 759,037 | u723574055 | cpp |
p02948 | #include <iostream>
#include <queue>
using namespace std;
priority_queue<int> q;
vector<vector<int>> jobs;
int main(void) {
int n, m;
cin >> n >> m;
jobs = vector<vector<int>>(m + 1);
for (int a = 0; a < n; a = a + 1) {
int ai, bi;
cin >> ai >> bi;
jobs[ai].push_back(bi);
}
int ans = 0;
for (int a = 1; a <= m; a = a + 1) {
for (auto day : jobs[a])
q.push(day);
if (!q.empty()) {
ans += q.top();
q.pop();
}
}
cout << ans;
return 0;
} | #include <iostream>
#include <queue>
using namespace std;
priority_queue<int> q;
vector<vector<int>> jobs;
int main(void) {
int n, m;
cin >> n >> m;
jobs = vector<vector<int>>(100001);
for (int a = 0; a < n; a = a + 1) {
int ai, bi;
cin >> ai >> bi;
jobs[ai].push_back(bi);
}
int ans = 0;
for (int a = 1; a <= m; a = a + 1) {
for (auto day : jobs[a])
q.push(day);
if (!q.empty()) {
ans += q.top();
q.pop();
}
}
cout << ans;
return 0;
} | [
"assignment.value.change",
"identifier.replace.remove",
"literal.replace.add",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 759,080 | 759,081 | u888251784 | cpp |
p02954 | #include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int ans[100000];
int main() {
for (int i = 0; i < 100000; i++) {
ans[i] = 0;
}
string S;
cin >> S;
int rb, re, lb, le;
int count = 0;
bool rr = true;
rb = 0;
for (int i = 0; i < S.size(); i++) {
if (rr == true) {
if (S[i] == 'L') {
rr = false;
re = i - 1;
lb = i;
}
} else {
if (S[i] == 'R') {
rr = true;
le = i - 1;
ans[lb] +=
int((le + 1 - (re % 2) + 2) / 2) - int((rb - (re % 2) + 2) / 2);
ans[re] +=
int((le + 1 - (lb % 2) + 2) / 2) - int((rb - (lb % 2) + 2) / 2);
rb = i;
}
}
}
le = S.size() - 1;
ans[lb] += int((le + 1 - (re % 2) + 2) / 2) - int((rb - (re % 2) + 2) / 2);
ans[re] += int((le + 1 - (lb % 2) + 2) / 2) - int((rb - (lb % 2) + 2) / 2);
if (re % 2 != le % 2) {
ans[re]++;
} else {
ans[lb]++;
}
for (int i = 0; i < S.size(); i++) {
cout << ans[i];
if (i != S.size()) {
cout << " ";
}
}
} | #include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int ans[100000];
int main() {
for (int i = 0; i < 100000; i++) {
ans[i] = 0;
}
string S;
cin >> S;
int rb, re, lb, le;
int count = 0;
bool rr = true;
rb = 0;
for (int i = 0; i < S.size(); i++) {
if (rr == true) {
if (S[i] == 'L') {
rr = false;
re = i - 1;
lb = i;
}
} else {
if (S[i] == 'R') {
rr = true;
le = i - 1;
ans[lb] +=
int((le + 1 - (re % 2) + 2) / 2) - int((rb - (re % 2) + 2) / 2);
ans[re] +=
int((le + 1 - (lb % 2) + 2) / 2) - int((rb - (lb % 2) + 2) / 2);
rb = i;
}
}
}
le = S.size() - 2;
ans[lb] += int((le + 1 - (re % 2) + 2) / 2) - int((rb - (re % 2) + 2) / 2);
ans[re] += int((le + 1 - (lb % 2) + 2) / 2) - int((rb - (lb % 2) + 2) / 2);
if (re % 2 != le % 2) {
ans[re]++;
} else {
ans[lb]++;
}
for (int i = 0; i < S.size(); i++) {
cout << ans[i];
if (i != S.size()) {
cout << " ";
}
}
} | [
"literal.number.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 759,086 | 759,087 | u023751250 | cpp |
p02954 | #include <iostream>
#include <string>
#include <vector>
using namespace std;
void d() {
string s;
cin >> s;
int n = s.length();
vector<int> count(n, 1);
for (int i = 0; i < n; i++) {
if (s[i] == 'R') {
if (s[i + 1] == 'R') {
count[i + 2] += count[i];
count[i] = 0;
}
}
}
for (int i = n - 1; i >= 0; i--) {
if (s[i] == 'L') {
if (s[i - 1] == 'L') {
count[i - 2] += count[i];
count[i] = 0;
}
}
}
cout << 0;
for (int i = 1; i < n; i++) {
cout << " " << count[i];
}
cout << endl;
}
int main() {
d();
return 0;
}
| #include <iostream>
#include <string>
#include <vector>
using namespace std;
void d() {
string s;
cin >> s;
int n = s.length();
vector<int> count(n, 1);
for (int i = 0; i < n; i++) {
if (s[i] == 'R') {
if (s[i + 1] == 'R') {
count[i + 2] += count[i];
count[i] = 0;
}
}
}
for (int i = n - 1; i >= 0; i--) {
if (s[i] == 'L') {
if (s[i - 1] == 'L') {
count[i - 2] += count[i];
count[i] = 0;
}
}
}
cout << count[0];
for (int i = 1; i < n; i++) {
cout << " " << count[i];
}
cout << endl;
}
int main() {
d();
return 0;
}
| [] | 759,088 | 759,089 | u261225456 | cpp |
p02954 | #include <iostream>
using namespace std;
int main() {
string s;
cin >> s;
int ans[100000] = {0};
int st = 0;
int la = 0;
char now = 'R';
int mid = 1;
for (int i = 1; i < s.length(); i++) {
if (i == s.length() - 1 || now != s[i + 1]) {
if (i != s.length() - 1 && s[i + 1] == 'L') {
mid = i + 1;
now = 'L';
} else {
la = i;
if ((mid - st) % 2) {
ans[mid - 1] += (mid - st + 1) / 2;
ans[mid] += (mid - st - 1) / 2;
} else {
ans[mid - 1] += (mid - st) / 2;
ans[mid] += (mid - st) / 2;
}
if ((la - mid + 1) % 2) {
ans[mid - 1] += (la - mid) / 2;
ans[mid] += (la - mid + 2) / 2;
} else {
ans[mid - 1] += (la - mid + 1) / 2;
ans[mid] += (la - mid + 1) / 2;
}
now = 'R';
st = i + 1;
}
}
}
for (int i = 0; i < s.size(); i++)
cout << ans[i] << " ";
cout << endl;
}
| #include <iostream>
using namespace std;
int main() {
string s;
cin >> s;
int ans[100000] = {0};
int st = 0;
int la = 0;
char now = 'R';
int mid = 1;
for (int i = 0; i < s.length(); i++) {
if (i == s.length() - 1 || now != s[i + 1]) {
if (i != s.length() - 1 && s[i + 1] == 'L') {
mid = i + 1;
now = 'L';
} else {
la = i;
if ((mid - st) % 2) {
ans[mid - 1] += (mid - st + 1) / 2;
ans[mid] += (mid - st - 1) / 2;
} else {
ans[mid - 1] += (mid - st) / 2;
ans[mid] += (mid - st) / 2;
}
if ((la - mid + 1) % 2) {
ans[mid - 1] += (la - mid) / 2;
ans[mid] += (la - mid + 2) / 2;
} else {
ans[mid - 1] += (la - mid + 1) / 2;
ans[mid] += (la - mid + 1) / 2;
}
now = 'R';
st = i + 1;
}
}
}
for (int i = 0; i < s.size(); i++)
cout << ans[i] << " ";
cout << endl;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 759,108 | 759,109 | u702906718 | cpp |
p02954 | #include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.size();
vector<int> B, C, E;
B.push_back(0);
for (int i = 1; i < N - 1; i++) {
if (S.at(i) == 'R' && S.at(i + 1) == 'L')
C.push_back(i);
if (S.at(i) == 'L' && S.at(i + 1) == 'R') {
E.push_back(i);
B.push_back(i + 1);
}
}
E.push_back(N - 1);
int A[100010] = {};
for (int i = 0; i < B.size(); i++) {
int l = C.at(i) - B.at(i) + 1;
int r = E.at(i) - C.at(i);
A[C.at(i)] += (l + 1) / 2;
A[C.at(i) + 1] += l - (l + 1) / 2;
A[C.at(i) + 1] += (r + 1) / 2;
A[C.at(i)] += r - (r + 1) / 2;
}
for (int i = 0; i < N; i++) {
cout << A[i] << " ";
}
cout << endl;
} | #include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
int N = S.size();
vector<int> B, C, E;
B.push_back(0);
for (int i = 0; i < N - 1; i++) {
if (S.at(i) == 'R' && S.at(i + 1) == 'L')
C.push_back(i);
if (S.at(i) == 'L' && S.at(i + 1) == 'R') {
E.push_back(i);
B.push_back(i + 1);
}
}
E.push_back(N - 1);
int A[100010] = {};
for (int i = 0; i < B.size(); i++) {
int l = C.at(i) - B.at(i) + 1;
int r = E.at(i) - C.at(i);
A[C.at(i)] += (l + 1) / 2;
A[C.at(i) + 1] += l - (l + 1) / 2;
A[C.at(i) + 1] += (r + 1) / 2;
A[C.at(i)] += r - (r + 1) / 2;
}
for (int i = 0; i < N; i++) {
cout << A[i] << " ";
}
cout << endl;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 759,112 | 759,113 | u465638326 | cpp |
p02954 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[100010];
int ans[100010];
int ans1[100010];
int n;
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
for (int i = 1; i <= n; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
int now = i;
int flag = 0;
while (s[now] == 'R') {
ans[now] = i + flag;
now--;
flag = 1 - flag;
}
now = i + 1;
flag = 1;
while (s[now] == 'L') {
ans[now] = i + flag;
now++;
flag = -flag;
}
}
}
for (int i = 1; i <= n; i++)
ans1[ans[i]]++;
for (int i = 1; i <= n; i++)
printf("%d ", ans1[i]);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[100010];
int ans[100010];
int ans1[100010];
int n;
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
for (int i = 1; i <= n; i++) {
if (s[i] == 'R' && s[i + 1] == 'L') {
int now = i;
int flag = 0;
while (s[now] == 'R') {
ans[now] = i + flag;
now--;
flag = 1 - flag;
}
now = i + 1;
flag = 1;
while (s[now] == 'L') {
ans[now] = i + flag;
now++;
flag = 1 - flag;
}
}
}
for (int i = 1; i <= n; i++)
ans1[ans[i]]++;
for (int i = 1; i <= n; i++)
printf("%d ", ans1[i]);
return 0;
}
| [] | 759,114 | 759,115 | u549192489 | cpp |
p02955 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, k, r, w, q, qq, p;
multiset<ll> z, zz;
bool b;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
ll x[n];
for (ll i = 0; i < n; i++)
cin >> x[i], r += x[i];
for (ll i = 1; i * i <= r; i++) {
if (r % i != 0)
continue;
w = r / i;
z.clear();
zz.clear();
q = 0;
qq = 0;
p = 0;
b = true;
for (ll j = 0; j < n; j++) {
if (x[j] % w < (w - x[j] % w) || (x[j] % w == (w - x[j] % w) && b)) {
z.insert(x[j] % w);
q += x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = false;
} else {
zz.insert(w - x[j] % w);
qq += w - x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = true;
}
}
while (q != qq) {
if (q > qq) {
if (z.size() == 0)
break;
auto t = z.rbegin();
q -= *t;
qq += (w - *t);
z.erase(z.find(*t));
} else {
if (zz.size() == 0)
break;
auto t = zz.rbegin();
qq -= *t;
q += (w - *t);
zz.erase(z.find(*t));
}
}
if (q == qq && q <= k) {
cout << w;
return 0;
}
}
for (ll i = sqrt(r); i >= 1; i--) {
if (r % i != 0)
continue;
w = i;
z.clear();
zz.clear();
q = 0;
qq = 0;
p = 0;
b = true;
for (ll j = 0; j < n; j++) {
if (x[j] % w < (w - x[j] % w) || (x[j] % w == (w - x[j] % w) && b)) {
z.insert(x[j] % w);
q += x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = false;
} else {
zz.insert(w - x[j] % w);
qq += w - x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = true;
}
}
while (q != qq) {
if (q > qq) {
if (z.size() == 0)
break;
auto t = z.rbegin();
q -= *t;
qq += (w - *t);
z.erase(z.find(*t));
p += *t;
} else {
if (zz.size() == 0)
break;
auto t = zz.rbegin();
qq -= *t;
q += (w - *t);
zz.erase(z.find(*t));
p += *t;
}
}
if (q == qq && q <= k) {
cout << w;
return 0;
}
}
cout << n;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, k, r, w, q, qq, p;
multiset<ll> z, zz;
bool b;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
ll x[n];
for (ll i = 0; i < n; i++)
cin >> x[i], r += x[i];
for (ll i = 1; i * i <= r; i++) {
if (r % i != 0)
continue;
w = r / i;
z.clear();
zz.clear();
q = 0;
qq = 0;
p = 0;
b = true;
for (ll j = 0; j < n; j++) {
if (x[j] % w < (w - x[j] % w) || (x[j] % w == (w - x[j] % w) && b)) {
z.insert(x[j] % w);
q += x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = false;
} else {
zz.insert(w - x[j] % w);
qq += w - x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = true;
}
}
while (q != qq) {
if (q > qq) {
if (z.size() == 0)
break;
auto t = z.rbegin();
q -= *t;
qq += (w - *t);
z.erase(z.find(*t));
} else {
if (zz.size() == 0)
break;
auto t = zz.rbegin();
qq -= *t;
q += (w - *t);
zz.erase(zz.find(*t));
}
}
if (q == qq && q <= k) {
cout << w;
return 0;
}
}
for (ll i = sqrt(r); i >= 1; i--) {
if (r % i != 0)
continue;
w = i;
z.clear();
zz.clear();
q = 0;
qq = 0;
p = 0;
b = true;
for (ll j = 0; j < n; j++) {
if (x[j] % w < (w - x[j] % w) || (x[j] % w == (w - x[j] % w) && b)) {
z.insert(x[j] % w);
q += x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = false;
} else {
zz.insert(w - x[j] % w);
qq += w - x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = true;
}
}
while (q != qq) {
if (q > qq) {
if (z.size() == 0)
break;
auto t = z.rbegin();
q -= *t;
qq += (w - *t);
z.erase(z.find(*t));
p += *t;
} else {
if (zz.size() == 0)
break;
auto t = zz.rbegin();
qq -= *t;
q += (w - *t);
zz.erase(zz.find(*t));
p += *t;
}
}
if (q == qq && q <= k) {
cout << w;
return 0;
}
}
cout << n;
}
| [
"identifier.change",
"call.arguments.change"
] | 759,118 | 759,119 | u197508298 | cpp |
p02955 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, k, r, w, q, qq, p;
multiset<ll> z, zz;
bool b;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
ll x[n];
for (ll i = 0; i < n; i++)
cin >> x[i], r += x[i];
for (ll i = 1; i * i <= r; i++) {
if (r % i != 0)
continue;
w = r / i;
z.clear();
zz.clear();
q = 0;
qq = 0;
p = 0;
b = true;
for (ll j = 0; j < n; j++) {
if (x[j] % w < (w - x[j] % w) || (x[j] % w == (w - x[j] % w) && b)) {
z.insert(x[j] % w);
q += x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = false;
} else {
zz.insert(w - x[j] % w);
qq += w - x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = true;
}
}
while (q != qq) {
if (q > qq) {
if (z.size() == 0)
break;
auto t = z.rbegin();
q -= *t;
qq += (w - *t);
z.erase(z.find(*t));
} else {
if (zz.size() == 0)
break;
auto t = zz.rbegin();
qq -= *t;
q += (w - *t);
z.erase(z.find(*t));
}
}
if (q == qq && q <= k) {
cout << w;
return 0;
}
}
for (ll i = sqrt(r); i >= 1; i--) {
if (r % i != 0)
continue;
w = i;
z.clear();
zz.clear();
q = 0;
qq = 0;
p = 0;
b = true;
for (ll j = 0; j < n; j++) {
if (x[j] % w < (w - x[j] % w) || (x[j] % w == (w - x[j] % w) && b)) {
z.insert(x[j] % w);
q += x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = false;
} else {
zz.insert(w - x[j] % w);
qq += w - x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = true;
}
}
while (q != qq) {
if (q > qq) {
if (z.size() == 0)
break;
auto t = z.rbegin();
q -= *t;
qq += (w - *t);
z.erase(z.find(*t));
p += *t;
} else {
if (zz.size() == 0)
break;
auto t = zz.rbegin();
qq -= *t;
q += (w - *t);
z.erase(z.find(*t));
p += *t;
}
}
if (q == qq && q <= k) {
cout << w;
return 0;
}
}
cout << n;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, k, r, w, q, qq, p;
multiset<ll> z, zz;
bool b;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
ll x[n];
for (ll i = 0; i < n; i++)
cin >> x[i], r += x[i];
for (ll i = 1; i * i <= r; i++) {
if (r % i != 0)
continue;
w = r / i;
z.clear();
zz.clear();
q = 0;
qq = 0;
p = 0;
b = true;
for (ll j = 0; j < n; j++) {
if (x[j] % w < (w - x[j] % w) || (x[j] % w == (w - x[j] % w) && b)) {
z.insert(x[j] % w);
q += x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = false;
} else {
zz.insert(w - x[j] % w);
qq += w - x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = true;
}
}
while (q != qq) {
if (q > qq) {
if (z.size() == 0)
break;
auto t = z.rbegin();
q -= *t;
qq += (w - *t);
z.erase(z.find(*t));
} else {
if (zz.size() == 0)
break;
auto t = zz.rbegin();
qq -= *t;
q += (w - *t);
zz.erase(zz.find(*t));
}
}
if (q == qq && q <= k) {
cout << w;
return 0;
}
}
for (ll i = sqrt(r); i >= 1; i--) {
if (r % i != 0)
continue;
w = i;
z.clear();
zz.clear();
q = 0;
qq = 0;
p = 0;
b = true;
for (ll j = 0; j < n; j++) {
if (x[j] % w < (w - x[j] % w) || (x[j] % w == (w - x[j] % w) && b)) {
z.insert(x[j] % w);
q += x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = false;
} else {
zz.insert(w - x[j] % w);
qq += w - x[j] % w;
if (x[j] % w == (w - x[j] % w))
b = true;
}
}
while (q != qq) {
if (q > qq) {
if (z.size() == 0)
break;
auto t = z.rbegin();
q -= *t;
qq += (w - *t);
z.erase(z.find(*t));
p += *t;
} else {
if (zz.size() == 0)
break;
auto t = zz.rbegin();
qq -= *t;
q += (w - *t);
zz.erase(zz.find(*t));
p += *t;
}
}
if (q == qq && q <= k) {
cout << w;
return 0;
}
}
cout << n;
}
| [
"identifier.change",
"call.arguments.change"
] | 759,120 | 759,119 | u197508298 | cpp |
p02955 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (n); i++)
#define REP(i, s, n) for (long long i = (s); i <= (n); i++)
#define repr(i, n) for (long long i = (n - 1); i >= 0; i--)
#define REPR(i, s, n) for (long long i = (s); i >= (n); i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sumvec(v) accumulate(all(v), 0LL)
#define DOUBLE fixed << setprecision(15)
#define OK cerr << "OK\n"
#define OK1 cerr << "OK1\n"
#define OK2 cerr << "OK2\n"
#define sz(s) (long long)s.size()
#define zero(x, n) setw(x) << setfill('0') << n
#define dbg(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
typedef pair<ll, ll> P;
typedef vector<P> vP;
void debug() { cerr << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &...args) {
cerr << x << " ";
debug(args...);
}
template <class A, class B>
ostream &operator<<(ostream &ost, const pair<A, B> &p) {
ost << "{" << p.first << ", " << p.second << "} ";
return ost;
}
template <class T> ostream &operator<<(ostream &ost, const vector<T> &v) {
ost << "{";
for (int i = 0; i < (int)v.size(); i++) {
if (i)
ost << " ";
ost << v[i];
}
ost << "} \n";
return ost;
}
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) {
os << "deq[";
for (auto v : vec)
os << v << ",";
os << "]\n";
return os;
}
template <class A, class B>
ostream &operator<<(ostream &ost, const map<A, B> &v) {
ost << "{";
for (auto p : v) {
ost << "{" << p.first << ", " << p.second << "} ";
}
ost << "}\n";
return ost;
}
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (T &e : vec)
is >> e;
return is;
}
template <typename A, typename B>
istream &operator>>(istream &is, pair<A, B> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T> string join(vector<T> &vec, string sep = " ") {
stringstream ss;
for (int i = 0; i < (int)vec.size(); i++) {
ss << vec[i] << (i + 1 == (int)vec.size() ? "\n" : sep);
}
return ss.str();
}
template <typename A, typename B>
pair<A, B> operator+(const pair<A, B> &l, const pair<A, B> &r) {
return make_pair(l.first + r.first, l.second + r.second);
}
template <typename A, typename B>
pair<A, B> operator-(const pair<A, B> &l, const pair<A, B> &r) {
return make_pair(l.first - r.first, l.second - r.second);
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ",";
os << "}\n";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ",";
os << "}\n";
return os;
}
template <class T> auto min(const T &a) {
return *min_element(a.begin(), a.end());
}
template <class T> auto max(const T &a) {
return *max_element(a.begin(), a.end());
}
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;
}
#define INT(...) \
int __VA_ARGS__; \
IN(__VA_ARGS__)
#define LL(...) \
long long __VA_ARGS__; \
IN(__VA_ARGS__)
#define CHR(...) \
char __VA_ARGS__; \
IN(__VA_ARGS__)
#define DBL(...) \
double __VA_ARGS__; \
IN(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
IN(__VA_ARGS__)
#define LD(...) \
long double __VA_ARGS__; \
IN(__VA_ARGS__)
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
scan(head);
IN(tail...);
}
void YES(bool b) { cout << ((b) ? "YES\n" : "NO\n"); }
void Yes(bool b) { cout << ((b) ? "Yes\n" : "No\n"); }
void yes(bool b) { cout << ((b) ? "yes\n" : "no\n"); }
void Yay(bool b) { cout << ((b) ? "Yay!\n" : ":(\n"); }
void possible(bool b) { cout << ((b) ? "possible\n" : "impossible\n"); }
void Possible(bool b) { cout << ((b) ? "Possible\n" : "Impossible\n"); }
void POSSIBLE(bool b) { cout << ((b) ? "POSSIBLE\n" : "IMPOSSIBLE\n"); }
const int dy[] = {-1, 0, 0, 1};
const int dx[] = {0, -1, 1, 0};
const int dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int inf = 1001001001;
const long long INF = ((1LL << 62) - (1LL << 31));
const long double pi = acos(-1.0);
const long long mod = 1000000007;
const long long MOD = 998244353;
ll powmod(ll a, ll b) {
ll c = 1;
while (b > 0) {
if (b & 1) {
c = a * c % mod;
}
a = a * a % mod;
b >>= 1;
}
return c;
}
ll nCrmod(ll n, ll r) {
ll x = 1, y = 1;
for (ll i = 0; i < r; i++) {
x = x * (n - i) % mod;
y = y * (i + 1) % mod;
}
return x * powmod(y, mod - 2) % mod;
}
ll gcd(ll a, ll b) {
while (b) {
ll c = b;
b = a % b;
a = c;
}
return a;
}
ll lcm(ll a, ll b) {
if (!a || !b)
return 0;
return a * b / gcd(a, b);
}
vll divisor(ll x) {
vll v;
for (ll i = 1; i * i <= x; i++)
if (x % i == 0) {
v.push_back(i);
if (i * i != x)
v.push_back(x / i);
}
sort(v.begin(), v.end());
return v;
};
map<ll, ll> prime_factor(ll n) {
map<ll, ll> m;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
m[i]++;
n /= i;
}
}
if (n != 1)
m[n] = 1;
return m;
}
int main() {
LL(n, k);
vll a(n);
cin >> a;
ll sum = sumvec(a);
vll d = divisor(sum);
ll ans = 1;
for (auto &&x : d) {
ll need;
vll r(n);
rep(i, n) r[i] = a[i] % x;
sort(all(r));
ll B = 0;
rep(i, n) B += x - r[i];
ll A = 0;
need = INF;
rep(i, n) {
A += r[i];
B -= x - r[i];
chmin(need, max(A, B));
}
if (need < k)
chmax(ans, x);
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (n); i++)
#define REP(i, s, n) for (long long i = (s); i <= (n); i++)
#define repr(i, n) for (long long i = (n - 1); i >= 0; i--)
#define REPR(i, s, n) for (long long i = (s); i >= (n); i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sumvec(v) accumulate(all(v), 0LL)
#define DOUBLE fixed << setprecision(15)
#define OK cerr << "OK\n"
#define OK1 cerr << "OK1\n"
#define OK2 cerr << "OK2\n"
#define sz(s) (long long)s.size()
#define zero(x, n) setw(x) << setfill('0') << n
#define dbg(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
typedef pair<ll, ll> P;
typedef vector<P> vP;
void debug() { cerr << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &...args) {
cerr << x << " ";
debug(args...);
}
template <class A, class B>
ostream &operator<<(ostream &ost, const pair<A, B> &p) {
ost << "{" << p.first << ", " << p.second << "} ";
return ost;
}
template <class T> ostream &operator<<(ostream &ost, const vector<T> &v) {
ost << "{";
for (int i = 0; i < (int)v.size(); i++) {
if (i)
ost << " ";
ost << v[i];
}
ost << "} \n";
return ost;
}
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) {
os << "deq[";
for (auto v : vec)
os << v << ",";
os << "]\n";
return os;
}
template <class A, class B>
ostream &operator<<(ostream &ost, const map<A, B> &v) {
ost << "{";
for (auto p : v) {
ost << "{" << p.first << ", " << p.second << "} ";
}
ost << "}\n";
return ost;
}
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (T &e : vec)
is >> e;
return is;
}
template <typename A, typename B>
istream &operator>>(istream &is, pair<A, B> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T> string join(vector<T> &vec, string sep = " ") {
stringstream ss;
for (int i = 0; i < (int)vec.size(); i++) {
ss << vec[i] << (i + 1 == (int)vec.size() ? "\n" : sep);
}
return ss.str();
}
template <typename A, typename B>
pair<A, B> operator+(const pair<A, B> &l, const pair<A, B> &r) {
return make_pair(l.first + r.first, l.second + r.second);
}
template <typename A, typename B>
pair<A, B> operator-(const pair<A, B> &l, const pair<A, B> &r) {
return make_pair(l.first - r.first, l.second - r.second);
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ",";
os << "}\n";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ",";
os << "}\n";
return os;
}
template <class T> auto min(const T &a) {
return *min_element(a.begin(), a.end());
}
template <class T> auto max(const T &a) {
return *max_element(a.begin(), a.end());
}
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;
}
#define INT(...) \
int __VA_ARGS__; \
IN(__VA_ARGS__)
#define LL(...) \
long long __VA_ARGS__; \
IN(__VA_ARGS__)
#define CHR(...) \
char __VA_ARGS__; \
IN(__VA_ARGS__)
#define DBL(...) \
double __VA_ARGS__; \
IN(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
IN(__VA_ARGS__)
#define LD(...) \
long double __VA_ARGS__; \
IN(__VA_ARGS__)
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
scan(head);
IN(tail...);
}
void YES(bool b) { cout << ((b) ? "YES\n" : "NO\n"); }
void Yes(bool b) { cout << ((b) ? "Yes\n" : "No\n"); }
void yes(bool b) { cout << ((b) ? "yes\n" : "no\n"); }
void Yay(bool b) { cout << ((b) ? "Yay!\n" : ":(\n"); }
void possible(bool b) { cout << ((b) ? "possible\n" : "impossible\n"); }
void Possible(bool b) { cout << ((b) ? "Possible\n" : "Impossible\n"); }
void POSSIBLE(bool b) { cout << ((b) ? "POSSIBLE\n" : "IMPOSSIBLE\n"); }
const int dy[] = {-1, 0, 0, 1};
const int dx[] = {0, -1, 1, 0};
const int dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int inf = 1001001001;
const long long INF = ((1LL << 62) - (1LL << 31));
const long double pi = acos(-1.0);
const long long mod = 1000000007;
const long long MOD = 998244353;
ll powmod(ll a, ll b) {
ll c = 1;
while (b > 0) {
if (b & 1) {
c = a * c % mod;
}
a = a * a % mod;
b >>= 1;
}
return c;
}
ll nCrmod(ll n, ll r) {
ll x = 1, y = 1;
for (ll i = 0; i < r; i++) {
x = x * (n - i) % mod;
y = y * (i + 1) % mod;
}
return x * powmod(y, mod - 2) % mod;
}
ll gcd(ll a, ll b) {
while (b) {
ll c = b;
b = a % b;
a = c;
}
return a;
}
ll lcm(ll a, ll b) {
if (!a || !b)
return 0;
return a * b / gcd(a, b);
}
vll divisor(ll x) {
vll v;
for (ll i = 1; i * i <= x; i++)
if (x % i == 0) {
v.push_back(i);
if (i * i != x)
v.push_back(x / i);
}
sort(v.begin(), v.end());
return v;
};
map<ll, ll> prime_factor(ll n) {
map<ll, ll> m;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
m[i]++;
n /= i;
}
}
if (n != 1)
m[n] = 1;
return m;
}
int main() {
LL(n, k);
vll a(n);
cin >> a;
ll sum = sumvec(a);
vll d = divisor(sum);
ll ans = 1;
for (auto &&x : d) {
ll need;
vll r(n);
rep(i, n) r[i] = a[i] % x;
sort(all(r));
ll B = 0;
rep(i, n) B += x - r[i];
ll A = 0;
need = INF;
rep(i, n) {
A += r[i];
B -= x - r[i];
chmin(need, max(A, B));
}
if (need <= k)
chmax(ans, x);
}
cout << ans << endl;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 759,127 | 759,128 | u232429509 | cpp |
p02955 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, K;
cin >> N >> K;
int sum = 0;
vector<int> A(N);
for (auto &&e : A) {
cin >> e;
sum += e;
}
vector<int> divisor;
for (int i = 1; i * i < sum + 1; i++) {
if (sum % i == 0) {
divisor.emplace_back(i);
divisor.emplace_back(sum / i);
}
}
int res = 0;
for (int d : divisor) {
vector<pair<int, int>> R;
for (const auto &e : A) {
R.emplace_back(make_pair(e % d, d - (e % d)));
}
sort(R.begin(), R.end());
vector<int64_t> X(R.size() + 1, 0), Y(R.size() + 1, 0);
for (int i = 0; i < (int)R.size(); i++) {
X[i + 1] += X[i] + R[i].first;
}
for (int i = (int)R.size(); i > 0; i--) {
Y[i - 1] += Y[i] + R[i - 1].second;
}
for (int i = 0; i < (int)R.size(); i++) {
if (X[i] == Y[i] && X[i] <= K) {
res = max(res, d);
}
}
if (Y.front() == 0)
res = max(res, d);
}
cout << res << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, K;
cin >> N >> K;
int sum = 0;
vector<int> A(N);
for (auto &&e : A) {
cin >> e;
sum += e;
}
vector<int> divisor;
for (int i = 1; i * i < sum + 1; i++) {
if (sum % i == 0) {
divisor.emplace_back(i);
divisor.emplace_back(sum / i);
}
}
int res = 0;
for (int d : divisor) {
vector<pair<int, int>> R;
for (const auto &e : A) {
R.emplace_back(make_pair(e % d, (d - (e % d)) % d));
}
sort(R.begin(), R.end());
vector<int64_t> X(R.size() + 1, 0), Y(R.size() + 1, 0);
for (int i = 0; i < (int)R.size(); i++) {
X[i + 1] += X[i] + R[i].first;
}
for (int i = (int)R.size(); i > 0; i--) {
Y[i - 1] += Y[i] + R[i - 1].second;
}
for (int i = 0; i < (int)R.size(); i++) {
if (X[i] == Y[i] && X[i] <= K) {
res = max(res, d);
}
}
if (Y.front() == 0)
res = max(res, d);
}
cout << res << '\n';
return 0;
}
| [
"call.arguments.change",
"call.arguments.add"
] | 759,129 | 759,130 | u782098901 | cpp |
p02955 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
vector<int> divisor(int N) {
vector<int> RES;
for (int I = 1; I * I <= N; I++) {
if (N % I == 0) {
RES.push_back(I);
if (I != N / I)
RES.push_back(N / I);
}
}
return RES;
}
int main() {
int n;
cin >> n;
ll k;
cin >> k;
int a[n];
rep(i, n) cin >> a[i];
int s = 0;
rep(i, n) s += a[i];
vector<int> d = divisor(s);
int ans = 1;
for (auto g : d) {
vector<int> r;
rep(i, n) r.push_back(a[i] % g);
sort(r.begin(), r.end());
int sum_r = 0;
rep(i, n) sum_r += r[i];
int cmax = sum_r / g;
int c = 0;
rep(i, n - cmax) c += r[i];
if ((ll)c <= k)
ans = g;
}
cout << ans << endl;
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++)
vector<int> divisor(int N) {
vector<int> RES;
for (int I = 1; I * I <= N; I++) {
if (N % I == 0) {
RES.push_back(I);
if (I != N / I)
RES.push_back(N / I);
}
}
return RES;
}
int main() {
int n;
cin >> n;
ll k;
cin >> k;
int a[n];
rep(i, n) cin >> a[i];
int s = 0;
rep(i, n) s += a[i];
vector<int> d = divisor(s);
int ans = 1;
for (auto g : d) {
vector<int> r;
rep(i, n) r.push_back(a[i] % g);
sort(r.begin(), r.end());
int sum_r = 0;
rep(i, n) sum_r += r[i];
int cmax = sum_r / g;
int c = 0;
rep(i, n - cmax) c += r[i];
if ((ll)c <= k)
ans = max(g, ans);
}
cout << ans << endl;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 759,131 | 759,132 | u747602774 | cpp |
p02955 | #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;
vector<int> divisor(int N) {
vector<int> RES;
for (int I = 1; I * I <= N; I++) {
if (N % I == 0) {
RES.push_back(I);
if (I != N / I)
RES.push_back(N / I);
}
}
return RES;
}
int main() {
int n;
cin >> n;
ll k;
cin >> k;
int a[n];
rep(i, n) cin >> a[i];
int s = 0;
rep(i, n) s += a[i];
vector<int> d = divisor(s);
sort(d.begin(), d.end());
int ans = 1;
for (auto di : d) {
vector<int> b;
rep(i, n) b.push_back(a[i] % di);
sort(b.begin(), b.end());
int s = 0;
rep(i, n) s += b[i];
int cmax = s / di;
int c = 0;
rep(i, n - cmax) c += b[i];
if ((ll)c <= k)
ans = di;
else
break;
// rep(i,n-1) printf("%d ",b[i]);
// printf("%d\n",b[n-1]);
}
cout << ans << endl;
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;
vector<int> divisor(int N) {
vector<int> RES;
for (int I = 1; I * I <= N; I++) {
if (N % I == 0) {
RES.push_back(I);
if (I != N / I)
RES.push_back(N / I);
}
}
return RES;
}
int main() {
int n;
cin >> n;
ll k;
cin >> k;
int a[n];
rep(i, n) cin >> a[i];
int s = 0;
rep(i, n) s += a[i];
vector<int> d = divisor(s);
sort(d.begin(), d.end());
int ans = 1;
for (auto di : d) {
vector<int> b;
rep(i, n) b.push_back(a[i] % di);
sort(b.begin(), b.end());
int s = 0;
rep(i, n) s += b[i];
int cmax = s / di;
int c = 0;
rep(i, n - cmax) c += b[i];
if ((ll)c <= k)
ans = di;
// rep(i,n-1) printf("%d ",b[i]);
// printf("%d\n",b[n-1]);
}
cout << ans << endl;
return 0;
}
| [
"control_flow.branch.else.remove"
] | 759,133 | 759,134 | u747602774 | cpp |
p02955 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define rep(i, n) for (lint i = 0; i < n; i++)
#define repr(i, n) for (lint i = n - 1; i >= 0; i--)
#define repi(i, ini, n) for (lint i = ini; i < n; i++)
#define repir(i, ini, n) for (lint i = n - 1; i >= ini; i--)
#define repb(i, start, end) for (lint i = start; i <= end; i++)
#define repbr(i, start, end) for (lint i = end; i >= start; i--)
#define bit(n) (1LL << (n))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rg(v, ini, end) v.begin() + ini, v.begin() + end
#define ret return 0;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
struct xy {
lint x, y;
xy() : x(0), y(0) {}
xy(lint _x, lint _y) : x(_x), y(_y) {}
xy operator+(const xy &p) const { return xy(x + p.x, y + p.y); }
bool operator<(xy p) const {
if (y == p.y)
return x < p.x;
return y < p.y;
}
};
struct xyd {
ld x, y;
xyd() : x(0), y(0) {}
xyd(long double _x, long double _y) : x(_x), y(_y) {}
};
using vec = vector<lint>;
using vecd = vector<ld>;
using vecs = vector<string>;
using vecp = vector<xy>;
template <class T> using vect = vector<T>;
class vec2 : public vector<vector<lint>> {
public:
vec2() {}
vec2(lint n) : vector(n) {}
vec2(lint h, lint w) : vector(h, vector<lint>(w)) {}
vec2(lint h, lint w, lint v) : vector(h, vector<lint>(w, v)) {}
};
template <class T> using priq = priority_queue<T>;
template <class T> using rpriq = priority_queue<T, vector<T>, greater<T>>;
template <class Key, class Val> using hashmap = unordered_map<Key, Val>;
template <class Key> using hashset = unordered_set<Key>;
template <class It> constexpr typename It::value_type rmax(It begin, It end) {
return *max_element(begin, end);
}
template <class T1, class T2> constexpr auto mmax(T1 arg1, T2 arg2) {
using T = decltype(arg1 + arg2);
return max(T(arg1), T(arg2));
}
template <class T, class... Types> constexpr auto mmax(T arg0, Types... args) {
return mmax(arg0, mmax(args...));
}
template <class It> constexpr typename It::value_type rmin(It begin, It end) {
return *min_element(begin, end);
}
template <class T1, class T2> constexpr auto mmin(T1 arg1, T2 arg2) {
using T = decltype(arg1 + arg2);
return min(T(arg1), T(arg2));
}
template <class T, class... Types> constexpr auto mmin(T arg0, Types... args) {
return mmin(arg0, mmin(args...));
}
mt19937 mtrand((random_device())());
const double pi = 3.141592653589793238462;
const lint intmax = 9223372036854775807;
const lint inf = 1100100100100100100LL;
constexpr lint div2(lint p, lint q) { return (p + q - 1) / q; }
#if (__cplusplus < 201703L)
lint gcd(lint a, lint b) {
while (1) {
if (a < b)
swap(a, b);
if (!b)
break;
a %= b;
}
return a;
}
lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
#endif
template <class T> struct nval {
lint n; // counts
T val;
nval() : n(0){};
nval(lint _n, T _val) : n(_n), val(_val){};
};
template <class It, class It2> auto spacel(It i, It2 end) {
if (i + 1 == end) {
return '\n';
} else {
return ' ';
}
}
ostream &setp(ostream &ost) {
cout << setprecision(60) << fixed;
return ost;
}
#ifdef _LOCAL
auto &dbg = cout;
#else
struct dummy_cout {
template <class T> dummy_cout &operator<<(T &&op) { return *this; }
using endl_t = basic_ostream<char, char_traits<char>>;
dummy_cout &operator<<(endl_t &(*)(endl_t &)) { return *this; }
};
dummy_cout dbg;
#endif
const ulint mod = 1000000007;
// const ulint mod = 998244353;
const ld eps = 0.0000001;
template <class T, class Pred> pair<T, T> bin(T begin, T end, Pred p) {
while (end - begin > 1) {
T tgt = begin + (end - begin) / 2;
if (p(tgt)) {
begin = tgt;
} else {
end = tgt;
}
}
return make_pair(begin, end);
}
template <class T> struct Mplus {
T operator()(const T &a, const T &b) { return a + b; }
const static T id = T(0);
};
template <class It, class T = typename It::value_type, class Monoid = Mplus<T>>
T acc(It begin, It end, Monoid f = Mplus<T>()) {
return accumulate(begin, end, Monoid::id, f);
}
int main() {
lint n, k;
cin >> n >> k;
vec a(n);
rep(i, n) cin >> a[i];
lint sum = acc(all(a));
lint ans = 1;
vec c(n), cs(n + 1), rcs(n + 1);
auto f = [&](lint d) {
rep(i, n) { c[i] = a[i] % d; }
sort(all(c));
cs[0] = 0;
rcs[0] = 0;
rep(i, n) cs[i + 1] = cs[i] + c[i];
reverse(all(c));
rep(i, n) c[i] = d - c[i];
rep(i, n) rcs[i + 1] = rcs[i] + c[i];
lint g = inf;
rep(i, n) {
lint p = cs[i], q = rcs[n - 1 - i];
if (p > q)
swap(p, q);
chmin(g, p + q);
}
return g <= k;
};
for (lint ii = 1; ii * ii <= sum; ii++) {
if (sum % ii != 0)
continue;
if (f(ii)) {
chmax(ans, ii);
}
if (f(sum / ii)) {
chmax(ans, sum / ii);
}
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define rep(i, n) for (lint i = 0; i < n; i++)
#define repr(i, n) for (lint i = n - 1; i >= 0; i--)
#define repi(i, ini, n) for (lint i = ini; i < n; i++)
#define repir(i, ini, n) for (lint i = n - 1; i >= ini; i--)
#define repb(i, start, end) for (lint i = start; i <= end; i++)
#define repbr(i, start, end) for (lint i = end; i >= start; i--)
#define bit(n) (1LL << (n))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rg(v, ini, end) v.begin() + ini, v.begin() + end
#define ret return 0;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
struct xy {
lint x, y;
xy() : x(0), y(0) {}
xy(lint _x, lint _y) : x(_x), y(_y) {}
xy operator+(const xy &p) const { return xy(x + p.x, y + p.y); }
bool operator<(xy p) const {
if (y == p.y)
return x < p.x;
return y < p.y;
}
};
struct xyd {
ld x, y;
xyd() : x(0), y(0) {}
xyd(long double _x, long double _y) : x(_x), y(_y) {}
};
using vec = vector<lint>;
using vecd = vector<ld>;
using vecs = vector<string>;
using vecp = vector<xy>;
template <class T> using vect = vector<T>;
class vec2 : public vector<vector<lint>> {
public:
vec2() {}
vec2(lint n) : vector(n) {}
vec2(lint h, lint w) : vector(h, vector<lint>(w)) {}
vec2(lint h, lint w, lint v) : vector(h, vector<lint>(w, v)) {}
};
template <class T> using priq = priority_queue<T>;
template <class T> using rpriq = priority_queue<T, vector<T>, greater<T>>;
template <class Key, class Val> using hashmap = unordered_map<Key, Val>;
template <class Key> using hashset = unordered_set<Key>;
template <class It> constexpr typename It::value_type rmax(It begin, It end) {
return *max_element(begin, end);
}
template <class T1, class T2> constexpr auto mmax(T1 arg1, T2 arg2) {
using T = decltype(arg1 + arg2);
return max(T(arg1), T(arg2));
}
template <class T, class... Types> constexpr auto mmax(T arg0, Types... args) {
return mmax(arg0, mmax(args...));
}
template <class It> constexpr typename It::value_type rmin(It begin, It end) {
return *min_element(begin, end);
}
template <class T1, class T2> constexpr auto mmin(T1 arg1, T2 arg2) {
using T = decltype(arg1 + arg2);
return min(T(arg1), T(arg2));
}
template <class T, class... Types> constexpr auto mmin(T arg0, Types... args) {
return mmin(arg0, mmin(args...));
}
mt19937 mtrand((random_device())());
const double pi = 3.141592653589793238462;
const lint intmax = 9223372036854775807;
const lint inf = 1100100100100100100LL;
constexpr lint div2(lint p, lint q) { return (p + q - 1) / q; }
#if (__cplusplus < 201703L)
lint gcd(lint a, lint b) {
while (1) {
if (a < b)
swap(a, b);
if (!b)
break;
a %= b;
}
return a;
}
lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
#endif
template <class T> struct nval {
lint n; // counts
T val;
nval() : n(0){};
nval(lint _n, T _val) : n(_n), val(_val){};
};
template <class It, class It2> auto spacel(It i, It2 end) {
if (i + 1 == end) {
return '\n';
} else {
return ' ';
}
}
ostream &setp(ostream &ost) {
cout << setprecision(60) << fixed;
return ost;
}
#ifdef _LOCAL
auto &dbg = cout;
#else
struct dummy_cout {
template <class T> dummy_cout &operator<<(T &&op) { return *this; }
using endl_t = basic_ostream<char, char_traits<char>>;
dummy_cout &operator<<(endl_t &(*)(endl_t &)) { return *this; }
};
dummy_cout dbg;
#endif
const ulint mod = 1000000007;
// const ulint mod = 998244353;
const ld eps = 0.0000001;
template <class T, class Pred> pair<T, T> bin(T begin, T end, Pred p) {
while (end - begin > 1) {
T tgt = begin + (end - begin) / 2;
if (p(tgt)) {
begin = tgt;
} else {
end = tgt;
}
}
return make_pair(begin, end);
}
template <class T> struct Mplus {
T operator()(const T &a, const T &b) { return a + b; }
const static T id = T(0);
};
template <class It, class T = typename It::value_type, class Monoid = Mplus<T>>
T acc(It begin, It end, Monoid f = Mplus<T>()) {
return accumulate(begin, end, Monoid::id, f);
}
int main() {
lint n, k;
cin >> n >> k;
vec a(n);
rep(i, n) cin >> a[i];
lint sum = acc(all(a));
lint ans = 1;
vec c(n), cs(n + 1), rcs(n + 1);
auto f = [&](lint d) {
rep(i, n) { c[i] = a[i] % d; }
sort(all(c));
cs[0] = 0;
rcs[0] = 0;
rep(i, n) cs[i + 1] = cs[i] + c[i];
reverse(all(c));
rep(i, n) c[i] = d - c[i];
rep(i, n) rcs[i + 1] = rcs[i] + c[i];
lint g = inf;
rep(i, n) {
lint p = cs[i], q = rcs[n - 1 - i];
if (p > q)
swap(p, q);
chmin(g, p + q - p);
}
return g <= k;
};
for (lint ii = 1; ii * ii <= sum; ii++) {
if (sum % ii != 0)
continue;
if (f(ii)) {
chmax(ans, ii);
}
if (f(sum / ii)) {
chmax(ans, sum / ii);
}
}
cout << ans << endl;
return 0;
}
| [
"assignment.change"
] | 759,149 | 759,150 | u275797573 | cpp |
p02955 | #include <bits/stdc++.h>
#define debug(x) \
cout << "DEBUG" \
<< " " << #x << ":" << x << '\n'
#define rep(i, n) \
for (int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++) // 0-indexed up
#define rep1(i, n) \
for (int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i, n) \
for (int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--) // 0-indexed down
#define rrep1(i, n) \
for (int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--) // 1-indexed down
#define all(x) (x).begin(), (x).end()
using namespace std;
template <typename T> using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;
template <class T> using maxheap = std::priority_queue<T>;
template <class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U> inline bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T, class U> inline bool chmin(T &a, const U &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL << 62) - 1;
constexpr int inf = (1 << 30) - 1;
const int mod = 1000000007;
// const int mod = 998244353;
/*FUNCs=================================================*/
/*MAIN==================================================*/
signed main() {
double START_TIME = clock();
cin.tie(nullptr);
ios::sync_with_stdio(false);
// cout << fixed << setprecision(15);
// Point
// ある操作を繰り返したりするとき
// ☆全体を通して不変な量を見つける
// 今回はAの総和が一定
// A全体の分割の仕方を考えるのでAの総和の約数全てを調べればよい
// ...fin
i64 n, k;
cin >> n >> k;
vl a(n);
rep(i, n) cin >> a[i];
i64 sum = 0;
rep(i, n) sum += a[i];
vl div;
for (i64 d = 1; d * d <= sum; ++d)
if (sum % d == 0) {
div.push_back(d);
if (d != sum / d)
div.push_back(sum / d);
}
i64 ans = 1;
for (auto d : div) {
vl a_mod(n, 0);
vl csum(n + 1, 0);
rep(i, n) a_mod[i] = a[i] % d;
sort(all(a_mod));
rep(i, n) csum[i + 1] = csum[i] + a_mod[i];
i64 tmp = 0;
rep(i, n) {
tmp = csum[i + 1] - csum[0];
if (tmp == d * (n - i) - (csum[n] - csum[i]))
break;
}
if (tmp / 2 <= k)
chmax(ans, d);
a_mod.clear();
csum.clear();
}
cout << ans << '\n';
// printf("ElapsedTime: %5.3f
// ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}
| #include <bits/stdc++.h>
#define debug(x) \
cout << "DEBUG" \
<< " " << #x << ":" << x << '\n'
#define rep(i, n) \
for (int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++) // 0-indexed up
#define rep1(i, n) \
for (int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i, n) \
for (int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--) // 0-indexed down
#define rrep1(i, n) \
for (int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--) // 1-indexed down
#define all(x) (x).begin(), (x).end()
using namespace std;
template <typename T> using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;
template <class T> using maxheap = std::priority_queue<T>;
template <class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U> inline bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T, class U> inline bool chmin(T &a, const U &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL << 62) - 1;
constexpr int inf = (1 << 30) - 1;
const int mod = 1000000007;
// const int mod = 998244353;
/*FUNCs=================================================*/
/*MAIN==================================================*/
signed main() {
double START_TIME = clock();
cin.tie(nullptr);
ios::sync_with_stdio(false);
// cout << fixed << setprecision(15);
// Point
// ある操作を繰り返したりするとき
// ☆全体を通して不変な量を見つける
// 今回はAの総和が一定
// A全体の分割の仕方を考えるのでAの総和の約数全てを調べればよい
// ...fin
i64 n, k;
cin >> n >> k;
vl a(n);
rep(i, n) cin >> a[i];
i64 sum = 0;
rep(i, n) sum += a[i];
vl div;
for (i64 d = 1; d * d <= sum; ++d)
if (sum % d == 0) {
div.push_back(d);
if (d != sum / d)
div.push_back(sum / d);
}
i64 ans = 1;
for (auto d : div) {
vl a_mod(n, 0);
vl csum(n + 1, 0);
rep(i, n) a_mod[i] = a[i] % d;
sort(all(a_mod));
rep(i, n) csum[i + 1] = csum[i] + a_mod[i];
i64 tmp = 0;
rep(i, n) {
tmp = csum[i + 1] - csum[0];
if (tmp == d * (n - 1 - i) - (csum[n] - csum[i + 1]))
break;
}
if (tmp <= k)
chmax(ans, d);
a_mod.clear();
csum.clear();
}
cout << ans << '\n';
// printf("ElapsedTime: %5.3f
// ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}
| [
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 759,153 | 759,154 | u457985479 | cpp |
p02955 | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll big = 1e18;
const double PI = 2 * asin(1);
int main() {
ll N, K;
cin >> N >> K;
ll A[N];
ll sum = 0;
for (int i = 0; i < N; ++i) {
cin >> A[i];
sum += A[i];
}
vector<ll> yaku;
for (ll i = 1; i * i <= sum; ++i) {
if (sum % i == 0) {
yaku.push_back(i);
if (i != sum / i)
yaku.push_back(sum / i);
}
}
ll ans = 0;
for (int i = 0; i < yaku.size(); ++i) {
vector<int> arr1, arr2;
for (int j = 0; j < N; ++j)
arr1.push_back(A[j] % yaku[i]);
sort(arr1.begin(), arr1.end());
for (int j = 0; j < N; ++j)
arr2.push_back(yaku[i] - arr1[j]);
for (int j = N - 2; j >= 0; --j)
arr2[j] += arr2[j + 1];
int tmp = 0;
for (int j = 0; j < N - 1; ++j) {
tmp += arr1[j];
if (tmp == arr2[j + 1]) {
if (tmp <= K)
ans = max(ans, yaku[i]);
break;
}
}
}
cout << ans << endl;
}
| #include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll big = 1e18;
const double PI = 2 * asin(1);
int main() {
ll N, K;
cin >> N >> K;
ll A[N];
ll sum = 0;
for (int i = 0; i < N; ++i) {
cin >> A[i];
sum += A[i];
}
vector<ll> yaku;
for (ll i = 1; i * i <= sum; ++i) {
if (sum % i == 0) {
yaku.push_back(i);
if (i != sum / i)
yaku.push_back(sum / i);
}
}
ll ans = 1;
for (int i = 0; i < yaku.size(); ++i) {
vector<int> arr1, arr2;
for (int j = 0; j < N; ++j)
arr1.push_back(A[j] % yaku[i]);
sort(arr1.begin(), arr1.end());
for (int j = 0; j < N; ++j)
arr2.push_back(yaku[i] - arr1[j]);
for (int j = N - 2; j >= 0; --j)
arr2[j] += arr2[j + 1];
int tmp = 0;
for (int j = 0; j < N - 1; ++j) {
tmp += arr1[j];
if (tmp == arr2[j + 1]) {
if (tmp <= K)
ans = max(ans, yaku[i]);
break;
}
}
}
cout << ans << endl;
}
| [
"literal.number.change",
"variable_declaration.value.change"
] | 759,160 | 759,161 | u860546679 | cpp |
p02955 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
#define SORT(a) sort((a).begin(), (a).end())
#define REV(a) reverse((a).begin(), (a).end())
#define For(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) For(i, 0, n)
#define debug(x) cerr << #x << " = " << (x) << endl;
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 coY() { cout << "Yes" << endl; }
void coN() { cout << "No" << endl; }
// Write From this Line
// const ll mod = 1e9+7;
// const ll mod = 998244353;
int main() {
int n, k;
cin >> n >> k;
vector<ll> a(n);
rep(i, n) cin >> a[i];
ll sum = 0;
rep(i, n) sum += a[i];
// sum の約数が出来る候補
set<ll> candidates;
for (int i = 1; i * i <= sum; i++) {
if (sum % i == 0) {
candidates.insert(i);
candidates.insert(sum / i);
}
}
ll ans = 1;
for (ll x : candidates) {
ll need;
{ // calc need
vector<ll> r(n);
rep(i, n) r[i] = a[i] % x;
sort(r.begin(), r.end());
ll B = 0;
rep(i, n) B += r[i];
ll A = 0; // 区切り位置を左から1個ずつ試す
need = 1e18;
rep(i, n) {
A += r[i];
B -= x - r[i];
need = min(need, max(A, B));
}
}
if (need <= k)
ans = max(ans, x);
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
#define SORT(a) sort((a).begin(), (a).end())
#define REV(a) reverse((a).begin(), (a).end())
#define For(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) For(i, 0, n)
#define debug(x) cerr << #x << " = " << (x) << endl;
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 coY() { cout << "Yes" << endl; }
void coN() { cout << "No" << endl; }
// Write From this Line
// const ll mod = 1e9+7;
// const ll mod = 998244353;
int main() {
int n, k;
cin >> n >> k;
vector<ll> a(n);
rep(i, n) cin >> a[i];
ll sum = 0;
rep(i, n) sum += a[i];
// sum の約数が出来る候補
set<ll> candidates;
for (int i = 1; i * i <= sum; i++) {
if (sum % i == 0) {
candidates.insert(i);
candidates.insert(sum / i);
}
}
ll ans = 1;
for (ll x : candidates) {
ll need;
{ // calc need
vector<ll> r(n);
rep(i, n) r[i] = a[i] % x;
sort(r.begin(), r.end());
ll B = 0;
rep(i, n) B += x - r[i];
ll A = 0; // 区切り位置を左から1個ずつ試す
need = 1e18;
rep(i, n) {
A += r[i];
B -= x - r[i];
need = min(need, max(A, B));
}
}
if (need <= k)
ans = max(ans, x);
}
cout << ans << endl;
}
| [
"assignment.change"
] | 759,162 | 759,163 | u298620933 | cpp |
p02955 | #include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
vll div(ll N) {
vll yakusuu;
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0) {
yakusuu.push_back(i);
if (i * i != N)
yakusuu.push_back(N / i);
}
}
return yakusuu;
}
int main() {
int N, K;
cin >> N >> K;
vint A(N);
ll sum = 0;
for (size_t i = 0; i < N; i++) {
cin >> A[i];
sum += A[i];
}
auto divs = div(sum);
sort(all(divs), greater<ll>());
for (auto &&i : divs) {
i = 102;
auto tmp = A;
int num = 0;
for (size_t j = 0; j < N; j++) {
tmp[j] %= i;
}
sort(all(tmp));
int first = 0, last = N - 1;
while (first < last) {
int diff = min((ll)tmp[first], i - tmp[last]);
num += diff;
tmp[first] -= diff;
tmp[last] = (tmp[last] + diff) % i;
if (tmp[first] == 0)
first++;
if (tmp[last] == 0)
last--;
}
num += min(tmp[first], ((int)i - tmp[first]));
if (num <= K) {
cout << i << endl;
break;
}
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
vll div(ll N) {
vll yakusuu;
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0) {
yakusuu.push_back(i);
if (i * i != N)
yakusuu.push_back(N / i);
}
}
return yakusuu;
}
int main() {
int N, K;
cin >> N >> K;
vint A(N);
ll sum = 0;
for (size_t i = 0; i < N; i++) {
cin >> A[i];
sum += A[i];
}
auto divs = div(sum);
sort(all(divs), greater<ll>());
for (auto &&i : divs) {
auto tmp = A;
int num = 0;
for (size_t j = 0; j < N; j++) {
tmp[j] %= i;
}
sort(all(tmp));
int first = 0, last = N - 1;
while (first < last) {
int diff = min((ll)tmp[first], i - tmp[last]);
num += diff;
tmp[first] -= diff;
tmp[last] = (tmp[last] + diff) % i;
if (tmp[first] == 0)
first++;
if (tmp[last] == 0)
last--;
}
num += min(tmp[first], ((int)i - tmp[first]));
if (num <= K) {
cout << i << endl;
break;
}
}
return 0;
} | [] | 759,164 | 759,165 | u987913144 | cpp |
p02955 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww {
cww() {
ios::sync_with_stdio(false);
cin.tie(0);
}
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
vll div(ll N) {
vll yakusuu;
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0) {
yakusuu.push_back(i);
if (i * i != N)
yakusuu.push_back(N / i);
}
}
return yakusuu;
}
int main() {
int N, K;
cin >> N >> K;
vll A(N);
ll sum = 0;
for (size_t i = 0; i < N; i++) {
cin >> A[i];
sum += A[i];
}
int ans = 0;
auto fac = div(sum);
for (int &&f : fac) {
vint res(N);
for (size_t i = 0; i < N; i++) {
res[i] = A[i] % f;
}
sort(all(res));
ll l = 0, r = N - 1, cnt = 0;
while (l < r) {
int t = min(res[l], res[r]);
cnt += t;
res[l] -= t;
res[r] = (res[r] + t) % f;
if (res[l] == 0) {
l++;
}
if (res[r] == 0) {
r--;
}
}
if (cnt <= K) {
chmax(ans, f);
}
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww {
cww() {
ios::sync_with_stdio(false);
cin.tie(0);
}
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
vll div(ll N) {
vll yakusuu;
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0) {
yakusuu.push_back(i);
if (i * i != N)
yakusuu.push_back(N / i);
}
}
return yakusuu;
}
int main() {
int N, K;
cin >> N >> K;
vll A(N);
ll sum = 0;
for (size_t i = 0; i < N; i++) {
cin >> A[i];
sum += A[i];
}
int ans = 0;
auto fac = div(sum);
for (int &&f : fac) {
vint res(N);
for (size_t i = 0; i < N; i++) {
res[i] = A[i] % f;
}
sort(all(res));
ll l = 0, r = N - 1, cnt = 0;
while (l < r) {
int t = min(res[l], f - res[r]);
cnt += t;
res[l] -= t;
res[r] = (res[r] + t) % f;
if (res[l] == 0) {
l++;
}
if (res[r] == 0) {
r--;
}
}
if (cnt <= K) {
chmax(ans, f);
}
}
cout << ans;
return 0;
} | [
"assignment.change"
] | 759,166 | 759,167 | u987913144 | cpp |
p02955 | #include "bits/stdc++.h"
#include <random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) \
for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
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;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) {
return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) {
return make_pair(l.first - r.first, l.second - r.second);
}
const lint MOD = 1e9 + 7, INF = 1e18;
vector<int64_t> divisor(int64_t n) {
vector<int64_t> ret;
for (int64_t i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
lint arr[500], N, K;
int main() {
cin >> N >> K;
lint sum = 0;
REP(i, N) {
cin >> arr[i];
sum += arr[i];
}
auto vec = divisor(sum);
IREP(x, SZ(vec)) {
if (vec[x] == 1) {
cout << 1 << endl;
return 0;
}
lint _arr[500], d = vec[x], minv = INF;
lint sum_p = 0, sum_m = 0;
REP(i, N) {
_arr[i] = arr[i] % d;
sum_m -= _arr[i];
}
sort(_arr, _arr + N);
chmin(minv, max(-sum_m, sum_p));
REP(i, N) {
sum_m += _arr[i];
sum_p += _arr[i];
chmin(minv, max(-sum_m, sum_p));
}
if (minv <= K) {
cout << d << endl;
return 0;
}
}
}
| #include "bits/stdc++.h"
#include <random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) \
for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
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;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) {
return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) {
return make_pair(l.first - r.first, l.second - r.second);
}
const lint MOD = 1e9 + 7, INF = 1e18;
vector<int64_t> divisor(int64_t n) {
vector<int64_t> ret;
for (int64_t i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
lint arr[500], N, K;
int main() {
cin >> N >> K;
lint sum = 0;
REP(i, N) {
cin >> arr[i];
sum += arr[i];
}
auto vec = divisor(sum);
IREP(x, SZ(vec)) {
if (vec[x] == 1) {
cout << 1 << endl;
return 0;
}
lint _arr[500], d = vec[x], minv = INF;
lint sum_p = 0, sum_m = 0;
REP(i, N) {
_arr[i] = arr[i] % d;
sum_m -= _arr[i];
}
sort(_arr, _arr + N);
chmin(minv, max(-sum_m, sum_p));
IREP(i, N) {
sum_m += _arr[i];
sum_p += (d - _arr[i]);
chmin(minv, max(-sum_m, sum_p));
}
if (minv <= K) {
cout << d << endl;
return 0;
}
}
}
| [
"identifier.change"
] | 759,179 | 759,180 | u554988565 | cpp |
p02955 | #include <bits/stdc++.h>
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) _range(i, 0, n)
#define _range(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)
#define _rrep(i, n) _rrange(i, n, 0)
#define _rrange(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rrep(...) _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__)
#define _all(arg) begin(arg), end(arg)
#define uniq(arg) sort(_all(arg)), (arg).erase(unique(_all(arg)), end(arg))
#define bit(n) (1LL << (n))
// #define DEBUG
#ifdef DEBUG
#define dump(...) fprintf(stderr, __VA_ARGS__)
#else
#define dump(...)
#endif
template <class T> bool chmax(T &a, const T &b) {
return (a < b) ? (a = b, 1) : 0;
}
template <class T> bool chmin(T &a, const T &b) {
return (b < a) ? (a = b, 1) : 0;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll extgcd(ll a, ll b, ll &x, ll &y) {
x = 1, y = 0;
ll g = a;
if (b != 0)
g = extgcd(b, a % b, y, x), y -= a / b * x;
return g;
}
ll ADD(const ll &a, const ll &b, const ll mod = MOD) { return (a + b) % mod; }
ll SUB(const ll &a, const ll &b, const ll mod = MOD) {
return (a - b + mod) % mod;
}
ll MUL(const ll &a, const ll &b, const ll mod = MOD) {
return (1LL * a * b) % mod;
}
ll DIV(const ll &a, const ll &b, const ll mod = MOD) {
ll x, y;
extgcd(b, mod, x, y);
return MUL(a, (x + mod) % mod, mod);
}
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int n, K;
cin >> n >> K;
vi a(n);
for (auto &e : a)
cin >> e;
int sum = 0;
for (auto &e : a)
cin >> e, sum += e;
vi ds;
rep(i, 1, (int)sqrt(sum) + 1) {
if (sum % i == 0) {
ds.emplace_back(i);
ds.emplace_back(sum / i);
}
}
uniq(ds);
int m = ds.size();
rrep(i, m) {
int d = ds[i];
vi b = a;
for (auto &e : b)
e %= d;
sort(_all(b));
sum = 0;
for (auto &e : b)
sum += e;
int rsum = 0;
rrep(i, n) {
sum -= b[i];
rsum += (d - b[i]);
if (sum == rsum) {
if (sum <= K) {
cout << d << endl;
return 0;
}
break;
}
}
}
return 0;
}
| #include <bits/stdc++.h>
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) _range(i, 0, n)
#define _range(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)
#define _rrep(i, n) _rrange(i, n, 0)
#define _rrange(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rrep(...) _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__)
#define _all(arg) begin(arg), end(arg)
#define uniq(arg) sort(_all(arg)), (arg).erase(unique(_all(arg)), end(arg))
#define bit(n) (1LL << (n))
// #define DEBUG
#ifdef DEBUG
#define dump(...) fprintf(stderr, __VA_ARGS__)
#else
#define dump(...)
#endif
template <class T> bool chmax(T &a, const T &b) {
return (a < b) ? (a = b, 1) : 0;
}
template <class T> bool chmin(T &a, const T &b) {
return (b < a) ? (a = b, 1) : 0;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll extgcd(ll a, ll b, ll &x, ll &y) {
x = 1, y = 0;
ll g = a;
if (b != 0)
g = extgcd(b, a % b, y, x), y -= a / b * x;
return g;
}
ll ADD(const ll &a, const ll &b, const ll mod = MOD) { return (a + b) % mod; }
ll SUB(const ll &a, const ll &b, const ll mod = MOD) {
return (a - b + mod) % mod;
}
ll MUL(const ll &a, const ll &b, const ll mod = MOD) {
return (1LL * a * b) % mod;
}
ll DIV(const ll &a, const ll &b, const ll mod = MOD) {
ll x, y;
extgcd(b, mod, x, y);
return MUL(a, (x + mod) % mod, mod);
}
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int n, K;
cin >> n >> K;
vi a(n);
for (auto &e : a)
cin >> e;
int sum = 0;
for (auto &e : a)
cin >> e, sum += e;
vi ds;
rep(i, 1, (int)sqrt(sum) + 1) {
if (sum % i == 0) {
ds.emplace_back(i);
ds.emplace_back(sum / i);
}
}
uniq(ds);
int m = ds.size();
rrep(i, m) {
int d = ds[i];
vi b = a;
for (auto &e : b)
e %= d;
sort(_all(b));
sum = 0;
for (auto &e : b)
sum += e;
int rsum = 0;
rrep(i, n) {
sum -= b[i];
rsum += (d - b[i]) % d;
if (sum == rsum) {
if (sum <= K) {
cout << d << endl;
return 0;
}
break;
}
}
}
return 0;
}
| [
"assignment.change"
] | 759,201 | 759,202 | u704625420 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.