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 |
|---|---|---|---|---|---|---|---|
p03126 | #include <stdio.h>
int c[30], cnt;
int main() {
int N, M;
scanf("%d%d", &N, &M);
int K[31], A[30][30];
int i, j;
for (i = 0; i < N; i++) {
scanf("%d", &K[i]);
for (j = 0; j < K[i]; j++) {
scanf("%d", &A[i][j]);
c[A[i][j]]++;
}
}
for (i = 0; i < N; i++) {
if (c[i + 1] == N)
cnt++;
}
printf("%d\n", cnt);
return 0;
} | #include <stdio.h>
int c[30], cnt;
int main() {
int N, M;
scanf("%d%d", &N, &M);
int K[31], A[30][30];
int i, j;
for (i = 0; i < N; i++) {
scanf("%d", &K[i]);
for (j = 0; j < K[i]; j++) {
scanf("%d", &A[i][j]);
c[A[i][j]]++;
}
}
for (i = 0; i < M; i++) {
if (c[i + 1] == N)
cnt++;
}
printf("%d\n", cnt);
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 928,583 | 928,584 | u792455295 | cpp |
p03126 | #include <bits/stdc++.h>
using namespace std;
int n, m, t, tt;
int a[32];
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> t;
for (int j = 0; j < t; j++) {
cin >> tt;
a[tt]++;
}
}
int ans = 0;
for (int i = 0; i < m; i++) {
if (a[i] == n) {
ans++;
}
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int n, m, t, tt;
int a[32];
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> t;
for (int j = 0; j < t; j++) {
cin >> tt;
a[tt]++;
}
}
int ans = 0;
for (int i = 1; i <= m; i++) {
if (a[i] == n) {
ans++;
}
}
cout << ans;
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 928,594 | 928,595 | u547457320 | cpp |
p03126 | #include <iostream>
using namespace std;
int a[35];
int main() {
int n, m, num;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
int flag;
cin >> num;
for (int j = 1; j <= num; ++j) {
cin >> flag;
a[flag]++;
}
}
int ans = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] == n) {
ans++;
}
}
cout << ans;
return 0;
} | #include <iostream>
using namespace std;
int a[35];
int main() {
int n, m, num;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
int flag;
cin >> num;
for (int j = 1; j <= num; ++j) {
cin >> flag;
a[flag]++;
}
}
int ans = 0;
for (int i = 1; i <= m; ++i) {
if (a[i] == n) {
ans++;
}
}
cout << ans;
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 928,647 | 928,648 | u493225326 | cpp |
p03126 | #include <iostream>
#include <stdio.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, m, t = 0, y = 0;
cin >> n;
cin >> m;
int a[n][m] = {0}, x[n] = {0};
for (int i = 0; i < n; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
cin >> a[i][j];
y = a[i][j] - 1;
x[y] = x[y] + 1;
}
}
for (int i = 0; i < n; i++) {
if (x[i] == n) {
t++;
}
}
printf("%d", t);
return 0;
}
| #include <iostream>
#include <stdio.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, m, t = 0, y = 0;
cin >> n;
cin >> m;
int a[n][m] = {0}, x[m] = {0};
for (int i = 0; i < n; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
cin >> a[i][j];
y = a[i][j] - 1;
x[y] = x[y] + 1;
}
}
for (int i = 0; i < m; i++) {
if (x[i] == n) {
t++;
}
}
printf("%d", t);
return 0;
}
| [
"identifier.change",
"variable_declaration.array_dimensions.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 928,653 | 928,654 | u187606204 | cpp |
p03126 | #include <bits/stdc++.h>
using namespace std;
//#define READ_NUMBER(i) scanf("%d",i)
int main() {
int N, M, K, nA, Anm;
int count = 0;
cin >> N >> M;
int array[M];
for (int j = 0; j < M; j++) {
array[j] = 0;
}
if (N == 1) {
cin >> K;
cout << K << endl;
} else {
for (int i = 0; i < N; i++) {
cin >> K;
for (int j = 0; j < K; j++) {
cin >> nA;
array[nA] += 1;
}
}
for (int i = 0; i < M; i++) {
if (array[i] == N) {
count++;
}
}
cout << count << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
//#define READ_NUMBER(i) scanf("%d",i)
int main() {
int N, M, K, nA, Anm;
int count = 0;
cin >> N >> M;
int array[M];
//配列のリセット
for (int j = 0; j < M; j++) {
array[j] = 0;
}
// N = 1 の時はK1個が答えになる
if (N == 1) {
cin >> K;
cout << K << endl;
} else {
for (int i = 0; i < N; i++) {
cin >> K; // 何個か調べる
for (int j = 0; j < K; j++) {
cin >> nA; // n - 1番目の配列に1を足す
array[nA - 1] += 1;
}
}
for (int i = 0; i < M; i++) {
if (array[i] == N) {
//配列のi番目がNだったら(全ての人が好き)
count++;
}
}
cout << count << endl;
}
} | [
"assignment.change"
] | 928,665 | 928,666 | u796853866 | cpp |
p03126 | #include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
vector<int> split(string data);
int main() {
int n, m;
cin >> n >> m;
cin.ignore();
int result[m] = {}; // initialized 0
for (size_t i = 0; i < n; i++) {
string s;
getline(cin, s);
vector<int> list = split(s);
for (size_t j = 0; j < list[0]; j++) {
result[list[j] + 1]++;
}
}
int count = 0;
for (size_t i = 0; i < m; i++) {
if (result[i] == n)
count++;
}
cout << count << "\n";
return 0;
}
vector<int> split(string data) {
vector<int> list;
stringstream ss(data);
string item;
while (getline(ss, item, ' ') && !item.empty()) {
list.push_back(stoi(item));
}
return list;
} | #include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
vector<int> split(string data);
int main() {
int n, m;
cin >> n >> m;
cin.ignore();
int result[m] = {}; // initialized 0
for (size_t i = 0; i < n; i++) {
string s;
getline(cin, s);
vector<int> list = split(s);
for (size_t j = 0; j < list[0]; j++) {
result[list[j + 1] - 1]++;
}
}
int count = 0;
for (size_t i = 0; i < m; i++) {
if (result[i] == n)
count++;
}
cout << count << "\n";
return 0;
}
vector<int> split(string data) {
vector<int> list;
stringstream ss(data);
string item;
while (getline(ss, item, ' ') && !item.empty()) {
list.push_back(stoi(item));
}
return list;
} | [
"expression.operation.binary.add"
] | 928,688 | 928,689 | u820315626 | cpp |
p03126 | #include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int M, N, K, A, *foods, count;
cin >> N >> M;
foods = new int[M];
for (int i = 0; i < N; i++) {
cin >> K;
for (int j = 0; j < K; j++) {
cin >> A;
foods[A - 1]++;
}
}
for (int i = 0; i < M; i++) {
if (foods[i] == N) {
count++;
}
}
cout << count << endl;
return 0;
}
| #include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int M, N, K, A, *foods, count = 0;
cin >> N >> M;
foods = new int[M];
for (int i = 0; i < N; i++) {
cin >> K;
for (int j = 0; j < K; j++) {
cin >> A;
foods[A - 1]++;
}
}
for (int i = 0; i < M; i++) {
if (foods[i] == N) {
count++;
}
}
cout << count << endl;
return 0;
}
| [
"variable_declaration.value.change"
] | 928,694 | 928,695 | u732491975 | cpp |
p03126 | /* B */
#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int *like = new int[m];
for (int i = 0; i < m; i++) {
like[i] = 0;
}
for (int t = 0; t < n; t++) {
int k;
int tmp;
cin >> k;
for (int j = 0; j < k; j++) {
cin >> tmp;
like[tmp - 1]++;
}
}
int cnt = 0;
for (int i = 0; i < n; ++i) {
if (like[i] == n) {
cnt++;
}
}
cout << cnt << endl;
} | /* B */
#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int *like = new int[m];
for (int i = 0; i < m; i++) {
like[i] = 0;
}
for (int t = 0; t < n; t++) {
int k;
int tmp;
cin >> k;
for (int j = 0; j < k; j++) {
cin >> tmp;
like[tmp - 1]++;
}
}
int cnt = 0;
for (int i = 0; i < m; ++i) {
if (like[i] == n) {
cnt++;
}
}
cout << cnt << endl;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 928,710 | 928,711 | u147762850 | cpp |
p03126 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int N, M;
vector<int> favorite;
cin >> N >> M;
favorite.resize(M);
fill(favorite.begin(), favorite.end(), 0);
for (int i = 0; i < N; i++) {
int K;
cin >> K;
for (int j = 0; j < K; j++) {
int A;
cin >> A;
favorite[A]++;
}
}
int ans = 0;
for (int i = 0; i < N; i++) {
if (favorite[i] == N)
ans++;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int N, M;
vector<int> favorite;
cin >> N >> M;
favorite.resize(M + 1);
fill(favorite.begin(), favorite.end(), 0);
for (int i = 0; i < N; i++) {
int K;
cin >> K;
for (int j = 0; j < K; j++) {
int A;
cin >> A;
favorite[A]++;
}
}
int ans = 0;
for (int i = 1; i <= M; i++) {
if (favorite[i] == N)
ans++;
}
cout << ans << endl;
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.loop.for.condition.change"
] | 928,714 | 928,715 | u021940499 | cpp |
p03126 | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> v(M);
for (int i = 0; i < N; i++) {
int K;
cin >> K;
vector<int> foods(K);
for (int j = 0; j < K; j++)
cin >> foods[j];
for (int f : foods)
v[f]++;
}
int count = 0;
for (int ff : v)
if (ff == N)
count++;
cout << count << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> v(M);
for (int i = 0; i < N; i++) {
int K;
cin >> K;
vector<int> foods(K);
for (int j = 0; j < K; j++)
cin >> foods[j];
for (int f : foods)
v[f - 1]++;
}
int count = 0;
for (int ff : v)
if (ff == N)
count++;
cout << count << endl;
return 0;
}
| [
"expression.operation.binary.add"
] | 928,722 | 928,723 | u562767072 | cpp |
p03126 | #include <iostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};
template <typename T> void show(T a) {
for (auto i : a) {
cout << i << " ";
}
cout << endl;
}
template <typename T> void showmatrix(T a) {
for (auto j : a) {
for (auto i : j) {
cout << i;
}
cout << endl;
}
cout << endl;
}
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<int> v(m, 0);
int tmp;
for (int i = 0; i < n; i++) {
cin >> tmp;
for (int j = 0; j < tmp; j++) {
int t;
cin >> t;
v[t - 1]++;
}
}
int count = 0;
for (int i = 0; i < n; i++) {
if (v[i] == n)
count++;
}
// show(v);
cout << count << endl;
}
| #include <iostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};
template <typename T> void show(T a) {
for (auto i : a) {
cout << i << " ";
}
cout << endl;
}
template <typename T> void showmatrix(T a) {
for (auto j : a) {
for (auto i : j) {
cout << i;
}
cout << endl;
}
cout << endl;
}
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<int> v(m, 0);
int tmp;
for (int i = 0; i < n; i++) {
cin >> tmp;
for (int j = 0; j < tmp; j++) {
int t;
cin >> t;
v[t - 1]++;
}
}
int count = 0;
for (int i = 0; i < m; i++) {
if (v[i] == n)
count++;
}
// show(v);
cout << count << endl;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 928,724 | 928,725 | u367592430 | cpp |
p03126 | #include <iostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};
template <typename T> void show(T a) {
for (auto i : a) {
cout << i << " ";
}
cout << endl;
}
template <typename T> void showmatrix(T a) {
for (auto j : a) {
for (auto i : j) {
cout << i;
}
cout << endl;
}
cout << endl;
}
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<int> v(n, 0);
int tmp;
for (int i = 0; i < n; i++) {
cin >> tmp;
for (int j = 0; j < tmp; j++) {
int t;
cin >> t;
v[t - 1]++;
}
}
int count = 0;
for (int i = 0; i < n; i++) {
if (v[i] == n)
count++;
}
// show(v);
cout << count << endl;
}
| #include <iostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};
template <typename T> void show(T a) {
for (auto i : a) {
cout << i << " ";
}
cout << endl;
}
template <typename T> void showmatrix(T a) {
for (auto j : a) {
for (auto i : j) {
cout << i;
}
cout << endl;
}
cout << endl;
}
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<int> v(m, 0);
int tmp;
for (int i = 0; i < n; i++) {
cin >> tmp;
for (int j = 0; j < tmp; j++) {
int t;
cin >> t;
v[t - 1]++;
}
}
int count = 0;
for (int i = 0; i < m; i++) {
if (v[i] == n)
count++;
}
// show(v);
cout << count << endl;
}
| [
"identifier.change",
"call.arguments.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 928,726 | 928,725 | u367592430 | cpp |
p03126 | #include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int N, M;
cin >> N >> M;
std::vector<int> v(N + 1, 0);
for (int i = 0; i < M; i++) {
int K;
cin >> K;
for (int j = 0; j < K; j++) {
int a;
cin >> a;
v[a]++;
}
}
int ans = 0;
for (int i = 1; i <= N; i++) {
if (v[i] == M)
ans++;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int N, M;
cin >> M >> N;
std::vector<int> v(N + 1, 0);
for (int i = 0; i < M; i++) {
int K;
cin >> K;
for (int j = 0; j < K; j++) {
int a;
cin >> a;
v[a]++;
}
}
int ans = 0;
for (int i = 1; i <= N; i++) {
if (v[i] == M)
ans++;
}
cout << ans << endl;
}
| [
"expression.operation.binary.remove"
] | 928,733 | 928,734 | u942774736 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(), v.end()
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (a % b == 0)
return b;
return gcd(a % b, b);
}
int main() {
int N;
cin >> N;
vector<int> A(N);
rep(i, N) { cin >> A.at(i); }
ll ans = A.at(0);
for (int i = 0; i < N - 1; i++) {
ans = gcd(A.at(i), ans);
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(), v.end()
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (a % b == 0)
return b;
return gcd(a % b, b);
}
int main() {
int N;
cin >> N;
vector<int> A(N);
rep(i, N) { cin >> A.at(i); }
ll ans = A.at(0);
for (int i = 0; i < N; i++) {
ans = gcd(A.at(i), ans);
}
cout << ans << endl;
}
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 928,737 | 928,738 | u948222358 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin >> N;
vector<long long> A(N);
for (int i = 0; i < N; i++)
cin >> A.at(i);
long long M = gcd(A.at(0), A.at(1));
for (int i = 2; i < N; i++) {
M = gcd(M, A.at(2));
}
cout << M << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<long long> A(N);
for (int i = 0; i < N; i++)
cin >> A.at(i);
long long M = gcd(A.at(0), A.at(1));
for (int i = 2; i < N; i++) {
M = gcd(M, A.at(i));
}
cout << M << endl;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.narrow.change",
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change"
] | 928,757 | 928,758 | u714624983 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<long long> A(N);
for (int i = 0; i < N; i++)
cin >> A.at(i);
long long M = gcd(A.at(0), A.at(1));
for (int i = 2; i < N; i++) {
M = gcd(M, A.at(2));
}
cout << M << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<long long> A(N);
for (int i = 0; i < N; i++)
cin >> A.at(i);
long long M = gcd(A.at(0), A.at(1));
for (int i = 2; i < N; i++) {
M = gcd(M, A.at(i));
}
cout << M << endl;
} | [
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change"
] | 928,759 | 928,758 | u714624983 | cpp |
p03127 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define reps(i, n) for (int i = 1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
using namespace std;
using ll = long long;
ll mod = 1000000007;
const ll INF = 1LL << 60;
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;
}
ll gcd(ll x, ll y) {
if (!(x % y))
return y;
else
return gcd(y, x % y);
}
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
sort(ALL(a));
ll g = a[0];
for (auto x : a)
g = gcd(g, x);
cout << (g == 1 ? a[0] : g);
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define reps(i, n) for (int i = 1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
using namespace std;
using ll = long long;
ll mod = 1000000007;
const ll INF = 1LL << 60;
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;
}
ll gcd(ll x, ll y) {
if (!(x % y))
return y;
else
return gcd(y, x % y);
}
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
sort(ALL(a));
ll g = a[0];
for (auto x : a)
g = gcd(g, x);
cout << (g == 1 ? 1 : g);
} | [
"identifier.replace.remove",
"literal.replace.add",
"io.output.change"
] | 928,919 | 928,918 | u467480147 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define sort(s) sort(s.begin(), s.end())
#define reverse(s) reverse(s.begin(), s.end())
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
const ll mod = 1e9 + 7;
//最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
//最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//素数判定
bool isPrime(ll x) {
ll i;
if (x < 2)
return 0;
else if (x == 2)
return 1;
if (x % 2 == 0)
return 0;
for (i = 3; i * i <= x; i += 2)
if (x % i == 0)
return 0;
return 1;
}
//桁和
int digsum(ll n) {
int res = 0;
while (n > 0) {
res += n % 10;
n /= 10;
}
return res;
}
//桁数
int dignum(ll n) {
int res = 0;
while (n > 0) {
res++;
n /= 10;
}
return res;
}
//文字列中の特定の文字カウント
ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); }
//階乗
ll ka(ll i) {
ll res = 1;
while (i > 0) {
res = res * i;
i--;
}
return res;
}
// ncr
ll ncr(ll x, ll y) {
ll a = x;
ll b = 1;
if (y > (x / 2)) {
y = x - y;
}
for (ll i = 1; i < y; i++) {
a *= x - i;
b *= i + 1;
}
return a / b;
}
int main() {
int n;
cin >> n;
int a[n];
rep(i, n) cin >> a[i];
int ans = gcd(a[0], a[1]);
for (int i = 2; i < n; i++) {
ans = gcd(ans, a[2]);
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define sort(s) sort(s.begin(), s.end())
#define reverse(s) reverse(s.begin(), s.end())
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
const ll mod = 1e9 + 7;
//最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
//最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//素数判定
bool isPrime(ll x) {
ll i;
if (x < 2)
return 0;
else if (x == 2)
return 1;
if (x % 2 == 0)
return 0;
for (i = 3; i * i <= x; i += 2)
if (x % i == 0)
return 0;
return 1;
}
//桁和
int digsum(ll n) {
int res = 0;
while (n > 0) {
res += n % 10;
n /= 10;
}
return res;
}
//桁数
int dignum(ll n) {
int res = 0;
while (n > 0) {
res++;
n /= 10;
}
return res;
}
//文字列中の特定の文字カウント
ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); }
//階乗
ll ka(ll i) {
ll res = 1;
while (i > 0) {
res = res * i;
i--;
}
return res;
}
// ncr
ll ncr(ll x, ll y) {
ll a = x;
ll b = 1;
if (y > (x / 2)) {
y = x - y;
}
for (ll i = 1; i < y; i++) {
a *= x - i;
b *= i + 1;
}
return a / b;
}
int main() {
int n;
cin >> n;
int a[n];
rep(i, n) cin >> a[i];
int ans = gcd(a[0], a[1]);
for (int i = 2; i < n; i++) {
ans = gcd(ans, a[i]);
}
cout << ans << endl;
return 0;
} | [
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 928,956 | 928,957 | u584787460 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1000000007;
const int MAX_N = 1000; // n の最大値
// nCk を取得
double nCk(int n, int k) {
double res = 1.0;
for (int i = 0; i < n; i++) {
res *= 0.5;
}
for (int i = 0; i < k; i++) {
res *= (double)(n - i);
res /= (double)(k - i);
}
return res;
}
int main() {
ll n;
cin >> n;
ll a[n] = {};
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
ll b = a[0];
ll c;
ll d;
for (ll i = 1; i < n; i++) {
c = __gcd(a[i], c);
}
cout << c << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1000000007;
const int MAX_N = 1000; // n の最大値
// nCk を取得
double nCk(int n, int k) {
double res = 1.0;
for (int i = 0; i < n; i++) {
res *= 0.5;
}
for (int i = 0; i < k; i++) {
res *= (double)(n - i);
res /= (double)(k - i);
}
return res;
}
int main() {
ll n;
cin >> n;
ll a[n] = {};
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
ll b = a[0];
ll c = a[0];
ll d;
for (ll i = 1; i < n; i++) {
c = __gcd(a[i], c);
}
cout << c << endl;
}
| [
"variable_declaration.value.change"
] | 929,095 | 929,096 | u722640678 | cpp |
p03127 | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int func1(int a, int b) {
if (b == 0) {
return a;
}
return func1(b, a % b);
}
int main() {
int n;
cin >> n;
int max = 1;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
for (int i = 0; i < n; i++) {
max = func1(v[i], max);
}
cout << max << endl;
} | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int func1(int a, int b) {
if (b == 0) {
return a;
}
return func1(b, a % b);
}
int main() {
int n;
cin >> n;
int max = 0;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
for (int i = 0; i < n; i++) {
max = func1(v[i], max);
}
cout << max << endl;
} | [
"literal.number.change",
"variable_declaration.value.change"
] | 929,232 | 929,233 | u130834452 | cpp |
p03127 | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int func1(int a, int b) {
if (b == 0) {
return a;
}
return func1(b, b % a);
}
int main() {
int n;
cin >> n;
int max = 1;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
for (int i = 0; i < n; i++) {
max = func1(v[i], max);
}
cout << max << endl;
} | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int func1(int a, int b) {
if (b == 0) {
return a;
}
return func1(b, a % b);
}
int main() {
int n;
cin >> n;
int max = 0;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
for (int i = 0; i < n; i++) {
max = func1(v[i], max);
}
cout << max << endl;
} | [
"expression.operation.binary.remove",
"literal.number.change",
"variable_declaration.value.change"
] | 929,234 | 929,233 | u130834452 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
int gcd_euclid(int u, int v) {
int r;
while (0 != v) {
r = u % v;
u = v;
v = r; /* swap */
}
return u;
}
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int j = 1; j < n; j++) {
a[j] = gcd_euclid(a[j], a[j - 1]);
}
cout << a[n] << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int gcd_euclid(int u, int v) {
int r;
while (0 != v) {
r = u % v;
u = v;
v = r; /* swap */
}
return u;
}
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int j = 1; j < n; j++) {
a[j] = gcd_euclid(a[j], a[j - 1]);
}
cout << a[n - 1] << endl;
} | [
"expression.operation.binary.add"
] | 929,238 | 929,239 | u593555034 | cpp |
p03127 | #include <iostream>
#include <vector>
using namespace std;
// 2変数の最大公約数を求める関数
int gcd_func(int a, int b) {
// 2変数の剰余が0になったら、『割られる数』=『最大公約数』
if (b == 0) {
return a;
}
return gcd_func(b, a % b);
}
int main() {
// Nは10の5乗なので、int型
int N;
cin >> N;
// Aは10の9乗なので、long型
vector<long> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
long answer = A[0];
// モンスターの体力の低い方から高い方に攻撃し続けると
// 最終的な体力の結果は元の体力における最大公約数と同じになるため、
// 全ての体力における最大公約数を求めてみる
for (int i = 1; i < N - 1; i++) {
answer = gcd_func(A[i + 1], answer);
}
cout << answer << endl;
return 0;
} | #include <iostream>
#include <vector>
using namespace std;
// 2変数の最大公約数を求める関数
int gcd_func(int a, int b) {
// 2変数の剰余が0になったら、『割られる数』=『最大公約数』
if (b == 0) {
return a;
}
return gcd_func(b, a % b);
}
int main() {
// Nは10の5乗なので、int型
int N;
cin >> N;
// Aは10の9乗なので、long型
vector<long> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
long answer = A[0];
// モンスターの体力の低い方から高い方に攻撃し続けると
// 最終的な体力の結果は元の体力における最大公約数と同じになるため、
// 全ての体力における最大公約数を求めてみる
for (int i = 0; i < N; i++) {
answer = gcd_func(A[i], answer);
}
cout << answer << endl;
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 929,284 | 929,285 | u865500049 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
while (b != 0) {
a %= b;
swap(a, b);
}
return a;
}
int main() {
ll N;
cin >> N;
vector<ll> A(N);
for (ll i = 0; i < N; i++) {
cin >> A[i];
}
ll B = 0;
for (ll i = 1; i < N; i++) {
B = gcd(A[i - 1], B);
}
cout << B << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
while (b != 0) {
a %= b;
swap(a, b);
}
return a;
}
int main() {
ll N;
cin >> N;
vector<ll> A(N);
for (ll i = 0; i < N; i++) {
cin >> A[i];
}
ll B = 0;
for (ll i = 0; i < N; i++) {
B = gcd(A[i], B);
}
cout << B << endl;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operation.binary.remove"
] | 929,311 | 929,312 | u584139221 | cpp |
p03127 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
int main() {
ios::sync_with_stdio(false);
int n, a[100005] = {};
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i], a[i] = __gcd(a[i], a[1]);
cout << a[1];
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
int main() {
ios::sync_with_stdio(false);
int n, a[100005] = {};
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i], a[1] = __gcd(a[i], a[1]);
cout << a[1];
}
| [
"assignment.variable.change",
"identifier.replace.remove",
"literal.replace.add",
"variable_access.subscript.index.change"
] | 929,325 | 929,326 | u151855078 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
int GCD(int x, int y) { return x ? GCD(y % x, x) : y; }
int main() {
int n;
cin >> n;
vector<int> k;
for (int i = 0; i < n; i++)
cin >> k.at(i);
int s = k[0];
for (int i = 0; i < n; i++)
s = GCD(s, k.at(i));
cout << s << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int GCD(int x, int y) { return x ? GCD(y % x, x) : y; }
int main() {
int n;
cin >> n;
vector<int> k(n);
for (int i = 0; i < n; i++)
cin >> k.at(i);
int s = k[0];
for (int i = 0; i < n; i++)
s = GCD(s, k.at(i));
cout << s << endl;
}
| [] | 929,339 | 929,340 | u813174766 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rreps(i, e, n) for (int i = (n)-1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
sort(all(a));
int ans = a[0];
reps(i, 1, n - 1) { ans = gcd(ans, a[i]); }
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rreps(i, e, n) for (int i = (n)-1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
sort(all(a));
int ans = a[0];
reps(i, 1, n) { ans = gcd(ans, a[i]); }
cout << ans << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 929,365 | 929,366 | u225581241 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
int my(int x, int y) {
if (x < y)
swap(x, y);
while (y > 0) {
int z = y;
y = x % z;
x = z;
}
return x;
}
int main() {
int n;
cin >> n;
vector<int> mon(n);
for (int i = 0; i < n; i++)
cin >> mon.at(i);
int x = mon.at(0);
for (int i = 1; i < n; i++)
x = my(x, mon.at(1));
cout << x << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int my(int x, int y) {
if (x < y)
swap(x, y);
while (y > 0) {
int z = y;
y = x % z;
x = z;
}
return x;
}
int main() {
int n;
cin >> n;
vector<int> mon(n);
for (int i = 0; i < n; i++)
cin >> mon.at(i);
int x = mon.at(0);
for (int i = 1; i < n; i++)
x = my(mon.at(i), x);
cout << x << endl;
}
| [
"call.arguments.change",
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.add"
] | 929,483 | 929,484 | u057079894 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
int my(int x, int y) {
if (x < y)
swap(x, y);
while (y > 0) {
int z = y;
y = x % z;
x = z;
}
return x;
}
int main() {
int n;
cin >> n;
vector<int> mon(n);
for (int i = 0; i < n; i++)
cin >> mon.at(i);
int x = mon.at(0);
for (int i = 1; i < n; i++)
x = my(x, mon.at(1));
cout << x << endl;
} | #include <bits/stdc++.h>
using namespace std;
int my(int x, int y) {
if (x < y)
swap(x, y);
while (y > 0) {
int z = y;
y = x % z;
x = z;
}
return x;
}
int main() {
int n;
cin >> n;
vector<int> mon(n);
for (int i = 0; i < n; i++)
cin >> mon.at(i);
int x = mon.at(0);
for (int i = 1; i < n; i++)
x = my(mon.at(i), x);
cout << x << endl;
}
| [
"call.arguments.change",
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.add"
] | 929,485 | 929,484 | u057079894 | cpp |
p03108 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF = 100100100;
using namespace std;
class UnionFind {
public:
// 親の番号を格納する。大家だった場合は-1
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)]; //親をとっていきたい
}
// AとBをくっつける
bool connect(int A, int B) {
A = root(A);
B = root(B);
//すでにくっついているからくっつけない
if (A == B)
return false;
// 大きい方(A)に小さい方(B)をくっつけたい
//大小が逆のばあいひっくり返す
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
REP(i, M) {
cin >> A[i] >> B[i];
// 1番目の島を0番目にしたい
A[i]--;
B[i]--;
}
vector<ll> ans(M);
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind uni(N);
for (int i = M - 1; 1 <= i; i--) {
ans[i - 1] = ans[i];
//繋がっていないのが繋がったとき
if (uni.root(A[i]) != uni.root(B[i])) {
ans[i - 1] -= (ll)uni.size(A[i]) * uni.size(B[i]);
uni.connect(A[i], B[i]);
}
}
REP(i, N) cout << ans[i] << endl;
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF = 100100100;
using namespace std;
class UnionFind {
public:
// 親の番号を格納する。大家だった場合は-1
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)]; //親をとっていきたい
}
// AとBをくっつける
bool connect(int A, int B) {
A = root(A);
B = root(B);
//すでにくっついているからくっつけない
if (A == B)
return false;
// 大きい方(A)に小さい方(B)をくっつけたい
//大小が逆のばあいひっくり返す
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
REP(i, M) {
cin >> A[i] >> B[i];
// 1番目の島を0番目にしたい
A[i]--;
B[i]--;
}
vector<ll> ans(M);
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind uni(N);
for (int i = M - 1; 1 <= i; i--) {
ans[i - 1] = ans[i];
//繋がっていないのが繋がったとき
if (uni.root(A[i]) != uni.root(B[i])) {
ans[i - 1] -= (ll)uni.size(A[i]) * uni.size(B[i]);
uni.connect(A[i], B[i]);
}
}
REP(i, M) cout << ans[i] << "\n";
return 0;
} | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 929,562 | 929,563 | u324303263 | cpp |
p03108 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF = 100100100;
using namespace std;
class UnionFind {
public:
// 親の番号を格納する。大家だった場合は-1
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)]; //親をとっていきたい
}
// AとBをくっつける
bool connect(int A, int B) {
A = root(A);
B = root(B);
//すでにくっついているからくっつけない
if (A == B)
return false;
// 大きい方(A)に小さい方(B)をくっつけたい
//大小が逆のばあいひっくり返す
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
REP(i, M) {
cin >> A[i] >> B[i];
// 1番目の島を0番目にしたい
A[i]--;
B[i]--;
}
vector<ll> ans(M);
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind uni(N);
for (int i = M - 1; 1 <= i; i--) {
ans[i - 1] = ans[i];
//繋がっていないのが繋がったとき
if (uni.root(A[i]) != uni.root(B[i])) {
ans[i - 1] -= (ll)uni.size(A[i]) * uni.size(B[i]);
uni.connect(A[i], B[i]);
}
}
REP(i, N) cout << ans[i] << endl;
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF = 100100100;
using namespace std;
class UnionFind {
public:
// 親の番号を格納する。大家だった場合は-1
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)]; //親をとっていきたい
}
// AとBをくっつける
bool connect(int A, int B) {
A = root(A);
B = root(B);
//すでにくっついているからくっつけない
if (A == B)
return false;
// 大きい方(A)に小さい方(B)をくっつけたい
//大小が逆のばあいひっくり返す
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
REP(i, M) {
cin >> A[i] >> B[i];
// 1番目の島を0番目にしたい
A[i]--;
B[i]--;
}
vector<ll> ans(M);
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind uni(N);
for (int i = M - 1; 1 <= i; i--) {
ans[i - 1] = ans[i];
//繋がっていないのが繋がったとき
if (uni.root(A[i]) != uni.root(B[i])) {
ans[i - 1] -= (ll)uni.size(A[i]) * uni.size(B[i]);
uni.connect(A[i], B[i]);
}
}
REP(i, M) cout << ans[i] << endl;
return 0;
} | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 929,562 | 929,564 | u324303263 | cpp |
p03108 | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 100001;
vector<pair<int, int>> edge;
int N, M;
int par[MAX_N]; //親
ll sizes[MAX_N]; //木の深さ
void init(int n) {
for (int i = 0; i < n; i++) {
par[i] = i;
sizes[i] = 1;
}
}
//木の根を求める
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
//併合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (par[x] > par[y])
swap(x, y); // merge technique
par[y] = x;
sizes[x] += sizes[y];
}
bool same(int x, int y) { return find(x) == find(y); }
void solve() {
init(N);
ll ans[MAX_N];
ans[M - 1] = (ll)(N * (N - 1) / 2);
for (int i = M - 1; i > 0; i--) {
int a = edge[i].first;
int b = edge[i].second;
if (!same(a, b)) {
ans[i - 1] = ans[i] - (ll)(sizes[find(a)] * sizes[find(b)]);
unite(a, b);
} else
ans[i - 1] = ans[i];
}
for (int i = 0; i < M; i++)
cout << ans[i] << '\n';
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
a = a - 1;
b = b - 1;
edge.push_back(make_pair(a, b));
}
solve();
return 0;
}
| #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 100001;
vector<pair<int, int>> edge;
ll N, M;
int par[MAX_N]; //親
ll sizes[MAX_N]; //木の深さ
void init(int n) {
for (int i = 0; i < n; i++) {
par[i] = i;
sizes[i] = 1;
}
}
//木の根を求める
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
//併合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (par[x] > par[y])
swap(x, y); // merge technique
par[y] = x;
sizes[x] += sizes[y];
}
bool same(int x, int y) { return find(x) == find(y); }
void solve() {
init(N);
ll ans[MAX_N];
ans[M - 1] = (ll)(N * (N - 1) / 2);
for (int i = M - 1; i > 0; i--) {
int a = edge[i].first;
int b = edge[i].second;
if (!same(a, b)) {
ans[i - 1] = ans[i] - (ll)(sizes[find(a)] * sizes[find(b)]);
unite(a, b);
} else
ans[i - 1] = ans[i];
}
for (int i = 0; i < M; i++)
cout << ans[i] << '\n';
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
a = a - 1;
b = b - 1;
edge.push_back(make_pair(a, b));
}
solve();
return 0;
}
| [
"variable_declaration.type.change"
] | 929,598 | 929,599 | u640323045 | cpp |
p03108 | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 100001;
vector<pair<int, int>> edge;
int N, M;
int par[MAX_N]; //親
ll sizes[MAX_N]; //木の深さ
void init(int n) {
for (int i = 0; i < n; i++) {
par[i] = i;
sizes[i] = 1;
}
}
//木の根を求める
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
//併合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (par[x] > par[y])
swap(x, y); // merge technique
par[y] = x;
sizes[x] += sizes[y];
}
bool same(int x, int y) { return find(x) == find(y); }
void solve() {
init(N);
ll ans[MAX_N];
ans[M - 1] = N * (N - 1) / 2;
for (int i = M - 1; i > 0; i--) {
int a = edge[i].first;
int b = edge[i].second;
if (!same(a, b)) {
ans[i - 1] = ans[i] - (ll)(sizes[find(a)] * sizes[find(b)]);
unite(a, b);
} else
ans[i - 1] = ans[i];
}
for (int i = 0; i < M; i++)
cout << ans[i] << '\n';
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
a = a - 1;
b = b - 1;
edge.push_back(make_pair(a, b));
}
solve();
return 0;
}
| #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 100001;
vector<pair<int, int>> edge;
ll N, M;
int par[MAX_N]; //親
ll sizes[MAX_N]; //木の深さ
void init(int n) {
for (int i = 0; i < n; i++) {
par[i] = i;
sizes[i] = 1;
}
}
//木の根を求める
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
//併合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (par[x] > par[y])
swap(x, y); // merge technique
par[y] = x;
sizes[x] += sizes[y];
}
bool same(int x, int y) { return find(x) == find(y); }
void solve() {
init(N);
ll ans[MAX_N];
ans[M - 1] = (ll)(N * (N - 1) / 2);
for (int i = M - 1; i > 0; i--) {
int a = edge[i].first;
int b = edge[i].second;
if (!same(a, b)) {
ans[i - 1] = ans[i] - (ll)(sizes[find(a)] * sizes[find(b)]);
unite(a, b);
} else
ans[i - 1] = ans[i];
}
for (int i = 0; i < M; i++)
cout << ans[i] << '\n';
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
a = a - 1;
b = b - 1;
edge.push_back(make_pair(a, b));
}
solve();
return 0;
}
| [
"variable_declaration.type.change",
"call.add",
"call.arguments.change"
] | 929,600 | 929,599 | u640323045 | cpp |
p03108 | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 100001;
vector<pair<int, int>> edge;
int N, M;
int par[MAX_N]; //親
ll sizes[MAX_N]; //木の深さ
void init(int n) {
for (int i = 0; i < n; i++) {
par[i] = i;
sizes[i] = 1;
}
}
//木の根を求める
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
//併合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (par[x] > par[y])
swap(x, y); // merge technique
par[y] = x;
sizes[x] += sizes[y];
}
bool same(int x, int y) { return find(x) == find(y); }
void solve() {
init(N);
ll ans[MAX_N];
ans[M - 1] = (ll)(N * (N - 1) / 2);
for (int i = M - 1; i > 0; i--) {
int a = edge[i].first;
int b = edge[i].second;
if (!same(a, b)) {
ans[i - 1] = ans[i] - (ll)(sizes[find(a)] * sizes[find(b)]);
unite(a, b);
} else
ans[i - 1] = ans[i];
}
for (int i = 0; i < M; i++)
cout << ans[i] << '\n';
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
a = a - 1;
b = b - 1;
edge.push_back(make_pair(a, b));
}
solve();
return 0;
}
| #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 100001;
vector<pair<int, int>> edge;
ll N, M;
int par[MAX_N]; //親
ll sizes[MAX_N]; //木の深さ
void init(int n) {
for (int i = 0; i < n; i++) {
par[i] = i;
sizes[i] = 1;
}
}
//木の根を求める
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
//併合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (sizes[x] > sizes[y])
swap(x, y); // merge technique
par[y] = x;
sizes[x] += sizes[y];
}
bool same(int x, int y) { return find(x) == find(y); }
void solve() {
init(N);
ll ans[MAX_N];
ans[M - 1] = (ll)(N * (N - 1) / 2);
for (int i = M - 1; i > 0; i--) {
int a = edge[i].first;
int b = edge[i].second;
if (!same(a, b)) {
ans[i - 1] = ans[i] - (ll)(sizes[find(a)] * sizes[find(b)]);
unite(a, b);
} else
ans[i - 1] = ans[i];
}
for (int i = 0; i < M; i++)
cout << ans[i] << '\n';
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
a = a - 1;
b = b - 1;
edge.push_back(make_pair(a, b));
}
solve();
return 0;
}
| [
"variable_declaration.type.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 929,598 | 929,601 | u640323045 | cpp |
p03108 | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 100001;
vector<pair<int, int>> edge;
int N, M;
int par[MAX_N]; //親
ll sizes[MAX_N]; //木の深さ
void init(int n) {
for (int i = 0; i < n; i++) {
par[i] = i;
sizes[i] = 1;
}
}
//木の根を求める
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
//併合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (sizes[x] > sizes[y])
swap(x, y); // merge technique
par[y] = x;
sizes[x] += sizes[y];
}
bool same(int x, int y) { return find(x) == find(y); }
void solve() {
init(N);
ll ans[MAX_N];
ans[M - 1] = N * (N - 1) / 2;
for (int i = M - 1; i > 0; i--) {
int a = edge[i].first;
int b = edge[i].second;
if (!same(a, b)) {
ans[i - 1] = ans[i] - (ll)(sizes[find(a)] * sizes[find(b)]);
unite(a, b);
} else
ans[i - 1] = ans[i];
}
for (int i = 0; i < M; i++)
cout << ans[i] << '\n';
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
a = a - 1;
b = b - 1;
edge.push_back(make_pair(a, b));
}
solve();
return 0;
}
| #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 100001;
vector<pair<int, int>> edge;
ll N, M;
int par[MAX_N]; //親
ll sizes[MAX_N]; //木の深さ
void init(int n) {
for (int i = 0; i < n; i++) {
par[i] = i;
sizes[i] = 1;
}
}
//木の根を求める
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
//併合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (sizes[x] > sizes[y])
swap(x, y); // merge technique
par[y] = x;
sizes[x] += sizes[y];
}
bool same(int x, int y) { return find(x) == find(y); }
void solve() {
init(N);
ll ans[MAX_N];
ans[M - 1] = (ll)(N * (N - 1) / 2);
for (int i = M - 1; i > 0; i--) {
int a = edge[i].first;
int b = edge[i].second;
if (!same(a, b)) {
ans[i - 1] = ans[i] - (ll)(sizes[find(a)] * sizes[find(b)]);
unite(a, b);
} else
ans[i - 1] = ans[i];
}
for (int i = 0; i < M; i++)
cout << ans[i] << '\n';
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
a = a - 1;
b = b - 1;
edge.push_back(make_pair(a, b));
}
solve();
return 0;
}
| [
"variable_declaration.type.change",
"call.add",
"call.arguments.change"
] | 929,602 | 929,601 | u640323045 | cpp |
p03108 | // include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
class UnionFind {
public:
vector<int> Parent; //親の番号を格納する。親だった場合は-1
// 作るときはParrentの値を-(その集合のサイズ)にする
// こうするとすべてばらばらになる
// 引数に初期化するノードの個数を指定する
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]);
}
// 自分のいるグループの頂点数を調べる
// rootの値はもともとマイナスにしているのでサイズとして返すときは
// さらに符号を付けることで正の値にしていることに注意
int size(int A) { return -Parent[root(A)]; }
int connect(int A, int B) {
// AとBを直接くっつけるのではなく、root(A) にroot(B)をくっつける
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() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
vector<LL> ans(M);
ans[M - 1] = (LL)N * (N - 1) / 2;
UnionFind uni(N);
for (int i = M - 1; i >= 1; i--) {
ans[i - 1] = ans[i];
if (uni.root(A[i]) != uni.root(B[i])) {
ans[i - 1] -= (LL)uni.size(A[i]) * uni.size(B[i]);
uni.connect(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
} | // include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
class UnionFind {
public:
vector<int> Parent; //親の番号を格納する。親だった場合は-1
// 作るときはParrentの値を-(その集合のサイズ)にする
// こうするとすべてばらばらになる
// 引数に初期化するノードの個数を指定する
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]);
}
// 自分のいるグループの頂点数を調べる
// rootの値はもともとマイナスにしているのでサイズとして返すときは
// さらに符号を付けることで正の値にしていることに注意
int size(int A) { return -Parent[root(A)]; }
int connect(int A, int B) {
// AとBを直接くっつけるのではなく、root(A) にroot(B)をくっつける
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() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
vector<LL> ans(M);
ans[M - 1] = (LL)N * (N - 1) / 2;
UnionFind uni(N);
for (int i = M - 1; i >= 1; i--) {
ans[i - 1] = ans[i];
if (uni.root(A[i]) != uni.root(B[i])) {
ans[i - 1] -= (LL)uni.size(A[i]) * uni.size(B[i]);
uni.connect(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
} | [
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo"
] | 929,640 | 929,641 | u468878441 | cpp |
p03108 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(), (c).end())
#define SZ(x) ((int)(x).size())
using namespace std;
class UnionFind {
public:
vector<int> Parent;
//コンストラクタ
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)]; }
//二つの木が同じ場合はtrueを返す
bool sameTree(int a, int b) {
int ra = root(a);
int rb = root(b);
return ra == rb;
}
//異なる二つの木を結合する
void unite(int a, int b) {
int ra = root(a);
int rb = root(b);
if (ra == rb)
return;
if (size(ra) < size(rb))
swap(ra, rb);
Parent[ra] += Parent[rb];
Parent[rb] = a;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
//配列を用意しているのは0-Nまでだからそこの位置に合わせている
A[i]--;
B[i]--;
}
vector<long long> ans(M);
//引き始めの初期値はNC2を採用(Nこの中から2個を選択する繋げからからそのパターン通り存在)
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i > 0; --i) {
ans[i - 1] = ans[i];
if (!Uni.sameTree(A[i], B[i])) {
ans[i - 1] -= (ll)Uni.size(A[i]) * Uni.size(B[i]);
Uni.unite(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(), (c).end())
#define SZ(x) ((int)(x).size())
using namespace std;
class UnionFind {
public:
vector<int> Parent;
//コンストラクタ
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)]; }
//二つの木が同じ場合はtrueを返す
bool sameTree(int a, int b) {
int ra = root(a);
int rb = root(b);
return ra == rb;
}
//異なる二つの木を結合する
void unite(int a, int b) {
int ra = root(a);
int rb = root(b);
if (ra == rb)
return;
if (size(ra) < size(rb))
swap(ra, rb);
Parent[ra] += Parent[rb];
Parent[rb] = ra;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
//配列を用意しているのは0-Nまでだからそこの位置に合わせている
A[i]--;
B[i]--;
}
vector<long long> ans(M);
//引き始めの初期値はNC2を採用(Nこの中から2個を選択する繋げからからそのパターン通り存在)
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i > 0; --i) {
ans[i - 1] = ans[i];
if (!Uni.sameTree(A[i], B[i])) {
ans[i - 1] -= (ll)Uni.size(A[i]) * Uni.size(B[i]);
Uni.unite(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
return 0;
}
| [
"assignment.value.change",
"identifier.change"
] | 929,646 | 929,647 | u921177152 | cpp |
p03108 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(), (c).end())
#define SZ(x) ((int)(x).size())
using namespace std;
class UnionFind {
public:
vector<int> Parent;
//コンストラクタ
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)]; }
//二つの木が同じ場合はtrueを返す
bool sameTree(int a, int b) {
int ra = root(a);
int rb = root(b);
return ra == rb;
}
//異なる二つの木を結合する
void unite(int a, int b) {
int ra = root(a);
int rb = root(b);
if (ra == rb)
return;
if (size(a) < size(b))
swap(ra, rb);
Parent[ra] += Parent[rb];
Parent[rb] = a;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
//配列を用意しているのは0-Nまでだからそこの位置に合わせている
A[i]--;
B[i]--;
}
vector<long long> ans(M);
//引き始めの初期値はNC2を採用(Nこの中から2個を選択する繋げからからそのパターン通り存在)
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i > 0; --i) {
ans[i - 1] = ans[i];
if (!Uni.sameTree(A[i], B[i])) {
ans[i - 1] -= (ll)Uni.size(A[i]) * Uni.size(B[i]);
Uni.unite(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(), (c).end())
#define SZ(x) ((int)(x).size())
using namespace std;
class UnionFind {
public:
vector<int> Parent;
//コンストラクタ
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)]; }
//二つの木が同じ場合はtrueを返す
bool sameTree(int a, int b) {
int ra = root(a);
int rb = root(b);
return ra == rb;
}
//異なる二つの木を結合する
void unite(int a, int b) {
int ra = root(a);
int rb = root(b);
if (ra == rb)
return;
if (size(ra) < size(rb))
swap(ra, rb);
Parent[ra] += Parent[rb];
Parent[rb] = ra;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
//配列を用意しているのは0-Nまでだからそこの位置に合わせている
A[i]--;
B[i]--;
}
vector<long long> ans(M);
//引き始めの初期値はNC2を採用(Nこの中から2個を選択する繋げからからそのパターン通り存在)
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i > 0; --i) {
ans[i - 1] = ans[i];
if (!Uni.sameTree(A[i], B[i])) {
ans[i - 1] -= (ll)Uni.size(A[i]) * Uni.size(B[i]);
Uni.unite(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
return 0;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change",
"assignment.value.change"
] | 929,648 | 929,647 | u921177152 | cpp |
p03108 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
class UnionFind {
public:
//親の番号、親だった場合は-(size)
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)]; }
// AとBをつなぐ
bool connect(int A, int B) {
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--, B[i]--;
}
vector<ll> ans(M);
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M; i >= 1; i--) {
ans[i - 1] = ans[i];
if (Uni.root(A[i]) != Uni.root(B[i])) {
ans[i - 1] -= (ll)Uni.size(A[i]) * Uni.size(B[i]);
Uni.connect(A[i], B[i]);
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
}
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
class UnionFind {
public:
//親の番号、親だった場合は-(size)
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)]; }
// AとBをつなぐ
bool connect(int A, int B) {
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--, B[i]--;
}
vector<ll> ans(M);
ans[M - 1] = (ll)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i >= 1; i--) {
ans[i - 1] = ans[i];
if (Uni.root(A[i]) != Uni.root(B[i])) {
ans[i - 1] -= (ll)Uni.size(A[i]) * Uni.size(B[i]);
Uni.connect(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
return 0;
}
| [
"control_flow.loop.for.initializer.change"
] | 929,665 | 929,666 | u806800460 | cpp |
p03108 | #include <bits/stdc++.h>
using namespace std;
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]); // Aの親を入れ替える
}
// 自分のいるグループの頂点数を調べる
int size(int A) {
return -Parent[root(A)]; //親をとってきたい
}
// 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)をくっつけたい
//大小が逆だったらヒックり返す
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;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--; // 0オリジンに
}
vector<long long> ans(M);
ans[M - 1] = (long long)N * (N - 1) / 2;
UnionFind Uni(M);
for (int i = M - 1; i >= 0; i--) {
ans[i - 1] = ans[i];
// 繋がってなかったのが繋がったとき
if (Uni.root(A[i]) != Uni.root(B[i])) {
ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
Uni.connect(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
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]); // Aの親を入れ替える
}
// 自分のいるグループの頂点数を調べる
int size(int A) {
return -Parent[root(A)]; //親をとってきたい
}
// 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)をくっつけたい
//大小が逆だったらヒックり返す
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;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--; // 0オリジンに
}
vector<long long> ans(M);
ans[M - 1] = (long long)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i >= 1; i--) {
ans[i - 1] = ans[i];
// 繋がってなかったのが繋がったとき
if (Uni.root(A[i]) != Uni.root(B[i])) {
ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
Uni.connect(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
return 0;
}
| [
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change",
"control_flow.return.add",
"control_flow.return.0.add"
] | 929,691 | 929,689 | u934246119 | cpp |
p03108 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
struct UnionFind {
vector<int> par;
UnionFind(int n) : par(n, -1) {}
void init(int n) { par.assign(n, -1); }
int root(int x) {
if (par[x] < 0)
return x;
return par[x] = root(par[x]);
}
bool issame(int x, int y) { return root(x) == root(y); }
bool merge(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (par[x] > par[y])
swap(x, y);
par[x] += par[y];
par[y] = x; //大きさが正になるよ
return true;
}
int size(int x) { return -par[root(x)]; }
};
int main() {
int N, M;
int A[100010];
int B[100010];
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
UnionFind uf(N);
long long cur = N * (N - 1) / 2;
vector<long long> res;
for (int i = 0; i < M; ++i) {
res.push_back(cur);
int a = A[M - 1 - i], b = B[M - 1 - i];
if (uf.issame(a, b))
continue;
long long sa = uf.size(a), sb = uf.size(b);
cur -= sa * sb;
uf.merge(a, b);
}
reverse(res.begin(), res.end());
for (int i = 0; i < res.size(); ++i)
cout << res[i] << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
struct UnionFind {
vector<int> par;
UnionFind(int n) : par(n, -1) {}
void init(int n) { par.assign(n, -1); }
int root(int x) {
if (par[x] < 0)
return x;
else
return par[x] = root(par[x]);
}
bool issame(int x, int y) { return root(x) == root(y); }
bool merge(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (par[x] > par[y])
swap(x, y); // merge technique
par[x] += par[y];
par[y] = x;
return true;
}
int size(int x) { return -par[root(x)]; }
};
int main() {
ll N, M;
int A[100010];
int B[100010];
cin >> N >> M;
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
UnionFind uf(N);
long long cur = N * (N - 1) / 2;
vector<long long> res;
for (int i = 0; i < M; ++i) {
res.push_back(cur);
int a = A[M - 1 - i], b = B[M - 1 - i];
if (uf.issame(a, b))
continue;
long long sa = uf.size(a), sb = uf.size(b);
cur -= sa * sb;
uf.merge(a, b);
}
reverse(res.begin(), res.end());
for (int i = 0; i < res.size(); ++i)
cout << res[i] << endl;
} | [
"control_flow.branch.else_if.replace.remove",
"control_flow.branch.if.replace.add",
"variable_declaration.type.change",
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 929,720 | 929,717 | u074445770 | cpp |
p03108 | #include <algorithm>
#include <iostream>
#include <vector>
#define pi pair<int, int>
using namespace std;
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)]; }
bool uni(int A, int B) {
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B);
parent[A] += parent[B];
parent[B] = A;
return true;
}
};
int main() {
int n, m;
scanf("%d %d", &n, &m);
vector<pi> vec(m);
for (auto &i : vec) {
scanf("%d %d", &i.first, &i.second);
i.first--;
i.second--;
}
vector<long long> res(m);
res[m - 1] = (long long)n * (n - 1) / 2;
// cout << res[m -1] << endl;
UnionFind Uni(n);
for (int i = m - 1; i > 0; i--) {
res[i - 1] = res[i];
if (Uni.root(vec[i - 1].first) != Uni.root(vec[i - 1].second)) {
res[i - 1] -= (long long)Uni.size(vec[i].first) * Uni.size(vec[i].second);
Uni.uni(vec[i].first, vec[i].second);
}
}
for (auto &i : res)
cout << i << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
#define pi pair<int, int>
using namespace std;
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)]; }
bool uni(int A, int B) {
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B);
parent[A] += parent[B];
parent[B] = A;
return true;
}
};
int main() {
int n, m;
scanf("%d %d", &n, &m);
vector<pi> vec(m);
for (auto &i : vec) {
scanf("%d %d", &i.first, &i.second);
i.first--;
i.second--;
}
vector<long long> res(m);
res[m - 1] = (long long)n * (n - 1) / 2;
// cout << res[m -1] << endl;
UnionFind Uni(n);
for (int i = m - 1; i > 0; i--) {
res[i - 1] = res[i];
if (Uni.root(vec[i].first) != Uni.root(vec[i].second)) {
res[i - 1] -= (long long)Uni.size(vec[i].first) * Uni.size(vec[i].second);
Uni.uni(vec[i].first, vec[i].second);
}
}
for (auto &i : res)
cout << i << endl;
return 0;
} | [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 929,723 | 929,724 | u501724534 | cpp |
p03108 | #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#include <immintrin.h>
#include <iostream>
#include <random>
#include <unordered_map>
#include <unordered_set>
using namespace std;
//呪文
#define DUMPOUT cerr
#define dump(...) \
DUMPOUT << " "; \
DUMPOUT << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" \
<< endl; \
DUMPOUT << " "; \
dump_func(__VA_ARGS__)
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
template <typename _KTy, typename _Ty>
ostream &operator<<(ostream &o, const pair<_KTy, _Ty> &m) {
o << "{" << m.first << ", " << m.second << "}";
return o;
}
template <typename _KTy, typename _Ty>
ostream &operator<<(ostream &o, const map<_KTy, _Ty> &m) {
if (m.empty()) {
o << "{ }";
return o;
}
o << "{" << *m.begin();
for (auto itr = ++m.begin(); itr != m.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _KTy, typename _Ty>
ostream &operator<<(ostream &o, const unordered_map<_KTy, _Ty> &m) {
if (m.empty()) {
o << "{ }";
return o;
}
o << "{" << *m.begin();
for (auto itr = ++m.begin(); itr != m.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _Ty> ostream &operator<<(ostream &o, const vector<_Ty> &v) {
if (v.empty()) {
o << "{ }";
return o;
}
o << "{" << v.front();
for (auto itr = ++v.begin(); itr != v.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _Ty> ostream &operator<<(ostream &o, const set<_Ty> &s) {
if (s.empty()) {
o << "{ }";
return o;
}
o << "{" << *(s.begin());
for (auto itr = ++s.begin(); itr != s.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _Ty>
ostream &operator<<(ostream &o, const unordered_set<_Ty> &s) {
if (s.empty()) {
o << "{ }";
return o;
}
o << "{" << *(s.begin());
for (auto itr = ++s.begin(); itr != s.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _Ty> ostream &operator<<(ostream &o, const stack<_Ty> &s) {
if (s.empty()) {
o << "{ }";
return o;
}
stack<_Ty> t(s);
o << "{" << t.top();
t.pop();
while (!t.empty()) {
o << ", " << t.top();
t.pop();
}
o << "}";
return o;
}
template <typename _Ty> ostream &operator<<(ostream &o, const list<_Ty> &l) {
if (l.empty()) {
o << "{ }";
return o;
}
o << "{" << l.front();
for (auto itr = ++l.begin(); itr != l.end(); ++itr) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _KTy, typename _Ty>
istream &operator>>(istream &is, pair<_KTy, _Ty> &m) {
is >> m.first >> m.second;
return is;
}
template <typename _Ty> istream &operator>>(istream &is, vector<_Ty> &v) {
for (size_t i = 0; i < v.size(); i++)
is >> v[i];
return is;
}
namespace aux { // print tuple
template <typename Ty, unsigned N, unsigned L> struct tp {
static void print(ostream &os, const Ty &v) {
os << get<N>(v) << ", ";
tp<Ty, N + 1, L>::print(os, v);
}
};
template <typename Ty, unsigned N> struct tp<Ty, N, N> {
static void print(ostream &os, const Ty &v) { os << get<N>(v); }
};
} // namespace aux
template <typename... Tys>
ostream &operator<<(ostream &os, const tuple<Tys...> &t) {
os << "{";
aux::tp<tuple<Tys...>, 0, sizeof...(Tys) - 1>::print(os, t);
os << "}";
return os;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
DUMPOUT << head;
if (sizeof...(Tail) == 0) {
DUMPOUT << " ";
} else {
DUMPOUT << ", ";
}
dump_func(std::move(tail)...);
}
#define PI 3.14159265358979323846
#define EPS 1e-10
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(j) (j).begin(), (j).end()
#define SZ(j) ((int)(j).size())
#define fake false
#define int long long
class DisjointSet {
private:
vector<unsigned> par;
vector<unsigned> rank;
vector<unsigned> sz; // 要素の個数
size_t set_sz; // 集合の個数
public:
DisjointSet() : set_sz(0) {}
DisjointSet(size_t n) : par(n), rank(n, 0), sz(n, 1), set_sz(n) {
for (size_t i = 0; i < n; i++)
par[i] = i;
}
size_t set_size() { return set_sz; }
size_t size(size_t v) { return sz[find(v)]; }
void makeset() {
par.push_back(par.size());
rank.push_back(0);
sz.push_back(1);
set_sz++;
}
void makeset(size_t n) {
for (size_t i = 0; i < n; i++)
makeset();
}
size_t find(size_t x) {
if (par[x] == x)
return x;
else
return par[x] = find(par[x]);
}
void unite(size_t x, size_t y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (rank[x] < rank[y])
par[x] = y;
else {
par[y] = x;
if (rank[x] == rank[y])
rank[x]++;
}
sz[x] += sz[y];
sz[y] = sz[x];
set_sz--;
}
bool same(size_t x, size_t y) { return find(x) == find(y); }
friend ostream &operator<<(ostream &ostr, const DisjointSet &ds) {
ostr << endl
<< "parent : " << ds.par << endl
<< "rank : " << ds.rank << endl
<< "size : " << ds.sz << endl
<< "size of set : " << ds.set_sz << endl;
return ostr;
}
};
signed main() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
REP(i, M) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
vector<int> ans;
DisjointSet ds(N);
// unite する前のサイズの積
int inc = N * (N - 1) / 2;
ans.push_back(inc);
for (int i = M - 1; i >= 0; i--) {
if (!ds.same(A[i], B[i])) {
int cnt = ds.size(A[i]) * ds.size(B[i]);
inc -= cnt;
ds.unite(A[i], B[i]);
}
ans.push_back(inc);
}
ans.pop_back();
reverse(all(ans));
for (auto &i : ans)
cerr << i << endl;
return 0;
}
| #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#include <immintrin.h>
#include <iostream>
#include <random>
#include <unordered_map>
#include <unordered_set>
using namespace std;
//呪文
#define DUMPOUT cerr
#define dump(...) \
DUMPOUT << " "; \
DUMPOUT << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" \
<< endl; \
DUMPOUT << " "; \
dump_func(__VA_ARGS__)
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
template <typename _KTy, typename _Ty>
ostream &operator<<(ostream &o, const pair<_KTy, _Ty> &m) {
o << "{" << m.first << ", " << m.second << "}";
return o;
}
template <typename _KTy, typename _Ty>
ostream &operator<<(ostream &o, const map<_KTy, _Ty> &m) {
if (m.empty()) {
o << "{ }";
return o;
}
o << "{" << *m.begin();
for (auto itr = ++m.begin(); itr != m.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _KTy, typename _Ty>
ostream &operator<<(ostream &o, const unordered_map<_KTy, _Ty> &m) {
if (m.empty()) {
o << "{ }";
return o;
}
o << "{" << *m.begin();
for (auto itr = ++m.begin(); itr != m.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _Ty> ostream &operator<<(ostream &o, const vector<_Ty> &v) {
if (v.empty()) {
o << "{ }";
return o;
}
o << "{" << v.front();
for (auto itr = ++v.begin(); itr != v.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _Ty> ostream &operator<<(ostream &o, const set<_Ty> &s) {
if (s.empty()) {
o << "{ }";
return o;
}
o << "{" << *(s.begin());
for (auto itr = ++s.begin(); itr != s.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _Ty>
ostream &operator<<(ostream &o, const unordered_set<_Ty> &s) {
if (s.empty()) {
o << "{ }";
return o;
}
o << "{" << *(s.begin());
for (auto itr = ++s.begin(); itr != s.end(); itr++) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _Ty> ostream &operator<<(ostream &o, const stack<_Ty> &s) {
if (s.empty()) {
o << "{ }";
return o;
}
stack<_Ty> t(s);
o << "{" << t.top();
t.pop();
while (!t.empty()) {
o << ", " << t.top();
t.pop();
}
o << "}";
return o;
}
template <typename _Ty> ostream &operator<<(ostream &o, const list<_Ty> &l) {
if (l.empty()) {
o << "{ }";
return o;
}
o << "{" << l.front();
for (auto itr = ++l.begin(); itr != l.end(); ++itr) {
o << ", " << *itr;
}
o << "}";
return o;
}
template <typename _KTy, typename _Ty>
istream &operator>>(istream &is, pair<_KTy, _Ty> &m) {
is >> m.first >> m.second;
return is;
}
template <typename _Ty> istream &operator>>(istream &is, vector<_Ty> &v) {
for (size_t i = 0; i < v.size(); i++)
is >> v[i];
return is;
}
namespace aux { // print tuple
template <typename Ty, unsigned N, unsigned L> struct tp {
static void print(ostream &os, const Ty &v) {
os << get<N>(v) << ", ";
tp<Ty, N + 1, L>::print(os, v);
}
};
template <typename Ty, unsigned N> struct tp<Ty, N, N> {
static void print(ostream &os, const Ty &v) { os << get<N>(v); }
};
} // namespace aux
template <typename... Tys>
ostream &operator<<(ostream &os, const tuple<Tys...> &t) {
os << "{";
aux::tp<tuple<Tys...>, 0, sizeof...(Tys) - 1>::print(os, t);
os << "}";
return os;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
DUMPOUT << head;
if (sizeof...(Tail) == 0) {
DUMPOUT << " ";
} else {
DUMPOUT << ", ";
}
dump_func(std::move(tail)...);
}
#define PI 3.14159265358979323846
#define EPS 1e-10
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(j) (j).begin(), (j).end()
#define SZ(j) ((int)(j).size())
#define fake false
#define int long long
class DisjointSet {
private:
vector<unsigned> par;
vector<unsigned> rank;
vector<unsigned> sz; // 要素の個数
size_t set_sz; // 集合の個数
public:
DisjointSet() : set_sz(0) {}
DisjointSet(size_t n) : par(n), rank(n, 0), sz(n, 1), set_sz(n) {
for (size_t i = 0; i < n; i++)
par[i] = i;
}
size_t set_size() { return set_sz; }
size_t size(size_t v) { return sz[find(v)]; }
void makeset() {
par.push_back(par.size());
rank.push_back(0);
sz.push_back(1);
set_sz++;
}
void makeset(size_t n) {
for (size_t i = 0; i < n; i++)
makeset();
}
size_t find(size_t x) {
if (par[x] == x)
return x;
else
return par[x] = find(par[x]);
}
void unite(size_t x, size_t y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (rank[x] < rank[y])
par[x] = y;
else {
par[y] = x;
if (rank[x] == rank[y])
rank[x]++;
}
sz[x] += sz[y];
sz[y] = sz[x];
set_sz--;
}
bool same(size_t x, size_t y) { return find(x) == find(y); }
friend ostream &operator<<(ostream &ostr, const DisjointSet &ds) {
ostr << endl
<< "parent : " << ds.par << endl
<< "rank : " << ds.rank << endl
<< "size : " << ds.sz << endl
<< "size of set : " << ds.set_sz << endl;
return ostr;
}
};
signed main() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
REP(i, M) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
vector<int> ans;
DisjointSet ds(N);
// unite する前のサイズの積
int inc = N * (N - 1) / 2;
ans.push_back(inc);
for (int i = M - 1; i >= 0; i--) {
if (!ds.same(A[i], B[i])) {
int cnt = ds.size(A[i]) * ds.size(B[i]);
inc -= cnt;
ds.unite(A[i], B[i]);
}
ans.push_back(inc);
}
ans.pop_back();
reverse(all(ans));
for (auto &i : ans)
cout << i << endl;
return 0;
}
| [
"identifier.change",
"io.output.change"
] | 929,750 | 929,751 | u034865202 | cpp |
p03108 | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
template <typename T> void vprint(T &v) {
REP(i, v.size()) { cout << v[i] << " "; }
cout << endl;
}
const int MAX_N = 1e7;
struct UnionFind {
int N;
int par[MAX_N];
UnionFind(int N) : N(N) {
for (int i = 0; i < N; i++) {
par[i] = i;
}
}
int root(int x) {
if (par[x] == x)
return x;
int rx = root(par[x]);
par[x] = rx;
return rx;
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if (rx == ry)
return;
par[rx] = ry;
}
bool find(int x, int y) { return root(x) == root(y); }
};
int main() {
ll N, M;
cin >> N >> M;
ll tmp = N * (N - 1) / 2;
vector<ll> res;
res.push_back(tmp);
UnionFind uf(N);
vector<ll> X(M), Y(M);
REP(i, M) { cin >> X[i] >> Y[i], X[i]--, Y[i]--; }
vector<ll> sz(N, 1);
REP(i, M) {
ll A = X[M - 1 - i];
ll B = Y[M - 1 - i];
if (uf.find(A, B))
continue;
ll sa = sz[uf.root(A)];
ll sb = sz[uf.root(B)];
tmp -= sa * sb;
uf.unite(A, B);
sz[uf.root(A)] = sa + sb;
res.push_back(tmp);
}
REP(i, M) { cout << res[M - 1 - i] << endl; }
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
template <typename T> void vprint(T &v) {
REP(i, v.size()) { cout << v[i] << " "; }
cout << endl;
}
const int MAX_N = 1e6;
struct UnionFind {
int N;
int par[MAX_N];
UnionFind(int N) : N(N) {
for (int i = 0; i < N; i++) {
par[i] = i;
}
}
int root(int x) {
if (par[x] == x)
return x;
int rx = root(par[x]);
par[x] = rx;
return rx;
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if (rx == ry)
return;
par[rx] = ry;
}
bool find(int x, int y) { return root(x) == root(y); }
};
int main() {
ll N, M;
cin >> N >> M;
ll tmp = N * (N - 1) / 2;
vector<ll> res;
res.push_back(tmp);
UnionFind uf(N);
vector<ll> X(M), Y(M);
REP(i, M) { cin >> X[i] >> Y[i], X[i]--, Y[i]--; }
vector<ll> sz(N, 1);
REP(i, M) {
ll A = X[M - 1 - i];
ll B = Y[M - 1 - i];
if (!uf.find(A, B)) {
ll sa = sz[uf.root(A)];
ll sb = sz[uf.root(B)];
tmp -= sa * sb;
uf.unite(A, B);
sz[uf.root(A)] = sa + sb;
}
res.push_back(tmp);
}
REP(i, M) { cout << res[M - 1 - i] << endl; }
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"expression.operation.unary.add",
"control_flow.branch.if.condition.change"
] | 929,768 | 929,769 | u895971408 | cpp |
p03108 | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
template <typename T> void vprint(T &v) {
REP(i, v.size()) { cout << v[i] << " "; }
cout << endl;
}
const int MAX_N = 1e6;
struct UnionFind {
int N;
int par[MAX_N];
UnionFind(int N) : N(N) {
for (int i = 0; i < N; i++) {
par[i] = i;
}
}
int root(int x) {
if (par[x] == x)
return x;
int rx = root(par[x]);
par[x] = rx;
return rx;
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if (rx == ry)
return;
par[rx] = ry;
}
bool find(int x, int y) { return root(x) == root(y); }
};
int main() {
ll N, M;
cin >> N >> M;
ll tmp = N * (N - 1) / 2;
vector<ll> res;
res.push_back(tmp);
UnionFind uf(N);
vector<ll> X(M), Y(M);
REP(i, M) { cin >> X[i] >> Y[i], X[i]--, Y[i]--; }
vector<ll> sz(N, 1);
REP(i, M) {
ll A = X[M - 1 - i];
ll B = Y[M - 1 - i];
if (uf.find(A, B))
continue;
ll sa = sz[uf.root(A)];
ll sb = sz[uf.root(B)];
tmp -= sa * sb;
uf.unite(A, B);
sz[uf.root(A)] = sa + sb;
res.push_back(tmp);
}
REP(i, M) { cout << res[M - 1 - i] << endl; }
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
template <typename T> void vprint(T &v) {
REP(i, v.size()) { cout << v[i] << " "; }
cout << endl;
}
const int MAX_N = 1e6;
struct UnionFind {
int N;
int par[MAX_N];
UnionFind(int N) : N(N) {
for (int i = 0; i < N; i++) {
par[i] = i;
}
}
int root(int x) {
if (par[x] == x)
return x;
int rx = root(par[x]);
par[x] = rx;
return rx;
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if (rx == ry)
return;
par[rx] = ry;
}
bool find(int x, int y) { return root(x) == root(y); }
};
int main() {
ll N, M;
cin >> N >> M;
ll tmp = N * (N - 1) / 2;
vector<ll> res;
res.push_back(tmp);
UnionFind uf(N);
vector<ll> X(M), Y(M);
REP(i, M) { cin >> X[i] >> Y[i], X[i]--, Y[i]--; }
vector<ll> sz(N, 1);
REP(i, M) {
ll A = X[M - 1 - i];
ll B = Y[M - 1 - i];
if (!uf.find(A, B)) {
ll sa = sz[uf.root(A)];
ll sb = sz[uf.root(B)];
tmp -= sa * sb;
uf.unite(A, B);
sz[uf.root(A)] = sa + sb;
}
res.push_back(tmp);
}
REP(i, M) { cout << res[M - 1 - i] << endl; }
return 0;
} | [
"expression.operation.unary.add",
"control_flow.branch.if.condition.change"
] | 929,770 | 929,769 | u895971408 | cpp |
p03108 | // ABC 055 D
#include <bits/stdc++.h>
using namespace std;
// container util
//------------------------------------------
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).begin(), (c).end(), greater<int>())
#define PB(a) push_back(a)
#define ALL(x) (x).begin(), (x).end()
#define MAX_EL(c) *max_element((c).begin(), (c).end())
#define MIN_EL(c) *min_element((c).begin(), (c).end())
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
//------------------------------------------
struct UnionFind {
vector<int> par;
UnionFind(int N) : par(N, -1) {}
int root(int x) {
if (par[x] < 0)
return x;
return par[x] = root(par[x]);
}
bool unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (size(x) < size(y))
swap(x, y);
par[x] += par[y];
par[y] = x;
return true;
}
bool same(int x, int y) { return root(x) == root(y); }
int size(int x) { return -par[root(x)]; }
};
//------------------------------------------
int main() {
// magic spell------------------------------
cin.tie(0);
ios::sync_with_stdio(false);
//------------------------------------------
int n, m;
cin >> n >> m;
LL ans[m];
// VI l(N);
ans[0] = n * (n - 1) / 2;
UnionFind tree(n);
int a[m], b[m];
REP(i, m) {
cin >> a[m - i - 1] >> b[m - i - 1];
a[m - i - 1]--;
b[m - i - 1]--;
}
REP(i, m) {
ans[i + 1] = ans[i];
if (!tree.same(a[i], b[i])) {
}
ans[i + 1] -= (LL)tree.size(a[i]) * tree.size(b[i]);
tree.unite(a[i], b[i]);
}
REP(i, m) cout << ans[m - i - 1] << endl;
return 0;
}
| // ABC 055 D
#include <bits/stdc++.h>
using namespace std;
// container util
//------------------------------------------
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).begin(), (c).end(), greater<int>())
#define PB(a) push_back(a)
#define ALL(x) (x).begin(), (x).end()
#define MAX_EL(c) *max_element((c).begin(), (c).end())
#define MIN_EL(c) *min_element((c).begin(), (c).end())
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
//------------------------------------------
struct UnionFind {
vector<int> par;
UnionFind(int N) : par(N, -1) {}
int root(int x) {
if (par[x] < 0)
return x;
return par[x] = root(par[x]);
}
bool unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (size(x) < size(y))
swap(x, y);
par[x] += par[y];
par[y] = x;
return true;
}
bool same(int x, int y) { return root(x) == root(y); }
int size(int x) { return -par[root(x)]; }
};
//------------------------------------------
int main() {
// magic spell------------------------------
cin.tie(0);
ios::sync_with_stdio(false);
//------------------------------------------
int n, m;
cin >> n >> m;
LL ans[m];
// VI l(N);
ans[0] = (LL)n * (n - 1) / 2;
UnionFind tree(n);
int a[m], b[m];
REP(i, m) {
cin >> a[m - i - 1] >> b[m - i - 1];
a[m - i - 1]--;
b[m - i - 1]--;
}
REP(i, m) {
ans[i + 1] = ans[i];
if (!tree.same(a[i], b[i])) {
ans[i + 1] -= (LL)tree.size(a[i]) * tree.size(b[i]);
tree.unite(a[i], b[i]);
}
}
REP(i, m) cout << ans[m - i - 1] << endl;
return 0;
}
| [
"type_conversion.add"
] | 929,773 | 929,772 | u513290715 | cpp |
p03108 | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class UnionFind {
public:
/* 親の番号を格納する。親だった場合は-(その集合のサイズ) */
vector<int> Parent;
// 作る時はParentの値を全て-1にする
// こうすると全てバラバラになる
UnionFind(int N) {
Parent = vector<int>(N, -1); // 要素数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)]; //親をとってきたい
}
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)をくっつけたい
//代償が逆だったらひっくり返しちゃう。
if (size(A) < size(B)) {
swap(A, B);
}
// Aのサイズを更新する
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
vector<long long> ans(M);
ans[M - 1] = (long long)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i >= 1; i--) {
ans[i - 1] = A[i];
// 繋がって無かったのが繋がった時
if (Uni.root(A[i]) != Uni.root(B[i])) {
ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
Uni.connect(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
}
| #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class UnionFind {
public:
/* 親の番号を格納する。親だった場合は-(その集合のサイズ) */
vector<int> Parent;
// 作る時はParentの値を全て-1にする
// こうすると全てバラバラになる
UnionFind(int N) {
Parent = vector<int>(N, -1); // 要素数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)]; //親をとってきたい
}
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)をくっつけたい
//代償が逆だったらひっくり返しちゃう。
if (size(A) < size(B)) {
swap(A, B);
}
// Aのサイズを更新する
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
vector<long long> ans(M);
ans[M - 1] = (long long)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i >= 1; i--) {
ans[i - 1] = ans[i];
// 繋がって無かったのが繋がった時
if (Uni.root(A[i]) != Uni.root(B[i])) {
ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
Uni.connect(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
}
| [
"assignment.value.change",
"identifier.change"
] | 929,774 | 929,775 | u813102292 | cpp |
p03108 | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class UnionFind {
public:
/* 親の番号を格納する。親だった場合は-(その集合のサイズ) */
vector<int> Parent;
// 作る時はParentの値を全て-1にする
// こうすると全てバラバラになる
UnionFind(int N) {
Parent = vector<int>(N, -1); // 要素数Nのベクトルの要素を全て-1で初期化
}
int root(int A) {
if (Parent[A] < 0) {
return A;
}
return Parent[A] = root(Parent[A]);
}
int size(int A) {
return -Parent[0]; //親をとってきたい
}
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)をくっつけたい
//代償が逆だったらひっくり返しちゃう。
if (size(A) < size(B)) {
swap(A, B);
}
// Aのサイズを更新する
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
vector<long long> ans(M);
ans[M - 1] = (long long)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i >= 1; i--) {
ans[i - 1] = A[i];
// 繋がって無かったのが繋がった時
if (Uni.root(A[i]) != Uni.root(B[i])) {
ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
Uni.connect(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
}
| #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class UnionFind {
public:
/* 親の番号を格納する。親だった場合は-(その集合のサイズ) */
vector<int> Parent;
// 作る時はParentの値を全て-1にする
// こうすると全てバラバラになる
UnionFind(int N) {
Parent = vector<int>(N, -1); // 要素数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)]; //親をとってきたい
}
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)をくっつけたい
//代償が逆だったらひっくり返しちゃう。
if (size(A) < size(B)) {
swap(A, B);
}
// Aのサイズを更新する
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
int main() {
int N, M;
cin >> N >> M;
vector<int> A(M), B(M);
for (int i = 0; i < M; i++) {
cin >> A[i] >> B[i];
A[i]--;
B[i]--;
}
vector<long long> ans(M);
ans[M - 1] = (long long)N * (N - 1) / 2;
UnionFind Uni(N);
for (int i = M - 1; i >= 1; i--) {
ans[i - 1] = ans[i];
// 繋がって無かったのが繋がった時
if (Uni.root(A[i]) != Uni.root(B[i])) {
ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
Uni.connect(A[i], B[i]);
}
}
for (int i = 0; i < M; i++) {
cout << ans[i] << endl;
}
}
| [
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"function.return_value.change",
"call.arguments.add",
"assignment.value.change",
"identifier.change"
] | 929,776 | 929,775 | u813102292 | cpp |
p03127 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
ll a[100000];
int main() {
int n;
ll ans = 0;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
ans = gcd(a[0], a[1]);
for (int i = 2; i < n; i++)
ans = gcd(a[2], ans);
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
int gcd(int a, int b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
int a[100000];
int main() {
int n;
int ans = 0;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
ans = gcd(a[0], a[1]);
for (int i = 2; i < n; i++)
ans = gcd(a[i], ans);
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change",
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 929,812 | 929,813 | u863507492 | cpp |
p03127 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
int gcd(int a, int b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
int a[100000];
int main() {
int n;
int ans = 0;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
ans = gcd(a[0], a[1]);
for (int i = 2; i < n; i++)
ans = gcd(a[2], ans);
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
int gcd(int a, int b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
int a[100000];
int main() {
int n;
int ans = 0;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
ans = gcd(a[0], a[1]);
for (int i = 2; i < n; i++)
ans = gcd(a[i], ans);
cout << ans << endl;
return 0;
} | [
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 929,814 | 929,813 | u863507492 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
int now = gcd(a[0], a[1]);
for (int i = 1; i < n - 1; i++) {
gcd(now, a[i + 1]);
}
cout << now << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
int now = gcd(a[0], a[1]);
for (int i = 1; i < n - 1; i++) {
now = gcd(now, a[i + 1]);
}
cout << now << endl;
}
| [
"assignment.change"
] | 929,935 | 929,936 | u410878763 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
else {
return gcd(b, a % b);
}
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
int n;
cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll ans = a[0];
for (int i = 1; i < a.size() - 1; i++) {
ans = gcd(a[i], ans);
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
else {
return gcd(b, a % b);
}
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
int n;
cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll ans = a[0];
for (int i = 1; i < a.size(); i++) {
ans = gcd(a[i], ans);
}
cout << ans << endl;
return 0;
} | [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 929,978 | 929,979 | u376817785 | cpp |
p03127 | #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
using namespace std;
int main() {
int n, num[110000];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> num[i];
}
int x = 1;
for (int j = 0; j < n; j++) {
x = __gcd(num[j], x);
}
cout << x << endl;
} | #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
using namespace std;
int main() {
int n, num[110000];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> num[i];
}
int x = num[0];
for (int j = 0; j < n; j++) {
x = __gcd(num[j], x);
}
cout << x << endl;
} | [
"identifier.replace.add",
"literal.replace.remove"
] | 930,004 | 930,005 | u127856129 | cpp |
p03127 | #include <algorithm>
#include <iostream>
#include <numeric>
using namespace std;
long long int n;
int gcd(int a, int b) {
while (b != 0) {
int t = b;
b = a % b;
a = t;
}
return a;
}
int main() {
cin >> n;
long long int a[1000000];
for (int i = 0; i < n; ++i)
cin >> a[i];
sort(a, a + n);
for (int i = 0; i < n - 1; i++) {
a[i + 1] = gcd(a[i], a[i + 1]);
}
cout << a[n] << endl;
}
| #include <algorithm>
#include <iostream>
#include <numeric>
using namespace std;
long long int n;
int gcd(int a, int b) {
while (b != 0) {
int t = b;
b = a % b;
a = t;
}
return a;
}
int main() {
cin >> n;
long long int a[1000000];
for (int i = 0; i < n; ++i)
cin >> a[i];
sort(a, a + n);
for (int i = 0; i < n - 1; i++) {
a[i + 1] = gcd(a[i], a[i + 1]);
}
cout << a[n - 1] << endl;
}
| [
"expression.operation.binary.add"
] | 930,021 | 930,022 | u809700806 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
int N, A;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
cin >> N >> A;
int ans = 0;
for (int i = 1; i < N; i++) {
cin >> A;
ans = gcd(ans, A);
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int N, A;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
cin >> N >> A;
int ans = A;
for (int i = 1; i < N; i++) {
cin >> A;
ans = gcd(ans, A);
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.value.change",
"identifier.replace.add",
"literal.replace.remove"
] | 930,034 | 930,035 | u691170040 | cpp |
p03127 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> P3;
const ll MOD = ll(1e9) + 7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()
int gcd(int p, int q) {
if (p % q == 0)
return q;
else
return gcd(q, p % q);
}
int main() {
int n, ans = 0;
cin >> n;
REP(i, n) {
int a;
cin >> a;
ans = gcd(a, ans);
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> P3;
const ll MOD = ll(1e9) + 7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()
int gcd(int p, int q) {
if (q == 0)
return p;
else
return gcd(q, p % q);
}
int main() {
int n, ans = 0;
cin >> n;
REP(i, n) {
int a;
cin >> a;
ans = gcd(a, ans);
}
cout << ans << endl;
return 0;
}
| [
"expression.operation.binary.remove",
"identifier.change",
"function.return_value.change"
] | 930,045 | 930,046 | u271063202 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, a) for (int i = 0; i < (a); i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
int d[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
signed main() {
int n, m;
cin >> n >> m;
bool use[10];
REP(i, m) {
int a;
cin >> a;
use[a] = true;
}
vector<int> dp(n + 1, -INF);
int prev[n + 1];
dp[0] = 0;
for (int i = 0; i <= n; i++) {
for (int j = 9; j >= 1; j--) {
if (!use[j])
continue;
if (i - d[j] < 0)
continue;
if (dp[i - d[j]] + 1 > dp[i]) {
dp[i] = dp[i - d[j]] + 1;
prev[i] = j;
}
}
}
string ans;
int i = n;
while (i != 0) {
ans.push_back('0' + prev[i]);
i -= d[prev[i]];
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, a) for (int i = 0; i < (a); i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
int d[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
signed main() {
int n, m;
cin >> n >> m;
bool use[10] = {};
REP(i, m) {
int a;
cin >> a;
use[a] = true;
}
vector<int> dp(n + 1, -INF);
int prev[n + 1];
dp[0] = 0;
for (int i = 0; i <= n; i++) {
for (int j = 9; j >= 1; j--) {
if (!use[j])
continue;
if (i - d[j] < 0)
continue;
if (dp[i - d[j]] + 1 > dp[i]) {
dp[i] = dp[i - d[j]] + 1;
prev[i] = j;
}
}
}
string ans;
int i = n;
while (i != 0) {
ans.push_back('0' + prev[i]);
i -= d[prev[i]];
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.value.change"
] | 930,091 | 930,092 | u366398972 | cpp |
p03128 | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int h[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
bool b[10] = {false};
int dp[10100][10];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int a;
cin >> a;
b[a] = true;
}
for (int i = 0; i < n + 10; i++) {
for (int j = 0; j < 10; j++) {
dp[i][j] = -1;
}
}
for (int i = 0; i < 10; i++) {
dp[0][i] = 0;
}
for (int i = 0; i <= n; i++) {
if (dp[i][0] == -1) {
continue;
}
for (int j = 1; j < 10; j++) {
if (!b[j]) {
continue;
}
if (dp[i + h[j]][0] == -1) {
for (int k = 0; k < 10; k++) {
dp[i + h[j]][k] = dp[i][k];
if (j == k) {
dp[i + h[j]][k]++;
}
}
} else {
int kari[10];
int sl = 0, sr = 0;
for (int k = 0; k < 10; k++) {
kari[k] = dp[i][k];
if (j == k) {
kari[k]++;
}
sl = dp[i + h[j]][k];
sr += kari[k];
}
bool bo = true;
if (sl != sr) {
if (sl >= sr) {
bo = false;
}
} else {
int l = 9, r = 9;
while (1) {
if (l == 0 && r == 0) {
bo = false;
break;
}
if (dp[i + h[j]][l] == 0) {
l--;
continue;
}
if (kari[r] == 0) {
r--;
continue;
}
if (l == r && dp[i + h[j]][l] == kari[r]) {
l--;
r--;
continue;
} else if (l < r) {
break;
} else if (l > r) {
bo = false;
break;
} else if (dp[i + h[j]][l] < kari[r]) {
break;
} else if (dp[i + h[j]][l] > kari[r]) {
bo = false;
break;
}
}
}
if (bo) {
for (int k = 0; k < 10; k++) {
dp[i + h[j]][k] = kari[k];
}
}
}
}
}
for (int i = 9; i > 0; i--) {
for (int j = 0; j < dp[n][i]; j++) {
cout << i;
}
}
cout << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int h[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
bool b[10] = {false};
int dp[10100][10];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int a;
cin >> a;
b[a] = true;
}
for (int i = 0; i < n + 10; i++) {
for (int j = 0; j < 10; j++) {
dp[i][j] = -1;
}
}
for (int i = 0; i < 10; i++) {
dp[0][i] = 0;
}
for (int i = 0; i <= n; i++) {
if (dp[i][0] == -1) {
continue;
}
for (int j = 1; j < 10; j++) {
if (!b[j]) {
continue;
}
if (dp[i + h[j]][0] == -1) {
for (int k = 0; k < 10; k++) {
dp[i + h[j]][k] = dp[i][k];
if (j == k) {
dp[i + h[j]][k]++;
}
}
} else {
int kari[10];
int sl = 0, sr = 0;
for (int k = 0; k < 10; k++) {
kari[k] = dp[i][k];
if (j == k) {
kari[k]++;
}
sl += dp[i + h[j]][k];
sr += kari[k];
}
bool bo = true;
if (sl != sr) {
if (sl > sr) {
bo = false;
}
} else {
int l = 9, r = 9;
while (1) {
if (l == 0 && r == 0) {
bo = false;
break;
}
if (dp[i + h[j]][l] == 0) {
l--;
continue;
}
if (kari[r] == 0) {
r--;
continue;
}
if (l == r && dp[i + h[j]][l] == kari[r]) {
l--;
r--;
continue;
} else if (l < r) {
break;
} else if (l > r) {
bo = false;
break;
} else if (dp[i + h[j]][l] < kari[r]) {
break;
} else if (dp[i + h[j]][l] > kari[r]) {
bo = false;
break;
}
}
}
if (bo) {
for (int k = 0; k < 10; k++) {
dp[i + h[j]][k] = kari[k];
}
}
}
}
}
for (int i = 9; i > 0; i--) {
for (int j = 0; j < dp[n][i]; j++) {
cout << i;
}
}
cout << endl;
return 0;
}
| [
"assignment.value.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 930,093 | 930,094 | u003026289 | cpp |
p03128 | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int h[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
bool b[10] = {false};
int dp[10100][10];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int a;
cin >> a;
b[a] = true;
}
for (int i = 0; i < n + 10; i++) {
for (int j = 0; j < 10; j++) {
dp[i][j] = -1;
}
}
for (int i = 0; i < 10; i++) {
dp[0][i] = 0;
}
for (int i = 0; i <= n; i++) {
if (dp[i][0] == -1) {
continue;
}
for (int j = 1; j < 10; j++) {
if (!b[j]) {
continue;
}
if (dp[i + h[j]][0] == -1) {
for (int k = 0; k < 10; k++) {
dp[i + h[j]][k] = dp[i][k];
if (j == k) {
dp[i + h[j]][k]++;
}
}
} else {
int kari[10];
int sl = 0, sr = 0;
for (int k = 0; k < 10; k++) {
kari[k] = dp[i][k];
if (j == k) {
kari[k]++;
}
sl = dp[i + h[j]][k];
sr += kari[k];
}
bool bo = true;
if (sl != sr) {
if (sl >= sr) {
bo = false;
}
} else {
int l = 9, r = 9;
while (1) {
if (l == 0 && r == 0) {
bo == false;
break;
}
if (dp[i + h[j]][l] == 0) {
l--;
continue;
}
if (kari[r] == 0) {
r--;
continue;
}
if (l == r && dp[i + h[j]][l] == kari[r]) {
l--;
r--;
continue;
} else if (l < r) {
break;
} else if (l > r) {
bo = false;
break;
} else if (dp[i + h[j]][l] < kari[r]) {
break;
} else if (dp[i + h[j]][l] > kari[r]) {
bo = false;
break;
}
}
}
if (bo) {
for (int k = 0; k < 10; k++) {
dp[i + h[j]][k] = kari[k];
}
}
}
}
}
for (int i = 9; i > 0; i--) {
for (int j = 0; j < dp[n][i]; j++) {
cout << i;
}
}
cout << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int h[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
bool b[10] = {false};
int dp[10100][10];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int a;
cin >> a;
b[a] = true;
}
for (int i = 0; i < n + 10; i++) {
for (int j = 0; j < 10; j++) {
dp[i][j] = -1;
}
}
for (int i = 0; i < 10; i++) {
dp[0][i] = 0;
}
for (int i = 0; i <= n; i++) {
if (dp[i][0] == -1) {
continue;
}
for (int j = 1; j < 10; j++) {
if (!b[j]) {
continue;
}
if (dp[i + h[j]][0] == -1) {
for (int k = 0; k < 10; k++) {
dp[i + h[j]][k] = dp[i][k];
if (j == k) {
dp[i + h[j]][k]++;
}
}
} else {
int kari[10];
int sl = 0, sr = 0;
for (int k = 0; k < 10; k++) {
kari[k] = dp[i][k];
if (j == k) {
kari[k]++;
}
sl += dp[i + h[j]][k];
sr += kari[k];
}
bool bo = true;
if (sl != sr) {
if (sl > sr) {
bo = false;
}
} else {
int l = 9, r = 9;
while (1) {
if (l == 0 && r == 0) {
bo = false;
break;
}
if (dp[i + h[j]][l] == 0) {
l--;
continue;
}
if (kari[r] == 0) {
r--;
continue;
}
if (l == r && dp[i + h[j]][l] == kari[r]) {
l--;
r--;
continue;
} else if (l < r) {
break;
} else if (l > r) {
bo = false;
break;
} else if (dp[i + h[j]][l] < kari[r]) {
break;
} else if (dp[i + h[j]][l] > kari[r]) {
bo = false;
break;
}
}
}
if (bo) {
for (int k = 0; k < 10; k++) {
dp[i + h[j]][k] = kari[k];
}
}
}
}
}
for (int i = 9; i > 0; i--) {
for (int j = 0; j < dp[n][i]; j++) {
cout << i;
}
}
cout << endl;
return 0;
}
| [
"assignment.value.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"expression.operation.compare.replace.remove",
"assignment.replace.add",
"misc.typo"
] | 930,095 | 930,094 | u003026289 | cpp |
p03128 | //#pragma once
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdlib> // srand,rand
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define lp(i, n) for (ll i = 0; i < n; i++)
#define modd 1000000007
#define mod2 998244353
#define INF 8223372036854775807ll
#define ALL(a) (a).begin(), (a).end()
typedef pair<long long, long long> pl;
typedef pair<double, double> pd;
typedef pair<ll, string> pls;
typedef string::const_iterator State;
class ParseError {};
/*
class SegmentTree {
private:
ll cont_num = 2;
pd initial_v;
vector<pd> dat;
public:
SegmentTree() {};
void init(ll size, double initial_value_first, double
initial_value_second) {
cont_num = 2;
initial_v.first = initial_value_first;
initial_v.second = initial_value_second;
while (cont_num < size) {
cont_num *= 2;
}
dat.resize(2 * cont_num);//サイズ設定
for (int i = 0; i < 2 * cont_num; i++)dat[i] =
initial_v;//初期化
}
void Update(ll position, double value_f, double value_s) {
ll k = cont_num + position;
dat[k].first = value_f;
dat[k].second = value_s;
while (k > 1) {
k /= 2;
dat[k].first = dat[k * 2 + 1].first * dat[k * 2].first;
dat[k].second = dat[k * 2 + 1].first * dat[k * 2].second
+ dat[k * 2 + 1].second;
}
}
/*
ll query_proces(ll a, ll b, ll k, ll l, ll r) {
if (r <= a || b <= l)return initial_v;
if (a <= l && r <= b)return dat[k];
else {
ll vl = query_proces(a, b, k * 2, l, (l + r) / 2);
ll vr = query_proces(a, b, k * 2 + 1, (l + r) / 2, r);
return min(vl, vr);
}
}
ll query(ll left, ll right) {
return query_proces(left, right, 1, 0, cont_num);
}
*/
/*
double query() {
return dat[1].first + dat[1].second;
}
};*/
template <typename T> class Zip {
vector<T> d;
bool flag;
void init() {
sort(d.begin(), d.end());
d.erase(unique(d.begin(), d.end()), d.end());
flag = false;
}
public:
Zip() { flag = false; }
void add(T x) {
d.push_back(x);
flag = true;
}
ll getNum(T x) {
if (flag)
init();
return lower_bound(d.begin(), d.end(), x) - d.begin();
}
ll size() {
if (flag)
init();
return (ll)d.size();
}
};
ll N, M, K, a, b, c, d, e, H, W, L, T;
ll x, y, z;
bool f;
string SS;
set<long long> sll;
pl bufpl;
vector<long long> vll;
vector<long long> v;
vector<pl> vpl;
vector<string> vs;
set<ll> llset;
set<string> Sset;
multiset<ll> llmset;
queue<ll> ql;
multiset<pl> plmset;
typedef struct ST {
ll first;
ll second;
ll cost;
bool operator<(const ST &another) const {
return cost < another.cost; //比較
};
bool operator>(const ST &another) const {
return cost > another.cost; //比較
};
} ST;
// queue<ST> qst;
// priority_queue<ST, vector<ST>, greater<ST> > qst;
/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/
long long modinv(long long aa, long long mm) {
long long bb = mm, uu = 1, vv = 0;
while (bb) {
long long tt = aa / bb;
aa -= tt * bb;
swap(aa, bb);
uu -= tt * vv;
swap(uu, vv);
}
uu %= mm;
if (uu < 0)
uu += mm;
return uu;
}
ll zettai(ll aa) {
if (aa < 0) {
aa *= -1;
}
return aa;
}
float zettai(float aa) {
if (aa < 0) {
aa *= -1;
}
return aa;
}
/*
class UnionFind
{
public:
vector <ll>pairent;
vector <ll>depth;
vector <ll>size;
UnionFind(ll Amount) : pairent(Amount, 1), depth(Amount, 1),
size(Amount, 1) {
for (ll i = 0; i < Amount; i++) {
pairent[i] = i;
}
}
ll FindPairent(ll x) {
if (pairent[x] == x)return x;
else return pairent[x] = FindPairent(pairent[x]);
}
ll Merge(ll x, ll y) {
x = FindPairent(x);
y = FindPairent(y);
if (x != y) {
if (depth[x] > depth[y]) {
pairent[y] = pairent[x];
return size[x] += size[y];
}
else {
pairent[x] = pairent[y];
if (depth[x] == depth[y]) {
depth[y] ++;
}
return size[y] += size[x];
}
}
else {
return -1;
}
}
bool IsSame(ll x, ll y) {
if (FindPairent(x) == FindPairent(y))return true;
else return false;
}
ll GetSize(ll x) {
x = FindPairent(x);
return size[x];
}
};
*/
class UnionFind {
public:
vector<ll> pairent;
vector<ll> depth;
vector<ll> size;
UnionFind(ll Amount) : pairent(Amount, 1), depth(Amount, 1), size(Amount, 1) {
for (ll i = 0; i < Amount; i++) {
pairent[i] = i;
}
}
ll FindPairent(ll x) {
if (pairent[x] == x)
return x;
else
return pairent[x] = FindPairent(pairent[x]);
}
ll Merge(ll x, ll y) {
x = FindPairent(x);
y = FindPairent(y);
if (x != y) {
if (depth[x] > depth[y]) {
pairent[y] = pairent[x];
return size[x] += size[y];
} else {
pairent[x] = pairent[y];
if (depth[x] == depth[y]) {
depth[y]++;
}
return size[y] += size[x];
}
} else {
return -1;
}
}
bool IsSame(ll x, ll y) {
if (FindPairent(x) == FindPairent(y))
return true;
else
return false;
}
ll GetSize(ll x) {
x = FindPairent(x);
return size[x];
}
};
struct Edge {
ll a, b, cost;
bool operator<(const Edge &other) const { return cost < other.cost; }
};
struct Graph {
ll n; // 頂点数
vector<Edge> es; // 辺集合
};
class Kruskal {
Graph origin_G;
Graph MST;
ll total_cost = 0;
public:
void Solve() {
UnionFind uf = UnionFind(MST.n);
for (ll i = 0; i < origin_G.es.size(); i++) {
ll a = origin_G.es[i].a;
ll b = origin_G.es[i].b;
ll cost = origin_G.es[i].cost;
if (!uf.IsSame(a, b)) {
uf.Merge(a, b);
MST.es.push_back(origin_G.es[i]);
total_cost += cost;
}
}
}
Kruskal(Graph graph) {
origin_G = graph;
MST = graph;
MST.es.clear();
sort(origin_G.es.begin(), origin_G.es.end());
}
ll GetMinCost() { return total_cost; }
};
ll RepeatSquaring(ll N, ll P, ll M) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = RepeatSquaring(N, P / 2, M) % M;
return t * t % M;
}
return N * RepeatSquaring(N, P - 1, M) % M;
}
/*
ll KurikaesiNijou(ll a, ll b, ll P) {
if (b == 0)return 1;
if (b % 2 == 0) {
ll c=KurikaesiNijou(a,b/2,P)%P;
return c * c %P;
}
else {
ll c = KurikaesiNijou(a, b/2, P) % P;
return a * c * c % P;
}
}*/
ll GCD(ll a, ll b) {
if (a % b == 0)
return b;
else
return GCD(b, a % b);
}
ll Min(ll a, ll b) {
if (a < b)
return a;
else
return b;
}
ll Max(ll a, ll b) {
if (a > b)
return a;
else
return b;
}
ll Sum(ll a, ll b) { return a + b; }
template <typename T> class SegmentTree {
ll n;
vector<T> node;
function<T(T, T)> fun, fun2;
bool customChange;
T outValue, initValue;
public:
void init(ll num, function<T(T, T)> resultFunction, T init, T out,
function<T(T, T)> changeFunction = NULL) {
// changeFunction: (input, beforevalue) => newvalue
fun = resultFunction;
fun2 = changeFunction;
customChange = changeFunction != NULL;
n = 1;
while (n < num)
n *= 2;
node.resize(2 * n - 1);
fill(node.begin(), node.end(), init);
outValue = out;
initValue = init;
}
void valueChange(ll num, T value) {
num += n - 1;
if (customChange)
node[num] = fun2(value, node[num]);
else
node[num] = value;
while (num > 0)
num = (num - 1) / 2,
node[num] = fun(node[num * 2 + 1], node[num * 2 + 2]);
}
T rangeQuery(ll a, ll b, ll l = 0, ll r = -1, ll k = 0) { // [a, b)
if (r == -1)
r = n;
if (a <= l && r <= b)
return node[k];
if (b <= l || r <= a)
return outValue;
ll mid = (l + r) / 2;
return fun(rangeQuery(a, b, l, mid, 2 * k + 1),
rangeQuery(a, b, mid, r, 2 * k + 2));
}
};
class Combination {
vector<ll> factorial;
vector<ll> factorial_inv;
ll mod;
ll max_n;
public:
void Init(ll init_max_n, ll init_mod) {
max_n = init_max_n;
mod = init_mod;
factorial.resize(max_n + 1);
factorial[0] = 1;
for (ll i = 1; i < factorial.size(); i++) {
factorial[i] = factorial[i - 1] * i;
factorial[i] %= mod;
}
factorial_inv.resize(max_n + 1);
factorial_inv[0] = 1;
for (ll i = 1; i < factorial_inv.size(); i++) {
factorial_inv[i] = factorial_inv[i - 1] * modinv(i, mod);
factorial_inv[i] %= mod;
}
}
ll GetComb(ll n, ll k) {
ll comb = factorial[n];
comb *= factorial_inv[k];
comb %= mod;
comb *= factorial_inv[n - k];
comb %= mod;
return comb;
}
ll GetH(ll n, ll k) { // n+k-1<=max_N
ll comb = factorial[n + k - 1];
comb *= factorial_inv[n];
comb %= mod;
comb *= factorial_inv[k - 1];
comb %= mod;
return comb;
}
};
class Tree {
ll node_N;
vector<ll> node;
vector<vector<pl>> pass;
ll diameter = -1;
vector<ll> dist_Diamieter[2];
pl maxDist_Num;
public:
void Init(ll node_Num) {
node_N = node_Num;
node.resize(node_N + 1);
pass.resize(node_N + 1);
dist_Diamieter[0].resize(node_N + 1);
lp(i, node_N + 1) dist_Diamieter[0][i] = -1;
dist_Diamieter[1].resize(node_N + 1);
lp(i, node_N + 1) dist_Diamieter[1][i] = -1;
}
void AddEdge(ll a, ll b, ll dist) {
bufpl.first = b;
bufpl.second = dist;
pass[a].push_back(bufpl);
bufpl.first = a;
pass[b].push_back(bufpl);
}
void DFS(ll step, ll now, ll dist) {
dist_Diamieter[step][now] = dist;
if (dist_Diamieter[step][now] > maxDist_Num.first) {
maxDist_Num.first = dist_Diamieter[step][now];
maxDist_Num.second = now;
}
for (ll i = 0; i < pass[now].size(); i++) {
ll next_node = pass[now][i].first;
if (dist_Diamieter[step][next_node] == -1) {
DFS(step, next_node, dist + pass[now][i].second);
}
}
}
ll GetDiameter(ll min_node_num) {
if (diameter >= 0)
return diameter;
else {
maxDist_Num.first = -1;
maxDist_Num.second = -1;
DFS(0, min_node_num, 0ll);
ll step2_start = maxDist_Num.second;
maxDist_Num.first = -1;
maxDist_Num.second = -1;
DFS(1, step2_start, 0ll);
diameter = maxDist_Num.first;
return diameter;
}
}
ll GetDistFromMinNode(ll num) { return dist_Diamieter[0][num]; }
};
ll A[200005] = {};
ll B[200005] = {};
ll C[200005] = {};
Combination co;
class SolveC {
ll N, M;
ll A[10];
ll B[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[10014] = {};
public:
void Main() {
ll x = 0;
cin >> N >> M;
lp(i, 10) A[i] = -1;
lp(i, M) {
cin >> a;
A[B[a]] = max(A[B[a]], a);
}
Solve();
sort(dp[N].begin(), dp[N].end());
reverse(dp[N].begin(), dp[N].end());
cout << dp[N] << endl;
}
void Solve() {
lp(i, N - 2) {
lp(j, 10) {
if (A[j] != -1) {
string comps = dp[i] + to_string(A[j]);
if (i > 0 && dp[i].size() == 0)
break;
dp[i + j] = CompS(dp[i + j], comps);
}
}
}
}
string CompS(string s1, string s2) {
if (s1.size() > s2.size())
return s1;
if (s1.size() < s2.size())
return s2;
ll c1[10] = {};
ll c2[10] = {};
lp(i, s1.size()) c1[s1[i] - '0']++;
lp(i, s2.size()) c2[s2[i] - '0']++;
for (ll i = 9; i >= 1; i--) {
if (c1[i] > c2[i])
return s1;
if (c1[i] < c2[i])
return s2;
}
return s1;
}
};
SolveC solvec;
int main() {
solvec.Main();
// cout << fixed << setprecision(12) << bb << endl;
return 0;
}
| //#pragma once
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdlib> // srand,rand
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define lp(i, n) for (ll i = 0; i < n; i++)
#define modd 1000000007
#define mod2 998244353
#define INF 8223372036854775807ll
#define ALL(a) (a).begin(), (a).end()
typedef pair<long long, long long> pl;
typedef pair<double, double> pd;
typedef pair<ll, string> pls;
typedef string::const_iterator State;
class ParseError {};
/*
class SegmentTree {
private:
ll cont_num = 2;
pd initial_v;
vector<pd> dat;
public:
SegmentTree() {};
void init(ll size, double initial_value_first, double
initial_value_second) {
cont_num = 2;
initial_v.first = initial_value_first;
initial_v.second = initial_value_second;
while (cont_num < size) {
cont_num *= 2;
}
dat.resize(2 * cont_num);//サイズ設定
for (int i = 0; i < 2 * cont_num; i++)dat[i] =
initial_v;//初期化
}
void Update(ll position, double value_f, double value_s) {
ll k = cont_num + position;
dat[k].first = value_f;
dat[k].second = value_s;
while (k > 1) {
k /= 2;
dat[k].first = dat[k * 2 + 1].first * dat[k * 2].first;
dat[k].second = dat[k * 2 + 1].first * dat[k * 2].second
+ dat[k * 2 + 1].second;
}
}
/*
ll query_proces(ll a, ll b, ll k, ll l, ll r) {
if (r <= a || b <= l)return initial_v;
if (a <= l && r <= b)return dat[k];
else {
ll vl = query_proces(a, b, k * 2, l, (l + r) / 2);
ll vr = query_proces(a, b, k * 2 + 1, (l + r) / 2, r);
return min(vl, vr);
}
}
ll query(ll left, ll right) {
return query_proces(left, right, 1, 0, cont_num);
}
*/
/*
double query() {
return dat[1].first + dat[1].second;
}
};*/
template <typename T> class Zip {
vector<T> d;
bool flag;
void init() {
sort(d.begin(), d.end());
d.erase(unique(d.begin(), d.end()), d.end());
flag = false;
}
public:
Zip() { flag = false; }
void add(T x) {
d.push_back(x);
flag = true;
}
ll getNum(T x) {
if (flag)
init();
return lower_bound(d.begin(), d.end(), x) - d.begin();
}
ll size() {
if (flag)
init();
return (ll)d.size();
}
};
ll N, M, K, a, b, c, d, e, H, W, L, T;
ll x, y, z;
bool f;
string SS;
set<long long> sll;
pl bufpl;
vector<long long> vll;
vector<long long> v;
vector<pl> vpl;
vector<string> vs;
set<ll> llset;
set<string> Sset;
multiset<ll> llmset;
queue<ll> ql;
multiset<pl> plmset;
typedef struct ST {
ll first;
ll second;
ll cost;
bool operator<(const ST &another) const {
return cost < another.cost; //比較
};
bool operator>(const ST &another) const {
return cost > another.cost; //比較
};
} ST;
// queue<ST> qst;
// priority_queue<ST, vector<ST>, greater<ST> > qst;
/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/
long long modinv(long long aa, long long mm) {
long long bb = mm, uu = 1, vv = 0;
while (bb) {
long long tt = aa / bb;
aa -= tt * bb;
swap(aa, bb);
uu -= tt * vv;
swap(uu, vv);
}
uu %= mm;
if (uu < 0)
uu += mm;
return uu;
}
ll zettai(ll aa) {
if (aa < 0) {
aa *= -1;
}
return aa;
}
float zettai(float aa) {
if (aa < 0) {
aa *= -1;
}
return aa;
}
/*
class UnionFind
{
public:
vector <ll>pairent;
vector <ll>depth;
vector <ll>size;
UnionFind(ll Amount) : pairent(Amount, 1), depth(Amount, 1),
size(Amount, 1) {
for (ll i = 0; i < Amount; i++) {
pairent[i] = i;
}
}
ll FindPairent(ll x) {
if (pairent[x] == x)return x;
else return pairent[x] = FindPairent(pairent[x]);
}
ll Merge(ll x, ll y) {
x = FindPairent(x);
y = FindPairent(y);
if (x != y) {
if (depth[x] > depth[y]) {
pairent[y] = pairent[x];
return size[x] += size[y];
}
else {
pairent[x] = pairent[y];
if (depth[x] == depth[y]) {
depth[y] ++;
}
return size[y] += size[x];
}
}
else {
return -1;
}
}
bool IsSame(ll x, ll y) {
if (FindPairent(x) == FindPairent(y))return true;
else return false;
}
ll GetSize(ll x) {
x = FindPairent(x);
return size[x];
}
};
*/
class UnionFind {
public:
vector<ll> pairent;
vector<ll> depth;
vector<ll> size;
UnionFind(ll Amount) : pairent(Amount, 1), depth(Amount, 1), size(Amount, 1) {
for (ll i = 0; i < Amount; i++) {
pairent[i] = i;
}
}
ll FindPairent(ll x) {
if (pairent[x] == x)
return x;
else
return pairent[x] = FindPairent(pairent[x]);
}
ll Merge(ll x, ll y) {
x = FindPairent(x);
y = FindPairent(y);
if (x != y) {
if (depth[x] > depth[y]) {
pairent[y] = pairent[x];
return size[x] += size[y];
} else {
pairent[x] = pairent[y];
if (depth[x] == depth[y]) {
depth[y]++;
}
return size[y] += size[x];
}
} else {
return -1;
}
}
bool IsSame(ll x, ll y) {
if (FindPairent(x) == FindPairent(y))
return true;
else
return false;
}
ll GetSize(ll x) {
x = FindPairent(x);
return size[x];
}
};
struct Edge {
ll a, b, cost;
bool operator<(const Edge &other) const { return cost < other.cost; }
};
struct Graph {
ll n; // 頂点数
vector<Edge> es; // 辺集合
};
class Kruskal {
Graph origin_G;
Graph MST;
ll total_cost = 0;
public:
void Solve() {
UnionFind uf = UnionFind(MST.n);
for (ll i = 0; i < origin_G.es.size(); i++) {
ll a = origin_G.es[i].a;
ll b = origin_G.es[i].b;
ll cost = origin_G.es[i].cost;
if (!uf.IsSame(a, b)) {
uf.Merge(a, b);
MST.es.push_back(origin_G.es[i]);
total_cost += cost;
}
}
}
Kruskal(Graph graph) {
origin_G = graph;
MST = graph;
MST.es.clear();
sort(origin_G.es.begin(), origin_G.es.end());
}
ll GetMinCost() { return total_cost; }
};
ll RepeatSquaring(ll N, ll P, ll M) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = RepeatSquaring(N, P / 2, M) % M;
return t * t % M;
}
return N * RepeatSquaring(N, P - 1, M) % M;
}
/*
ll KurikaesiNijou(ll a, ll b, ll P) {
if (b == 0)return 1;
if (b % 2 == 0) {
ll c=KurikaesiNijou(a,b/2,P)%P;
return c * c %P;
}
else {
ll c = KurikaesiNijou(a, b/2, P) % P;
return a * c * c % P;
}
}*/
ll GCD(ll a, ll b) {
if (a % b == 0)
return b;
else
return GCD(b, a % b);
}
ll Min(ll a, ll b) {
if (a < b)
return a;
else
return b;
}
ll Max(ll a, ll b) {
if (a > b)
return a;
else
return b;
}
ll Sum(ll a, ll b) { return a + b; }
template <typename T> class SegmentTree {
ll n;
vector<T> node;
function<T(T, T)> fun, fun2;
bool customChange;
T outValue, initValue;
public:
void init(ll num, function<T(T, T)> resultFunction, T init, T out,
function<T(T, T)> changeFunction = NULL) {
// changeFunction: (input, beforevalue) => newvalue
fun = resultFunction;
fun2 = changeFunction;
customChange = changeFunction != NULL;
n = 1;
while (n < num)
n *= 2;
node.resize(2 * n - 1);
fill(node.begin(), node.end(), init);
outValue = out;
initValue = init;
}
void valueChange(ll num, T value) {
num += n - 1;
if (customChange)
node[num] = fun2(value, node[num]);
else
node[num] = value;
while (num > 0)
num = (num - 1) / 2,
node[num] = fun(node[num * 2 + 1], node[num * 2 + 2]);
}
T rangeQuery(ll a, ll b, ll l = 0, ll r = -1, ll k = 0) { // [a, b)
if (r == -1)
r = n;
if (a <= l && r <= b)
return node[k];
if (b <= l || r <= a)
return outValue;
ll mid = (l + r) / 2;
return fun(rangeQuery(a, b, l, mid, 2 * k + 1),
rangeQuery(a, b, mid, r, 2 * k + 2));
}
};
class Combination {
vector<ll> factorial;
vector<ll> factorial_inv;
ll mod;
ll max_n;
public:
void Init(ll init_max_n, ll init_mod) {
max_n = init_max_n;
mod = init_mod;
factorial.resize(max_n + 1);
factorial[0] = 1;
for (ll i = 1; i < factorial.size(); i++) {
factorial[i] = factorial[i - 1] * i;
factorial[i] %= mod;
}
factorial_inv.resize(max_n + 1);
factorial_inv[0] = 1;
for (ll i = 1; i < factorial_inv.size(); i++) {
factorial_inv[i] = factorial_inv[i - 1] * modinv(i, mod);
factorial_inv[i] %= mod;
}
}
ll GetComb(ll n, ll k) {
ll comb = factorial[n];
comb *= factorial_inv[k];
comb %= mod;
comb *= factorial_inv[n - k];
comb %= mod;
return comb;
}
ll GetH(ll n, ll k) { // n+k-1<=max_N
ll comb = factorial[n + k - 1];
comb *= factorial_inv[n];
comb %= mod;
comb *= factorial_inv[k - 1];
comb %= mod;
return comb;
}
};
class Tree {
ll node_N;
vector<ll> node;
vector<vector<pl>> pass;
ll diameter = -1;
vector<ll> dist_Diamieter[2];
pl maxDist_Num;
public:
void Init(ll node_Num) {
node_N = node_Num;
node.resize(node_N + 1);
pass.resize(node_N + 1);
dist_Diamieter[0].resize(node_N + 1);
lp(i, node_N + 1) dist_Diamieter[0][i] = -1;
dist_Diamieter[1].resize(node_N + 1);
lp(i, node_N + 1) dist_Diamieter[1][i] = -1;
}
void AddEdge(ll a, ll b, ll dist) {
bufpl.first = b;
bufpl.second = dist;
pass[a].push_back(bufpl);
bufpl.first = a;
pass[b].push_back(bufpl);
}
void DFS(ll step, ll now, ll dist) {
dist_Diamieter[step][now] = dist;
if (dist_Diamieter[step][now] > maxDist_Num.first) {
maxDist_Num.first = dist_Diamieter[step][now];
maxDist_Num.second = now;
}
for (ll i = 0; i < pass[now].size(); i++) {
ll next_node = pass[now][i].first;
if (dist_Diamieter[step][next_node] == -1) {
DFS(step, next_node, dist + pass[now][i].second);
}
}
}
ll GetDiameter(ll min_node_num) {
if (diameter >= 0)
return diameter;
else {
maxDist_Num.first = -1;
maxDist_Num.second = -1;
DFS(0, min_node_num, 0ll);
ll step2_start = maxDist_Num.second;
maxDist_Num.first = -1;
maxDist_Num.second = -1;
DFS(1, step2_start, 0ll);
diameter = maxDist_Num.first;
return diameter;
}
}
ll GetDistFromMinNode(ll num) { return dist_Diamieter[0][num]; }
};
ll A[200005] = {};
ll B[200005] = {};
ll C[200005] = {};
Combination co;
class SolveC {
ll N, M;
ll A[10];
ll B[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[10014] = {};
public:
void Main() {
ll x = 0;
cin >> N >> M;
lp(i, 10) A[i] = -1;
lp(i, M) {
cin >> a;
A[B[a]] = max(A[B[a]], a);
}
Solve();
sort(dp[N].begin(), dp[N].end());
reverse(dp[N].begin(), dp[N].end());
cout << dp[N] << endl;
}
void Solve() {
lp(i, N) {
lp(j, 10) {
if (A[j] != -1) {
string comps = dp[i] + to_string(A[j]);
if (i > 0 && dp[i].size() == 0)
break;
dp[i + j] = CompS(dp[i + j], comps);
}
}
}
}
string CompS(string s1, string s2) {
if (s1.size() > s2.size())
return s1;
if (s1.size() < s2.size())
return s2;
ll c1[10] = {};
ll c2[10] = {};
lp(i, s1.size()) c1[s1[i] - '0']++;
lp(i, s2.size()) c2[s2[i] - '0']++;
for (ll i = 9; i >= 1; i--) {
if (c1[i] > c2[i])
return s1;
if (c1[i] < c2[i])
return s2;
}
return s1;
}
};
SolveC solvec;
int main() {
solvec.Main();
// cout << fixed << setprecision(12) << bb << endl;
return 0;
}
| [
"expression.operation.binary.remove"
] | 930,105 | 930,106 | u058317639 | cpp |
p03128 | ///////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <typeinfo>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////////////////////////
#define pb push_back
#define V vector
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
struct UnionFind {
unsigned long *parent, *count, *rank;
UnionFind(unsigned long n) {
parent = new unsigned long[n + 1];
count = new unsigned long[n + 1];
rank = new unsigned long[n + 1];
for (unsigned long i = 0UL; i < n + 1; ++i) {
parent[i] = i;
count[i] = 1;
rank[i] = 0;
}
}
unsigned long root(unsigned long i) {
if (parent[i] == i)
return i;
parent[i] = root(parent[i]);
return parent[i];
}
void unite(unsigned long i, unsigned long j) {
unsigned long rooti = root(i);
unsigned long rootj = root(j);
if (rooti == rootj)
return;
if (rank[rootj] < rank[rooti]) {
parent[i] = parent[j] = parent[rootj] = rooti;
count[rooti] += count[rootj];
} else {
parent[i] = parent[j] = parent[rooti] = rootj;
count[rootj] += count[rooti];
if (rank[rootj] == rank[rooti])
rank[rootj]++;
}
}
bool same(unsigned long i, unsigned long j) { return root(i) == root(j); }
};
struct T2 {
long t0;
long t1;
};
struct T3 {
long t0;
long t1;
long t2;
};
struct T4 {
long t0;
long t1;
long t2;
long t3;
};
bool operator<(const T2 &lhs, const T2 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 < rhs.t0;
return lhs.t1 < rhs.t1;
}
bool operator>(const T2 &lhs, const T2 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 > rhs.t0;
return lhs.t1 > rhs.t1;
}
bool operator==(const T2 &lhs, const T2 &rhs) {
if (lhs.t0 != rhs.t0)
return false;
return lhs.t1 == rhs.t1;
}
bool operator!=(const T2 &lhs, const T2 &rhs) { return !(lhs == rhs); }
bool operator<(const T3 &lhs, const T3 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 < rhs.t0;
if (lhs.t1 != rhs.t1)
return lhs.t1 < rhs.t1;
return lhs.t2 < rhs.t2;
}
bool operator>(const T3 &lhs, const T3 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 > rhs.t0;
if (lhs.t1 != rhs.t1)
return lhs.t1 > rhs.t1;
return lhs.t2 > rhs.t2;
}
bool operator==(const T3 &lhs, const T3 &rhs) {
if (lhs.t0 != rhs.t0)
return false;
if (lhs.t1 != rhs.t1)
return false;
return lhs.t2 == rhs.t2;
}
bool operator!=(const T3 &lhs, const T3 &rhs) { return !(lhs == rhs); }
bool operator<(const T4 &lhs, const T4 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 < rhs.t0;
if (lhs.t1 != rhs.t1)
return lhs.t1 < rhs.t1;
if (lhs.t2 != rhs.t2)
return lhs.t2 < rhs.t2;
return lhs.t3 < rhs.t3;
}
bool operator>(const T4 &lhs, const T4 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 > rhs.t0;
if (lhs.t1 != rhs.t1)
return lhs.t1 > rhs.t1;
if (lhs.t2 != rhs.t2)
return lhs.t2 > rhs.t2;
return lhs.t3 > rhs.t3;
}
bool operator==(const T4 &lhs, const T4 &rhs) {
if (lhs.t0 != rhs.t0)
return false;
if (lhs.t1 != rhs.t1)
return false;
if (lhs.t2 != rhs.t2)
return false;
return lhs.t3 == rhs.t3;
}
bool operator!=(const T4 &lhs, const T4 &rhs) { return !(lhs == rhs); }
void longin(long &a) { cin >> a; }
void longinl1(auto &v, long count) {
for (long i = 0; i < count; ++i) {
long a;
cin >> a;
v.push_back(a);
}
}
void longinl2(auto &v, long count) {
for (long i = 0; i < count; ++i) {
long a, b;
cin >> a >> b;
v.push_back({a, b});
}
}
void longinl3(auto &v, long count) {
for (long i = 0; i < count; ++i) {
long a, b, c;
cin >> a >> b >> c;
v.push_back({a, b, c});
}
}
void longina(auto &v, long count) { longinl1(v, count); }
long min(const vector<long> v) {
long ret = (long)numeric_limits<double>::infinity();
for (auto i : v)
ret = min(ret, i);
return ret;
}
void sort(vector<long> &v) { sort(v.begin(), v.end()); }
void sort_reverse(vector<long> &v) {
sort(v.begin(), v.end(), greater<long>());
}
void get_divisors(vector<long> &retlist, long x) {
for (int i = 1; i < sqrt(x) + 3; ++i) {
if (x % i == 0) {
retlist.push_back(i);
retlist.push_back(x / i);
}
}
}
void intersection(const set<long> &a, const set<long> &b, set<long> &result) {
vector<long> resultlist;
set_intersection(a.begin(), a.end(), b.begin(), b.end(),
back_inserter(resultlist));
set<long> resultset(resultlist.begin(), resultlist.end());
result = resultset;
}
unsigned long combination(long x, long y) {
if (y > x / 2L)
y = x - y;
unsigned long ret = 1;
for (int i = 0; i < y; ++i) {
ret *= x--;
ret /= (i + 1);
}
return ret;
}
void debug_print(auto xlist) {
for (auto x : xlist)
cout << "-- " << x << endl;
}
///////////////////////////////////////////////////////////////////////////////
static long counts[10] = {1000, 2, 5, 5, 4, 5, 6, 3, 7, 6};
static long nums[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
void get_divs(V<V<long>> &vv, long n, const vector<long> &subcounts) {
long subcmax[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (auto subc : subcounts)
subcmax[subc] = n / subc;
long patterns = 1;
rep(i, 10) patterns *= (subcmax[i] + 1);
long subc[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
rep(i, patterns) {
long nn = 0;
rep(j, 10) nn += j * subc[j];
if (n == nn) {
V<long> v;
rep(j, 10) v.pb(subc[j]);
vv.pb(v);
}
rep(j, 10) {
if (subc[j] >= subcmax[j]) {
subc[j] = 0;
} else {
subc[j]++;
break;
}
}
}
}
int main() {
long n, m;
longin(n);
longin(m);
vector<long> alist;
longina(alist, m);
for (auto a : alist) {
long count = counts[a];
nums[count] = max(a, nums[count]);
}
long min_count = 1000;
rep(i, 10) {
if (nums[i] > 0) {
min_count = i;
break;
}
}
vector<long> anslist;
while (n >= min_count) {
anslist.pb(nums[min_count]);
n -= min_count;
}
vector<long> subcounts;
rep(i, 10) {
if (nums[i] > 0 && i > min_count) {
subcounts.pb(i - min_count);
}
}
for (;;) {
V<long> ans;
V<V<long>> vv;
get_divs(vv, n, subcounts);
for (V<long> v : vv) {
V<long> anslistl(anslist);
rep(i, 10) {
rep(j, v[i]) {
long tmp = anslistl[0];
anslistl.erase(anslistl.begin());
anslistl.pb(nums[counts[tmp] + i]);
}
}
sort_reverse(anslistl);
if (ans.size() == 0)
ans = anslistl;
else {
rep(i, anslist.size()) {
if (ans[i] < anslistl[i]) {
ans = anslistl;
break;
}
if (ans[i] > anslistl[i]) {
break;
}
}
}
}
if (ans.size() == 0) {
n += anslist[0];
anslist.erase(anslist.begin());
continue;
}
for (auto num : ans)
cout << num;
return 0;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
| ///////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <typeinfo>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////////////////////////
#define pb push_back
#define V vector
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
struct UnionFind {
unsigned long *parent, *count, *rank;
UnionFind(unsigned long n) {
parent = new unsigned long[n + 1];
count = new unsigned long[n + 1];
rank = new unsigned long[n + 1];
for (unsigned long i = 0UL; i < n + 1; ++i) {
parent[i] = i;
count[i] = 1;
rank[i] = 0;
}
}
unsigned long root(unsigned long i) {
if (parent[i] == i)
return i;
parent[i] = root(parent[i]);
return parent[i];
}
void unite(unsigned long i, unsigned long j) {
unsigned long rooti = root(i);
unsigned long rootj = root(j);
if (rooti == rootj)
return;
if (rank[rootj] < rank[rooti]) {
parent[i] = parent[j] = parent[rootj] = rooti;
count[rooti] += count[rootj];
} else {
parent[i] = parent[j] = parent[rooti] = rootj;
count[rootj] += count[rooti];
if (rank[rootj] == rank[rooti])
rank[rootj]++;
}
}
bool same(unsigned long i, unsigned long j) { return root(i) == root(j); }
};
struct T2 {
long t0;
long t1;
};
struct T3 {
long t0;
long t1;
long t2;
};
struct T4 {
long t0;
long t1;
long t2;
long t3;
};
bool operator<(const T2 &lhs, const T2 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 < rhs.t0;
return lhs.t1 < rhs.t1;
}
bool operator>(const T2 &lhs, const T2 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 > rhs.t0;
return lhs.t1 > rhs.t1;
}
bool operator==(const T2 &lhs, const T2 &rhs) {
if (lhs.t0 != rhs.t0)
return false;
return lhs.t1 == rhs.t1;
}
bool operator!=(const T2 &lhs, const T2 &rhs) { return !(lhs == rhs); }
bool operator<(const T3 &lhs, const T3 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 < rhs.t0;
if (lhs.t1 != rhs.t1)
return lhs.t1 < rhs.t1;
return lhs.t2 < rhs.t2;
}
bool operator>(const T3 &lhs, const T3 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 > rhs.t0;
if (lhs.t1 != rhs.t1)
return lhs.t1 > rhs.t1;
return lhs.t2 > rhs.t2;
}
bool operator==(const T3 &lhs, const T3 &rhs) {
if (lhs.t0 != rhs.t0)
return false;
if (lhs.t1 != rhs.t1)
return false;
return lhs.t2 == rhs.t2;
}
bool operator!=(const T3 &lhs, const T3 &rhs) { return !(lhs == rhs); }
bool operator<(const T4 &lhs, const T4 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 < rhs.t0;
if (lhs.t1 != rhs.t1)
return lhs.t1 < rhs.t1;
if (lhs.t2 != rhs.t2)
return lhs.t2 < rhs.t2;
return lhs.t3 < rhs.t3;
}
bool operator>(const T4 &lhs, const T4 &rhs) {
if (lhs.t0 != rhs.t0)
return lhs.t0 > rhs.t0;
if (lhs.t1 != rhs.t1)
return lhs.t1 > rhs.t1;
if (lhs.t2 != rhs.t2)
return lhs.t2 > rhs.t2;
return lhs.t3 > rhs.t3;
}
bool operator==(const T4 &lhs, const T4 &rhs) {
if (lhs.t0 != rhs.t0)
return false;
if (lhs.t1 != rhs.t1)
return false;
if (lhs.t2 != rhs.t2)
return false;
return lhs.t3 == rhs.t3;
}
bool operator!=(const T4 &lhs, const T4 &rhs) { return !(lhs == rhs); }
void longin(long &a) { cin >> a; }
void longinl1(auto &v, long count) {
for (long i = 0; i < count; ++i) {
long a;
cin >> a;
v.push_back(a);
}
}
void longinl2(auto &v, long count) {
for (long i = 0; i < count; ++i) {
long a, b;
cin >> a >> b;
v.push_back({a, b});
}
}
void longinl3(auto &v, long count) {
for (long i = 0; i < count; ++i) {
long a, b, c;
cin >> a >> b >> c;
v.push_back({a, b, c});
}
}
void longina(auto &v, long count) { longinl1(v, count); }
long min(const vector<long> v) {
long ret = (long)numeric_limits<double>::infinity();
for (auto i : v)
ret = min(ret, i);
return ret;
}
void sort(vector<long> &v) { sort(v.begin(), v.end()); }
void sort_reverse(vector<long> &v) {
sort(v.begin(), v.end(), greater<long>());
}
void get_divisors(vector<long> &retlist, long x) {
for (int i = 1; i < sqrt(x) + 3; ++i) {
if (x % i == 0) {
retlist.push_back(i);
retlist.push_back(x / i);
}
}
}
void intersection(const set<long> &a, const set<long> &b, set<long> &result) {
vector<long> resultlist;
set_intersection(a.begin(), a.end(), b.begin(), b.end(),
back_inserter(resultlist));
set<long> resultset(resultlist.begin(), resultlist.end());
result = resultset;
}
unsigned long combination(long x, long y) {
if (y > x / 2L)
y = x - y;
unsigned long ret = 1;
for (int i = 0; i < y; ++i) {
ret *= x--;
ret /= (i + 1);
}
return ret;
}
void debug_print(auto xlist) {
for (auto x : xlist)
cout << "-- " << x << endl;
}
///////////////////////////////////////////////////////////////////////////////
static long counts[10] = {1000, 2, 5, 5, 4, 5, 6, 3, 7, 6};
static long nums[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
void get_divs(V<V<long>> &vv, long n, const vector<long> &subcounts) {
long subcmax[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (auto subc : subcounts)
subcmax[subc] = n / subc;
long patterns = 1;
rep(i, 10) patterns *= (subcmax[i] + 1);
long subc[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
rep(i, patterns) {
long nn = 0;
rep(j, 10) nn += j * subc[j];
if (n == nn) {
V<long> v;
rep(j, 10) v.pb(subc[j]);
vv.pb(v);
}
rep(j, 10) {
if (subc[j] >= subcmax[j]) {
subc[j] = 0;
} else {
subc[j]++;
break;
}
}
}
}
int main() {
long n, m;
longin(n);
longin(m);
vector<long> alist;
longina(alist, m);
for (auto a : alist) {
long count = counts[a];
nums[count] = max(a, nums[count]);
}
long min_count = 1000;
rep(i, 10) {
if (nums[i] > 0) {
min_count = i;
break;
}
}
vector<long> anslist;
while (n >= min_count) {
anslist.pb(nums[min_count]);
n -= min_count;
}
vector<long> subcounts;
rep(i, 10) {
if (nums[i] > 0 && i > min_count) {
subcounts.pb(i - min_count);
}
}
for (;;) {
V<long> ans;
V<V<long>> vv;
get_divs(vv, n, subcounts);
for (V<long> v : vv) {
V<long> anslistl(anslist);
rep(i, 10) {
rep(j, v[i]) {
long tmp = anslistl[0];
anslistl.erase(anslistl.begin());
anslistl.pb(nums[counts[tmp] + i]);
}
}
sort_reverse(anslistl);
if (ans.size() == 0)
ans = anslistl;
else {
rep(i, anslist.size()) {
if (ans[i] < anslistl[i]) {
ans = anslistl;
break;
}
if (ans[i] > anslistl[i]) {
break;
}
}
}
}
if (ans.size() == 0) {
n += counts[anslist[0]];
anslist.erase(anslist.begin());
continue;
}
for (auto num : ans)
cout << num;
return 0;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
| [] | 930,120 | 930,121 | u167931717 | cpp |
p03128 | #include <bits/stdc++.h>
#define ll long long
using namespace std;
const int nMatch[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string append(string s, string t) {
if (s == "")
return t;
int n = s.length();
for (int i = 0; i < n; i++) {
if (s[i] < t[0]) {
s.insert(i, t);
break;
}
}
return s;
}
int main() {
int N, M;
vector<int> A;
cin >> N >> M;
A = vector<int>(M, 0);
for (int i = 0; i < M; i++)
cin >> A[i];
vector<string> dp(N + 1, "");
for (int i = 0; i < M; i++) {
int ii = nMatch[A[i]];
if (ii > N)
continue;
if (dp[ii] == "" || dp[ii] < to_string(A[i]))
dp[ii] = to_string(A[i]);
}
for (int i = 1; i <= N; i++) {
if (dp[i] == "")
continue;
for (int j = 0; j < M; j++) {
int nxt = i + nMatch[A[j]];
if (nxt > N)
continue;
if (dp[nxt] == "" || dp[nxt].length() < dp[i].length() + 1) {
dp[nxt] = append(dp[i], to_string(A[j]));
} else if (dp[nxt].length() == dp[i].length() + 1) {
string tmp = append(dp[i], to_string(A[j]));
if (dp[nxt] < tmp)
dp[nxt] = tmp;
}
}
}
cout << dp[N] << endl;
}
| #include <bits/stdc++.h>
#define ll long long
using namespace std;
const int nMatch[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string append(string s, string t) {
if (s == "")
return t;
int n = s.length();
for (int i = 0; i < n; i++) {
if (s[i] <= t[0]) {
s.insert(i, t);
break;
}
}
return s;
}
int main() {
int N, M;
vector<int> A;
cin >> N >> M;
A = vector<int>(M, 0);
for (int i = 0; i < M; i++)
cin >> A[i];
vector<string> dp(N + 1, "");
for (int i = 0; i < M; i++) {
int ii = nMatch[A[i]];
if (ii > N)
continue;
if (dp[ii] == "" || dp[ii] < to_string(A[i]))
dp[ii] = to_string(A[i]);
}
for (int i = 1; i <= N; i++) {
if (dp[i] == "")
continue;
for (int j = 0; j < M; j++) {
int nxt = i + nMatch[A[j]];
if (nxt > N)
continue;
if (dp[nxt] == "" || dp[nxt].length() < dp[i].length() + 1) {
dp[nxt] = append(dp[i], to_string(A[j]));
} else if (dp[nxt].length() == dp[i].length() + 1) {
string tmp = append(dp[i], to_string(A[j]));
if (dp[nxt] < tmp)
dp[nxt] = tmp;
}
}
}
cout << dp[N] << endl;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 930,181 | 930,182 | u119098168 | cpp |
p03128 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rep2(i, s, n) for (int i = s; i < n; ++i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define tmax(a, b, c) max(a, max(b, c))
#define tmin(a, b, c) min(a, min(b, c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
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;
}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
bool dp[5100][10100];
int main() {
int n, m;
cin >> n >> m;
vector<int> ex(8, 0);
rep(i, m) {
int a;
cin >> a;
int b;
if (a == 1)
b = 2;
else if (a == 7)
b = 3;
else if (a == 4)
b = 4;
else if (a == 2 || a == 3 || a == 5)
b = 5;
else if (a == 6 || a == 9)
b = 6;
else
b = 7;
chmax(ex[b], a);
}
rep(i, 5100) rep(j, 10100) dp[i][j] = false;
dp[0][0] = true;
rep(i, 5099) {
rep(j, n + 1) {
if (!dp[i][j])
continue;
rep2(k, 2, 7) if (ex[k] > 0) { dp[i + 1][j + k] = true; }
}
}
int mx;
rrep(i, 5100) {
if (dp[i][n]) {
mx = i + 1;
break;
}
}
int now = n;
for (int i = mx - 1; i > 0; i--) {
int can = 0;
int use;
rep2(j, 2, min(8, now + 1)) {
if (ex[j] > can && dp[i - 1][now - j]) {
can = ex[j];
use = j;
}
}
now -= use;
cout << can;
}
cout << endl;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rep2(i, s, n) for (int i = s; i < n; ++i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define tmax(a, b, c) max(a, max(b, c))
#define tmin(a, b, c) min(a, min(b, c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
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;
}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
bool dp[5100][10100];
int main() {
int n, m;
cin >> n >> m;
vector<int> ex(8, 0);
rep(i, m) {
int a;
cin >> a;
int b;
if (a == 1)
b = 2;
else if (a == 7)
b = 3;
else if (a == 4)
b = 4;
else if (a == 2 || a == 3 || a == 5)
b = 5;
else if (a == 6 || a == 9)
b = 6;
else
b = 7;
chmax(ex[b], a);
}
rep(i, 5100) rep(j, 10100) dp[i][j] = false;
dp[0][0] = true;
rep(i, 5099) {
rep(j, n + 1) {
if (!dp[i][j])
continue;
rep2(k, 2, 8) if (ex[k] > 0) { dp[i + 1][j + k] = true; }
}
}
int mx;
rrep(i, 5100) {
if (dp[i][n]) {
mx = i + 1;
break;
}
}
int now = n;
for (int i = mx - 1; i > 0; i--) {
int can = 0;
int use;
rep2(j, 2, min(8, now + 1)) {
if (ex[j] > can && dp[i - 1][now - j]) {
can = ex[j];
use = j;
}
}
now -= use;
cout << can;
}
cout << endl;
}
| [
"literal.number.change",
"call.arguments.change"
] | 930,187 | 930,188 | u853721692 | cpp |
p03128 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rep2(i, s, n) for (int i = s; i < n; ++i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define tmax(a, b, c) max(a, max(b, c))
#define tmin(a, b, c) min(a, min(b, c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
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;
}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
bool dp[510][10100];
int main() {
int n, m;
cin >> n >> m;
vector<int> ex(8, 0);
rep(i, m) {
int a;
cin >> a;
int b;
if (a == 1)
b = 2;
else if (a == 7)
b = 3;
else if (a == 4)
b = 4;
else if (a == 2 || a == 3 || a == 5)
b = 5;
else if (a == 6 || a == 9)
b = 6;
else
b = 7;
chmax(ex[b], a);
}
rep(i, 510) rep(j, 10100) dp[i][j] = false;
dp[0][0] = true;
rep(i, 509) {
rep(j, n + 1) {
if (!dp[i][j])
continue;
rep2(k, 2, 7) if (ex[k] > 0) { dp[i + 1][j + k] = true; }
}
}
int mx;
rrep(i, 510) {
if (dp[i][n]) {
mx = i + 1;
break;
}
}
int now = n;
for (int i = mx - 1; i > 0; i--) {
int can = 0;
int use;
rep2(j, 2, min(8, now + 1)) {
if (ex[j] > can && dp[i - 1][now - j]) {
can = ex[j];
use = j;
}
}
now -= use;
cout << can;
}
cout << endl;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rep2(i, s, n) for (int i = s; i < n; ++i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define tmax(a, b, c) max(a, max(b, c))
#define tmin(a, b, c) min(a, min(b, c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
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;
}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
bool dp[5100][10100];
int main() {
int n, m;
cin >> n >> m;
vector<int> ex(8, 0);
rep(i, m) {
int a;
cin >> a;
int b;
if (a == 1)
b = 2;
else if (a == 7)
b = 3;
else if (a == 4)
b = 4;
else if (a == 2 || a == 3 || a == 5)
b = 5;
else if (a == 6 || a == 9)
b = 6;
else
b = 7;
chmax(ex[b], a);
}
rep(i, 5100) rep(j, 10100) dp[i][j] = false;
dp[0][0] = true;
rep(i, 5099) {
rep(j, n + 1) {
if (!dp[i][j])
continue;
rep2(k, 2, 8) if (ex[k] > 0) { dp[i + 1][j + k] = true; }
}
}
int mx;
rrep(i, 5100) {
if (dp[i][n]) {
mx = i + 1;
break;
}
}
int now = n;
for (int i = mx - 1; i > 0; i--) {
int can = 0;
int use;
rep2(j, 2, min(8, now + 1)) {
if (ex[j] > can && dp[i - 1][now - j]) {
can = ex[j];
use = j;
}
}
now -= use;
cout << can;
}
cout << endl;
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change",
"call.arguments.change"
] | 930,189 | 930,188 | u853721692 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
#define rep1(i, N) for (int i = 1; i < int(N); ++i)
#define all(a) (a).begin(), (a).end()
#define print(v) \
{ \
cerr << #v << ": [ "; \
for (auto _ : v) \
cerr << _ << ", "; \
cerr << "]" << endl; \
}
#define printpair(v) \
{ \
cerr << #v << ": [ "; \
for (auto _ : v) \
cerr << "{" << _.first << "," << _.second << "}" \
<< ", "; \
cerr << "]" << endl; \
}
#define dump(x) cerr << #x << ": " << x << endl;
#define bit(k) (1LL << (k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const int INF = (ll)1e9;
const ll INFLL = (ll)1e18 + 1;
const ll MOD = (ll)1e9 + 7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
const string MINUSINF = "-";
void chmax(string &a, string b) {
if (a == MINUSINF)
a = b;
else if (a.size() < b.size())
a = b;
else if (a.size() == b.size()) {
if (a < b)
a = b;
}
}
// dp[i]: i本使って作れる数字の最大値
int cost[] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int N, M;
cin >> N >> M;
vector<int> A(N);
rep(i, M) cin >> A[i];
vector<string> dp(N + 1, MINUSINF);
dp[0] = "";
rep(i, N) {
if (dp[i] == MINUSINF)
continue;
rep(j, M) {
if (i + cost[A[j]] > N)
continue;
chmax(dp[i + cost[A[j]]], dp[i] + char('0' + A[j]));
}
}
cout << dp[N] << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
#define rep1(i, N) for (int i = 1; i < int(N); ++i)
#define all(a) (a).begin(), (a).end()
#define print(v) \
{ \
cerr << #v << ": [ "; \
for (auto _ : v) \
cerr << _ << ", "; \
cerr << "]" << endl; \
}
#define printpair(v) \
{ \
cerr << #v << ": [ "; \
for (auto _ : v) \
cerr << "{" << _.first << "," << _.second << "}" \
<< ", "; \
cerr << "]" << endl; \
}
#define dump(x) cerr << #x << ": " << x << endl;
#define bit(k) (1LL << (k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const int INF = (ll)1e9;
const ll INFLL = (ll)1e18 + 1;
const ll MOD = (ll)1e9 + 7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
const string MINUSINF = "-";
void chmax(string &a, string b) {
if (a == MINUSINF)
a = b;
else if (a.size() < b.size())
a = b;
else if (a.size() == b.size()) {
if (a < b)
a = b;
}
}
// dp[i]: i本使って作れる数字の最大値
int cost[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int N, M;
cin >> N >> M;
vector<int> A(M);
rep(i, M) cin >> A[i];
vector<string> dp(N + 1, MINUSINF);
dp[0] = "";
rep(i, N) {
if (dp[i] == MINUSINF)
continue;
rep(j, M) {
if (i + cost[A[j]] > N)
continue;
chmax(dp[i + cost[A[j]]], dp[i] + char('0' + A[j]));
}
}
cout << dp[N] << endl;
} | [
"literal.number.change"
] | 930,218 | 930,219 | u106297876 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
vector<int> maxvec(vector<int> &a, vector<int> &b) {
if (a[0] > b[0])
return a;
if (a[0] < b[0])
return b;
for (int i = 9; i >= 1; i--) {
if (a[i] > b[i])
return a;
if (a[i] < b[i])
return b;
}
return a;
}
int main() {
int N, M;
cin >> N >> M;
vector<int> A = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<int> Acheck(N, 0);
for (int i = 0; i < M; i++) {
int Ai;
cin >> Ai;
Acheck[Ai] = 1;
}
for (int i = 0; i < 10; i++)
A[i] *= Acheck[i];
vector<vector<int>> dp(N + 1, vector<int>(10, -1));
dp[0] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (int i = 0; i <= N; i++) {
vector<int> vec = {INT_MIN};
for (int j = 0; j < 10; j++) {
if (A[j] != 0 and i - A[j] >= 0) {
if (dp[i - A[j]][0] != -1) {
vector<int> tmp = dp[i - A[j]];
tmp[0]++;
tmp[j]++;
vec = maxvec(vec, tmp);
}
}
}
dp[i] = maxvec(dp[i], vec);
}
for (int i = 9; i >= 1; i--) {
for (int j = 0; j < dp[N][i]; j++) {
cout << i;
}
}
cout << endl;
} | #include <bits/stdc++.h>
using namespace std;
vector<int> maxvec(vector<int> &a, vector<int> &b) {
if (a[0] > b[0])
return a;
if (a[0] < b[0])
return b;
for (int i = 9; i >= 1; i--) {
if (a[i] > b[i])
return a;
if (a[i] < b[i])
return b;
}
return a;
}
int main() {
int N, M;
cin >> N >> M;
vector<int> A = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<int> Acheck(10, 0);
for (int i = 0; i < M; i++) {
int Ai;
cin >> Ai;
Acheck[Ai] = 1;
}
for (int i = 0; i < 10; i++)
A[i] *= Acheck[i];
vector<vector<int>> dp(N + 1, vector<int>(10, -1));
dp[0] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (int i = 0; i <= N; i++) {
vector<int> vec = {INT_MIN};
for (int j = 0; j < 10; j++) {
if (A[j] != 0 and i - A[j] >= 0) {
if (dp[i - A[j]][0] != -1) {
vector<int> tmp = dp[i - A[j]];
tmp[0]++;
tmp[j]++;
vec = maxvec(vec, tmp);
}
}
}
dp[i] = maxvec(dp[i], vec);
}
for (int i = 9; i >= 1; i--) {
for (int j = 0; j < dp[N][i]; j++) {
cout << i;
}
}
cout << endl;
} | [
"identifier.replace.remove",
"literal.replace.add",
"call.arguments.change"
] | 930,286 | 930,287 | u544437817 | cpp |
p03128 | #include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main(void) {
int match[10] = {10, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int N, M;
cin >> N >> M;
vector<int> A(M);
for (int i = 0; i < M; i++) {
cin >> A[i];
}
vector<int> dp(N + 1, -1);
dp[0] = 0;
for (int i = 1; i < N + 1; i++) {
for (int k = 0; k < M; k++) {
int leftMatch = i - match[A[k]];
if (leftMatch >= 0 && dp[leftMatch] >= 0) {
dp[i] = max(dp[i], dp[leftMatch] + 1);
}
}
}
sort(A.begin(), A.end(), greater<int>());
string ans = "";
int digit = dp[N];
for (int i = 0; i < digit; i++) {
for (int k = 0; k < M; k++) {
if (N - match[A[k]] && dp[N - match[A[k]]] == (dp[N] - 1)) {
ans += to_string(A[k]);
N -= match[A[k]];
break;
}
}
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main(void) {
int match[10] = {10, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int N, M;
cin >> N >> M;
vector<int> A(M);
for (int i = 0; i < M; i++) {
cin >> A[i];
}
vector<int> dp(N + 1, -1);
dp[0] = 0;
for (int i = 1; i < N + 1; i++) {
for (int k = 0; k < M; k++) {
int leftMatch = i - match[A[k]];
if (leftMatch >= 0 && dp[leftMatch] >= 0) {
dp[i] = max(dp[i], dp[leftMatch] + 1);
}
}
}
sort(A.begin(), A.end(), greater<int>());
string ans = "";
int digit = dp[N];
for (int i = 0; i < digit; i++) {
for (int k = 0; k < M; k++) {
if (N - match[A[k]] >= 0 && dp[N - match[A[k]]] == (dp[N] - 1)) {
ans += to_string(A[k]);
N -= match[A[k]];
break;
}
}
}
cout << ans << endl;
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 930,311 | 930,312 | u494037974 | cpp |
p03128 | #include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int N, M;
bool used[10] = {}; // used[i]: iを使う
int cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string n_to_s = "0123456789";
string dp[10001]; // dp[i]:i本の中で作れる数の各桁の数字の内訳
bool comp_str(string a, string b) {
// aがbより大きい数字を作れるのならtrue そうでないのならfalse
int cnt_a[10], cnt_b[10];
for (int i = 0; i < a.size(); i++) {
cnt_a[a[i] - '0']++;
}
for (int i = 0; i < b.size(); i++) {
cnt_b[b[i] - '0']++;
}
if (a.size() > b.size())
return true;
else if (a.size() < b.size())
return false;
for (int j = 9; j >= 0; j--) {
if (cnt_a[j] == 0 && cnt_b[j] == 0) {
continue;
} else if (cnt_a[j] > cnt_b[j])
return true;
else if (cnt_a[j] < cnt_b[j])
return false;
}
return true;
}
int main() {
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a;
cin >> a;
used[a] = true;
}
for (int i = 0; i <= N; i++) {
if (dp[i] == "" && i != 0)
continue;
for (int j = 1; j <= 9; j++) {
if (used[j] && i + cost[j] <= N) {
if (dp[i + cost[j]] == "") {
dp[i + cost[j]] = dp[i] + n_to_s[j];
} else {
if (!comp_str(dp[i + cost[j]], dp[i] + n_to_s[j])) {
dp[i + cost[j]] = dp[i] + n_to_s[j];
}
}
}
}
}
//出力
int cnt[10] = {};
for (int i = 0; i < dp[N].size(); i++) {
cnt[dp[N][i] - '0']++;
}
for (int i = 9; i >= 1; i--) {
for (int j = 0; j < cnt[i]; j++) {
cout << i;
}
}
cout << endl;
return 0;
} | #include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int N, M;
bool used[10] = {}; // used[i]: iを使う
int cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string n_to_s = "0123456789";
string dp[10001]; // dp[i]:i本の中で作れる数の各桁の数字の内訳
bool comp_str(string a, string b) {
// aがbより大きい数字を作れるのならtrue そうでないのならfalse
int cnt_a[10] = {}, cnt_b[10] = {};
for (int i = 0; i < a.size(); i++) {
cnt_a[a[i] - '0']++;
}
for (int i = 0; i < b.size(); i++) {
cnt_b[b[i] - '0']++;
}
if (a.size() > b.size())
return true;
else if (a.size() < b.size())
return false;
for (int j = 9; j >= 0; j--) {
if (cnt_a[j] == 0 && cnt_b[j] == 0) {
continue;
} else if (cnt_a[j] > cnt_b[j])
return true;
else if (cnt_a[j] < cnt_b[j])
return false;
}
return true;
}
int main() {
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a;
cin >> a;
used[a] = true;
}
for (int i = 0; i <= N; i++) {
if (dp[i] == "" && i != 0)
continue;
for (int j = 1; j <= 9; j++) {
if (used[j] && i + cost[j] <= N) {
if (dp[i + cost[j]] == "") {
dp[i + cost[j]] = dp[i] + n_to_s[j];
} else {
if (!comp_str(dp[i + cost[j]], dp[i] + n_to_s[j])) {
dp[i + cost[j]] = dp[i] + n_to_s[j];
}
}
}
}
}
//出力
int cnt[10] = {};
for (int i = 0; i < dp[N].size(); i++) {
cnt[dp[N][i] - '0']++;
}
for (int i = 9; i >= 1; i--) {
for (int j = 0; j < cnt[i]; j++) {
cout << i;
}
}
cout << endl;
return 0;
} | [
"variable_declaration.value.change"
] | 930,317 | 930,318 | u107077805 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using pi = pair<int32, int32>;
using pll = pair<int64, int64>;
using vi = vector<int32>;
using vvi = vector<vector<int32>>;
using vll = vector<int64>;
using ll = int64;
using ull = uint64;
constexpr int32 INF = 1 << 30;
constexpr ll INFLL = 1LL << 62;
#define all(x) x.begin(), x.end()
#define LB(V, x) lower_bound(all(V), x) - V.begin()
#define uint uint32
void Main() {
int N, M, Cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
cin >> N >> M;
vi P(8, 0);
while (M--) {
int32 a;
cin >> a;
P[Cost[a]] = max(a, P[Cost[a]]);
}
vi U;
for (int i = 2; i < 8; i++)
if (P[i] != 0)
U.push_back(i);
vvi dp(N + 1, vi(8, -1));
dp[0] = vi(8, 0);
vi H = U;
for (auto &h : H)
h = P[h];
sort(all(H), greater<int>());
for (auto &h : H)
h = Cost[h];
for (int i = 2; i <= N; i++) {
for (auto u : U) {
if ((u <= i) && (dp[i - u][0] != -1)) {
vi temp = dp[i - u];
temp[u]++;
int tempS = accumulate(all(temp), 0);
int dpS = accumulate(all(dp[i]), 0);
if (tempS > dpS)
dp[i] = temp;
else if (tempS == dpS) {
for (auto h : H)
if (temp[h] > dp[i][h])
dp[i] = temp;
else if (temp[h] > dp[i][h])
break;
else if (temp[h] == dp[i][h])
continue;
}
}
}
}
vi Ans(accumulate(all(dp[N]), 0));
int j = 0;
for (int i = 2; i < 8; i++) {
while (dp[N][i]--)
Ans[j++] = P[i];
}
sort(all(Ans), greater<int32>());
for (auto ans : Ans)
cout << ans;
cout << endl;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
Main();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using pi = pair<int32, int32>;
using pll = pair<int64, int64>;
using vi = vector<int32>;
using vvi = vector<vector<int32>>;
using vll = vector<int64>;
using ll = int64;
using ull = uint64;
constexpr int32 INF = 1 << 30;
constexpr ll INFLL = 1LL << 62;
#define all(x) x.begin(), x.end()
#define LB(V, x) lower_bound(all(V), x) - V.begin()
#define uint uint32
void Main() {
int N, M, Cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
cin >> N >> M;
vi P(8, 0);
while (M--) {
int32 a;
cin >> a;
P[Cost[a]] = max(a, P[Cost[a]]);
}
vi U;
for (int i = 2; i < 8; i++)
if (P[i] != 0)
U.push_back(i);
vvi dp(N + 1, vi(8, -1));
dp[0] = vi(8, 0);
vi H = U;
for (auto &h : H)
h = P[h];
sort(all(H), greater<int>());
for (auto &h : H)
h = Cost[h];
for (int i = 2; i <= N; i++) {
for (auto u : U) {
if ((u <= i) && (dp[i - u][0] != -1)) {
vi temp = dp[i - u];
temp[u]++;
int tempS = accumulate(all(temp), 0);
int dpS = accumulate(all(dp[i]), 0);
if (tempS > dpS)
dp[i] = temp;
else if (tempS == dpS) {
for (auto h : H)
if (temp[h] > dp[i][h])
dp[i] = temp;
else if (temp[h] < dp[i][h])
break;
else if (temp[h] == dp[i][h])
continue;
}
}
}
}
vi Ans(accumulate(all(dp[N]), 0));
int j = 0;
for (int i = 2; i < 8; i++) {
while (dp[N][i]--)
Ans[j++] = P[i];
}
sort(all(Ans), greater<int32>());
for (auto ans : Ans)
cout << ans;
cout << endl;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
Main();
return 0;
} | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 930,340 | 930,341 | u572532976 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
int dic[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
bool compare(vi atk, int j, vi def) {
int m = atk.size();
atk.at(j)++;
int a = 0;
int d = 0;
rep(i, m) {
a += atk.at(i);
d += def.at(i);
}
if (a > d)
return true;
else
return false;
rep(i, m) {
if (atk.at(i) == def.at(i))
continue;
if (atk.at(i) > def.at(i))
return true;
else
return false;
}
}
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
rep(i, m) cin >> a.at(i);
sort(a.begin(), a.end(), greater<int>());
vector<vector<int>> dp(n + 1, vector<int>(m, 0));
// rep(i,m) dp.at(0).at(i) = 0;
vector<bool> flag(n + 1, false);
flag.at(0) = true;
rep(i, n) {
// if(dp.at(i).at(0) == -1) continue;
if (!flag.at(i))
continue;
rep(j, m) {
int num = a.at(j);
int match = dic[num];
if (i + match > n)
continue;
flag.at(i + match) = true;
if (compare(dp.at(i), j, dp.at(i + match))) {
rep(k, m) {
if (k == j)
dp.at(i + match).at(k) = dp.at(i).at(k) + 1;
else
dp.at(i + match).at(k) = dp.at(i).at(k);
}
}
}
}
int cnt = 0;
rep(i, m) {
rep(j, dp.at(n).at(i)) {
cout << a.at(i);
cnt += dic[a.at(i)];
}
}
cout << endl;
// cout << cnt << endl;
/*rep(i,n+1){
cout << i << ":";
rep(j,m) cout << dp.at(i).at(j);
cout << endl;
}*/
} | #include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
int dic[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
bool compare(vi atk, int j, vi def) {
int m = atk.size();
atk.at(j)++;
int a = 0;
int d = 0;
rep(i, m) {
a += atk.at(i);
d += def.at(i);
}
if (a > d)
return true;
else if (a < d)
return false;
rep(i, m) {
if (atk.at(i) == def.at(i))
continue;
if (atk.at(i) > def.at(i))
return true;
else
return false;
}
}
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
rep(i, m) cin >> a.at(i);
sort(a.begin(), a.end(), greater<int>());
vector<vector<int>> dp(n + 1, vector<int>(m, 0));
// rep(i,m) dp.at(0).at(i) = 0;
vector<bool> flag(n + 1, false);
flag.at(0) = true;
rep(i, n) {
// if(dp.at(i).at(0) == -1) continue;
if (!flag.at(i))
continue;
rep(j, m) {
int num = a.at(j);
int match = dic[num];
if (i + match > n)
continue;
flag.at(i + match) = true;
if (compare(dp.at(i), j, dp.at(i + match))) {
rep(k, m) {
if (k == j)
dp.at(i + match).at(k) = dp.at(i).at(k) + 1;
else
dp.at(i + match).at(k) = dp.at(i).at(k);
}
}
}
}
int cnt = 0;
rep(i, m) {
rep(j, dp.at(n).at(i)) {
cout << a.at(i);
cnt += dic[a.at(i)];
}
}
cout << endl;
// cout << cnt << endl;
/*rep(i,n+1){
cout << i << ":";
rep(j,m) cout << dp.at(i).at(j);
cout << endl;
}*/
} | [
"control_flow.branch.if.add"
] | 930,386 | 930,387 | u184335045 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
#define int long long
string INF = "-";
int match[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[10001]; //マッチi本で作れる最大数
string chmax(string s, string t) {
if (s == INF)
return t;
if (s.size() < t.size())
return t;
if (s.size() == s.size() && s < t)
return t;
return s;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> a(m);
for (int i = 0; i < m; i++) {
cin >> a[i];
}
fill(dp, dp + 10001, INF);
dp[0] = "";
for (int i = 0; i <= n; i++) {
if (dp[i] == INF)
continue;
for (auto x : a) {
dp[i + match[x - 1]] = chmax(dp[i + match[x - 1]], dp[i] + to_string(x));
}
}
cout << dp[n] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
string INF = "-";
int match[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[10001 + 9]; //マッチi本で作れる最大数
string chmax(string s, string t) {
if (s == INF)
return t;
if (s.size() < t.size())
return t;
if (s.size() == s.size() && s < t)
return t;
return s;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> a(m);
for (int i = 0; i < m; i++) {
cin >> a[i];
}
fill(dp, dp + 10001 + 9, INF);
dp[0] = "";
for (int i = 0; i < n; i++) {
if (dp[i] == INF)
continue;
for (auto x : a) {
dp[i + match[x - 1]] = chmax(dp[i + match[x - 1]], dp[i] + to_string(x));
}
}
cout << dp[n] << endl;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 930,424 | 930,423 | u344122377 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string MINF = "-";
void chmax(string &a, string b) {
if (a == MINF)
a = b;
else if (b.size() > a.size())
a = b;
else if (b.size() < a.size())
return;
else if (a < b)
a = b;
}
int main() {
int N, M;
cin >> N >> M;
vector<int> a(M);
for (int i = 0; i < M; i++)
cin >> a[i];
int match[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string MINF = "-";
vector<string> dp(N + 5, MINF);
dp[0] = "";
for (int i = 0; i < N; i++) {
if (dp[i] == MINF)
continue;
for (int j = 0; j < M; j++) {
chmax(dp[i + match[a[j]]], dp[i] + (char)(a[j] + '0'));
chmax(dp[i + match[a[j]]], (char)(a[j] + '0') + dp[i]);
}
}
cout << dp[N] << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string MINF = "-";
void chmax(string &a, string b) {
if (a == MINF)
a = b;
else if (b.size() > a.size())
a = b;
else if (b.size() < a.size())
return;
else if (a < b)
a = b;
}
int main() {
int N, M;
cin >> N >> M;
vector<int> a(M);
for (int i = 0; i < M; i++)
cin >> a[i];
int match[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string MINF = "-";
vector<string> dp(N + 50, MINF);
dp[0] = "";
for (int i = 0; i < N; i++) {
if (dp[i] == MINF)
continue;
for (int j = 0; j < M; j++) {
chmax(dp[i + match[a[j]]], dp[i] + (char)(a[j] + '0'));
chmax(dp[i + match[a[j]]], (char)(a[j] + '0') + dp[i]);
}
}
cout << dp[N] << endl;
} | [
"literal.number.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 930,454 | 930,455 | u052332717 | cpp |
p03128 | #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i, N) for (ll i = 0; i < N; i++)
#define loop(i, N, M) for (ll i = N; i < M; i++)
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define SORTL2S(type, v) sort(v.begin(), v.end(), greater<type>())
#define SORTS2L(type, v) sort(v.begin(), v.end())
#define SORTMF(v, func) sort(v.begin(), v.end(), func)
ll debugFlag = false;
template <typename T> void debug(T &);
template <typename T> void debug(T &, bool);
template <typename T> void debug(vector<T> &);
template <typename T> void debug(vector<T> &, bool);
template <typename T, typename U> void debug(pair<T, U> &);
template <typename T, typename U> void debug(pair<T, U> &, bool);
template <typename T> void debug(T &obj) { debug(obj, true); }
template <typename T> void debug(T &obj, bool lnFlag) {
if (!debugFlag)
return;
cout << obj;
if (lnFlag)
cout << endl;
}
template <typename T> void debug(vector<T> &obj) { debug(obj, true); }
template <typename T> void debug(vector<T> &obj, bool lnFlag) {
if (!debugFlag)
return;
cout << "[";
rep(i, obj.size()) {
if (i != 0)
cout << ",";
debug(obj[i], false);
}
cout << "]";
if (lnFlag)
cout << endl;
}
template <typename T, typename U> void debug(pair<T, U> &obj) {
debug(obj, true);
}
template <typename T, typename U> void debug(pair<T, U> &obj, bool lnFlag) {
if (!debugFlag)
return;
cout << "(";
debug(obj.first, false);
cout << ",";
debug(obj.second, false);
cout << ")";
if (lnFlag)
cout << endl;
}
const vector<int> match = {0, 2, 5, 5, 4, 5, 6, 3, 7, 8};
ll N, M;
vector<ll> vec;
vector<ll> check(const vector<ll> &x, const vector<ll> &y, ll sum) {
ll sumX = 0, sumY = 0;
ll cntX = 0, cntY = 0;
rep(i, x.size()) {
sumX += x[i] * match[vec[i]];
sumY += y[i] * match[vec[i]];
cntX += x[i];
cntY += y[i];
}
if (sumX != sum && sumY != sum) {
return vector<ll>(M, 0);
}
if (sumX == sum && sumY != sum) {
return x;
}
if (sumX != sum && sumY == sum) {
return y;
}
if (cntX > cntY)
return x;
if (cntX < cntY)
return y;
rep(i, x.size()) {
if (x[i] > y[i])
return x;
if (x[i] < y[i])
return y;
}
return x;
}
void solve() {
cin >> N >> M;
vec.resize(M);
rep(i, M) cin >> vec[i];
SORTL2S(ll, vec);
vector<vector<ll>> dp(N + 1, vector<ll>(M, 0));
vector<ll> cnt(N + 1);
for (ll i = 1; i <= N; i++) {
vector<ll> best(M, 0);
rep(j, M) {
if (i < match[vec[j]])
continue;
vector<ll> tmp = dp[i - match[vec[j]]];
tmp[j]++;
best = check(best, tmp, i);
}
dp[i] = best;
debug(dp[i]);
}
rep(i, M) { rep(j, dp[N][i]) cout << vec[i]; }
}
int main(int argc, char *argv[]) {
if (argc == 2 && string(argv[1]) == "debug")
debugFlag = true;
solve();
cout << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i, N) for (ll i = 0; i < N; i++)
#define loop(i, N, M) for (ll i = N; i < M; i++)
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define SORTL2S(type, v) sort(v.begin(), v.end(), greater<type>())
#define SORTS2L(type, v) sort(v.begin(), v.end())
#define SORTMF(v, func) sort(v.begin(), v.end(), func)
ll debugFlag = false;
template <typename T> void debug(T &);
template <typename T> void debug(T &, bool);
template <typename T> void debug(vector<T> &);
template <typename T> void debug(vector<T> &, bool);
template <typename T, typename U> void debug(pair<T, U> &);
template <typename T, typename U> void debug(pair<T, U> &, bool);
template <typename T> void debug(T &obj) { debug(obj, true); }
template <typename T> void debug(T &obj, bool lnFlag) {
if (!debugFlag)
return;
cout << obj;
if (lnFlag)
cout << endl;
}
template <typename T> void debug(vector<T> &obj) { debug(obj, true); }
template <typename T> void debug(vector<T> &obj, bool lnFlag) {
if (!debugFlag)
return;
cout << "[";
rep(i, obj.size()) {
if (i != 0)
cout << ",";
debug(obj[i], false);
}
cout << "]";
if (lnFlag)
cout << endl;
}
template <typename T, typename U> void debug(pair<T, U> &obj) {
debug(obj, true);
}
template <typename T, typename U> void debug(pair<T, U> &obj, bool lnFlag) {
if (!debugFlag)
return;
cout << "(";
debug(obj.first, false);
cout << ",";
debug(obj.second, false);
cout << ")";
if (lnFlag)
cout << endl;
}
const vector<int> match = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
ll N, M;
vector<ll> vec;
vector<ll> check(const vector<ll> &x, const vector<ll> &y, ll sum) {
ll sumX = 0, sumY = 0;
ll cntX = 0, cntY = 0;
rep(i, x.size()) {
sumX += x[i] * match[vec[i]];
sumY += y[i] * match[vec[i]];
cntX += x[i];
cntY += y[i];
}
if (sumX != sum && sumY != sum) {
return vector<ll>(M, 0);
}
if (sumX == sum && sumY != sum) {
return x;
}
if (sumX != sum && sumY == sum) {
return y;
}
if (cntX > cntY)
return x;
if (cntX < cntY)
return y;
rep(i, x.size()) {
if (x[i] > y[i])
return x;
if (x[i] < y[i])
return y;
}
return x;
}
void solve() {
cin >> N >> M;
vec.resize(M);
rep(i, M) cin >> vec[i];
SORTL2S(ll, vec);
vector<vector<ll>> dp(N + 1, vector<ll>(M, 0));
vector<ll> cnt(N + 1);
for (ll i = 1; i <= N; i++) {
vector<ll> best(M, 0);
rep(j, M) {
if (i < match[vec[j]])
continue;
vector<ll> tmp = dp[i - match[vec[j]]];
tmp[j]++;
best = check(best, tmp, i);
}
dp[i] = best;
debug(dp[i]);
}
rep(i, M) { rep(j, dp[N][i]) cout << vec[i]; }
}
int main(int argc, char *argv[]) {
if (argc == 2 && string(argv[1]) == "debug")
debugFlag = true;
solve();
cout << endl;
return 0;
}
| [
"literal.number.change"
] | 930,467 | 930,468 | u426855695 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define BR "\n"
#define SP " "
#define SHOW(x) \
for (int i = 0; i < x.size(); i++) { \
cout << x[i] << SP; \
} \
cout << BR;
#define SHOW2(x) \
for (int j = 0; j < x.size(); j++) { \
SHOW(x[j]); \
} \
cout << BR;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> A(10, 0);
vector<ll> stick = {2, 5, 5, 4, 5, 6, 3, 7, 6};
for (int i = 0; i < M; i++) {
int temp;
cin >> temp;
A[temp] = 1;
}
vector<string> dp(1001, "");
for (int i = 0; i < 9; i++) {
if (A[i] == 0)
continue;
ll s = stick[i];
for (int j = 0; j < N; j++) {
if (j + s > N)
break;
if (dp[j] == "" && j > 0)
continue;
string oldString = dp[j + s];
string newString = to_string(i) + dp[j];
if ((newString.length() > oldString.length()) ||
(newString.length() == oldString.length()) &&
(newString > oldString)) {
dp[j + s] = newString;
}
}
}
cout << dp[N] << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define BR "\n"
#define SP " "
#define SHOW(x) \
for (int i = 0; i < x.size(); i++) { \
cout << x[i] << SP; \
} \
cout << BR;
#define SHOW2(x) \
for (int j = 0; j < x.size(); j++) { \
SHOW(x[j]); \
} \
cout << BR;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> A(10, 0);
vector<ll> stick = {2, 5, 5, 4, 5, 6, 3, 7, 6};
for (int i = 0; i < M; i++) {
int temp;
cin >> temp;
A[temp] = 1;
}
vector<string> dp(10001, "");
for (int i = 1; i < 10; i++) {
if (A[i] == 0)
continue;
ll s = stick[i - 1];
for (int j = 0; j < N; j++) {
if (j + s > N)
break;
if (dp[j] == "" && j > 0)
continue;
string oldString = dp[j + s];
string newString = to_string(i) + dp[j];
if ((newString.length() > oldString.length()) ||
(newString.length() == oldString.length()) &&
(newString > oldString)) {
dp[j + s] = newString;
}
}
}
cout << dp[N] << "\n";
return 0;
} | [
"literal.number.change",
"call.arguments.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 930,479 | 930,478 | u339233484 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define BR "\n"
#define SP " "
#define SHOW(x) \
for (int i = 0; i < x.size(); i++) { \
cout << x[i] << SP; \
} \
cout << BR;
#define SHOW2(x) \
for (int j = 0; j < x.size(); j++) { \
SHOW(x[j]); \
} \
cout << BR;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> A(10, 0);
vector<ll> stick = {2, 5, 5, 4, 5, 6, 3, 7, 6};
for (int i = 0; i < M; i++) {
int temp;
cin >> temp;
A[temp] = 1;
}
vector<string> dp(1001, "");
for (int i = 0; i < 9; i++) {
if (A[i] == 0)
continue;
ll s = stick[i - 1];
for (int j = 0; j < N; j++) {
if (j + s > N)
break;
if (dp[j] == "" && j > 0)
continue;
string oldString = dp[j + s];
string newString = to_string(i) + dp[j];
if ((newString.length() > oldString.length()) ||
(newString.length() == oldString.length()) &&
(newString > oldString)) {
dp[j + s] = newString;
}
}
}
cout << dp[N] << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define BR "\n"
#define SP " "
#define SHOW(x) \
for (int i = 0; i < x.size(); i++) { \
cout << x[i] << SP; \
} \
cout << BR;
#define SHOW2(x) \
for (int j = 0; j < x.size(); j++) { \
SHOW(x[j]); \
} \
cout << BR;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> A(10, 0);
vector<ll> stick = {2, 5, 5, 4, 5, 6, 3, 7, 6};
for (int i = 0; i < M; i++) {
int temp;
cin >> temp;
A[temp] = 1;
}
vector<string> dp(10001, "");
for (int i = 1; i < 10; i++) {
if (A[i] == 0)
continue;
ll s = stick[i - 1];
for (int j = 0; j < N; j++) {
if (j + s > N)
break;
if (dp[j] == "" && j > 0)
continue;
string oldString = dp[j + s];
string newString = to_string(i) + dp[j];
if ((newString.length() > oldString.length()) ||
(newString.length() == oldString.length()) &&
(newString > oldString)) {
dp[j + s] = newString;
}
}
}
cout << dp[N] << "\n";
return 0;
} | [
"literal.number.change",
"call.arguments.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 930,480 | 930,478 | u339233484 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define BR "\n"
#define SP " "
#define SHOW(x) \
for (int i = 0; i < x.size(); i++) { \
cout << x[i] << SP; \
} \
cout << BR;
#define SHOW2(x) \
for (int j = 0; j < x.size(); j++) { \
SHOW(x[j]); \
} \
cout << BR;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> A(10, 0);
vector<ll> stick = {2, 5, 5, 4, 5, 6, 3, 7, 6};
for (int i = 0; i < M; i++) {
int temp;
cin >> temp;
A[temp] = 1;
}
vector<string> dp(501, "");
for (int i = 0; i < 9; i++) {
if (A[i] == 0)
continue;
ll s = stick[i - 1];
for (int j = 0; j < N; j++) {
if (j + s > N)
break;
if (dp[j] == "" && j > 0)
continue;
string oldString = dp[j + s];
string newString = to_string(i) + dp[j];
if ((newString.length() > oldString.length()) ||
(newString.length() == oldString.length()) &&
(newString > oldString)) {
dp[j + s] = newString;
}
}
}
cout << dp[N] << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define BR "\n"
#define SP " "
#define SHOW(x) \
for (int i = 0; i < x.size(); i++) { \
cout << x[i] << SP; \
} \
cout << BR;
#define SHOW2(x) \
for (int j = 0; j < x.size(); j++) { \
SHOW(x[j]); \
} \
cout << BR;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> A(10, 0);
vector<ll> stick = {2, 5, 5, 4, 5, 6, 3, 7, 6};
for (int i = 0; i < M; i++) {
int temp;
cin >> temp;
A[temp] = 1;
}
vector<string> dp(10001, "");
for (int i = 1; i < 10; i++) {
if (A[i] == 0)
continue;
ll s = stick[i - 1];
for (int j = 0; j < N; j++) {
if (j + s > N)
break;
if (dp[j] == "" && j > 0)
continue;
string oldString = dp[j + s];
string newString = to_string(i) + dp[j];
if ((newString.length() > oldString.length()) ||
(newString.length() == oldString.length()) &&
(newString > oldString)) {
dp[j + s] = newString;
}
}
}
cout << dp[N] << "\n";
return 0;
} | [
"literal.number.change",
"call.arguments.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 930,481 | 930,478 | u339233484 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
const int num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[2][10010];
bool cmp(const string &s, const string &t) {
if (t == "#")
return true;
if (s.size() != t.size()) {
return (s.size() > t.size()) ? true : false;
}
int size = s.size();
rep(i, size) {
if (s[i] != t[i]) {
return (s[i] > t[i]) ? true : false;
}
}
}
int main(int argc, char const *argv[]) {
int n, m;
cin >> n >> m;
vector<int> a(m);
rep(i, m) cin >> a[i];
rep(i, 2) rep(j, 10010) dp[i][j] = "#";
dp[0][0] = "";
rep(i, n) {
rep(j, 10010) dp[(i + 1) % 2][j] = dp[i % 2][j];
rep(j, m) {
if (dp[i % 2][i] == "#")
continue;
if (i + num[a[j]] > n)
continue;
// dp[(i + 1) % 2][i + num[a[j]]] = max(dp[i % 2][i] * 10 + a[j], dp[i %
// 2][i + num[a[j]]]);
if (cmp(dp[i % 2][i] + to_string(a[i]), dp[(i + 1) % 2][i + num[a[j]]])) {
dp[(i + 1) % 2][i + num[a[j]]] = dp[i % 2][i] + to_string(a[j]);
}
// printf("i %d dp[%d] (%d) = dp[%d] (%d)\n", i, i + num[a[j]], dp[(i + 1)
// % 2][i + num[a[j]]], i, dp[i % 2][i]);
}
}
cout << dp[n % 2][n] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
const int num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[2][10010];
bool cmp(const string &s, const string &t) {
if (t == "#")
return true;
if (s.size() != t.size()) {
return (s.size() > t.size()) ? true : false;
}
int size = s.size();
rep(i, size) {
if (s[i] != t[i]) {
return (s[i] > t[i]) ? true : false;
}
}
}
int main(int argc, char const *argv[]) {
int n, m;
cin >> n >> m;
vector<int> a(m);
rep(i, m) cin >> a[i];
rep(i, 2) rep(j, 10010) dp[i][j] = "#";
dp[0][0] = "";
rep(i, n) {
rep(j, 10010) dp[(i + 1) % 2][j] = dp[i % 2][j];
rep(j, m) {
if (dp[i % 2][i] == "#")
continue;
if (i + num[a[j]] > n)
continue;
if (cmp(dp[i % 2][i] + to_string(a[j]), dp[(i + 1) % 2][i + num[a[j]]])) {
dp[(i + 1) % 2][i + num[a[j]]] = dp[i % 2][i] + to_string(a[j]);
}
}
}
cout << dp[n % 2][n] << endl;
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 930,484 | 930,485 | u029876051 | cpp |
p03128 | #include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double
struct XX {
int b;
ll c;
};
class xxGreater {
public:
bool operator()(const XX &riLeft, const XX &riRight) const {
//第2条件
if ((riLeft.c) == (riRight.c)) {
return riLeft.b >
riRight.b; //<:昇順(小さいものから順番)、>:降順(大きいものから順番)
//プライオリティキューの場合は > で、top()すると値の小さいものがとれる
}
//第1条件
return (riLeft.c) > (riRight.c);
}
};
// map<long long,long long> prime_f(long long n){
// map<long long,long long>res;
// for(int i=2;i*i<=n;i++){
// while(n%i==0){
// ++res[i];
// n/=i;
// }
// }
// if(n!=1)res[n]=1;
// return res;
//}
// int n;
////int dat[2*10000000];
////int dat2[2*10000000];
// int dat[10];
// int dat2[10];
//
// void init(int n_){
// n=1;
// while(n<n_)n*=2;
// for(int i=0;i<2*n-1;i++){
// dat[i]=0;
// dat2[i]=0;
// }
//}
//
// void initset(int k,int a){
// k+=n-1;
// dat[k]=a;
// while(k>0){
// k=(k-1)/2;
// dat[k]=dat[k*2+1]+dat[k*2+2];
// }
//}
//
////[a,b)の間を[l,r]区間で比較しアップデート
////引数のindexに注意
////nは固定。initで計算すみ
////update2(L[i],R[i]+1,0,0,n,D[i]);
// void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
// if(r<=a || b<=l)return;
// if(a<=l && r<=b){
// dat[k]+=dat2[k];
// if(r-l>1){
// dat2[k*2+1]+=dat2[k]/2;
// dat2[k*2+1]+=dat2[k]/2;
// }
// dat2[k]=v*(r-l);
// return;
// }else{
// update2(a,b,k*2+1,l,(l+r)/2,v);
// update2(a,b,k*2+2,(l+r)/2,r,v);
// return;
// }
//}
//
// int query(int a,int b,int k,int l,int r){
// if(r<=a || b<=l)return 0;
// if(a<=l && r<=b){
// dat[k]+=dat2[k];
// if(r-l>1){
// dat2[k*2+1]+=dat2[k]/2;
// dat2[k*2+1]+=dat2[k]/2;
// }
// dat2[k]=0;
// return dat[k];
// }
// else{
// int vl=query(a,b,k*2+1,l,(l+r)/2);
// int vr=query(a,b,k*2+2,(l+r)/2,r);
// return vl+vr;
// }
//}
int main(int argc, const char *argv[]) {
// scanf("%s",S);
// scanf("%d",&N);
// scanf("%lld %lld",&target1,&target2);
// sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
// getline(cin, target);
// ifstream ifs("a.txt");//テスト用
// ifs >> a;
//ここから
//入力高速化
ios::sync_with_stdio(false);
cin.tie(0);
int N, M;
cin >> N >> M;
bool a[10];
for (int i = 0; i < 10; i++) {
a[i] = false;
}
for (int i = 0; i < M; i++) {
int tmp;
cin >> tmp;
a[tmp] = true;
}
// 1,7,4,5,9,8
// 2,3,4,5,6,7
int suji[] = {1, 7, 4, 5, 3, 2, 9, 6, 8};
int cost[] = {2, 3, 4, 5, 5, 5, 6, 6, 7};
string dp[10010]; // i:文字の長さ、j:残りのコスト
for (int p = 0; p < 9; p++) {
if (a[suji[p]]) {
dp[cost[p]] = '0' + suji[p];
}
}
for (int i = 1; i < N; i++) {
for (int p = 0; p < 9; p++) {
if (a[suji[p]] && dp[i] != "") {
string tmp = "";
tmp = '0' + suji[p];
if (dp[i + cost[p]].size() < dp[i].size() + 1) {
dp[i + cost[p]] = dp[i] + tmp;
} else if (dp[i + cost[p]].size() == dp[i].size() + 1) {
string t1 = dp[i + cost[p]];
string t2 = dp[i] + tmp;
if (t1 < t2) {
dp[i + cost[p]] = dp[i] + tmp;
}
}
}
}
}
cout << dp[N] << endl;
//ここまで
// cout << "ans" << endl;
// printf("%.0f\n",ans);//小数点以下表示なし
// printf("%.7f\n",p);
return 0;
}
| #include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double
struct XX {
int b;
ll c;
};
class xxGreater {
public:
bool operator()(const XX &riLeft, const XX &riRight) const {
//第2条件
if ((riLeft.c) == (riRight.c)) {
return riLeft.b >
riRight.b; //<:昇順(小さいものから順番)、>:降順(大きいものから順番)
//プライオリティキューの場合は > で、top()すると値の小さいものがとれる
}
//第1条件
return (riLeft.c) > (riRight.c);
}
};
// map<long long,long long> prime_f(long long n){
// map<long long,long long>res;
// for(int i=2;i*i<=n;i++){
// while(n%i==0){
// ++res[i];
// n/=i;
// }
// }
// if(n!=1)res[n]=1;
// return res;
//}
// int n;
////int dat[2*10000000];
////int dat2[2*10000000];
// int dat[10];
// int dat2[10];
//
// void init(int n_){
// n=1;
// while(n<n_)n*=2;
// for(int i=0;i<2*n-1;i++){
// dat[i]=0;
// dat2[i]=0;
// }
//}
//
// void initset(int k,int a){
// k+=n-1;
// dat[k]=a;
// while(k>0){
// k=(k-1)/2;
// dat[k]=dat[k*2+1]+dat[k*2+2];
// }
//}
//
////[a,b)の間を[l,r]区間で比較しアップデート
////引数のindexに注意
////nは固定。initで計算すみ
////update2(L[i],R[i]+1,0,0,n,D[i]);
// void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
// if(r<=a || b<=l)return;
// if(a<=l && r<=b){
// dat[k]+=dat2[k];
// if(r-l>1){
// dat2[k*2+1]+=dat2[k]/2;
// dat2[k*2+1]+=dat2[k]/2;
// }
// dat2[k]=v*(r-l);
// return;
// }else{
// update2(a,b,k*2+1,l,(l+r)/2,v);
// update2(a,b,k*2+2,(l+r)/2,r,v);
// return;
// }
//}
//
// int query(int a,int b,int k,int l,int r){
// if(r<=a || b<=l)return 0;
// if(a<=l && r<=b){
// dat[k]+=dat2[k];
// if(r-l>1){
// dat2[k*2+1]+=dat2[k]/2;
// dat2[k*2+1]+=dat2[k]/2;
// }
// dat2[k]=0;
// return dat[k];
// }
// else{
// int vl=query(a,b,k*2+1,l,(l+r)/2);
// int vr=query(a,b,k*2+2,(l+r)/2,r);
// return vl+vr;
// }
//}
int main(int argc, const char *argv[]) {
// scanf("%s",S);
// scanf("%d",&N);
// scanf("%lld %lld",&target1,&target2);
// sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
// getline(cin, target);
// ifstream ifs("a.txt");//テスト用
// ifs >> a;
//ここから
//入力高速化
ios::sync_with_stdio(false);
cin.tie(0);
int N, M;
cin >> N >> M;
bool a[10];
for (int i = 0; i < 10; i++) {
a[i] = false;
}
for (int i = 0; i < M; i++) {
int tmp;
cin >> tmp;
a[tmp] = true;
}
// 1,7,4,5,9,8
// 2,3,4,5,6,7
int suji[] = {1, 7, 4, 2, 3, 5, 6, 9, 8};
int cost[] = {2, 3, 4, 5, 5, 5, 6, 6, 7};
string dp[10010]; // i:文字の長さ、j:残りのコスト
for (int p = 0; p < 9; p++) {
if (a[suji[p]]) {
dp[cost[p]] = '0' + suji[p];
}
}
for (int i = 1; i < N; i++) {
for (int p = 0; p < 9; p++) {
if (a[suji[p]] && dp[i] != "") {
string tmp = "";
tmp = '0' + suji[p];
if (dp[i + cost[p]].size() < dp[i].size() + 1) {
dp[i + cost[p]] = dp[i] + tmp;
} else if (dp[i + cost[p]].size() == dp[i].size() + 1) {
string t1 = dp[i + cost[p]];
string t2 = dp[i] + tmp;
if (t1 < t2) {
dp[i + cost[p]] = dp[i] + tmp;
}
}
}
}
}
cout << dp[N] << endl;
//ここまで
// cout << "ans" << endl;
// printf("%.0f\n",ans);//小数点以下表示なし
// printf("%.7f\n",p);
return 0;
}
| [
"literal.number.change"
] | 930,490 | 930,491 | u649310245 | cpp |
p03128 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame \
{ \
puts("-1"); \
return 0; \
}
#define yn \
{ puts("Yes"); } \
else { \
puts("No"); \
}
int main() {
int n, m;
cin >> n >> m;
int x[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int f[10] = {};
int dp[n + 100][10];
int sum[n + 100] = {};
rep(i, n + 100) {
rep(j, 10) { dp[i][j] = 0; }
}
rep(i, m) {
int a;
cin >> a;
f[a] = 1;
}
if (f[6] + f[9] == 2)
f[6] = 0;
if (f[2] + f[3] == 2)
f[2] = 0;
if (f[3] + f[5] == 2)
f[3] = 0;
if (f[2] + f[5] == 2)
f[2] = 0;
srep(i, 1, n + 1) {
srep(j, 1, 10) {
if (f[j] == 0)
continue;
if (i < x[j])
continue;
if (x[j] == i) {
if (sum[i] == 0) {
dp[i][j] = 1;
sum[i] = 1;
} else if (sum[i] == 1) {
rep(k, 10) {
if (dp[i][k] == 1) {
if (k < j) {
dp[i][k] = 0;
dp[i][j] = 1;
}
}
}
}
} else {
if (sum[i - x[j]] == 0)
continue;
if (sum[i] <= sum[i - x[j]]) {
sum[i] = sum[i - x[j]] + 1;
rep(k, 10) { dp[i][k] = dp[i - x[j]][k]; }
dp[i][j]++;
} else if (sum[i] + 1 == sum[i - x[j]]) {
int tmp[10];
rep(k, 10) { tmp[k] = dp[i - x[j]][k]; }
tmp[j]++;
int flag = 0;
drep(k, 10) {
if (dp[i][k] < tmp[k]) {
flag = 1;
break;
}
if (dp[i][k] > tmp[k]) {
break;
}
}
if (flag == 1) {
rep(k, 10) { dp[i][k] = tmp[k]; }
}
}
}
}
}
drep(i, 10) {
rep(j, dp[n][i]) { cout << i; }
}
cout << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame \
{ \
puts("-1"); \
return 0; \
}
#define yn \
{ puts("Yes"); } \
else { \
puts("No"); \
}
int main() {
int n, m;
cin >> n >> m;
int x[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int f[10] = {};
int dp[n + 100][10];
int sum[n + 100] = {};
rep(i, n + 100) {
rep(j, 10) { dp[i][j] = 0; }
}
rep(i, m) {
int a;
cin >> a;
f[a] = 1;
}
if (f[6] + f[9] == 2)
f[6] = 0;
if (f[2] + f[3] == 2)
f[2] = 0;
if (f[3] + f[5] == 2)
f[3] = 0;
if (f[2] + f[5] == 2)
f[2] = 0;
srep(i, 1, n + 1) {
srep(j, 1, 10) {
if (f[j] == 0)
continue;
if (i < x[j])
continue;
if (x[j] == i) {
if (sum[i] == 0) {
dp[i][j] = 1;
sum[i] = 1;
} else if (sum[i] == 1) {
rep(k, 10) {
if (dp[i][k] == 1) {
if (k < j) {
dp[i][k] = 0;
dp[i][j] = 1;
}
}
}
}
} else {
if (sum[i - x[j]] == 0)
continue;
if (sum[i] <= sum[i - x[j]]) {
sum[i] = sum[i - x[j]] + 1;
rep(k, 10) { dp[i][k] = dp[i - x[j]][k]; }
dp[i][j]++;
} else if (sum[i] == sum[i - x[j]] + 1) {
int tmp[10];
rep(k, 10) { tmp[k] = dp[i - x[j]][k]; }
tmp[j]++;
int flag = 0;
drep(k, 10) {
if (dp[i][k] < tmp[k]) {
flag = 1;
break;
}
if (dp[i][k] > tmp[k]) {
break;
}
}
if (flag == 1) {
rep(k, 10) { dp[i][k] = tmp[k]; }
}
}
}
}
}
drep(i, 10) {
rep(j, dp[n][i]) { cout << i; }
}
cout << endl;
return 0;
}
| [
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 930,494 | 930,495 | u791593901 | cpp |
p03128 | #include <algorithm> // minmax, sort, swap
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <cstdio> // printf, scanf
#include <iomanip> // cout<<setprecision(n)
#include <iostream> // cin, cout, cerr, clog
#include <map> // key-value pairs sorted by keys
#include <numeric> // iota, accumulate, inner_product
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <string> // string, stoi, to_string
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <vector> // vector
#define rep(i, n) for (int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"
#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
#define INF 10101010
signed main() {
int n, m;
std::cin >> n >> m;
std::vector<int> a(m);
rep(i, m) std::cin >> a[i];
int mc[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
std::vector<std::vector<int>> dp(n + 1, std::vector<int>(10, -INF));
dp[0] = std::vector<int>(10, 0);
for (auto &i : a) {
for (int j = 0; j <= n - mc[i]; j++) {
if (dp[j][0] == -INF)
continue;
std::vector<int> tmp = dp[j];
tmp[0]++;
tmp[i]++;
if (dp[mc[i] + j][0] == tmp[0]) {
bool re;
for (int k = 9; k > 0; k--) {
if (dp[mc[i] + j][k] == tmp[k])
continue;
re = dp[mc[i] + j][k] < tmp[k];
}
if (re)
dp[mc[i] + j] = tmp;
} else if (dp[mc[i] + j][0] < tmp[0]) {
dp[mc[i] + j] = tmp;
}
}
}
std::string ans = "";
for (int i = 1; i <= 9; i++) {
while (dp[n][i] > 0) {
ans = std::to_string(i) + ans;
dp[n][i]--;
}
}
print(ans);
return 0;
}
| #include <algorithm> // minmax, sort, swap
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <cstdio> // printf, scanf
#include <iomanip> // cout<<setprecision(n)
#include <iostream> // cin, cout, cerr, clog
#include <map> // key-value pairs sorted by keys
#include <numeric> // iota, accumulate, inner_product
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <string> // string, stoi, to_string
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <vector> // vector
#define rep(i, n) for (int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"
#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
#define INF 10101010
signed main() {
int n, m;
std::cin >> n >> m;
std::vector<int> a(m);
rep(i, m) std::cin >> a[i];
int mc[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
std::vector<std::vector<int>> dp(n + 1, std::vector<int>(10, -INF));
dp[0] = std::vector<int>(10, 0);
for (auto &i : a) {
for (int j = 0; j <= n - mc[i]; j++) {
if (dp[j][0] == -INF)
continue;
std::vector<int> tmp = dp[j];
tmp[0]++;
tmp[i]++;
if (dp[mc[i] + j][0] == tmp[0]) {
bool re = false;
for (int k = 9; k > 0; k--) {
if (dp[mc[i] + j][k] == tmp[k])
continue;
re = dp[mc[i] + j][k] < tmp[k];
break;
}
if (re)
dp[mc[i] + j] = tmp;
} else if (dp[mc[i] + j][0] < tmp[0]) {
dp[mc[i] + j] = tmp;
}
}
}
std::string ans = "";
for (int i = 1; i <= 9; i++) {
while (dp[n][i] > 0) {
ans = std::to_string(i) + ans;
dp[n][i]--;
}
}
print(ans);
return 0;
}
| [
"variable_declaration.value.change"
] | 930,498 | 930,499 | u128456980 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
#define int long long
// 1,2,3,4,5,6,7,8,9
// 2,5,5,4,5,6,3,7,6
// 2,3,4,5,6,7
// 1,7,4,5,9,8
using P = pair<int, int>;
map<int, int> mx;
vector<int> num = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int vnum = 10020;
int dp[vnum];
int dig[vnum];
signed main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
for (auto &&w : a) {
cin >> w;
mx[num[w]] = max(mx[num[w]], w);
}
vector<P> vmx = vector<P>(mx.begin(), mx.end());
sort(vmx.begin(), vmx.end(), [&](P x, P y) { return x.second < y.second; });
fill(dp, dp + vnum, -1);
fill(dig, dig + vnum, -1);
dp[0] = 0;
for (auto &&w : vmx) {
for (int i = 0; i <= n; i++) {
if (dp[i] == -1)
continue;
if (dp[i + w.first] < dp[i] + 1) {
dp[i + w.first] = dp[i] + 1;
// if(dig[i+w.first]<w.second)
dig[i + w.first] = w.second;
}
}
}
string ans = "";
int y = n;
int b;
while (y > 0) {
int x = dig[y];
ans += ('0' + x);
y -= num[x];
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
// 1,2,3,4,5,6,7,8,9
// 2,5,5,4,5,6,3,7,6
// 2,3,4,5,6,7
// 1,7,4,5,9,8
using P = pair<int, int>;
map<int, int> mx;
vector<int> num = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int vnum = 10020;
int dp[vnum];
int dig[vnum];
signed main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
for (auto &&w : a) {
cin >> w;
mx[num[w]] = max(mx[num[w]], w);
}
vector<P> vmx = vector<P>(mx.begin(), mx.end());
sort(vmx.begin(), vmx.end(), [&](P x, P y) { return x.second < y.second; });
fill(dp, dp + vnum, -1);
fill(dig, dig + vnum, -1);
dp[0] = 0;
for (auto &&w : vmx) {
for (int i = 0; i <= n; i++) {
if (dp[i] == -1)
continue;
if (dp[i + w.first] <= dp[i] + 1) {
dp[i + w.first] = dp[i] + 1;
// if(dig[i+w.first]<w.second)
dig[i + w.first] = w.second;
}
}
}
string ans = "";
int y = n;
int b;
while (y > 0) {
int x = dig[y];
ans += ('0' + x);
y -= num[x];
}
cout << ans << endl;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 930,510 | 930,511 | u731175398 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
#define int long long
// 1,2,3,4,5,6,7,8,9
// 2,5,5,4,5,6,3,7,6
// 2,3,4,5,6,7
// 1,7,4,5,9,8
using P = pair<int, int>;
map<int, int> mx;
vector<int> num = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int vnum = 10020;
int dp[vnum];
int dig[vnum];
signed main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
for (auto &&w : a) {
cin >> w;
mx[num[w]] = max(mx[num[w]], w);
}
vector<P> vmx = vector<P>(mx.begin(), mx.end());
sort(vmx.begin(), vmx.end(), [&](P x, P y) { return x.second < y.second; });
fill(dp, dp + vnum, -1);
fill(dig, dig + vnum, -1);
dp[0] = 0;
for (auto &&w : vmx) {
for (int i = 0; i <= n; i++) {
if (dp[i] == -1)
continue;
if (dp[i + w.first] < dp[i] + 1) {
dp[i + w.first] = dp[i] + 1;
// if(dig[i+w.first]<w.second)
dig[i + w.first] = w.second;
}
}
}
string ans = "";
int y = n;
int b;
while (y > 0) {
int x = dig[y];
ans += ('0' + x);
y -= num[x - 1];
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
// 1,2,3,4,5,6,7,8,9
// 2,5,5,4,5,6,3,7,6
// 2,3,4,5,6,7
// 1,7,4,5,9,8
using P = pair<int, int>;
map<int, int> mx;
vector<int> num = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int vnum = 10020;
int dp[vnum];
int dig[vnum];
signed main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
for (auto &&w : a) {
cin >> w;
mx[num[w]] = max(mx[num[w]], w);
}
vector<P> vmx = vector<P>(mx.begin(), mx.end());
sort(vmx.begin(), vmx.end(), [&](P x, P y) { return x.second < y.second; });
fill(dp, dp + vnum, -1);
fill(dig, dig + vnum, -1);
dp[0] = 0;
for (auto &&w : vmx) {
for (int i = 0; i <= n; i++) {
if (dp[i] == -1)
continue;
if (dp[i + w.first] <= dp[i] + 1) {
dp[i + w.first] = dp[i] + 1;
// if(dig[i+w.first]<w.second)
dig[i + w.first] = w.second;
}
}
}
string ans = "";
int y = n;
int b;
while (y > 0) {
int x = dig[y];
ans += ('0' + x);
y -= num[x];
}
cout << ans << endl;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 930,512 | 930,511 | u731175398 | cpp |
p03128 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int Match[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int N, M;
void traceback(vector<int> A, vector<int> dp) {
int pos = N;
int dig = dp[N];
while (pos != 0) {
for (int i = A.size() - 1; i >= 0; i--) {
if (pos - Match[A[i]] < 0)
continue;
if (dp[pos - Match[A[i]]] != (dig - 1))
continue;
cout << A[i];
dig -= 1;
pos -= Match[A[i]];
break;
}
}
cout << endl;
return;
}
void dfs(vector<int> A, vector<int> dp, int dig, int pos) {
// cout <<"pos : " << pos << " dig: " << dig << endl;
if (dig == 0)
return;
for (int i = M - 1; i >= 0; i--) {
// if(dig == 1) cout << i << " " << pos << " " << A[i] << endl;
if (pos >= Match[A[i]] && dp[pos - Match[A[i]]] == dig - 1) {
pos -= Match[A[i]];
cout << A[i];
dfs(A, dp, dig - 1, pos);
return;
}
}
}
int main() {
cin >> N >> M;
vector<int> A(M);
vector<int> B;
vector<int> check(10);
for (int i = 0; i < M; i++) {
cin >> A[i];
check[A[i]] = 1;
}
sort(A.begin(), A.end());
vector<int> dp(N + 1); //マッチをn本使った時の最大の桁数を格納dp(n)
for (int i = 1; i < N + 1; i++) {
dp[i] = -1e8;
}
for (int i = 0; i < N + 1; i++) {
for (int j = 0; j < A.size() - 1; j++) {
if ((i - Match[A[j]]) >= 0) {
dp[i] = max(dp[i], dp[i - Match[A[j]]] + 1);
}
}
}
// traceback(A,dp);
dfs(A, dp, dp[N], N);
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int Match[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int N, M;
void traceback(vector<int> A, vector<int> dp) {
int pos = N;
int dig = dp[N];
while (pos != 0) {
for (int i = A.size() - 1; i >= 0; i--) {
if (pos - Match[A[i]] < 0)
continue;
if (dp[pos - Match[A[i]]] != (dig - 1))
continue;
cout << A[i];
dig -= 1;
pos -= Match[A[i]];
break;
}
}
cout << endl;
return;
}
void dfs(vector<int> A, vector<int> dp, int dig, int pos) {
// cout <<"pos : " << pos << " dig: " << dig << endl;
if (dig == 0)
return;
for (int i = M - 1; i >= 0; i--) {
// if(dig == 1) cout << i << " " << pos << " " << A[i] << endl;
if (pos >= Match[A[i]] && dp[pos - Match[A[i]]] == dig - 1) {
pos -= Match[A[i]];
cout << A[i];
dfs(A, dp, dig - 1, pos);
return;
}
}
}
int main() {
cin >> N >> M;
vector<int> A(M);
vector<int> B;
vector<int> check(10);
for (int i = 0; i < M; i++) {
cin >> A[i];
check[A[i]] = 1;
}
sort(A.begin(), A.end());
vector<int> dp(N + 1); //マッチをn本使った時の最大の桁数を格納dp(n)
for (int i = 1; i < N + 1; i++) {
dp[i] = -1e8;
}
for (int i = 0; i < N + 1; i++) {
for (int j = 0; j < A.size(); j++) {
if ((i - Match[A[j]]) >= 0) {
dp[i] = max(dp[i], dp[i - Match[A[j]]] + 1);
}
}
}
// traceback(A,dp);
dfs(A, dp, dp[N], N);
return 0;
} | [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 930,558 | 930,559 | u564056510 | cpp |
p03128 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define yesno(flg) \
if (flg) { \
cout << "Yes" << endl; \
} else { \
cout << "No" << endl; \
}
using namespace std;
typedef long long ll;
typedef pair<int, int> P1;
typedef pair<int, P1> P2;
const ll inf = 100000000000000000;
struct edge {
int to, cost;
};
struct pos {
int to;
ll cost;
};
struct pos2 {
int to, from;
ll cost;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
#define MAX_N 1002
ll dp2[100001];
vector<pos> vec[100001];
vector<int> vec2[100001];
int dp[10011][10] = {};
int main() {
int n, m;
cin >> n >> m;
int b[10] = {};
int c[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
rep(i, m) {
int a;
cin >> a;
b[a] = 1;
}
for (int i = 9; i > 0; --i) {
if (b[i] > 0 && dp[c[i]][0] == 0) {
dp[c[i]][i] = 1;
dp[c[i]][0] = 1;
}
}
for (int i = 2; i < n; ++i) {
if (dp[i][0] > 0) {
for (int i2 = 9; i2 > 0; --i2) {
if (b[i2] > 0) {
int ndp[10] = {};
rep(i3, 10) { ndp[i3] = dp[i][i3]; }
ndp[i2]++;
ndp[0]++;
bool flg = false;
if (ndp[0] > dp[i + c[i2]][0]) {
flg = true;
} else if (ndp[0] == dp[i + c[i2]][0]) {
int flg2 = 0;
for (int i3 = 9; i3 > 0; --i3) {
if (flg2 == 0) {
if (ndp[i3] > dp[i + c[i2]][i3])
flg2 = 1;
if (ndp[i3] < dp[i + c[i2]][i3])
flg2 = -1;
}
}
if (flg == 1)
flg = true;
}
if (flg) {
rep(i3, 10) dp[i + c[i2]][i3] = ndp[i3];
}
}
}
}
}
for (int i = 9; i > 0; --i) {
rep(i2, dp[n][i]) cout << i;
}
cout << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define yesno(flg) \
if (flg) { \
cout << "Yes" << endl; \
} else { \
cout << "No" << endl; \
}
using namespace std;
typedef long long ll;
typedef pair<int, int> P1;
typedef pair<int, P1> P2;
const ll inf = 100000000000000000;
struct edge {
int to, cost;
};
struct pos {
int to;
ll cost;
};
struct pos2 {
int to, from;
ll cost;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
#define MAX_N 1002
ll dp2[100001];
vector<pos> vec[100001];
vector<int> vec2[100001];
int dp[10011][10] = {};
int main() {
int n, m;
cin >> n >> m;
int b[10] = {};
int c[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
rep(i, m) {
int a;
cin >> a;
b[a] = 1;
}
for (int i = 9; i > 0; --i) {
if (b[i] > 0 && dp[c[i]][0] == 0) {
dp[c[i]][i] = 1;
dp[c[i]][0] = 1;
}
}
for (int i = 2; i < n; ++i) {
if (dp[i][0] > 0) {
for (int i2 = 9; i2 > 0; --i2) {
if (b[i2] > 0) {
int ndp[10] = {};
rep(i3, 10) { ndp[i3] = dp[i][i3]; }
ndp[i2]++;
ndp[0]++;
bool flg = false;
if (ndp[0] > dp[i + c[i2]][0]) {
flg = true;
} else if (ndp[0] == dp[i + c[i2]][0]) {
int flg2 = 0;
for (int i3 = 9; i3 > 0; --i3) {
if (flg2 == 0) {
if (ndp[i3] > dp[i + c[i2]][i3])
flg2 = 1;
if (ndp[i3] < dp[i + c[i2]][i3])
flg2 = -1;
}
}
if (flg2 == 1)
flg = true;
}
if (flg) {
rep(i3, 10) dp[i + c[i2]][i3] = ndp[i3];
}
}
}
}
}
for (int i = 9; i > 0; --i) {
rep(i2, dp[n][i]) cout << i;
}
cout << endl;
return 0;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 930,604 | 930,605 | u707053380 | cpp |
p03128 | #include <algorithm>
#include <array>
#include <cstring>
#include <iostream>
#include <list>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
const int MOD = 1000000007;
const int INF = 1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vp;
string s;
int n, m;
vector<pair<bool, int>> a(10);
string ans = "";
int dp[10100];
int main(int argc, char const *argv[]) {
for (int i = 1; i <= 9; i++) {
a[i].first = false;
}
cin >> n >> m;
int digit = 0;
for (int i = 0; i < m; i++) {
int num;
cin >> num;
a[num].first = true;
if (num == 1) {
a[num].second = 2;
} else if (num == 2 || num == 3 || num == 5) {
a[num].second = 5;
} else if (num == 4) {
a[num].second = 4;
} else if (num == 6 || num == 9) {
a[num].second = 6;
} else if (num == 7) {
a[num].second = 3;
} else if (num == 8) {
a[num].second = 8;
}
}
for (int j = 0; j <= n; j++) {
dp[j] = INF * -1;
}
dp[0] = 0;
for (int i = 1; i <= 9; i++) {
if (a[i].first)
dp[a[i].second] = 1;
}
for (int j = 2; j <= n; j++) {
for (int i = 9; i >= 1; i--) {
if (a[i].first == true) {
if (j - a[i].second >= 0) {
dp[j] = max(dp[j], dp[j - a[i].second] + 1);
}
}
}
}
int num[8] = {-1, -1, 1, 7, 4, 2, 6, 8};
if (a[3].first)
num[5] = 3;
if (a[5].first)
num[5] = 5;
if (a[9].first)
num[6] = 9;
int tmp = n;
for (int i = 0; i < dp[n]; i++) {
for (int j = 9; j >= 1; j--) {
if (a[j].first && tmp - a[j].second >= 0) {
if (dp[tmp - a[j].second] == dp[tmp] - 1) {
cout << num[a[j].second];
tmp -= a[j].second;
break;
}
}
}
}
cout << endl;
return 0;
// cout << dp[n] << endl;
// cout << ans << endl;
}
| #include <algorithm>
#include <array>
#include <cstring>
#include <iostream>
#include <list>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
const int MOD = 1000000007;
const int INF = 1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vp;
string s;
int n, m;
vector<pair<bool, int>> a(10);
string ans = "";
int dp[10100];
int main(int argc, char const *argv[]) {
for (int i = 1; i <= 9; i++) {
a[i].first = false;
}
cin >> n >> m;
int digit = 0;
for (int i = 0; i < m; i++) {
int num;
cin >> num;
a[num].first = true;
if (num == 1) {
a[num].second = 2;
} else if (num == 2 || num == 3 || num == 5) {
a[num].second = 5;
} else if (num == 4) {
a[num].second = 4;
} else if (num == 6 || num == 9) {
a[num].second = 6;
} else if (num == 7) {
a[num].second = 3;
} else if (num == 8) {
a[num].second = 7;
}
}
for (int j = 0; j <= n; j++) {
dp[j] = INF * -1;
}
dp[0] = 0;
for (int i = 1; i <= 9; i++) {
if (a[i].first)
dp[a[i].second] = 1;
}
for (int j = 2; j <= n; j++) {
for (int i = 9; i >= 1; i--) {
if (a[i].first == true) {
if (j - a[i].second >= 0) {
dp[j] = max(dp[j], dp[j - a[i].second] + 1);
}
}
}
}
int num[8] = {-1, -1, 1, 7, 4, 2, 6, 8};
if (a[3].first)
num[5] = 3;
if (a[5].first)
num[5] = 5;
if (a[9].first)
num[6] = 9;
int tmp = n;
for (int i = 0; i < dp[n]; i++) {
for (int j = 9; j >= 1; j--) {
if (a[j].first && tmp - a[j].second >= 0) {
if (dp[tmp - a[j].second] == dp[tmp] - 1) {
cout << num[a[j].second];
tmp -= a[j].second;
break;
}
}
}
}
cout << endl;
return 0;
// cout << dp[n] << endl;
// cout << ans << endl;
}
| [
"literal.number.change",
"assignment.value.change"
] | 930,637 | 930,638 | u945017646 | cpp |
p03128 | #include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x, to) for (x = 0; x < (to); x++)
#define FORR(x, arr) for (auto &x : arr)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
//-------------------------------------------------------
int N, M;
int D[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int C[10];
int num[101010];
int best[101010];
int hoge(int L) {
if (L == 0)
return 0;
if (num[L] != -1)
return num[L];
num[L] = -101010;
int i;
FOR(i, 10) if (C[i] && L >= C[i]) {
int cand = hoge(L - i);
if (cand + 1 >= num[L])
num[L] = cand + 1, best[L] = i;
}
return num[L];
}
void solve() {
int i, j, k, l, r, x, y;
string s;
cin >> N >> M;
FOR(i, M) {
cin >> x;
C[x] = D[x];
}
MINUS(num);
string S;
hoge(N);
while (N) {
x = best[N];
S.push_back('0' + x);
N -= D[best[N]];
}
sort(ALL(S));
reverse(ALL(S));
cout << S << endl;
}
int main(int argc, char **argv) {
string s;
int i;
if (argc == 1)
ios::sync_with_stdio(false), cin.tie(0);
FOR(i, argc - 1) s += argv[i + 1], s += '\n';
FOR(i, s.size()) ungetc(s[s.size() - 1 - i], stdin);
cout.tie(0);
solve();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x, to) for (x = 0; x < (to); x++)
#define FORR(x, arr) for (auto &x : arr)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
//-------------------------------------------------------
int N, M;
int D[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int C[10];
int num[101010];
int best[101010];
int hoge(int L) {
if (L == 0)
return 0;
if (num[L] != -1)
return num[L];
num[L] = -101010;
int i;
FOR(i, 10) if (C[i] && L >= C[i]) {
int cand = hoge(L - C[i]);
if (cand + 1 >= num[L])
num[L] = cand + 1, best[L] = i;
}
return num[L];
}
void solve() {
int i, j, k, l, r, x, y;
string s;
cin >> N >> M;
FOR(i, M) {
cin >> x;
C[x] = D[x];
}
MINUS(num);
string S;
hoge(N);
while (N) {
x = best[N];
S.push_back('0' + x);
N -= D[best[N]];
}
sort(ALL(S));
reverse(ALL(S));
cout << S << endl;
}
int main(int argc, char **argv) {
string s;
int i;
if (argc == 1)
ios::sync_with_stdio(false), cin.tie(0);
FOR(i, argc - 1) s += argv[i + 1], s += '\n';
FOR(i, s.size()) ungetc(s[s.size() - 1 - i], stdin);
cout.tie(0);
solve();
return 0;
}
| [
"call.arguments.change"
] | 930,680 | 930,681 | u452725238 | cpp |
p03129 | #include <iostream>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
N - K >= K - 1 ? cout << "Yes" << endl : cout << "No" << endl;
return 0;
}
| #include <iostream>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
N - K >= K - 1 ? cout << "YES" << endl : cout << "NO" << endl;
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"expression.operation.binary.change"
] | 930,688 | 930,689 | u211175911 | cpp |
p03129 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for (int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vvs vector<vector<string>>
#define pq priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = 2000000000;
const int MINF = -2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ-------------------- */
ll fact(int i) { //階乗
if (i == 0)
return 1;
return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) { //最大公約数
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { //最小公倍数
return a * b / gcd(a, b);
}
bool isprime(ll a) //素数判定、primeならtrue,違うならfalse
{
if (a < 2)
return false;
else if (a == 2)
return true;
else if (a % 2 == 0)
return false;
double m = sqrt(a);
for (int i = 3; i <= m; i += 2) {
if (a % i == 0) {
return false;
}
}
// 素数である
return true;
}
ll ketasum(ll n) { //各桁の和
ll sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
/* ----------------------end----------------------- */
signed main() {
int N, K;
cin >> N >> K;
N > K ? puts("YES") : puts("NO");
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for (int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vvs vector<vector<string>>
#define pq priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = 2000000000;
const int MINF = -2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ-------------------- */
ll fact(int i) { //階乗
if (i == 0)
return 1;
return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) { //最大公約数
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { //最小公倍数
return a * b / gcd(a, b);
}
bool isprime(ll a) //素数判定、primeならtrue,違うならfalse
{
if (a < 2)
return false;
else if (a == 2)
return true;
else if (a % 2 == 0)
return false;
double m = sqrt(a);
for (int i = 3; i <= m; i += 2) {
if (a % i == 0) {
return false;
}
}
// 素数である
return true;
}
ll ketasum(ll n) { //各桁の和
ll sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
/* ----------------------end----------------------- */
signed main() {
int N, K;
cin >> N >> K;
N >= K * 2 - 1 ? puts("YES") : puts("NO");
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 930,692 | 930,693 | u851044959 | cpp |
p03129 | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k;
cin >> n >> k;
if ((n + 1) / 2 >= k)
cout << "Yes\n";
else
cout << "No\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k;
cin >> n >> k;
if ((n + 1) / 2 >= k)
cout << "YES\n";
else
cout << "NO\n";
return 0;
} | [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 930,697 | 930,698 | u750630712 | cpp |
p03129 | #include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
int main() {
int n, k;
cin >> n >> k;
if (k == 1) {
if (n <= 1)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
n--;
k--;
if (2 <= n / k) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
| #include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
int main() {
int n, k;
cin >> n >> k;
if (k == 1) {
if (1 <= n)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
n--;
k--;
if (2 <= n / k) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
| [
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 930,699 | 930,700 | u730499268 | cpp |
p03129 | #include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
int main() {
int n, k;
cin >> n >> k;
if (k == 1) {
if (n == 1)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
n--;
k--;
if (2 <= n / k) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
| #include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
int main() {
int n, k;
cin >> n >> k;
if (k == 1) {
if (1 <= n)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
n--;
k--;
if (2 <= n / k) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
| [
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 930,701 | 930,700 | u730499268 | cpp |
p03129 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (n >= 2 * k + 1) {
cout << "YES";
} else {
cout << "NO";
}
} |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (n >= 2 * k - 1) {
cout << "YES";
} else {
cout << "NO";
}
} | [
"misc.opposites",
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change"
] | 930,715 | 930,716 | u520276780 | cpp |
p03129 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
if ((N / 2 + 1) >= K) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
if ((N + 1) / 2 >= K) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
} | [
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 930,723 | 930,724 | u345589723 | cpp |
p03129 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define sort(s) sort(s.begin(), s.end())
#define reverse(s) reverse(s.begin(), s.end())
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
const ll mod = 1e9 + 7;
//最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
//最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//素数判定
bool isPrime(ll x) {
ll i;
if (x < 2)
return 0;
else if (x == 2)
return 1;
if (x % 2 == 0)
return 0;
for (i = 3; i * i <= x; i += 2)
if (x % i == 0)
return 0;
return 1;
}
//桁和
int digsum(ll n) {
int res = 0;
while (n > 0) {
res += n % 10;
n /= 10;
}
return res;
}
//桁数
int dignum(ll n) {
int res = 0;
while (n > 0) {
res++;
n /= 10;
}
return res;
}
//文字列中の特定の文字カウント
ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); }
//階乗
ll ka(ll i) {
ll res = 1;
while (i > 0) {
res = res * i;
i--;
}
return res;
}
// ncr
ll ncr(ll x, ll y) {
ll a = x;
ll b = 1;
if (y > (x / 2)) {
y = x - y;
}
for (ll i = 1; i < y; i++) {
a *= x - i;
b *= i + 1;
}
return a / b;
}
//フィボナッチ数列
ll f(ll x) {
ll dp[x + 1];
dp[1] = 1;
dp[2] = 1;
for (ll i = 3; i <= x; i++) {
dp[i] = dp[i - 1] + dp[i - 2];
}
return dp[x];
}
// char->int
int ctoi(char c) { return c - '0'; }
vector<pair<long long, long long>> prime_factorize(long long N) {
vector<pair<long long, long long>> res;
for (long long a = 2; a * a <= N; ++a) {
if (N % a != 0)
continue;
long long ex = 0; // 指数
// 割れる限り割り続ける
while (N % a == 0) {
++ex;
N /= a;
}
// その結果を push
res.push_back({a, ex});
}
// 最後に残った数について
if (N != 1)
res.push_back({N, 1});
return res;
}
int main() {
int n, k;
cin >> n >> k;
if (n % 2 + 1 > k) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define sort(s) sort(s.begin(), s.end())
#define reverse(s) reverse(s.begin(), s.end())
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
const ll mod = 1e9 + 7;
//最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
//最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//素数判定
bool isPrime(ll x) {
ll i;
if (x < 2)
return 0;
else if (x == 2)
return 1;
if (x % 2 == 0)
return 0;
for (i = 3; i * i <= x; i += 2)
if (x % i == 0)
return 0;
return 1;
}
//桁和
int digsum(ll n) {
int res = 0;
while (n > 0) {
res += n % 10;
n /= 10;
}
return res;
}
//桁数
int dignum(ll n) {
int res = 0;
while (n > 0) {
res++;
n /= 10;
}
return res;
}
//文字列中の特定の文字カウント
ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); }
//階乗
ll ka(ll i) {
ll res = 1;
while (i > 0) {
res = res * i;
i--;
}
return res;
}
// ncr
ll ncr(ll x, ll y) {
ll a = x;
ll b = 1;
if (y > (x / 2)) {
y = x - y;
}
for (ll i = 1; i < y; i++) {
a *= x - i;
b *= i + 1;
}
return a / b;
}
//フィボナッチ数列
ll f(ll x) {
ll dp[x + 1];
dp[1] = 1;
dp[2] = 1;
for (ll i = 3; i <= x; i++) {
dp[i] = dp[i - 1] + dp[i - 2];
}
return dp[x];
}
// char->int
int ctoi(char c) { return c - '0'; }
vector<pair<long long, long long>> prime_factorize(long long N) {
vector<pair<long long, long long>> res;
for (long long a = 2; a * a <= N; ++a) {
if (N % a != 0)
continue;
long long ex = 0; // 指数
// 割れる限り割り続ける
while (N % a == 0) {
++ex;
N /= a;
}
// その結果を push
res.push_back({a, ex});
}
// 最後に残った数について
if (N != 1)
res.push_back({N, 1});
return res;
}
int main() {
int n, k;
cin >> n >> k;
if ((n - 1) / 2 + 1 >= k) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
| [
"control_flow.branch.if.condition.change",
"expression.operator.arithmetic.change",
"expression.operator.compare.change"
] | 930,725 | 930,726 | u584787460 | cpp |
p03129 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define MOD 1000000007LL
#define rep(i, n) for (ll(i) = 0LL; (i) < (ll)(n); (i)++)
#define rep2(i, s, e) for (ll(i) = (ll)(s); (i) < (ll)(e); (i)++)
#define repi(i, n) for (ll(i) = 0LL; (i) <= (ll)(n); (i)++)
#define repi2(i, s, e) for (ll(i) = (ll)(s); (i) <= (ll)(e); (i)++)
#define per(i, n) for (ll(i) = (ll)(n)-1LL; (i) >= 0LL; (i)--)
#define per2(i, s, e) for (ll(i) = (ll)(s)-1LL; (i) >= (ll)(e); (i)--)
#define peri(i, n) for (ll(i) = (ll)(n); (i) >= 0LL; (i)--)
#define peri2(i, s, e) for (ll(i) = (ll)(s); (i) >= (ll)(e); (i)--)
#define iter(i, it) for (auto &(i) : (it))
template <typename T, typename U>
ostream &operator<<(ostream &s, const pair<T, U> m) {
cout << "(" << m.first << ", " << m.second << ")";
return s;
}
template <typename T, typename U>
ostream &operator<<(ostream &s, const map<T, U> m) {
ll c = 0;
cout << "{ ";
iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
cout << "}";
return s;
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
cout << "{ ";
rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
cout << "}";
return s;
}
template <typename T> ostream &operator<<(ostream &s, const list<T> &v) {
ll c = 0;
cout << "{ ";
iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
cout << "}";
return s;
}
int main(void) {
ll N, K;
cin >> N >> K;
if (N / 2 + N % 2 >= K)
cout << "Yes";
else
cout << "No";
cout << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define MOD 1000000007LL
#define rep(i, n) for (ll(i) = 0LL; (i) < (ll)(n); (i)++)
#define rep2(i, s, e) for (ll(i) = (ll)(s); (i) < (ll)(e); (i)++)
#define repi(i, n) for (ll(i) = 0LL; (i) <= (ll)(n); (i)++)
#define repi2(i, s, e) for (ll(i) = (ll)(s); (i) <= (ll)(e); (i)++)
#define per(i, n) for (ll(i) = (ll)(n)-1LL; (i) >= 0LL; (i)--)
#define per2(i, s, e) for (ll(i) = (ll)(s)-1LL; (i) >= (ll)(e); (i)--)
#define peri(i, n) for (ll(i) = (ll)(n); (i) >= 0LL; (i)--)
#define peri2(i, s, e) for (ll(i) = (ll)(s); (i) >= (ll)(e); (i)--)
#define iter(i, it) for (auto &(i) : (it))
template <typename T, typename U>
ostream &operator<<(ostream &s, const pair<T, U> m) {
cout << "(" << m.first << ", " << m.second << ")";
return s;
}
template <typename T, typename U>
ostream &operator<<(ostream &s, const map<T, U> m) {
ll c = 0;
cout << "{ ";
iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
cout << "}";
return s;
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
cout << "{ ";
rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
cout << "}";
return s;
}
template <typename T> ostream &operator<<(ostream &s, const list<T> &v) {
ll c = 0;
cout << "{ ";
iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
cout << "}";
return s;
}
int main(void) {
ll N, K;
cin >> N >> K;
if (N / 2 + N % 2 >= K)
cout << "YES";
else
cout << "NO";
cout << endl;
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 930,727 | 930,728 | u196953553 | cpp |
p03129 | // include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
// func
// ------------------------------------------------
int CalcSumOfDigit(int n); // 各桁の和を計算する。
int getDigit(int n); // 数字の桁数を取得する。
string upper(string str); // 英字を大文字に変換する。
string lower(string str); // 英字を小文字に変換する。
vector<pair<long long, long long>> prime_factorize(long long p); // 素因数分解
// class
// ------------------------------------------------
class Combi {
public:
Combi();
long long Combination(long long n, long long k);
long long nPk_modp(long long n, long long k, long long p);
private:
map<long long, map<long long, long long>> memo;
long long n_num;
long long k_num;
};
// define
// ------------------------------------------------
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define rep(i, n) for (long long(i) = 0; (i) < (n); (i)++)
#define repe(i, n) for (long long(i) = 0; (i) <= (n); (i)++)
#define vsort(v) sort((v).begin(), (v).end())
#define rvsort(v) sort(rall((v)))
#define vi vector<int>
#define GCD(a, b) __gcd((a), (b))
#define LCM(a, b) (a) / GCD((a), (b)) * (b)
#define kiriage(a, b) ((a) + (b)-1) / (b)
const int INF = 1e9;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {
ll n, k;
cin >> n >> k;
if (n - 1 >= k) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
int i = 1;
while (1) {
n = n / 10;
if (n == 1)
break;
i++;
}
return i;
}
int CalcSumOfDigit(int n) {
int s = 0;
while (n) {
s += n % 10;
n = n / 10;
}
return s;
}
string upper(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (97 <= *itr && *itr <= 122) {
*itr = *itr - 32;
}
}
return str;
}
string lower(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (65 <= *itr && *itr <= 90) {
*itr = *itr + 32;
}
}
return str;
}
Combi::Combi() {
n_num = -1;
k_num = -1;
};
ll Combi::Combination(ll n, ll k) {
ll ret;
if (memo[n][k] != 0) {
ret = memo[n][k];
} else if (n == k || k == 0) {
memo[n][k] = 1;
ret = 1;
} else {
ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
memo[n][k] = ret;
}
return ret;
}
long long Combi::nPk_modp(long long n, long long k, long long p) {
ll ans = 1;
for (long long i = k; i <= n; i++) {
ans = (ans * i) % p;
}
return ans;
};
vector<pair<long long, long long>> prime_factorize(long long p) {
vector<pair<long long, long long>> ret;
for (long long x = 2; x * x <= p; ++x) {
if (p % x != 0)
continue;
long long num = 0;
while (p % x == 0) {
num++;
p /= x;
}
ret.push_back(make_pair(x, num));
}
if (p != 1)
ret.push_back(make_pair(p, 1));
return ret;
}
| // include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
// func
// ------------------------------------------------
int CalcSumOfDigit(int n); // 各桁の和を計算する。
int getDigit(int n); // 数字の桁数を取得する。
string upper(string str); // 英字を大文字に変換する。
string lower(string str); // 英字を小文字に変換する。
vector<pair<long long, long long>> prime_factorize(long long p); // 素因数分解
// class
// ------------------------------------------------
class Combi {
public:
Combi();
long long Combination(long long n, long long k);
long long nPk_modp(long long n, long long k, long long p);
private:
map<long long, map<long long, long long>> memo;
long long n_num;
long long k_num;
};
// define
// ------------------------------------------------
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define rep(i, n) for (long long(i) = 0; (i) < (n); (i)++)
#define repe(i, n) for (long long(i) = 0; (i) <= (n); (i)++)
#define vsort(v) sort((v).begin(), (v).end())
#define rvsort(v) sort(rall((v)))
#define vi vector<int>
#define GCD(a, b) __gcd((a), (b))
#define LCM(a, b) (a) / GCD((a), (b)) * (b)
#define kiriage(a, b) ((a) + (b)-1) / (b)
const int INF = 1e9;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {
ll n, k;
cin >> n >> k;
if (kiriage(n, 2) >= k) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
int i = 1;
while (1) {
n = n / 10;
if (n == 1)
break;
i++;
}
return i;
}
int CalcSumOfDigit(int n) {
int s = 0;
while (n) {
s += n % 10;
n = n / 10;
}
return s;
}
string upper(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (97 <= *itr && *itr <= 122) {
*itr = *itr - 32;
}
}
return str;
}
string lower(string str) {
for (auto itr = str.begin(); itr != str.end(); itr++) {
if (65 <= *itr && *itr <= 90) {
*itr = *itr + 32;
}
}
return str;
}
Combi::Combi() {
n_num = -1;
k_num = -1;
};
ll Combi::Combination(ll n, ll k) {
ll ret;
if (memo[n][k] != 0) {
ret = memo[n][k];
} else if (n == k || k == 0) {
memo[n][k] = 1;
ret = 1;
} else {
ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
memo[n][k] = ret;
}
return ret;
}
long long Combi::nPk_modp(long long n, long long k, long long p) {
ll ans = 1;
for (long long i = k; i <= n; i++) {
ans = (ans * i) % p;
}
return ans;
};
vector<pair<long long, long long>> prime_factorize(long long p) {
vector<pair<long long, long long>> ret;
for (long long x = 2; x * x <= p; ++x) {
if (p % x != 0)
continue;
long long num = 0;
while (p % x == 0) {
num++;
p /= x;
}
ret.push_back(make_pair(x, num));
}
if (p != 1)
ret.push_back(make_pair(p, 1));
return ret;
}
| [
"control_flow.branch.if.condition.change",
"call.add"
] | 930,729 | 930,730 | u610897920 | cpp |
p03129 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
cout << (n >= 2 * (k - 1) ? "YES\n" : "NO\n");
return 0;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
cout << (n >= 2 * (k - 1) + 1 ? "YES\n" : "NO\n");
return 0;
}
| [
"expression.operation.binary.add"
] | 930,731 | 930,732 | u283907492 | cpp |
p03129 | #include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i, a, N) for ((i) = (a); (i) < (N); (i)++)
#define rrp(i, N, a) for ((i) = (N)-1; (i) >= (a); (i)--)
#define llfor ll i, j, k
#define sc(a) cin >> a
#define pr(a) cout << a << endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(), a.end())
#define push(a, b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a, b) (a, vector<ll>(b))
#define llpvec vector<pair<ll, ll>>
/*繰り上げ除算*/ ll cei(ll x, ll y) {
ll ans = x / y;
if (x % y != 0)
ans++;
return ans;
}
/*最大公約数*/ ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
/*最小公倍数*/ ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
/*n乗*/ ll llpow(ll x, ll n) {
ll i, ans = 1;
rep(i, 0, n) ans *= x;
return ans;
}
/*階乗*/ ll fact(ll x) {
ll i, ans = 1;
rep(i, 0, x) ans *= (x - i);
return ans;
}
/*nCr*/ ll ncr(ll n, ll r) { return fact(n) / fact(r) / fact(n - r); }
/*nPr*/ ll npr(ll n, ll r) { return fact(n) / fact(n - r); }
/*primejudge*/ bool prime(ll a) {
if (a <= 1)
return false;
ll i;
for (i = 2; i * i <= a; i++) {
if (a % i == 0)
return false;
}
return true;
}
ll ans = 0;
llfor; ///////////////////////////////////////////////////////////
int main() {
int N, K;
cin >> N >> K;
if (N >= 2 * K - 1)
cout << "Yes";
else
cout << "No";
return 0;
} | #include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i, a, N) for ((i) = (a); (i) < (N); (i)++)
#define rrp(i, N, a) for ((i) = (N)-1; (i) >= (a); (i)--)
#define llfor ll i, j, k
#define sc(a) cin >> a
#define pr(a) cout << a << endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(), a.end())
#define push(a, b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a, b) (a, vector<ll>(b))
#define llpvec vector<pair<ll, ll>>
/*繰り上げ除算*/ ll cei(ll x, ll y) {
ll ans = x / y;
if (x % y != 0)
ans++;
return ans;
}
/*最大公約数*/ ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
/*最小公倍数*/ ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
/*n乗*/ ll llpow(ll x, ll n) {
ll i, ans = 1;
rep(i, 0, n) ans *= x;
return ans;
}
/*階乗*/ ll fact(ll x) {
ll i, ans = 1;
rep(i, 0, x) ans *= (x - i);
return ans;
}
/*nCr*/ ll ncr(ll n, ll r) { return fact(n) / fact(r) / fact(n - r); }
/*nPr*/ ll npr(ll n, ll r) { return fact(n) / fact(n - r); }
/*primejudge*/ bool prime(ll a) {
if (a <= 1)
return false;
ll i;
for (i = 2; i * i <= a; i++) {
if (a % i == 0)
return false;
}
return true;
}
ll ans = 0;
llfor; ///////////////////////////////////////////////////////////
int main() {
int N, K;
cin >> N >> K;
if (N >= 2 * K - 1)
cout << "YES";
else
cout << "NO";
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 930,743 | 930,744 | u125669112 | cpp |
p03129 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (3 * k - 2 <= n) {
cout << "YES";
} else {
cout << "NO";
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (2 * k - 1 <= n) {
cout << "YES";
} else {
cout << "NO";
}
return 0;
} | [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 930,755 | 930,756 | u714796740 | cpp |
p03129 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if ((n + k - 1) / k >= 2)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if ((n + 1) / 2 >= k)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
} | [
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 930,761 | 930,762 | u071396528 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.