Datasets:

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
p03089
#include <bits/stdc++.h> using namespace std; #define FOR(i, begin, end) for (ll i = (begin); i < (end); i++) #define REP(i, n) FOR(i, 0, n) #define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--) #define IREP(i, n) IFOR(i, n, 0) #define SORT(a) sort(a.begin(), a.end()) #define ISORT(a) sort(a.begin(), a.end(), greater<ll>()) #define REVERSE(a) reverse(a.begin(), a.end()) #define debug(x) cout << #x << "=" << x << endl; #define vdebug(v) \ cout << #v << "=(" << v[0]; \ FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; } \ cout << ")" << endl; #define mdebug(m) \ cout << #m << "=" << endl; \ REP(i_debug, m.size()) { \ REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; } \ cout << endl; \ } #define Lower_bound(v, x) \ distance(v.begin(), lower_bound(v.begin(), v.end(), x)) #define Upper_bound(v, x) \ distance(v.begin(), upper_bound(v.begin(), v.end(), x)) #define Max(a, b) a = max(a, b) #define Min(a, b) a = min(a, b) #define ll long long #define f first #define s second #define mp make_pair #define pb push_back #define INF 1000000000000000000 using vec = vector<ll>; using mat = vector<vec>; using Pii = pair<ll, ll>; using PiP = pair<ll, Pii>; using PPi = pair<Pii, ll>; using bvec = vector<bool>; using Pvec = vector<Pii>; template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; } void readv_m1(vector<int> &a) { REP(i, a.size()) { cin >> a[i]; a[i]--; } } ll mod = 1000000007; int main() { ll N; cin >> N; vec b(N); REP(i, N) { cin >> b[i]; b[i]--; } vec ans(N, -1); IREP(i, N) { IREP(j, i + 1) { if (b[j] == j) { debug(j); b.erase(b.begin() + j); ans[i] = j; break; } } if (ans[i] == -1) { cout << -1 << endl; return 0; } } REP(i, N) { ans[i]++; cout << ans[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, begin, end) for (ll i = (begin); i < (end); i++) #define REP(i, n) FOR(i, 0, n) #define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--) #define IREP(i, n) IFOR(i, n, 0) #define SORT(a) sort(a.begin(), a.end()) #define ISORT(a) sort(a.begin(), a.end(), greater<ll>()) #define REVERSE(a) reverse(a.begin(), a.end()) #define debug(x) cout << #x << "=" << x << endl; #define vdebug(v) \ cout << #v << "=(" << v[0]; \ FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; } \ cout << ")" << endl; #define mdebug(m) \ cout << #m << "=" << endl; \ REP(i_debug, m.size()) { \ REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; } \ cout << endl; \ } #define Lower_bound(v, x) \ distance(v.begin(), lower_bound(v.begin(), v.end(), x)) #define Upper_bound(v, x) \ distance(v.begin(), upper_bound(v.begin(), v.end(), x)) #define Max(a, b) a = max(a, b) #define Min(a, b) a = min(a, b) #define ll long long #define f first #define s second #define mp make_pair #define pb push_back #define INF 1000000000000000000 using vec = vector<ll>; using mat = vector<vec>; using Pii = pair<ll, ll>; using PiP = pair<ll, Pii>; using PPi = pair<Pii, ll>; using bvec = vector<bool>; using Pvec = vector<Pii>; template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; } void readv_m1(vector<int> &a) { REP(i, a.size()) { cin >> a[i]; a[i]--; } } ll mod = 1000000007; int main() { ll N; cin >> N; vec b(N); REP(i, N) { cin >> b[i]; b[i]--; } vec ans(N, -1); IREP(i, N) { IREP(j, i + 1) { if (b[j] == j) { // debug(j); b.erase(b.begin() + j); ans[i] = j; break; } } if (ans[i] == -1) { cout << -1 << endl; return 0; } } REP(i, N) { ans[i]++; cout << ans[i] << endl; } return 0; }
[ "call.remove" ]
904,563
904,564
u973797979
cpp
p03089
#include <iostream> #include <vector> int main() { int n; std::cin >> n; std::vector<int> b(n); std::vector<int> ans(n); for (int i = 0; i < n; ++i) { std::cin >> b[i]; --b[i]; } for (int i = 0; i < n; ++i) { int upd = -1; for (int j = 0, p = 0; j < n; ++j) { if (b[j] >= 0) ++p; if (b[j] == p - 1 && b[j] <= n - 1 - i) { upd = j; } } if (upd == -1) { std::cout << -1 << std::endl; return 0; } else { ans[n - 1 - i] = b[upd]; b[upd] = -1; } } for (int i = 0; i < n; ++i) { std::cout << (ans[i] + 1) << std::endl; } return 0; }
#include <iostream> #include <vector> int main() { int n; std::cin >> n; std::vector<int> b(n); std::vector<int> ans(n); for (int i = 0; i < n; ++i) { std::cin >> b[i]; --b[i]; } for (int i = 0; i < n; ++i) { int upd = -1; for (int j = 0, p = 0; j < n; ++j) { if (b[j] < 0) continue; ++p; if (b[j] == p - 1 && b[j] <= n - 1 - i) { upd = j; } } if (upd == -1) { std::cout << -1 << std::endl; return 0; } else { ans[n - 1 - i] = b[upd]; b[upd] = -1; } } for (int i = 0; i < n; ++i) { std::cout << ans[i] + 1 << std::endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
904,565
904,566
u313111801
cpp
p03089
#include <algorithm> // sort #include <cstring> #include <iostream> #include <vector> #define REP(i, n) for (long long i = 0; i < (n); i++) typedef long long ll; static const ll MOD = 1000000007; static const ll INF = 1000000000000000000LL; using namespace std; using Graph = vector<vector<ll>>; // グラフ型 //数の書かれた N 個のボールが一列に並んでいる。すぬけ君は左から k 番目のボールに //k と書いてあ //るとき、それを選んで取り除くことができる。全てのボールを取り除くことは可能か? // agc032_a int main() { ll N; cin >> N; vector<ll> a(N); REP(i, N) { cin >> a[i]; --a[i]; } vector<ll> res; for (ll i = 0; i < N; ++i) { ll pivot = -1; //最大のものを取り除く for (ll j = a.size() - 1; j >= 0; --j) { if (a[j] == j) { pivot = j; break; } } if (pivot = -1) { cout << -1 << endl; return 0; } //追加の逆順に出力 res.push_back(pivot + 1); a.erase(a.begin() + pivot); } reverse(res.begin(), res.end()); for (auto v : res) { cout << v << endl; } return 0; }
#include <algorithm> // sort #include <cstring> #include <iostream> #include <vector> #define REP(i, n) for (long long i = 0; i < (n); i++) typedef long long ll; static const ll MOD = 1000000007; static const ll INF = 1000000000000000000LL; using namespace std; using Graph = vector<vector<ll>>; // グラフ型 //数の書かれた N 個のボールが一列に並んでいる。すぬけ君は左から k 番目のボールに //k と書いてあ //るとき、それを選んで取り除くことができる。全てのボールを取り除くことは可能か? // agc032_a int main() { ll N; cin >> N; vector<ll> a(N); REP(i, N) { cin >> a[i]; --a[i]; } vector<ll> res; for (ll i = 0; i < N; ++i) { ll pivot = -1; //最大のものを取り除く for (ll j = a.size() - 1; j >= 0; --j) { if (a[j] == j) { pivot = j; break; } } if (pivot == -1) { cout << -1 << endl; return 0; } //追加の逆順に出力 res.push_back(pivot + 1); a.erase(a.begin() + pivot); } reverse(res.begin(), res.end()); for (auto v : res) { cout << v << endl; } return 0; }
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
904,571
904,572
u485731913
cpp
p03089
#include <bits/stdc++.h> using namespace std; using lint = int64_t; #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) begin(v), end(v) #define in \ [] { \ lint n; \ cin >> n; \ return n; \ }() int main() { int N = in; vector<int> A(N); rep(i, N) A[i] = in - 1; vector<int> ans(N); while (!A.empty()) { for (int i = A.size() - 1; i >= 0; i--) { if (A[i] == i) { A.erase(A.begin() + i); ans[A.size() - 1] = i; goto E; } } cout << "-1\n"; return 0; E:; } rep(i, N) cout << ans[i] + 1 << "\n"; }
#include <bits/stdc++.h> using namespace std; using lint = int64_t; #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) begin(v), end(v) #define in \ [] { \ lint n; \ cin >> n; \ return n; \ }() int main() { int N = in; vector<int> A(N); rep(i, N) A[i] = in - 1; vector<int> ans(N); while (!A.empty()) { for (int i = A.size() - 1; i >= 0; i--) { if (A[i] == i) { A.erase(A.begin() + i); ans[A.size()] = i; goto E; } } cout << "-1\n"; return 0; E:; } rep(i, N) cout << ans[i] + 1 << "\n"; }
[ "expression.operation.binary.remove" ]
904,575
904,576
u151724181
cpp
p03089
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main() { cin.tie(0); ios_base::sync_with_stdio(false); int N; cin >> N; vector<int> v(N), ans; REP(i, N) cin >> v[i]; for (int i = N; i >= 1; --i) { int pos = -1; for (int j = 0; j < i; ++j) { // which num should be removed in turn-i if (v[j] == j + 1) { pos = j; } } if (pos == -1) { cout << -1 << '\n'; return 0; } ans.push_back(pos); for (int j = pos; j < i; ++j) v[j] = v[j + 1]; } for (int i = ans.size(); i >= 0; --i) cout << ans[i] + 1 << '\n'; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main() { cin.tie(0); ios_base::sync_with_stdio(false); int N; cin >> N; vector<int> v(N), ans; REP(i, N) cin >> v[i]; for (int i = N; i >= 1; --i) { int pos = -1; for (int j = 0; j < i; ++j) { // which num should be removed in turn-i if (v[j] == j + 1) { pos = j; } } if (pos == -1) { cout << -1 << '\n'; return 0; } ans.push_back(pos); for (int j = pos; j < i; ++j) v[j] = v[j + 1]; } for (int i = ans.size() - 1; i >= 0; --i) cout << ans[i] + 1 << '\n'; return 0; }
[ "control_flow.loop.for.initializer.change" ]
904,577
904,578
u843175622
cpp
p03090
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define hash dhsjakhd typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef long double ld; ll n, m, T, k, q; const ll big = 1000000007; unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); std::mt19937 eng(seed); uniform_int_distribution<> DD(0, 1000000000); ll random(ll r) { return (ll(DD(eng)) * 1000000000 + ll(DD(eng))) % r; } const ll MAXN = 5001; int main() { ios_base::sync_with_stdio(0); cin.tie(0); // freopen("input.txt","r",stdin); // freopen("autput.txt","w",stdout); ll a, b, c, d; cin >> n; if (n % 2 == 0) { m = (n * (n - 1)) / 2 - n / 2; cout << m << "\n"; for (int c1 = 0; c1 < n; c1++) { for (int c2 = c1 + 1; c2 < n; c2++) { if (c1 + c2 != n - 1) { cout << c1 + 1 << " " << c2 + 1 << "\n"; } } } } else { m = (n * (n - 1)) / 2 - n / 2; cout << m << "\n"; for (int c1 = 0; c1 < n; c1++) { for (int c2 = c1 + 1; c2 < n; c2++) { if (c1 + c2 != n - 1) { cout << c1 + 1 << " " << c2 + 1 << "\n"; } } } } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define hash dhsjakhd typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef long double ld; ll n, m, T, k, q; const ll big = 1000000007; unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); std::mt19937 eng(seed); uniform_int_distribution<> DD(0, 1000000000); ll random(ll r) { return (ll(DD(eng)) * 1000000000 + ll(DD(eng))) % r; } const ll MAXN = 5001; int main() { ios_base::sync_with_stdio(0); cin.tie(0); // freopen("input.txt","r",stdin); // freopen("autput.txt","w",stdout); ll a, b, c, d; cin >> n; if (n % 2 == 0) { m = (n * (n - 1)) / 2 - n / 2; cout << m << "\n"; for (int c1 = 0; c1 < n; c1++) { for (int c2 = c1 + 1; c2 < n; c2++) { if (c1 + c2 != n - 1) { cout << c1 + 1 << " " << c2 + 1 << "\n"; } } } } else { m = (n * (n - 1)) / 2 - n / 2; cout << m << "\n"; for (int c1 = 0; c1 < n; c1++) { for (int c2 = c1 + 1; c2 < n; c2++) { if (c1 + c2 != n - 2) { cout << c1 + 1 << " " << c2 + 1 << "\n"; } } } } return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
904,590
904,591
u791622911
cpp
p03090
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef unsigned long ul; typedef pair<ul, ul> P; map<int, int> dp; #define REP(i, n) for (int i = 0; i < n; i++) ul H, W; int CalcAns(int n) { return n * (n - 2) / 2; } void PrintAns(int N) { for (int ii = 1; ii <= N; ++ii) { for (int jj = ii + 1; jj <= N; ++jj) { if (ii + jj == N + 1) continue; cout << ii << " " << jj << endl; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; string S; cin >> N; if (N % 2 == 0) { cout << CalcAns(N) << endl; PrintAns(N); } else { cout << CalcAns(N - 1) + N << endl; PrintAns(N - 1); for (int ii = 1; ii <= N - 1; ++ii) { cout << ii << " " << N << endl; } } }
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef unsigned long ul; typedef pair<ul, ul> P; map<int, int> dp; #define REP(i, n) for (int i = 0; i < n; i++) ul H, W; int CalcAns(int n) { return n * (n - 2) / 2; } void PrintAns(int N) { for (int ii = 1; ii <= N; ++ii) { for (int jj = ii + 1; jj <= N; ++jj) { if (ii + jj == N + 1) continue; cout << ii << " " << jj << endl; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; string S; cin >> N; if (N % 2 == 0) { cout << CalcAns(N) << endl; PrintAns(N); } else { cout << CalcAns(N - 1) + N - 1 << endl; PrintAns(N - 1); for (int ii = 1; ii <= N - 1; ++ii) { cout << ii << " " << N << endl; } } }
[ "expression.operation.binary.add" ]
904,606
904,607
u276479653
cpp
p03090
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; int main() { int n; cin >> n; if (n & 1) { cout << (n - 1) * (n - 3) / 2 + n - 1 << endl; for (int i = 1; i < n; i++) { for (int j = i + 1; j < n; j++) { if (i + j != n) { cout << i << " " << j << endl; } } cout << i << " " << n << endl; } } else { cout << n * (n - 1) / 2 << endl; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { cout << i << " " << j << endl; } } } } return 0; }
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; int main() { int n; cin >> n; if (n & 1) { cout << (n - 1) * (n - 3) / 2 + n - 1 << endl; for (int i = 1; i < n; i++) { for (int j = i + 1; j < n; j++) { if (i + j != n) { cout << i << " " << j << endl; } } cout << i << " " << n << endl; } } else { cout << n * (n - 2) / 2 << endl; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { cout << i << " " << j << endl; } } } } return 0; }
[ "literal.number.change", "io.output.change" ]
904,608
904,609
u891482208
cpp
p03090
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #define ll long long #define mp make_pair using namespace std; ll read() { ll x = 0, f = 1; char c = getchar(); while (c > '9' || c < '0') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return f * x; } int n, top; struct node { int from, to; } as[10000]; bool flag; int main() { n = read(); if (n & 1) { flag = 1; n--; } for (int i = 1; i <= n / 2; ++i) for (int j = 1; j <= n; ++j) if (j != i && j + i != n + 1) as[++top] = (node){i, j}; if (flag) { for (int i = 1; i <= n; ++i) as[++top] = (node){i, n + 1}; } cout << top << '\n'; for (int i = 1; i <= top; ++i) cout << as[i].from << " " << as[i].to << '\n'; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #define ll long long #define mp make_pair using namespace std; ll read() { ll x = 0, f = 1; char c = getchar(); while (c > '9' || c < '0') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return f * x; } int n, top; struct node { int from, to; } as[10000]; bool flag; int main() { n = read(); if (n & 1) { flag = 1; n--; } for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j) if (j != i && j + i != n + 1) as[++top] = (node){i, j}; if (flag) { for (int i = 1; i <= n; ++i) as[++top] = (node){i, n + 1}; } cout << top << '\n'; for (int i = 1; i <= top; ++i) cout << as[i].from << " " << as[i].to << '\n'; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "control_flow.loop.for.initializer.change" ]
904,610
904,611
u543967420
cpp
p03090
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; typedef long long ll; typedef long double ld; typedef unsigned long long ull; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; x *= f; } template <typename T> void write(T x) { if (x < 0) x = -x, putchar('-'); if (x > 9) write(x / 10); putchar(x % 10 + '0'); } template <typename T> void writeln(T x) { write(x); puts(""); } int n; vector<pair<int, int>> a; int main() { read(n); for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != n + 1) a.emplace_back(i, j); writeln(a.size()); for (auto x : a) printf("%d %d\n", x.first, x.second); return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; typedef long long ll; typedef long double ld; typedef unsigned long long ull; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; x *= f; } template <typename T> void write(T x) { if (x < 0) x = -x, putchar('-'); if (x > 9) write(x / 10); putchar(x % 10 + '0'); } template <typename T> void writeln(T x) { write(x); puts(""); } int n; vector<pair<int, int>> a; int main() { read(n); for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != n + (n + 1) % 2) a.emplace_back(i, j); writeln(a.size()); for (auto x : a) printf("%d %d\n", x.first, x.second); return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,614
904,615
u744755176
cpp
p03090
#include <bits/stdc++.h> using namespace std; int l[1200000], r[1200000]; int a[1200], tot, n, ans[1200]; int solve() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int solve1() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int main() { // freopen("1.in","r",stdin); scanf("%d", &n); if (n & 1) solve(); else solve1(); }
#include <bits/stdc++.h> using namespace std; int l[1200000], r[1200000]; int a[1200], tot, n, ans[1200]; int solve() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int solve1() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int main() { // freopen("1.in","r",stdin); scanf("%d", &n); if (n & 1) solve1(); else solve(); }
[ "call.remove", "control_flow.branch.else.remove", "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add", "call.add" ]
904,616
904,617
u218946416
cpp
p03090
#include <bits/stdc++.h> using namespace std; int l[1200000], r[1200000]; int a[1200], tot, n, ans[1200]; int solve() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int solve1() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int main() { scanf("%d", &n); if (n == 1) solve(); else solve1(); }
#include <bits/stdc++.h> using namespace std; int l[1200000], r[1200000]; int a[1200], tot, n, ans[1200]; int solve() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int solve1() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int main() { // freopen("1.in","r",stdin); scanf("%d", &n); if (n & 1) solve1(); else solve(); }
[ "control_flow.branch.if.condition.change", "call.remove", "control_flow.branch.else.remove", "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add", "call.add" ]
904,618
904,617
u218946416
cpp
p03090
#include <bits/stdc++.h> using namespace std; int l[1200], r[1200]; int a[1200], tot, n, ans[1200]; int solve() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int solve1() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int main() { scanf("%d", &n); if (n == 1) solve(); else solve1(); }
#include <bits/stdc++.h> using namespace std; int l[1200000], r[1200000]; int a[1200], tot, n, ans[1200]; int solve() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int solve1() { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n) { tot++; l[tot] = i; r[tot] = j; } } } printf("%d\n", tot); for (int i = 1; i <= tot; i++) printf("%d %d\n", l[i], r[i]); } int main() { // freopen("1.in","r",stdin); scanf("%d", &n); if (n & 1) solve1(); else solve(); }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "control_flow.branch.if.condition.change", "call.remove", "control_flow.branch.else.remove", "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add", "call.add" ]
904,619
904,617
u218946416
cpp
p03090
#include <iostream> using namespace std; int main() { int N, i, j; cin >> N; cout << N * (N - 1) - N / 2 << endl; for (i = 0; i < N - 1; i++) { for (j = i + 1; j < N; j++) { if (i + j != N / 2 * 2 - 1) cout << i + 1 << " " << j + 1 << endl; } } }
#include <iostream> using namespace std; int main() { int N, i, j; cin >> N; cout << N * (N - 1) / 2 - N / 2 << endl; for (i = 0; i < N - 1; i++) { for (j = i + 1; j < N; j++) { if (i + j != N / 2 * 2 - 1) cout << i + 1 << " " << j + 1 << endl; } } }
[ "expression.operation.binary.add" ]
904,620
904,621
u956908227
cpp
p03090
#include <bits/stdc++.h> using namespace std; using ll = long long; #define forx(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) #define caseout(i, x) cout << "Case #" << i << ": " << x << endl; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; if (n % 2 == 0) { cout << n * (n - 2) / 2 << endl; forx(i, 1, n) { forx(j, i + 1, n + 1) { if (i + j == n + 1) continue; cout << i << ' ' << j << endl; } } } else { cout << (n - 1) * (n - 1) / 2 << endl; forx(i, 1, n) { forx(j, i + 1, n + 1) { if (i + j == n + 1) continue; cout << i << ' ' << j << endl; } } } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define forx(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) #define caseout(i, x) cout << "Case #" << i << ": " << x << endl; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; if (n % 2 == 0) { cout << n * (n - 2) / 2 << endl; forx(i, 1, n) { forx(j, i + 1, n + 1) { if (i + j == n + 1) continue; cout << i << ' ' << j << endl; } } } else { cout << (n - 1) * (n - 1) / 2 << endl; forx(i, 1, n) { forx(j, i + 1, n + 1) { if (i + j == n) continue; cout << i << ' ' << j << endl; } } } return 0; }
[ "expression.operation.binary.remove" ]
904,623
904,624
u604231488
cpp
p03090
#include <iostream> using namespace std; int main() { int n, e; cin >> n; e = (n / 2 ? n : n + 1); cout << n * (n - 1) / 2 - (n - 2) << endl; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != e) cout << i << " " << j << endl; return 0; }
#include <iostream> using namespace std; int main() { int n, e; cin >> n; e = (n % 2 ? n : (n + 1)); cout << n * (n - 1) / 2 - n / 2 << endl; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != e) cout << i << " " << j << endl; return 0; }
[ "expression.operator.arithmetic.change", "assignment.value.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "io.output.change" ]
904,627
904,628
u612175324
cpp
p03090
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) const char sp = ' '; const char cmm = ','; const int MOD = 1000000007; using ll = long long; ll mod(ll a, ll b) { return (a % b + b) % b; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } void Yes() { cout << "Yes" << endl; } void No() { cout << "No" << endl; } void Judge(bool b) { b ? Yes() : No(); } void YES() { cout << "YES" << endl; } void NO() { cout << "NO" << endl; } void JUDGE(bool b) { b ? YES() : NO(); } ll powMod(ll b, ll e, ll m) { ll r = 1; while (e > 0) { if (e & 1) r = (r % m) * (b % m) % m; b = (b % m) * (b % m) % m; e >>= 1; } return r; } double distance(ll x1, ll y1, ll x2, ll y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } template <typename T> void ppp(T n) { cout << n << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; bool mat[n][n]; fill_n(*mat, n * n, true); for (int i = 0; i < n; ++i) { mat[i][i] = false; } for (int i = 0; i < n - n % 2; ++i) { mat[i][n - i - 1 - n % 2] = false; } int cnt = 0; vector<pair<int, int>> edge; for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { if (mat[i - 1][j - 1]) edge.push_back(make_pair(i, j)); ++cnt; } } ppp(cnt); for (auto e : edge) { cout << e.first << sp << e.second << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) const char sp = ' '; const char cmm = ','; const int MOD = 1000000007; using ll = long long; ll mod(ll a, ll b) { return (a % b + b) % b; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } void Yes() { cout << "Yes" << endl; } void No() { cout << "No" << endl; } void Judge(bool b) { b ? Yes() : No(); } void YES() { cout << "YES" << endl; } void NO() { cout << "NO" << endl; } void JUDGE(bool b) { b ? YES() : NO(); } ll powMod(ll b, ll e, ll m) { ll r = 1; while (e > 0) { if (e & 1) r = (r % m) * (b % m) % m; b = (b % m) * (b % m) % m; e >>= 1; } return r; } double distance(ll x1, ll y1, ll x2, ll y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } template <typename T> void ppp(T n) { cout << n << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; bool mat[n][n]; fill_n(*mat, n * n, true); for (int i = 0; i < n; ++i) { mat[i][i] = false; } for (int i = 0; i < n - n % 2; ++i) { mat[i][n - i - 1 - n % 2] = false; } int cnt = 0; vector<pair<int, int>> edge; for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { if (mat[i - 1][j - 1]) { edge.push_back(make_pair(i, j)); ++cnt; } } } ppp(cnt); for (auto e : edge) { cout << e.first << sp << e.second << endl; } return 0; }
[]
904,633
904,634
u306142032
cpp
p03090
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a) for (int i = 0; i < (a); i++) const ll MOD = 1000000007; int E[111][111]; int main() { int N; cin >> N; int cnt = 0; rep(i, N) rep(j, N) { if (i >= j) continue; if (N % 2 && i + j + 2 != N) E[i][j] = 1, cnt++; if (!N % 2 && i + j + 2 != N + 1) E[i][j] = 1, cnt++; } cout << cnt << endl; rep(i, N) rep(j, N) { if (E[i][j]) cout << i + 1 << " " << j + 1 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a) for (int i = 0; i < (a); i++) const ll MOD = 1000000007; int E[111][111]; int main() { int N; cin >> N; int cnt = 0; rep(i, N) rep(j, N) { if (i >= j) continue; if (N % 2 && i + j + 2 != N) E[i][j] = 1, cnt++; if (N % 2 == 0 && i + j + 2 != N + 1) E[i][j] = 1, cnt++; } cout << cnt << endl; rep(i, N) rep(j, N) { if (E[i][j]) cout << i + 1 << " " << j + 1 << endl; } return 0; }
[ "expression.operation.unary.logical.remove", "control_flow.branch.if.condition.change" ]
904,637
904,638
u046768272
cpp
p03090
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <iterator> #include <set> using namespace std; using namespace __gnu_pbds; #define ft first #define sd second #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define ll long long int #define vi vector<int> #define vii vector<pair<int, int>> #define pii pair<int, int> #define plii pair<pair<ll, int>, int> #define piii pair<pii, int> #define viii vector<pair<pii, int>> #define vl vector<ll> #define vll vector<pair<ll, ll>> #define pll pair<ll, ll> #define pli pair<ll, int> #define mp make_pair #define ms(x, v) memset(x, v, sizeof x) #define pr_vec(v) \ for (int i = 0; i < v.size(); i++) \ cout << v[i] << " "; #define f_in(st) freopen(st, "r", stdin) #define f_out(st) freopen(st, "w", stdout) #define INF INT_MAX #define fr(i, a, b) for (i = a; i <= b; i++) #define fb(i, a, b) for (i = a; i >= b; i--) #define ASST(x, l, r) assert(x <= r && x >= l) typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; const int N = 1e5 + 10, M = (ll)1e6 + 10; const int mod = 1e9 + 7; vl g[N]; vl vis(N, 0); // vl compute(string s){ // vl has(s.length()); // ll i; // for(i=0;i<s.length();i++){ // if(i==0){ // has[i]=((s[i]-'a'+1))%mod; // } // else // has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod; // } // return has; // } ll dfs(ll x) { // cout << x << endl; vis[x] = 1; ll c = 1; for (auto &it : g[x]) { if (!vis[it]) c += dfs(it); } return c; } ll po(ll a, ll x, ll m) { if (x == 0) return 1; if (x == 1) return a % m; ll z = po(a, x / 2, m) % m; if (x & 1) return (((z % m) * (z % m)) % m * (a % m)) % m; return (((z % m) * (z % m)) % m) % m; } int main() { ios_base::sync_with_stdio(0); ll i, n, s = 0, j; cin >> n; s = n; if (!n % 2) s++; vll ans; for (i = 1; i <= n; i++) { for (j = i + 1; j <= n; j++) { if (i + j == s) continue; ans.eb(i, j); } } cout << ans.size() << endl; for (i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << "\n"; return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <iterator> #include <set> using namespace std; using namespace __gnu_pbds; #define ft first #define sd second #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define ll long long int #define vi vector<int> #define vii vector<pair<int, int>> #define pii pair<int, int> #define plii pair<pair<ll, int>, int> #define piii pair<pii, int> #define viii vector<pair<pii, int>> #define vl vector<ll> #define vll vector<pair<ll, ll>> #define pll pair<ll, ll> #define pli pair<ll, int> #define mp make_pair #define ms(x, v) memset(x, v, sizeof x) #define pr_vec(v) \ for (int i = 0; i < v.size(); i++) \ cout << v[i] << " "; #define f_in(st) freopen(st, "r", stdin) #define f_out(st) freopen(st, "w", stdout) #define INF INT_MAX #define fr(i, a, b) for (i = a; i <= b; i++) #define fb(i, a, b) for (i = a; i >= b; i--) #define ASST(x, l, r) assert(x <= r && x >= l) typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; const int N = 1e5 + 10, M = (ll)1e6 + 10; const int mod = 1e9 + 7; vl g[N]; vl vis(N, 0); // vl compute(string s){ // vl has(s.length()); // ll i; // for(i=0;i<s.length();i++){ // if(i==0){ // has[i]=((s[i]-'a'+1))%mod; // } // else // has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod; // } // return has; // } ll dfs(ll x) { // cout << x << endl; vis[x] = 1; ll c = 1; for (auto &it : g[x]) { if (!vis[it]) c += dfs(it); } return c; } ll po(ll a, ll x, ll m) { if (x == 0) return 1; if (x == 1) return a % m; ll z = po(a, x / 2, m) % m; if (x & 1) return (((z % m) * (z % m)) % m * (a % m)) % m; return (((z % m) * (z % m)) % m) % m; } int main() { ios_base::sync_with_stdio(0); ll i, n, s = 0, j; cin >> n; s = n; if (n % 2 == 0) s++; vll ans; for (i = 1; i <= n; i++) { for (j = i + 1; j <= n; j++) { if (i + j == s) continue; ans.eb(i, j); } } cout << ans.size() << endl; for (i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << "\n"; return 0; }
[ "expression.operation.unary.logical.remove", "control_flow.branch.if.condition.change" ]
904,639
904,640
u888735570
cpp
p03090
#include <bits/stdc++.h> using namespace std; #define REP(i, N) for (i = 0; i < N; i++) typedef long long ll; typedef pair<int, int> P; typedef struct { int first; int second; int third; } T; //昇順 bool comp_Se(T &l, T &r) { return l.second < r.second; } int main(void) { int N; cin >> N; cout << N * (N - 1) / 2 - (N + 1) / 2 << endl; int i, j; int m = (N + 1) % 2; REP(i, N) { for (j = i + 1; j < N; j++) { if (i + j + 2 != N + m) cout << i + 1 << " " << j + 1 << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, N) for (i = 0; i < N; i++) typedef long long ll; typedef pair<int, int> P; typedef struct { int first; int second; int third; } T; //昇順 bool comp_Se(T &l, T &r) { return l.second < r.second; } int main(void) { int N; cin >> N; cout << N * (N - 1) / 2 - N / 2 << endl; int i, j; int m = (N + 1) % 2; REP(i, N) { for (j = i + 1; j < N; j++) { if (i + j + 2 != N + m) cout << i + 1 << " " << j + 1 << endl; } } return 0; }
[]
904,647
904,648
u069450081
cpp
p03090
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int iINF = 1000000000; const long long int llINF = 1000000000000000000; using namespace std; using ll = long long int; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>; using edge = struct { int to; int cost; }; #define REP(i, n) for (ll i = 0; i < (n); i++) #define RREP(i, n) for (ll i = (n)-1; i >= 0; i--) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define AUTO(i, m) for (auto &i : m) #define ALL(a) (a).begin(), (a).end() #define MAX(vec) *std::max_element(vec.begin(), vec.end()) #define MIN(vec) *std::min_element(vec.begin(), vec.end()) #define ARGMAX(vec) \ std::distance(vec.begin(), std::max_element(vec.begin(), vec.end())) #define ARGMIN(vec) \ std::distance(vec.begin(), std::min_element(vec.begin(), vec.end())) #define BIT(n, num) std::bitset<(n)>((num)).to_string() #define REV(T) greater<T>() #define PQ(T) priority_queue<T, vector<T>, greater<T>> #define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c)) #define VVVL(a, b, c, d) \ vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d))) typedef pair<ll, ll> pll; bool paircomp(const pll &a, const pll &b) { if (a.first == b.first) return a.second < b.second; return a.first < b.first; } ll POW(ll n, ll m) { if (m == 0) { return 1; } else if (m % 2 == 0) { ll tmp = POW(n, m / 2); return (tmp * tmp); } else { return (n * POW(n, m - 1)); } } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll N; cin >> N; if (N % 2 == 0) { cout << (N * (N - 1) / 2) - (N / 2) << endl; FOR(i, 1, N + 1) FOR(j, 1, i) { if (i + j != N + 1) cout << j << " " << i << endl; } } else { cout << (N * (N - 1) / 2) - (N / 2) - 1 << endl; FOR(i, 1, N + 1) FOR(j, 1, i) { if (i + j != N) cout << j << " " << i << endl; } } return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int iINF = 1000000000; const long long int llINF = 1000000000000000000; using namespace std; using ll = long long int; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>; using edge = struct { int to; int cost; }; #define REP(i, n) for (ll i = 0; i < (n); i++) #define RREP(i, n) for (ll i = (n)-1; i >= 0; i--) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define AUTO(i, m) for (auto &i : m) #define ALL(a) (a).begin(), (a).end() #define MAX(vec) *std::max_element(vec.begin(), vec.end()) #define MIN(vec) *std::min_element(vec.begin(), vec.end()) #define ARGMAX(vec) \ std::distance(vec.begin(), std::max_element(vec.begin(), vec.end())) #define ARGMIN(vec) \ std::distance(vec.begin(), std::min_element(vec.begin(), vec.end())) #define BIT(n, num) std::bitset<(n)>((num)).to_string() #define REV(T) greater<T>() #define PQ(T) priority_queue<T, vector<T>, greater<T>> #define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c)) #define VVVL(a, b, c, d) \ vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d))) typedef pair<ll, ll> pll; bool paircomp(const pll &a, const pll &b) { if (a.first == b.first) return a.second < b.second; return a.first < b.first; } ll POW(ll n, ll m) { if (m == 0) { return 1; } else if (m % 2 == 0) { ll tmp = POW(n, m / 2); return (tmp * tmp); } else { return (n * POW(n, m - 1)); } } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll N; cin >> N; if (N % 2 == 0) { cout << (N * (N - 1) / 2) - (N / 2) << endl; FOR(i, 1, N + 1) FOR(j, 1, i) { if (i + j != N + 1) cout << j << " " << i << endl; } } else { cout << (N * (N - 1) / 2) - (N / 2) << endl; FOR(i, 1, N + 1) FOR(j, 1, i) { if (i + j != N) cout << j << " " << i << endl; } } return 0; }
[ "expression.operation.binary.remove" ]
904,653
904,654
u050865477
cpp
p03090
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int INF = (1LL << 30) - 1; int MOD = 1e9 + 7; main() { int N; cin >> N; int graph[N][N]; rep(i, 0, N) rep(j, 0, N) graph[i][j] = 1; rep(i, 0, N) graph[i][i] = 0; if (N % 2) { rep(i, 0, N - 1) { graph[i][N - i - 1] = graph[N - i - 1][i] = 0; } } else { rep(i, 0, N) { graph[i][N - i - 1] = graph[i][N - i - 1] = 0; } } vector<P> ans; rep(i, 0, N) rep(j, i + 1, N) { if (graph[i][j]) ans.emplace_back(i + 1, j + 1); } cout << ans.size() << endl; for (auto p : ans) { cout << p.first << " " << p.second << endl; } }
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int INF = (1LL << 30) - 1; int MOD = 1e9 + 7; main() { int N; cin >> N; int graph[N][N]; rep(i, 0, N) rep(j, 0, N) graph[i][j] = 1; rep(i, 0, N) graph[i][i] = 0; if (N % 2) { rep(i, 0, N - 1) { graph[i][N - i - 2] = graph[N - i - 2][i] = 0; } } else { rep(i, 0, N) { graph[i][N - i - 1] = graph[i][N - i - 1] = 0; } } vector<P> ans; rep(i, 0, N) rep(j, i + 1, N) { if (graph[i][j]) ans.emplace_back(i + 1, j + 1); } cout << ans.size() << endl; for (auto p : ans) { cout << p.first << " " << p.second << endl; } }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
904,661
904,662
u157322125
cpp
p03090
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; int main(void) { int n; cin >> n; vector<int> a, b; if (n % 2 == 1) { for (int i = 0; i < n - 1; i++) { a.push_back(i + 1); b.push_back(n); } for (int i = 1; i <= n - 1; i++) { for (int j = i + 1; j <= n - 1; j++) { if (i + j != n) { a.push_back(i); b.push_back(j); } } } cout << a.size() << endl; for (int i = 0; i < a.size(); i++) { cout << a[i] << " " << b[i] << endl; } } else { for (int i = 1; i <= n - 1; i++) { for (int j = i + 1; j <= n - 1; j++) { if (i + j != n) { a.push_back(i); b.push_back(j); } } } cout << a.size() << endl; for (int i = 0; i < a.size(); i++) { cout << a[i] << " " << b[i] << endl; } } }
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; int main(void) { int n; cin >> n; vector<int> a, b; if (n % 2 == 1) { for (int i = 0; i < n - 1; i++) { a.push_back(i + 1); b.push_back(n); } for (int i = 1; i <= n - 1; i++) { for (int j = i + 1; j <= n - 1; j++) { if (i + j != n) { a.push_back(i); b.push_back(j); } } } cout << a.size() << endl; for (int i = 0; i < a.size(); i++) { cout << a[i] << " " << b[i] << endl; } } else { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { a.push_back(i); b.push_back(j); } } } cout << a.size() << endl; for (int i = 0; i < a.size(); i++) { cout << a[i] << " " << b[i] << endl; } } }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "control_flow.branch.if.condition.change", "misc.off_by_one" ]
904,674
904,673
u921168761
cpp
p03090
#include <bits/stdc++.h> using namespace std; typedef long long int llint; typedef pair<int, int> pii; typedef pair<llint, llint> pll; typedef vector<int> vi; typedef vector<llint> vl; typedef vector<pii> vii; typedef vector<pll> vll; #define ci cin #define co cout #define en endl #define ln cout << '\n' #define rep(i, n) for (int i = 0; i < n; i++) #define outl(x) cout << (x) << '\n' #define pb push_back #define fi first #define se second #define MOD 1000000007 template <typename Tn> Tn gcd(Tn a, Tn b) { return (b ? gcd(b, a % b) : a); } template <typename Tn> Tn lcm(Tn a, Tn b) { return a / gcd(a, b) * b; } string IntToString(int number) { stringstream ss; ss << number; return ss.str(); } llint cnt = 0; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int n; int main() { ci >> n; llint sum = 0; for (int i = 1; i <= n; i++) sum += i; co << sum - n / 2 << en; if (n % 2 == 0) { for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j == n + 1) continue; co << i << ' ' << j << en; } } } else { for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j == n) continue; co << i << ' ' << j << en; } } } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int llint; typedef pair<int, int> pii; typedef pair<llint, llint> pll; typedef vector<int> vi; typedef vector<llint> vl; typedef vector<pii> vii; typedef vector<pll> vll; #define ci cin #define co cout #define en endl #define ln cout << '\n' #define rep(i, n) for (int i = 0; i < n; i++) #define outl(x) cout << (x) << '\n' #define pb push_back #define fi first #define se second #define MOD 1000000007 template <typename Tn> Tn gcd(Tn a, Tn b) { return (b ? gcd(b, a % b) : a); } template <typename Tn> Tn lcm(Tn a, Tn b) { return a / gcd(a, b) * b; } string IntToString(int number) { stringstream ss; ss << number; return ss.str(); } llint cnt = 0; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int n; int main() { ci >> n; llint sum = 0; for (int i = 1; i < n; i++) sum += i; co << sum - n / 2 << en; if (n % 2 == 0) { for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j == n + 1) continue; co << i << ' ' << j << en; } } } else { for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j == n) continue; co << i << ' ' << j << en; } } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
904,677
904,678
u966921248
cpp
p03090
#include <bits/stdc++.h> using namespace std; template <class T> inline void init(T &x) { x = 0; char ch = getchar(); bool t = 0; for (; ch > '9' || ch < '0'; ch = getchar()) if (ch == '-') t = 1; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + (ch - 48); if (t) x = -x; return; } int n; typedef pair<int, int> PA; vector<PA> Ans; const int N = 1000; int bel[N]; int main() { init(n); if (n & 1) { for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { if (i + j == n || j == n) continue; Ans.push_back(PA(i, j)); } } } else { for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { if (i + j == n + 1) continue; Ans.push_back(PA(i, j)); } } } int num = Ans.size(); cout << num << endl; for (int i = 0; i < num; ++i) { printf("%d %d\n", Ans[i].first, Ans[i].second); } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline void init(T &x) { x = 0; char ch = getchar(); bool t = 0; for (; ch > '9' || ch < '0'; ch = getchar()) if (ch == '-') t = 1; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + (ch - 48); if (t) x = -x; return; } int n; typedef pair<int, int> PA; vector<PA> Ans; const int N = 1000; int bel[N]; int main() { init(n); if (n & 1) { for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { if (i + j == n && j != n) continue; Ans.push_back(PA(i, j)); } } } else { for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { if (i + j == n + 1) continue; Ans.push_back(PA(i, j)); } } } int num = Ans.size(); cout << num << endl; for (int i = 0; i < num; ++i) { printf("%d %d\n", Ans[i].first, Ans[i].second); } return 0; }
[ "misc.opposites", "control_flow.branch.if.condition.change", "expression.operator.compare.change" ]
904,685
904,686
u142717651
cpp
p03090
#include <algorithm> #include <array> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <utility> #include <vector> using namespace std; using lli = long long int; template <class T, class U> void init_n(vector<T> &v, size_t n, U x) { v = vector<T>(n, x); } template <class T> void init_n(vector<T> &v, size_t n) { init_n(v, n, T()); } template <class T> void read_n(vector<T> &v, size_t n, size_t o = 0) { v = vector<T>(n + o); for (lli i = o; i < n + o; ++i) cin >> v[i]; } template <class T> void read_n(T a[], size_t n, size_t o = 0) { for (lli i = o; i < n + o; ++i) cin >> a[i]; } template <class T> T gabs(const T &x) { return max(x, -x); } #define abs gabs lli n; int main() { cin >> n; lli m = n / 2 * 2; vector<pair<lli, lli>> e; for (lli i = 1; i <= m / 2; ++i) { for (lli j = 1; j <= m; ++j) { if (i != j && j != m + 1 - i && i < j) e.emplace_back(i, j); } } if (n % 2 == 1) { for (lli i = 1; i <= n - 1; ++i) { e.emplace_back(i, n); } } cout << e.size() << '\n'; for (auto &p : e) { cout << p.first << ' ' << p.second << '\n'; } return 0; }
#include <algorithm> #include <array> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <utility> #include <vector> using namespace std; using lli = long long int; template <class T, class U> void init_n(vector<T> &v, size_t n, U x) { v = vector<T>(n, x); } template <class T> void init_n(vector<T> &v, size_t n) { init_n(v, n, T()); } template <class T> void read_n(vector<T> &v, size_t n, size_t o = 0) { v = vector<T>(n + o); for (lli i = o; i < n + o; ++i) cin >> v[i]; } template <class T> void read_n(T a[], size_t n, size_t o = 0) { for (lli i = o; i < n + o; ++i) cin >> a[i]; } template <class T> T gabs(const T &x) { return max(x, -x); } #define abs gabs lli n; int main() { cin >> n; lli m = n / 2 * 2; vector<pair<lli, lli>> e; for (lli i = 1; i <= m; ++i) { for (lli j = 1; j <= m; ++j) { if (i != j && j != m + 1 - i && i < j) e.emplace_back(i, j); } } if (n % 2 == 1) { for (lli i = 1; i <= n - 1; ++i) { e.emplace_back(i, n); } } cout << e.size() << '\n'; for (auto &p : e) { cout << p.first << ' ' << p.second << '\n'; } return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
904,689
904,690
u090994275
cpp
p03090
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; using ll = long long; ll N; void input() { // cin >> N; N = 5; } void solve() { if (N == 3) { cout << 2 << endl; cout << 1 << ' ' << 3 << endl; cout << 2 << ' ' << 3 << endl; return; } vector<pair<ll, ll>> ans; auto n = N - (N % 2); for (ll i = 1; i <= n; i++) { for (ll j = i + 1; j <= n; j++) { if (j == n - i + 1) continue; ans.push_back({i, j}); } } if (N % 2) { for (ll i = 1; i <= n; i++) ans.push_back({i, N}); } cout << ans.size() << endl; for (auto p : ans) cout << p.first << " " << p.second << endl; } int main() { input(); // cout << solve() << endl; solve(); return 0; }
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; using ll = long long; ll N; void input() { cin >> N; } void solve() { if (N == 3) { cout << 2 << endl; cout << 1 << ' ' << 3 << endl; cout << 2 << ' ' << 3 << endl; return; } vector<pair<ll, ll>> ans; auto n = N - (N % 2); for (ll i = 1; i <= n; i++) { for (ll j = i + 1; j <= n; j++) { if (j == n - i + 1) continue; ans.push_back({i, j}); } } if (N % 2) { for (ll i = 1; i <= n; i++) ans.push_back({i, N}); } cout << ans.size() << endl; for (auto p : ans) cout << p.first << " " << p.second << endl; } int main() { input(); // cout << solve() << endl; solve(); return 0; }
[ "assignment.change" ]
904,697
904,698
u500092662
cpp
p03090
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; if (n % 2 == 0) { cout << n * (n - 2) / 2 << endl; for (int i = 1; i < n + 1; i++) { for (int j = 1; j < n + 1; j++) { if (i + j != n + 1) { cout << i << " " << j << endl; } } } } else { cout << (n - 1) * (n - 1) / 2 << endl; for (int i = 1; i < n + 1; i++) { for (int j = i + 1; j < n + 1; j++) { if (i + j != n) { cout << i << " " << j << endl; } } } } }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; if (n % 2 == 0) { cout << n * (n - 2) / 2 << endl; for (int i = 1; i < n + 1; i++) { for (int j = i + 1; j < n + 1; j++) { if (i + j != n + 1) { cout << i << " " << j << endl; } } } } else { cout << (n - 1) * (n - 1) / 2 << endl; for (int i = 1; i < n + 1; i++) { for (int j = i + 1; j < n + 1; j++) { if (i + j != n) { cout << i << " " << j << endl; } } } } }
[ "control_flow.loop.for.initializer.change" ]
904,700
904,701
u467826805
cpp
p03090
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; if (n % 2 == 0) { cout << n * (n - 2) / 2 << endl; for (int i = 1; i < n + 1; i++) { for (int j = 1; j < n + 1; j++) { if (i + j != n + 1) { cout << i << " " << "j" << endl; } } } } else { cout << (n - 1) * (n - 1) / 2 << endl; for (int i = 1; i < n + 1; i++) { for (int j = i + 1; j < n + 1; j++) { if (i + j != n) { cout << i << " " << j << endl; } } } } }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; if (n % 2 == 0) { cout << n * (n - 2) / 2 << endl; for (int i = 1; i < n + 1; i++) { for (int j = i + 1; j < n + 1; j++) { if (i + j != n + 1) { cout << i << " " << j << endl; } } } } else { cout << (n - 1) * (n - 1) / 2 << endl; for (int i = 1; i < n + 1; i++) { for (int j = i + 1; j < n + 1; j++) { if (i + j != n) { cout << i << " " << j << endl; } } } } }
[ "control_flow.loop.for.initializer.change" ]
904,702
904,701
u467826805
cpp
p03090
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; if (N % 2 == 1) { cout << (N - 1) * (N - 1) / 2 << endl; for (int i = 1; i < N; i++) { for (int j = i; j <= N; j++) { if (i + j != N) { cout << i << " " << j << endl; } } } } else { cout << N * (N - 2) / 2 << endl; for (int i = 1; i <= N; i++) { for (int j = i + 1; j <= N; j++) { if (i + j != N + 1) { cout << i << " " << j << endl; } } } } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; if (N % 2 == 1) { cout << (N - 1) * (N - 1) / 2 << endl; for (int i = 1; i < N; i++) { for (int j = i + 1; j <= N; j++) { if (i + j != N) { cout << i << " " << j << endl; } } } } else { cout << N * (N - 2) / 2 << endl; for (int i = 1; i <= N; i++) { for (int j = i + 1; j <= N; j++) { if (i + j != N + 1) { cout << i << " " << j << endl; } } } } }
[ "control_flow.loop.for.initializer.change" ]
904,712
904,713
u045811375
cpp
p03088
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <stdio.h> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #define rep(i, a, n) for (ll i = (a); i < (n); ++i) #define urep(i, a, n) for (ll i = (a); i >= (n); --i) #define all(x) (x).begin(), (x).end() #define INF 1e18 const int mod = 1e9 + 7; typedef long long ll; using namespace std; ll dx[4] = {1, -1, 0, 0}; ll dy[4] = {0, 0, 1, -1}; ll N, M, X, Y, A, B, C, D, Q, K, R, W, H, P, L; ll ans; string S, T; ll y[101010]; ll a[101010]; ll b[101010]; ll t[101010]; ll p[101010]; ll n[101010]; ll l[101010]; ll r[101010]; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } struct Edge { ll to, cost; Edge(ll to, ll cost) : to(to), cost(cost) {} }; typedef vector<vector<Edge>> AdjList; AdjList graph; vector<ll> dist; struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 vector<ll> size; UnionFind(ll N) : par(N), size(N) { //最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; for (ll i = 0; i < N; i++) size[i] = 1; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } ll GetSize(ll x) { return size[root(x)]; } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける size[ry] += size[rx]; } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } }; ll DP[1010][5][5][5]; int main() { cin >> N; ans = 0; ll A = 0, C = 1, G = 2, T = 3; rep(i, 0, 4) { rep(j, 0, 4) { rep(k, 0, 4) { rep(l, 0, 4) { if (i == A && j == G && k == C) continue; // AGC if (i == G && j == A && k == C) continue; // GAC if (i == A && j == C && k == G) continue; // ACG DP[3][i][j][k] = 1; } } } } rep(i, 3, N + 1) { rep(j, 0, 4) { rep(k, 0, 4) { rep(l, 0, 4) { rep(m, 0, 4) { if (k == A && l == G && m == C) continue; // AGC if (k == G && l == A && m == C) continue; // GAC if (k == A && l == C && m == G) continue; // ACG if (j == A && l == G && m == C) continue; // A?GC if (j == A && k == G && m == C) continue; // AG?C DP[i + 1][k][l][m] += DP[i][j][k][l] %= mod; } } } } } rep(i, 0, 4) { rep(j, 0, 4) { rep(k, 0, 4) { ans += DP[N][i][j][k] %= mod; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <stdio.h> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #define rep(i, a, n) for (ll i = (a); i < (n); ++i) #define urep(i, a, n) for (ll i = (a); i >= (n); --i) #define all(x) (x).begin(), (x).end() #define INF 1e18 const int mod = 1e9 + 7; typedef long long ll; using namespace std; ll dx[4] = {1, -1, 0, 0}; ll dy[4] = {0, 0, 1, -1}; ll N, M, X, Y, A, B, C, D, Q, K, R, W, H, P, L; ll ans; string S, T; ll y[101010]; ll a[101010]; ll b[101010]; ll t[101010]; ll p[101010]; ll n[101010]; ll l[101010]; ll r[101010]; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } struct Edge { ll to, cost; Edge(ll to, ll cost) : to(to), cost(cost) {} }; typedef vector<vector<Edge>> AdjList; AdjList graph; vector<ll> dist; struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 vector<ll> size; UnionFind(ll N) : par(N), size(N) { //最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; for (ll i = 0; i < N; i++) size[i] = 1; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } ll GetSize(ll x) { return size[root(x)]; } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける size[ry] += size[rx]; } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } }; ll DP[1010][5][5][5]; int main() { cin >> N; ans = 0; ll A = 0, C = 1, G = 2, T = 3; rep(i, 0, 4) { rep(j, 0, 4) { rep(k, 0, 4) { rep(l, 0, 4) { if (i == A && j == G && k == C) continue; // AGC if (i == G && j == A && k == C) continue; // GAC if (i == A && j == C && k == G) continue; // ACG DP[3][i][j][k] = 1; } } } } rep(i, 3, N + 1) { rep(j, 0, 4) { rep(k, 0, 4) { rep(l, 0, 4) { rep(m, 0, 4) { if (k == A && l == G && m == C) continue; // AGC if (k == G && l == A && m == C) continue; // GAC if (k == A && l == C && m == G) continue; // ACG if (j == A && l == G && m == C) continue; // A?GC if (j == A && k == G && m == C) continue; // AG?C (DP[i + 1][k][l][m] += DP[i][j][k][l]) %= mod; } } } } } rep(i, 0, 4) { rep(j, 0, 4) { rep(k, 0, 4) { (ans += DP[N][i][j][k]) %= mod; } } } cout << ans << endl; return 0; }
[]
904,716
904,717
u406225550
cpp
p03088
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e2 + 5; const int mod = 1e9 + 7; // head const char s[] = "ATGC"; const int maxsta = 64; int n, dp[maxn][maxsta]; bool Check(int i, int j, int k) { string str{s[i], s[j], s[k]}; if (str == "AGC" || str == "GAC" || str == "ACG") return false; } int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); scanf("%d", &n); for (int sta = 0; sta < maxsta; ++sta) { int i = sta % 4, j = (sta / 4) % 4, k = sta / 16; dp[3][sta] = (int)Check(i, j, k); } for (int len = 4; len <= n; ++len) { for (int sta = 0; sta < maxsta; ++sta) { int i = sta % 4, j = (sta / 4) % 4, k = sta / 16; for (int ch = 0; ch < 4; ++ch) { int nsta = j + k * 4 + ch * 16; dp[len][nsta] = (dp[len][nsta] + dp[len - 1][sta]) % mod; if (!Check(j, k, ch)) dp[len][nsta] = 0; if (ch == 3) { if (i == 0 && k == 2) dp[len][nsta] = 0; if (i == 0 && j == 2) dp[len][nsta] = 0; } } } } int ans = 0; for (int sta = 0; sta < maxsta; ++sta) { ans = (ans + dp[n][sta]) % mod; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e2 + 5; const int mod = 1e9 + 7; // head const char s[] = "ATGC"; const int maxsta = 64; int n, dp[maxn][maxsta]; bool Check(int i, int j, int k) { string str{s[i], s[j], s[k]}; if (str == "AGC" || str == "GAC" || str == "ACG") return false; return true; } int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); scanf("%d", &n); for (int sta = 0; sta < maxsta; ++sta) { int i = sta % 4, j = (sta / 4) % 4, k = sta / 16; dp[3][sta] = (int)Check(i, j, k); } for (int len = 4; len <= n; ++len) { for (int sta = 0; sta < maxsta; ++sta) { int i = sta % 4, j = (sta / 4) % 4, k = sta / 16; for (int ch = 0; ch < 4; ++ch) { int nsta = j + k * 4 + ch * 16; dp[len][nsta] = (dp[len][nsta] + dp[len - 1][sta]) % mod; if (!Check(j, k, ch)) dp[len][nsta] = 0; if (ch == 3) { if (i == 0 && k == 2) dp[len][nsta] = 0; if (i == 0 && j == 2) dp[len][nsta] = 0; } } } } int ans = 0; for (int sta = 0; sta < maxsta; ++sta) { ans = (ans + dp[n][sta]) % mod; } cout << ans << endl; return 0; }
[ "control_flow.return.add" ]
904,726
904,727
u138715738
cpp
p03088
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define reps(i, n) for (int i = 1; i <= (n); i++) #define repi(i, a, b) for (int i = (a); i < (b); i++) #define all(a) (a).begin(), (a).end() #define bit(b) (1ull << (b)) using namespace std; using i32 = long long; using u32 = unsigned long long; using i64 = long long; using u64 = unsigned long long; using f64 = double; using vi32 = vector<i32>; using vu32 = vector<u32>; using vi64 = vector<i64>; using vu64 = vector<u64>; using vf64 = vector<f64>; using vstr = vector<string>; using vvi32 = vector<vi32>; using vvu32 = vector<vu32>; using vvi64 = vector<vi64>; using vvu64 = vector<vu64>; using vvf64 = vector<vf64>; template <typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; } template <typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; } template <int mod> class modint { public: int x; modint() : x(0) {} modint(int a) { x = a % mod; if (x < 0) x += mod; } modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; } modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; } modint &operator*=(modint that) { x = (long long)x * that.x % mod; return *this; } modint &operator/=(modint that) { return *this *= that.inverse(); } modint operator-() { return modint(-this->x); } friend ostream &operator<<(ostream &out, modint m) { return out << m.x; } modint inverse() { int a = x, b = mod, u = 1, v = 0; while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); } return modint(u); } #define op(o, p) \ modint operator o(modint that) { return modint(*this) p that; } op(+, +=) op(-, -=) op(*, *=) op(/, /=) #undef op #define op(o) \ bool operator o(modint that) const { return x o that.x; } op(==) op(!=) op(<) op(<=) op(>) op(>=) #undef op }; using mint = modint<1000000007>; mint dp[101][5][5][5]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(16); dp[0][0][0][0] = 1; int n; cin >> n; rep(i, n) rep(j, 5) rep(k, 5) rep(l, 5) reps(m, 4) { if (k == 1 && l == 2 && m == 3) continue; if (k == 1 && l == 3 && m == 2) continue; if (k == 3 && l == 2 && m == 2) continue; if (j == 1 && k == 3 && m == 2) continue; if (j == 1 && l == 3 && m == 2) continue; dp[i + 1][k][l][m] += dp[i][j][k][l]; } mint ans = 0; rep(j, 5) rep(k, 5) rep(l, 5) { ans += dp[n][j][k][l]; } cout << ans << endl; return 0; }
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define reps(i, n) for (int i = 1; i <= (n); i++) #define repi(i, a, b) for (int i = (a); i < (b); i++) #define all(a) (a).begin(), (a).end() #define bit(b) (1ull << (b)) using namespace std; using i32 = long long; using u32 = unsigned long long; using i64 = long long; using u64 = unsigned long long; using f64 = double; using vi32 = vector<i32>; using vu32 = vector<u32>; using vi64 = vector<i64>; using vu64 = vector<u64>; using vf64 = vector<f64>; using vstr = vector<string>; using vvi32 = vector<vi32>; using vvu32 = vector<vu32>; using vvi64 = vector<vi64>; using vvu64 = vector<vu64>; using vvf64 = vector<vf64>; template <typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; } template <typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; } template <int mod> class modint { public: int x; modint() : x(0) {} modint(int a) { x = a % mod; if (x < 0) x += mod; } modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; } modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; } modint &operator*=(modint that) { x = (long long)x * that.x % mod; return *this; } modint &operator/=(modint that) { return *this *= that.inverse(); } modint operator-() { return modint(-this->x); } friend ostream &operator<<(ostream &out, modint m) { return out << m.x; } modint inverse() { int a = x, b = mod, u = 1, v = 0; while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); } return modint(u); } #define op(o, p) \ modint operator o(modint that) { return modint(*this) p that; } op(+, +=) op(-, -=) op(*, *=) op(/, /=) #undef op #define op(o) \ bool operator o(modint that) const { return x o that.x; } op(==) op(!=) op(<) op(<=) op(>) op(>=) #undef op }; using mint = modint<1000000007>; mint dp[101][5][5][5]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(16); dp[0][0][0][0] = 1; int n; cin >> n; rep(i, n) rep(j, 5) rep(k, 5) rep(l, 5) reps(m, 4) { if (k == 1 && l == 2 && m == 3) continue; if (k == 1 && l == 3 && m == 2) continue; if (k == 3 && l == 1 && m == 2) continue; if (j == 1 && k == 3 && m == 2) continue; if (j == 1 && l == 3 && m == 2) continue; dp[i + 1][k][l][m] += dp[i][j][k][l]; } mint ans = 0; rep(j, 5) rep(k, 5) rep(l, 5) { ans += dp[n][j][k][l]; } cout << ans << endl; return 0; }
[ "literal.number.change", "assignment.variable.change", "expression.operation.binary.change" ]
904,741
904,742
u908318580
cpp
p03088
#include <bits/stdc++.h> #define int long long using namespace std; int dp[101][4][4][4]; signed main() { int N; cin >> N; //長さ0の文字列は一 //0,1,2に関する制約しかないので // Sは、333Sと考えても問題ない dp[0][3][3][3] = 1; int mod = 1000000000 + 7; //文字列の文字数 for (int len = 0; len < N; len++) { //最後から1文字目の文字 for (int c1 = 0; c1 < 4; c1++) { //最後から2文字目の文字 for (int c2 = 0; c2 < 4; c2++) { //最後から3文字目の文字 for (int c3 = 0; c3 < 4; c3++) { //条件に当てはまるものがない場合はcontinue; if (dp[len][c1][c2][c3] == 0) continue; //新しく追加する文字 for (int a = 0; a < 4; a++) { if (a == 2 && c1 == 1 && c2 == 0) continue; if (a == 2 && c1 == 0 && c2 == 1) continue; if (a == 1 && c1 == 2 && c2 == 0) continue; if (a == 2 && c1 == 1 && c2 == 0) continue; if (a == 2 && c1 == 1 && c2 == 0) continue; //ダメな条件を抜けたら、aを足した文字列が作れる // S=...... c3 c2 c1 // nextS = ...... c2 c1 a dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3]; dp[len + 1][a][c1][c2] %= mod; } } } } } int ans = 0; //長さNの全体をまとめる //最後から1文字目の文字 for (int c1 = 0; c1 < 4; c1++) { //最後から2文字目の文字 for (int c2 = 0; c2 < 4; c2++) { //最後から3文字目の文字 for (int c3 = 0; c3 < 4; c3++) { ans += dp[N][c1][c2][c3]; ans %= mod; } } } cout << ans << endl; }
#include <bits/stdc++.h> #define int long long using namespace std; int dp[101][4][4][4]; signed main() { int N; cin >> N; //長さ0の文字列は一 //0,1,2に関する制約しかないので // Sは、333Sと考えても問題ない dp[0][3][3][3] = 1; //グローバルにおいてあげると全部0に初期化せれる。 int mod = 1000000000 + 7; //文字列の文字数 for (int len = 0; len < N; len++) { //最後から1文字目の文字 for (int c1 = 0; c1 < 4; c1++) { //最後から2文字目の文字 for (int c2 = 0; c2 < 4; c2++) { //最後から3文字目の文字 for (int c3 = 0; c3 < 4; c3++) { //条件に当てはまるものがない場合はcontinue; if (dp[len][c1][c2][c3] == 0) continue; //新しく追加する文字 for (int a = 0; a < 4; a++) { if (a == 2 && c1 == 1 && c2 == 0) continue; if (a == 2 && c1 == 0 && c2 == 1) continue; if (a == 1 && c1 == 2 && c2 == 0) continue; if (a == 2 && c1 == 1 && c3 == 0) continue; if (a == 2 && c2 == 1 && c3 == 0) continue; //ダメな条件を抜けたら、aを足した文字列が作れる // S=...... c3 c2 c1 // nextS = ...... c2 c1 a dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3]; dp[len + 1][a][c1][c2] %= mod; } } } } } int ans = 0; //長さNの全体をまとめる //最後から1文字目の文字 for (int c1 = 0; c1 < 4; c1++) { //最後から2文字目の文字 for (int c2 = 0; c2 < 4; c2++) { //最後から3文字目の文字 for (int c3 = 0; c3 < 4; c3++) { ans += dp[N][c1][c2][c3]; ans %= mod; } } } cout << ans << endl; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
904,757
904,758
u577926181
cpp
p03088
#include <bits/stdc++.h> #define int long long using namespace std; int dp[101][4][4][4]; signed main() { int N; cin >> N; //長さ0の文字列は一 //0,1,2に関する制約しかないので // Sは、333Sと考えても問題ない dp[0][3][3][3] = 1; int mod = 1'000'000'000 + 7; //文字列の文字数 for (int len = 0; len < N; len++) { //最後から1文字目の文字 for (int c1 = 0; c1 < 4; c1++) { //最後から2文字目の文字 for (int c2 = 0; c2 < 4; c2++) { //最後から3文字目の文字 for (int c3 = 0; c3 < 4; c3++) { //条件に当てはまるものがない場合はcontinue; if (dp[len][c1][c2][c3] == 0) continue; //新しく追加する文字 for (int a = 0; a < 4; a++) { if (a == 2 && c1 == 1 && c2 == 0) continue; if (a == 2 && c1 == 0 && c2 == 1) continue; if (a == 1 && c1 == 2 && c2 == 0) continue; if (a == 2 && c1 == 1 && c2 == 0) continue; if (a == 2 && c1 == 1 && c2 == 0) continue; //ダメな条件を抜けたら、aを足した文字列が作れる // S=...... c3 c2 c1 // nextS = ...... c2 c1 a dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3]; dp[len + 1][a][c1][c2] %= mod; } } } } } int ans = 0; //長さNの全体をまとめる //最後から1文字目の文字 for (int c1 = 0; c1 < 4; c1++) { //最後から2文字目の文字 for (int c2 = 0; c2 < 4; c2++) { //最後から3文字目の文字 for (int c3 = 0; c3 < 4; c3++) { ans += dp[N][c1][c2][c3]; ans %= mod; } } } cout << ans << endl; }
#include <bits/stdc++.h> #define int long long using namespace std; int dp[101][4][4][4]; signed main() { int N; cin >> N; //長さ0の文字列は一 //0,1,2に関する制約しかないので // Sは、333Sと考えても問題ない dp[0][3][3][3] = 1; //グローバルにおいてあげると全部0に初期化せれる。 int mod = 1000000000 + 7; //文字列の文字数 for (int len = 0; len < N; len++) { //最後から1文字目の文字 for (int c1 = 0; c1 < 4; c1++) { //最後から2文字目の文字 for (int c2 = 0; c2 < 4; c2++) { //最後から3文字目の文字 for (int c3 = 0; c3 < 4; c3++) { //条件に当てはまるものがない場合はcontinue; if (dp[len][c1][c2][c3] == 0) continue; //新しく追加する文字 for (int a = 0; a < 4; a++) { if (a == 2 && c1 == 1 && c2 == 0) continue; if (a == 2 && c1 == 0 && c2 == 1) continue; if (a == 1 && c1 == 2 && c2 == 0) continue; if (a == 2 && c1 == 1 && c3 == 0) continue; if (a == 2 && c2 == 1 && c3 == 0) continue; //ダメな条件を抜けたら、aを足した文字列が作れる // S=...... c3 c2 c1 // nextS = ...... c2 c1 a dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3]; dp[len + 1][a][c1][c2] %= mod; } } } } } int ans = 0; //長さNの全体をまとめる //最後から1文字目の文字 for (int c1 = 0; c1 < 4; c1++) { //最後から2文字目の文字 for (int c2 = 0; c2 < 4; c2++) { //最後から3文字目の文字 for (int c3 = 0; c3 < 4; c3++) { ans += dp[N][c1][c2][c3]; ans %= mod; } } } cout << ans << endl; }
[ "literal.number.change", "expression.operation.binary.change", "identifier.change", "control_flow.branch.if.condition.change" ]
904,760
904,758
u577926181
cpp
p03088
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const int mod = 1e9 + 7; int n; ll dp[105][4][4][4]; bool valid(int a, int b, int c, int d) { if (a == 0 && b == 1 && c == 2) return false; // AGCX if (a == 1 && b == 0 && c == 2) return false; // GACX if (a == 0 && b == 2 && c == 1) return false; // ACGX if (a == 0 && b == 1 && d == 2) return false; // AGXC if (b == 0 && c == 1 && d == 2) return false; // XAGC if (b == 1 && c == 0 && d == 2) return false; // XGAC if (b == 0 && c == 2 && d == 1) return false; // XACG if (a == 0 && c == 1 && d == 2) return false; // AXCG -> was missing this one return true; } ll dag(int ind, int a, int b, int c) { if (dp[ind][a][b][c] != -1) return dp[ind][a][b][c]; if (ind == n) { return 1; } ll ans = 0; for (int i = 0; i < 4; ++i) { if (valid(a, b, c, i)) { ans += dag(ind + 1, b, c, i); ans %= mod; } } dp[ind][a][b][c] = ans; return ans; } int main() { cin >> n; for (int i = 0; i < 100; ++i) { for (int q = 0; q < 4; ++q) { for (int w = 0; w < 4; ++w) { for (int e = 0; e < 4; ++e) { dp[i][q][w][e] = -1; } } } } ll ans = dag(0, 3, 3, 3); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const int mod = 1e9 + 7; int n; ll dp[105][4][4][4]; bool valid(int a, int b, int c, int d) { if (a == 0 && b == 1 && c == 2) return false; // AGCX if (a == 1 && b == 0 && c == 2) return false; // GACX if (a == 0 && b == 2 && c == 1) return false; // ACGX if (a == 0 && b == 1 && d == 2) return false; // AGXC if (b == 0 && c == 1 && d == 2) return false; // XAGC if (b == 1 && c == 0 && d == 2) return false; // XGAC if (b == 0 && c == 2 && d == 1) return false; // XACG if (a == 0 && c == 1 && d == 2) return false; // AXCG -> was missing this one return true; } ll dag(int ind, int a, int b, int c) { if (dp[ind][a][b][c] != -1) return dp[ind][a][b][c]; if (ind == n) { return 1; } ll ans = 0; for (int i = 0; i < 4; ++i) { if (valid(a, b, c, i)) { ans += dag(ind + 1, b, c, i); ans %= mod; } } dp[ind][a][b][c] = ans; return ans; } int main() { cin >> n; for (int i = 0; i <= 100; ++i) { for (int q = 0; q < 4; ++q) { for (int w = 0; w < 4; ++w) { for (int e = 0; e < 4; ++e) { dp[i][q][w][e] = -1; } } } } ll ans = dag(0, 3, 3, 3); ans %= mod; cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "assignment.add" ]
904,761
904,762
u286318237
cpp
p03088
#ifdef LOCAL #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> #else #include <bits/stdc++.h> #endif using namespace std; typedef long long ll; typedef unsigned long long ull; #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define _sort(arg) sort(begin(arg), end(arg)) #define MOD 1000000007 #define pb push_back #define DEBUG(x) cout << #x << ": " << x << endl; class UnionFind { private: ull size_; std::vector<ull> par, rank, count; public: UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()){}; UnionFind(ull size__) : size_(size__) { par.resize(size_); rank.resize(size_); count.resize(size__); for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1; } ull size() { return size_; } // ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); } ull root(ull x) { while (par[x] != x) { par[x] = par[par[x]]; x = par[x]; } return x; } bool same(ull x, ull y) { return root(x) == root(y); } void unite(ull x, ull y) { x = root(x), y = root(y); if (x == y) return; if (rank[x] < rank[y]) par[x] = y, count[y] += count[x], count[x] = 0; else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x] += count[y], count[y] = 0; else par[y] = x, count[x] += count[y], count[y] = 0; } ull size__(ull x) { return count[root(x)]; } bool operator==(const UnionFind &u) { return par == u.par; } bool operator!=(const UnionFind &u) { return par != u.par; } }; /* maybe sth wrong got wa in one problem */ ll modpow(ll a, ll b) { if (b == 0) { return 1; } if (b % 2) { return a * modpow(a, b - 1) % MOD; } else { ll halfB = b / 2; ll half = modpow(a, halfB); return half * half % MOD; } } ll calcComb(ll n, ll m) { if (m > n - m) { return calcComb(n, n - m); } ll ansMul = 1; ll ansDiv = 1; rep(i, m) { ansMul *= (n - i); ansDiv *= (i + 1); ansMul %= MOD; ansDiv %= MOD; } return ansMul * modpow(ansDiv, MOD - 2) % MOD; } __attribute__((constructor)) void initial() { cin.tie(NULL); ios::sync_with_stdio(false); } #if 0 int ans = 0; void dfs(string s, int l, int total) { //cout <<"s=" << s << ";l = " << l << endl; if (l >= 3) { string sub = s.substr(l-3); //cout << "sub=" << sub << endl; if ((sub == "ACG") || (sub == "GAC") || (sub == "AGC")) { return; } if (l >= 4) { //string sub2 = s.substr(l-4); string sub_p = s.substr(l-4, 2); string sub_s = s.substr(l-2); if ((sub_p == "AG") && ((s[l-2] == 'C') || (s[l-1] == 'C'))) { return; } if ((sub_s == "CG") && ((s[l-4] == 'A') || (s[l-3] == 'A'))) { return; } } } if (l >= total) { ans++; return; } dfs(s+'A', l+1, total); dfs(s+'T', l+1, total); dfs(s+'G', l+1, total); dfs(s+'C', l+1, total); } int main() { int N; cin >> N; //dfs("", 0, N); ll tmp = 4; rep(i, N - 1) { tmp = tmp * 4 % MOD; } //cout << tmp << endl; //cout << calcComb(N, 4) << endl; if (N>=4) { cout << tmp - calcComb(N, 4) * 26 % MOD << endl; } else { cout << tmp - 3 << endl; } //cout << ans << endl; return 0; } #endif int dp[101][4][4][4]; int main() { int n; cin >> n; dp[0][3][3][3] = 1; rep(len, n) { rep(i, 4) { rep(j, 4) { rep(k, 4) { if (dp[len][i][j][k] == 0) { continue; } rep(a, 4) { if (a == 2 && (i == 0) && (j == 1)) continue; if (a == 2 && (i == 1) && (j == 0)) continue; if (a == 1 && (i == 2) && (j == 0)) continue; if (a == 2 && (i == 1) && (k == 0)) continue; if (a == 2 && (j == 1) && (k == 0)) continue; dp[len + 1][a][i][j] += dp[len][i][j][k]; dp[len + 1][a][i][j] %= MOD; } } } } } int ans = 0; rep(i, 4) { rep(j, 4) { rep(k, 4) { ans += dp[n][i][j][k]; } } } cout << ans << endl; return 0; }
#ifdef LOCAL #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> #else #include <bits/stdc++.h> #endif using namespace std; typedef long long ll; typedef unsigned long long ull; #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define _sort(arg) sort(begin(arg), end(arg)) #define MOD 1000000007 #define pb push_back #define DEBUG(x) cout << #x << ": " << x << endl; class UnionFind { private: ull size_; std::vector<ull> par, rank, count; public: UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()){}; UnionFind(ull size__) : size_(size__) { par.resize(size_); rank.resize(size_); count.resize(size__); for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1; } ull size() { return size_; } // ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); } ull root(ull x) { while (par[x] != x) { par[x] = par[par[x]]; x = par[x]; } return x; } bool same(ull x, ull y) { return root(x) == root(y); } void unite(ull x, ull y) { x = root(x), y = root(y); if (x == y) return; if (rank[x] < rank[y]) par[x] = y, count[y] += count[x], count[x] = 0; else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x] += count[y], count[y] = 0; else par[y] = x, count[x] += count[y], count[y] = 0; } ull size__(ull x) { return count[root(x)]; } bool operator==(const UnionFind &u) { return par == u.par; } bool operator!=(const UnionFind &u) { return par != u.par; } }; /* maybe sth wrong got wa in one problem */ ll modpow(ll a, ll b) { if (b == 0) { return 1; } if (b % 2) { return a * modpow(a, b - 1) % MOD; } else { ll halfB = b / 2; ll half = modpow(a, halfB); return half * half % MOD; } } ll calcComb(ll n, ll m) { if (m > n - m) { return calcComb(n, n - m); } ll ansMul = 1; ll ansDiv = 1; rep(i, m) { ansMul *= (n - i); ansDiv *= (i + 1); ansMul %= MOD; ansDiv %= MOD; } return ansMul * modpow(ansDiv, MOD - 2) % MOD; } __attribute__((constructor)) void initial() { cin.tie(NULL); ios::sync_with_stdio(false); } #if 0 int ans = 0; void dfs(string s, int l, int total) { //cout <<"s=" << s << ";l = " << l << endl; if (l >= 3) { string sub = s.substr(l-3); //cout << "sub=" << sub << endl; if ((sub == "ACG") || (sub == "GAC") || (sub == "AGC")) { return; } if (l >= 4) { //string sub2 = s.substr(l-4); string sub_p = s.substr(l-4, 2); string sub_s = s.substr(l-2); if ((sub_p == "AG") && ((s[l-2] == 'C') || (s[l-1] == 'C'))) { return; } if ((sub_s == "CG") && ((s[l-4] == 'A') || (s[l-3] == 'A'))) { return; } } } if (l >= total) { ans++; return; } dfs(s+'A', l+1, total); dfs(s+'T', l+1, total); dfs(s+'G', l+1, total); dfs(s+'C', l+1, total); } int main() { int N; cin >> N; //dfs("", 0, N); ll tmp = 4; rep(i, N - 1) { tmp = tmp * 4 % MOD; } //cout << tmp << endl; //cout << calcComb(N, 4) << endl; if (N>=4) { cout << tmp - calcComb(N, 4) * 26 % MOD << endl; } else { cout << tmp - 3 << endl; } //cout << ans << endl; return 0; } #endif int dp[101][4][4][4]; int main() { int n; cin >> n; dp[0][3][3][3] = 1; rep(len, n) { rep(i, 4) { rep(j, 4) { rep(k, 4) { if (dp[len][i][j][k] == 0) { continue; } rep(a, 4) { if (a == 2 && (i == 0) && (j == 1)) continue; if (a == 2 && (i == 1) && (j == 0)) continue; if (a == 1 && (i == 2) && (j == 0)) continue; if (a == 2 && (i == 1) && (k == 0)) continue; if (a == 2 && (j == 1) && (k == 0)) continue; dp[len + 1][a][i][j] += dp[len][i][j][k]; dp[len + 1][a][i][j] %= MOD; } } } } } int ans = 0; rep(i, 4) { rep(j, 4) { rep(k, 4) { ans += dp[n][i][j][k]; ans %= MOD; } } } cout << ans << endl; return 0; }
[ "assignment.add" ]
904,767
904,768
u528744583
cpp
p03088
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1000000000 + 7; ll dp[100][625]; bool ng[625]; int f(int a, int b, int c, int d) { return a * 125 + b * 25 + c * 5 + d; } // a:1, g:2, c:3, t:4 int main() { ll N; cin >> N; dp[0][0] = 1; for (int i = 0; i < 5; ++i) { ng[f(i, 1, 2, 3)] = true; ng[f(1, i, 2, 3)] = true; ng[f(1, 2, i, 3)] = true; ng[f(i, 2, 1, 3)] = true; ng[f(i, 1, 3, 2)] = true; } for (int i = 0; i < N; ++i) { for (int j = 0; j < 625; ++j) { if (dp[i][j]) { for (int k = 1; k < 5; ++k) { int next = (j * 5 % 625) + k; if (ng[next]) continue; dp[i + 1][next] += dp[i][j]; dp[i + 1][next] %= mod; } } } } ll ans = 0; for (int i = 0; i < 625; ++i) { ans += dp[N][i]; } ans %= mod; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1000000000 + 7; ll dp[111][625]; bool ng[625]; int f(int a, int b, int c, int d) { return a * 125 + b * 25 + c * 5 + d; } // a:1, g:2, c:3, t:4 int main() { ll N; cin >> N; dp[0][0] = 1; for (int i = 0; i < 5; ++i) { ng[f(i, 1, 2, 3)] = true; ng[f(1, i, 2, 3)] = true; ng[f(1, 2, i, 3)] = true; ng[f(i, 2, 1, 3)] = true; ng[f(i, 1, 3, 2)] = true; } for (int i = 0; i < N; ++i) { for (int j = 0; j < 625; ++j) { if (dp[i][j]) { for (int k = 1; k < 5; ++k) { int next = (j * 5 % 625) + k; if (ng[next]) continue; dp[i + 1][next] += dp[i][j]; dp[i + 1][next] %= mod; } } } } ll ans = 0; for (int i = 0; i < 625; ++i) { ans += dp[N][i]; } ans %= mod; cout << ans << endl; }
[ "literal.number.change", "variable_declaration.array_dimensions.change" ]
904,775
904,776
u084968244
cpp
p03092
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define INF 0x3f3f3f3f3f3f3f3f using namespace std; typedef pair<int, int> P; typedef long long ll; ll dp[6000][6000]; int p[6000]; int main() { int n, a, b; cin >> n >> a >> b; rep(i, n) scanf("%d", &p[i]); memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; rep(i, n) rep(j, n) { if (dp[i][j] == INF) continue; if (j > p[i]) { dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + b); } else { dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + a); dp[i + 1][p[i]] = min(dp[i + 1][p[i]], dp[i][j]); } } cout << *min_element(dp[n], dp[n] + n + 1) << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define INF 0x3f3f3f3f3f3f3f3f using namespace std; typedef pair<int, int> P; typedef long long ll; ll dp[6000][6000]; int p[6000]; int main() { int n, a, b; cin >> n >> a >> b; rep(i, n) scanf("%d", &p[i]); memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; rep(i, n) rep(j, n + 1) { if (dp[i][j] == INF) continue; if (j > p[i]) { dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + b); } else { dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + a); dp[i + 1][p[i]] = min(dp[i + 1][p[i]], dp[i][j]); } } cout << *min_element(dp[n], dp[n] + n + 1) << endl; }
[ "expression.operation.binary.add" ]
904,785
904,786
u781091740
cpp
p03092
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <string> #define N 5001 #include <bitset> #include <cstdlib> #include <ctime> #include <deque> #include <set> #define ll long long #define mp make_pair using namespace std; ll read() { ll x = 0, f = 1; char c = getchar(); while (c > '9' || c < '0') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return f * x; } int n, pos[N], A, B; ll dp[N][N]; int main() { n = read(), A = read(), B = read(); memset(dp, 20, sizeof(dp)); dp[0][0] = 0; for (int i = 1; i <= n; ++i) { int x = read(); pos[x] = i; } for (int i = 1; i <= n; ++i) { ll mn = dp[i - 1][0]; for (int j = 1; j <= n; ++j) { if (pos[i] == j) dp[i][j] = mn; mn = min(mn, dp[i - 1][j]); dp[i][j] = min(dp[i][j], mn + (j < pos[i] ? B : A)); } } ll ans = 1e18; for (int i = 1; i <= n; ++i) ans = min(ans, dp[n][i]); cout << ans << '\n'; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <string> #define N 5001 #include <bitset> #include <cstdlib> #include <ctime> #include <deque> #include <set> #define ll long long #define mp make_pair using namespace std; ll read() { ll x = 0, f = 1; char c = getchar(); while (c > '9' || c < '0') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return f * x; } int n, pos[N], A, B; ll dp[N][N]; int main() { n = read(), A = read(), B = read(); memset(dp, 20, sizeof(dp)); dp[0][0] = 0; for (int i = 1; i <= n; ++i) { int x = read(); pos[x] = i; } for (int i = 1; i <= n; ++i) { ll mn = dp[i - 1][0]; for (int j = 0; j <= n; ++j) { if (pos[i] == j) dp[i][j] = mn; mn = min(mn, dp[i - 1][j]); dp[i][j] = min(dp[i][j], mn + (j < pos[i] ? B : A)); } } ll ans = 1e18; for (int i = 1; i <= n; ++i) ans = min(ans, dp[n][i]); cout << ans << '\n'; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
904,787
904,788
u543967420
cpp
p03092
/* ЗАПУСКАЕМ ░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░ ▄███▀░◐░░░▌░░░░░░░ ░░░░▌░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░▄▀▒▒▀▀▀▀▄ ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄ ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░▄▄▌▌▄▌▌░░░░░ */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; template <typename T1, typename T2> inline void chkmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chkmax(T1 &a, T2 b) { if (a < b) a = b; } #define files(FILENAME) \ read(FILENAME); \ write(FILENAME) #define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin) #define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout) #define all(c) (c).begin(), (c).end() #define sz(c) (int)(c).size() #define left left228 #define right right228 #define y1 y1228 #define mp update_pair #define pb push_back #define y2 y2228 const string FILENAME = "input"; const int MAXN = 5005; int n, a, b; int p[MAXN]; long long dp[MAXN][MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // read(FILENAME); cin >> n >> a >> b; for (int i = 0; i < n; i++) { cin >> p[i]; } for (int i = 0; i <= n + 1; i++) { for (int j = 0; j <= n + 1; j++) { dp[i][j] = 1e18; } } dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= n; j++) { if (p[i] < j) { chkmin(dp[i + 1][j], dp[i][j] + a); } else { chkmin(dp[i + 1][p[i]], dp[i][j]); chkmin(dp[i + 1][j], dp[i][j] + b); } } } long long ans = 1e18; for (int i = 0; i <= n; i++) { chkmin(ans, dp[n][i]); } cout << ans << '\n'; return 0; }
/* ЗАПУСКАЕМ ░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░ ▄███▀░◐░░░▌░░░░░░░ ░░░░▌░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░▄▀▒▒▀▀▀▀▄ ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄ ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░▄▄▌▌▄▌▌░░░░░ */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; template <typename T1, typename T2> inline void chkmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chkmax(T1 &a, T2 b) { if (a < b) a = b; } #define files(FILENAME) \ read(FILENAME); \ write(FILENAME) #define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin) #define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout) #define all(c) (c).begin(), (c).end() #define sz(c) (int)(c).size() #define left left228 #define right right228 #define y1 y1228 #define mp update_pair #define pb push_back #define y2 y2228 const string FILENAME = "input"; const int MAXN = 5005; int n, a, b; int p[MAXN]; long long dp[MAXN][MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // read(FILENAME); cin >> n >> a >> b; for (int i = 0; i < n; i++) { cin >> p[i]; } for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { dp[i][j] = 1e18; } } dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= n; j++) { if (p[i] < j) { chkmin(dp[i + 1][j], dp[i][j] + b); } else { chkmin(dp[i + 1][p[i]], dp[i][j]); chkmin(dp[i + 1][j], dp[i][j] + a); } } } long long ans = 1e18; for (int i = 0; i <= n; i++) { chkmin(ans, dp[n][i]); } cout << ans << '\n'; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
904,803
904,804
u139147798
cpp
p03092
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define eprintf(...) 42 #endif typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef long double ld; #define mp make_pair mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll INF = (ll)1e17; const int N = 5050; ll dp[N]; int n; int a[N]; ll A, B; int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); scanf("%d%lld%lld", &n, &A, &B); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); if (A < B) { reverse(a + 1, a + n + 1); for (int i = 1; i <= n; i++) a[i] = n + 1 - a[i]; swap(A, B); } a[0] = 0; a[n + 1] = n + 1; for (int i = 0; i <= n + 1; i++) dp[i] = INF; dp[0] = 0; for (int l = 0; l <= n; l++) { ll w = 0; for (int r = l + 1; r <= n + 1; r++) { if (a[r] < a[l]) { w += A; } else { dp[r] = min(dp[r], dp[l] + w); w += B; } } } printf("%lld\n", dp[n + 1]); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define eprintf(...) 42 #endif typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef long double ld; #define mp make_pair mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll INF = (ll)1e17; const int N = 5050; ll dp[N]; int n; int a[N]; ll A, B; int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); scanf("%d%lld%lld", &n, &B, &A); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); if (A < B) { reverse(a + 1, a + n + 1); for (int i = 1; i <= n; i++) a[i] = n + 1 - a[i]; swap(A, B); } a[0] = 0; a[n + 1] = n + 1; for (int i = 0; i <= n + 1; i++) dp[i] = INF; dp[0] = 0; for (int l = 0; l <= n; l++) { ll w = 0; for (int r = l + 1; r <= n + 1; r++) { if (a[r] < a[l]) { w += A; } else { dp[r] = min(dp[r], dp[l] + w); w += B; } } } printf("%lld\n", dp[n + 1]); return 0; }
[ "identifier.change", "call.arguments.change" ]
904,811
904,812
u883692173
cpp
p03093
#include <bits/stdc++.h> #define ll long long using namespace std; int n, m, ans, a[500010], mn; int pd(int mid) { int i, j; for (i = mid * 2 + 1, j = n * 2; i <= n * 2; i++, j--) if (a[i] + a[j] < m) return 0; return 1; } int main() { int i, j, l, r, mid; scanf("%d%d", &n, &m); for (i = 1; i <= n * 2; i++) scanf("%d", &a[i]); sort(a + 1, a + n + 1); l = 0; r = n; mn = n; while (l <= r) { mid = (l + r) / 2; if (pd(mid)) mn = mid, r = mid - 1; else l = mid + 1; } // printf("%d\n",mn); for (i = 1; i <= mn; i++) ans = max(ans, a[i] + a[mn * 2 - i + 1]); for (i = mn * 2 + 1, j = n * 2; i <= n * 2; i++, j--) ans = max(ans, a[i] + a[j] - m); printf("%d", ans); }
#include <bits/stdc++.h> #define ll long long using namespace std; int n, m, ans, a[500010], mn; int pd(int mid) { int i, j; for (i = mid * 2 + 1, j = n * 2; i <= n * 2; i++, j--) if (a[i] + a[j] < m) return 0; return 1; } int main() { int i, j, l, r, mid; scanf("%d%d", &n, &m); for (i = 1; i <= n * 2; i++) scanf("%d", &a[i]); sort(a + 1, a + n * 2 + 1); l = 0; r = n; mn = n; while (l <= r) { mid = (l + r) / 2; if (pd(mid)) mn = mid, r = mid - 1; else l = mid + 1; } // printf("%d\n",mn); for (i = 1; i <= mn; i++) ans = max(ans, a[i] + a[mn * 2 - i + 1]); for (i = mn * 2 + 1, j = n * 2; i <= n * 2; i++, j--) ans = max(ans, a[i] + a[j] - m); printf("%d", ans); }
[ "expression.operation.binary.add" ]
904,825
904,826
u041115493
cpp
p03093
#include <bits/stdc++.h> using namespace std; int arr[200005]; int main() { int n, m; scanf("%d%d", &n, &m); for (int x = 0; x < 2 * n; x++) { scanf("%d", &arr[x]); } sort(arr, arr + 2 * n); int l = -1; int r = n; while (l + 1 < r) { int mid = (l + r) / 2; for (int t = mid * 2; 2 * n - 1 + 2 * mid - t > t; t++) { int other = 2 * n - 1 + 2 * mid - t; if (arr[t] + arr[other] < m) { l = mid; break; } } if (l != mid) r = mid; } int ans = 0; for (int x = 0; 2 * r - 1 - x > x; x++) { ans = max(ans, arr[x] + arr[2 * r - 1 - x]); } for (int x = 2 * r; 2 * n - 1 - 2 * r - x > x; x++) { ans = max(ans, arr[x] + arr[2 * n - 1 - 2 * r - x] - m); } printf("%d", ans); }
#include <bits/stdc++.h> using namespace std; int arr[200005]; int main() { int n, m; scanf("%d%d", &n, &m); for (int x = 0; x < 2 * n; x++) { scanf("%d", &arr[x]); } sort(arr, arr + 2 * n); int l = -1; int r = n; while (l + 1 < r) { int mid = (l + r) / 2; for (int t = mid * 2; 2 * n - 1 + 2 * mid - t > t; t++) { int other = 2 * n - 1 + 2 * mid - t; if (arr[t] + arr[other] < m) { l = mid; break; } } if (l != mid) r = mid; } int ans = 0; for (int x = 0; 2 * r - 1 - x > x; x++) { ans = max(ans, arr[x] + arr[2 * r - 1 - x]); } for (int x = 2 * r; 2 * n - 1 + 2 * r - x > x; x++) { ans = max(ans, arr[x] + arr[2 * n - 1 + 2 * r - x] - m); } printf("%d", ans); }
[ "misc.opposites", "expression.operator.arithmetic.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change" ]
904,842
904,843
u698054178
cpp
p03093
#include <bits/stdc++.h> using namespace std; namespace io { const int l = 1 << 20; char buf[l], *s, *t, c; inline void gc() { if (s == t) { t = (s = buf) + fread(buf, 1, l, stdin); c = s == t ? EOF : *s++; } else c = *s++; } template <class IT> inline void gi(IT &x) { x = 0; gc(); while (c < '0' || c > '9') gc(); while ('0' <= c && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); gc(); } } char buf0[20]; int a; template <class IT> inline void pi(IT x) { if (x < 0) { putchar('-'); x = -x; } do buf0[++a] = x % 10 + 48; while (x /= 10); while (a) putchar(buf0[a--]); putchar('\n'); } }; // namespace io using io::gi; using io::pi; typedef unsigned int ui; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; #define pque priority_queue #define rep(i, l, r) for (i = (l); i <= (r); ++i) #define per(i, l, r) for (i = (l); i >= (r); --i) #define REP(i, l, r) for (i = (l); i < (r); ++i) #define PER(i, l, r) for (i = (l); i > (r); --i) #define mp make_pair #define pb push_back #define pf push_front #define pob pop_back #define pof pop_front #define fi first #define se second template <class IT> inline void cmax(IT &a, IT b) { if (a < b) a = b; } template <class IT> inline void cmin(IT &a, IT b) { if (b < a) a = b; } const int N = 200005; int a[N]; int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n, m, i, j, l = 1, r, mid, ans, t = 0; scanf("%d%d", &n, &m); r = (ans = (n <<= 1) - 1) - 2; rep(i, 1, n) scanf("%d", &a[i]); sort(a + 1, a + i); while (l <= r) { mid = (l + r) >> 1; if (!(mid & 1)) mid |= 1; i = mid; j = n; while (i <= j) { if (a[i] + a[j] < m) break; ++i; --j; } // printf("judge mid=%d result=%d\n",mid,i>j); if (i > j) r = (ans = mid) - 2; else l = mid + 2; } // printf("ans=%d\n",ans); i = 1; j = ans - 1; while (i <= j) { cmax(t, a[i] + a[j]); ++i; --j; } i = ans; j = n; while (i <= j) { cmax(t, a[i] + a[j] - m); ++i; --j; } printf("%d", t); return 0; }
#include <bits/stdc++.h> using namespace std; namespace io { const int l = 1 << 20; char buf[l], *s, *t, c; inline void gc() { if (s == t) { t = (s = buf) + fread(buf, 1, l, stdin); c = s == t ? EOF : *s++; } else c = *s++; } template <class IT> inline void gi(IT &x) { x = 0; gc(); while (c < '0' || c > '9') gc(); while ('0' <= c && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); gc(); } } char buf0[20]; int a; template <class IT> inline void pi(IT x) { if (x < 0) { putchar('-'); x = -x; } do buf0[++a] = x % 10 + 48; while (x /= 10); while (a) putchar(buf0[a--]); putchar('\n'); } }; // namespace io using io::gi; using io::pi; typedef unsigned int ui; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; #define pque priority_queue #define rep(i, l, r) for (i = (l); i <= (r); ++i) #define per(i, l, r) for (i = (l); i >= (r); --i) #define REP(i, l, r) for (i = (l); i < (r); ++i) #define PER(i, l, r) for (i = (l); i > (r); --i) #define mp make_pair #define pb push_back #define pf push_front #define pob pop_back #define pof pop_front #define fi first #define se second template <class IT> inline void cmax(IT &a, IT b) { if (a < b) a = b; } template <class IT> inline void cmin(IT &a, IT b) { if (b < a) a = b; } const int N = 200005; int a[N]; int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n, m, i, j, l = 1, r, mid, ans, t = 0; scanf("%d%d", &n, &m); r = (ans = (n <<= 1) + 1) - 2; rep(i, 1, n) scanf("%d", &a[i]); sort(a + 1, a + i); while (l <= r) { mid = (l + r) >> 1; if (!(mid & 1)) mid |= 1; i = mid; j = n; while (i <= j) { if (a[i] + a[j] < m) break; ++i; --j; } // printf("judge mid=%d result=%d\n",mid,i>j); if (i > j) r = (ans = mid) - 2; else l = mid + 2; } // printf("ans=%d\n",ans); i = 1; j = ans - 1; while (i <= j) { cmax(t, a[i] + a[j]); ++i; --j; } i = ans; j = n; while (i <= j) { cmax(t, a[i] + a[j] - m); ++i; --j; } printf("%d", t); return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
904,855
904,856
u064646788
cpp
p03093
#include <bits/stdc++.h> using namespace std; namespace io { const int l = 1 << 20; char buf[l], *s, *t, c; inline void gc() { if (s == t) { t = (s = buf) + fread(buf, 1, l, stdin); c = s == t ? EOF : *s++; } else c = *s++; } template <class IT> inline void gi(IT &x) { x = 0; gc(); while (c < '0' || c > '9') gc(); while ('0' <= c && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); gc(); } } char buf0[20]; int a; template <class IT> inline void pi(IT x) { if (x < 0) { putchar('-'); x = -x; } do buf0[++a] = x % 10 + 48; while (x /= 10); while (a) putchar(buf0[a--]); putchar('\n'); } }; // namespace io using io::gi; using io::pi; typedef unsigned int ui; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; #define pque priority_queue #define rep(i, l, r) for (i = (l); i <= (r); ++i) #define per(i, l, r) for (i = (l); i >= (r); --i) #define REP(i, l, r) for (i = (l); i < (r); ++i) #define PER(i, l, r) for (i = (l); i > (r); --i) #define mp make_pair #define pb push_back #define pf push_front #define pob pop_back #define pof pop_front #define fi first #define se second template <class IT> inline void cmax(IT &a, IT b) { if (a < b) a = b; } template <class IT> inline void cmin(IT &a, IT b) { if (b < a) a = b; } const int N = 200005; int a[N]; int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n, m, i, j, l = 1, r, mid, ans, t = 0; scanf("%d%d", &n, &m); r = (ans = (n <<= 1) - 1) - 2; rep(i, 1, n) scanf("%d", &a[i]); sort(a + 1, a + i); while (l <= r) { mid = (l + r) >> 1; if (!(mid & 1)) mid |= 1; i = mid; j = n; while (i <= j) { if (a[i] + a[j] < m) break; ++i; --j; } // printf("judge mid=%d result=%d\n",mid,i>j); if (i > j) r = (ans = mid) - 2; else l = mid + 2; } // printf("ans=%d\n",ans); i = 1; j = ans - 1; while (i <= j) { cmax(t, a[i] + a[j]); ++i; --j; } i = ans; j = n; while (i <= j) { cmax(t, a[i] + a[j] - m); ++i; --j; } printf("%lld", t); return 0; }
#include <bits/stdc++.h> using namespace std; namespace io { const int l = 1 << 20; char buf[l], *s, *t, c; inline void gc() { if (s == t) { t = (s = buf) + fread(buf, 1, l, stdin); c = s == t ? EOF : *s++; } else c = *s++; } template <class IT> inline void gi(IT &x) { x = 0; gc(); while (c < '0' || c > '9') gc(); while ('0' <= c && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); gc(); } } char buf0[20]; int a; template <class IT> inline void pi(IT x) { if (x < 0) { putchar('-'); x = -x; } do buf0[++a] = x % 10 + 48; while (x /= 10); while (a) putchar(buf0[a--]); putchar('\n'); } }; // namespace io using io::gi; using io::pi; typedef unsigned int ui; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; #define pque priority_queue #define rep(i, l, r) for (i = (l); i <= (r); ++i) #define per(i, l, r) for (i = (l); i >= (r); --i) #define REP(i, l, r) for (i = (l); i < (r); ++i) #define PER(i, l, r) for (i = (l); i > (r); --i) #define mp make_pair #define pb push_back #define pf push_front #define pob pop_back #define pof pop_front #define fi first #define se second template <class IT> inline void cmax(IT &a, IT b) { if (a < b) a = b; } template <class IT> inline void cmin(IT &a, IT b) { if (b < a) a = b; } const int N = 200005; int a[N]; int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n, m, i, j, l = 1, r, mid, ans, t = 0; scanf("%d%d", &n, &m); r = (ans = (n <<= 1) + 1) - 2; rep(i, 1, n) scanf("%d", &a[i]); sort(a + 1, a + i); while (l <= r) { mid = (l + r) >> 1; if (!(mid & 1)) mid |= 1; i = mid; j = n; while (i <= j) { if (a[i] + a[j] < m) break; ++i; --j; } // printf("judge mid=%d result=%d\n",mid,i>j); if (i > j) r = (ans = mid) - 2; else l = mid + 2; } // printf("ans=%d\n",ans); i = 1; j = ans - 1; while (i <= j) { cmax(t, a[i] + a[j]); ++i; --j; } i = ans; j = n; while (i <= j) { cmax(t, a[i] + a[j] - m); ++i; --j; } printf("%d", t); return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
904,857
904,856
u064646788
cpp
p03093
/* ` ` ` ` ` ` ` ` `!!!;' ` '%$@########################&&%:. ` .%###################################%. ` .`|######################################% ` .!@###############################################$' ` .!@#########################@@@#########################&;. ` :@##################@@@&&@@@$!!%&@@@@@@@###################&' ` :&################@@@&$%%||||!!:'':;!!||%|!%&@@#################%` ` |###############@@&&$%|!;;::::':'''':::;;!!|%%%$&&@###############$` ` :&#############@&$%||||!;'````````````'''```'':::'':!|$@@###############; ` :@#############@$$%|!;;;;:'``````...```...`...`'':::''';|%$$$&############&' ` |##############&$$$%||!!;:'`````..````....`...```''::::;!!||$&&@@###########&' ` !##############@$%|!!!;::'''`````...``.....`````````'''::::;;::!|%$&############| ` :@##########@&%!:'`::;;:'``....```....... .``....````````````'':;!|%$@############; ` ;##########@%;```...`'''`... ..... ................ .`. `:!!!!%%%&#########| ` ;##########&|:.`'`. ..`... ....... ..... .. ..... ... .'':!!:.`''!@#########|. ` !##########|'`.;!` . ...... .. . .... .::'`. .. .`'|@########@: ` ;##########%'`'%! .. . . .. .```. ';:`..``.`':|@########@: ` !##########$:;$&; . `|%;. `;||;::`.``';;. .;!: `;:`';|$#########@!. ` !##########@$&@|. ...... .`':!|;` !$|%%'!##$' `|####$:`:;:!&$:. '$&!';!!||%&############; ` `$#############&: `!!'`:;;;||%@&!'!&&$;.|##%`.|#####%`'$@$&##%` .:||;;;;%@##############! ` :@#############|. .!&@|;%@@@@@&@@#@&@#@&@############@@#####@: .`'%@%!!&###############! ` :@############@; :&@!;$###@|%|!$@@######################@%` .;|!;!|%@###############! ` :@############@: `$#$%#@@##&@################@$$$&$%|!' `%#@|;':|&###############! ` !##########@$%: |####@&######$;. ..`'` ;@##############! ` !##########! ;#########|. `;` ;###############! ` ;##########; `%######; '$###&: `%@############&' ` !########@: .'. .:;` .|%: !##########&' ` !########@: ;#########@: ` !######%. !##&;. . `%&!` '&###&' !#########! ` |#######;.%###! `!&###@|;;%@###%. ';;|&$:;;` |#%. .%###%$###! ` !#######| `%#&' |##&$####&: !##########; `%#####%.!#|. .%@: ;###;`%##! ` !#$!$##! :@#! .|###$'. ;##|. :&#@; .``::` ;@|. :@#@: `$#| ` :&&|&##; :&#! :&##; .%##! !&' ;@##! |#! ` |@@##@; .`%#! '$##; ;##$` :@! .|##@; :&! ` !&|&##%:'. :&! :@#%. .%##; |&!. `|@! `$! ` '$%%###&;. '&&' `%##&' |##@&: ...;&&&@; .;&#|':;$&: ` .|######&; '$@@@@@@@@#| :&######%` ` !#####&: '$#####@: ` '$#####@: ;#####$` ` '&####%. `` '$#####; ` !#####$' |@: .:%|;;;;!$#####@#| '&###$: ` :&####&: ;####################@: ':` `%###@: ` ;#####@%:. `'';|@######$` ` `$######@|` !#&||@#####$` ` :&######@%'. .`''''` .';!|%@#@$$@####&: ` |######@|'. ;##$!!%@##########################@: '$####; ` :&#####$;''.`%#########&' `|@$: .%###@; ` :@####@; |#@##&$; `|%' .|####! ` !####@; . |####! ` :@###@|` . `|!. |####%. ` .|####! `;$@%|!!!!!%&&@#$;. !#####| ` .%####&: '%&@@@|` '&#####| ` .%#####|. :&######%` ` :|||;` !#######; .%#####@@#####@$;. ` `$#############&%!%#####|. :@####%:..'!&######@; ` `$#############|`..'%#######! ;####&;. .'%#######! ` .|##############@!` .'%#########%'. '%#####%` :@#######@%;:. ` ;%|;. !############%::;' `!&############@&&@#######@%' !###########&' ` !################$' .:' '|&######################$:. :@#############@@@@@@; ` ';$##&;:&###########$` :|$@################%:. !#####################@; ` '%####@$!:. `%#########! .:!%&@#######@%!;'. |##############%!$@####! ` .|#######&;'. . |#######%. .':;!!!!!!;`... .|############|. :$@@####%. ` !####&$&@#@!:'. ;#####%` .`';;'... ..''``. !##########%` ''':$######$` ` ;#####@$$;`%&:. `%####; .:;;:'':;||!:` !#########! :&#@@####! ` '%######@######! !! :$@$` ...`.'::`.. '$######@!` '|$$&!!@#######@!. ` '$#########@&$$@######@: ;: . `' .... ...``. `$######&' '!;`'!@######&&########$' ` ;############@#@@@@@$|%@###$` `!!.;' . :!. .%#####!. .;::&####|`..` ..;@########!' |########&|;'``..`:' ..!##%:. ;; `. .|###|` `'|###@&$|` .. .`|&&@#######%: |###@#@@#&|:`.`';;:;!!!;:;''!$##&;'. .'%; .;&###&|$! '$; .|$:;|` ...;&###$' .... :||%&########%: |#######@$;!%%:``` .!@###&|` :|'!########@#! ;@! :@####%'. `|@###&: ..`:::%$$&$$$&@##@@@##|: |########$;::'` .`. `%#####%!: .. !#####%` !#%. !; '%; !#############&: `::`.```. .':. :$@&&&###|: !####@%:::;;:::::` ......... '. !#######%;;';; `%#&' ;&: `;``$@!%########&&##&|::::'. ':. `!%@@######|: !#####%;;::. ...... ....`.. .. '::!|&########$';%`.'` .;%: !#$';$%|&$!&##########$' `';;;;!&##&%||||||%;` .:|&###@###|: |#######|`... `|$&&$$!`.... ;$: :&#@: `'''``. .%########&' .%#@&$%$#####$` ....`:%&@@@@@@&&@@!`. .`'%@#######|' |######@@$: .`..`!@&$&&&&: ;@#######@@#$%@######&$; '%@##%!@###@&&@####%. `!&@@@@@$:..`..``.``... `|&####@@##!' ;###&|;::!&#&%%%%: .'::::;|$&&$%|'..;%%&#######%;$########@&#####%` '|@###; '%####$;::::::` '!|%%%%%%%%%&#$:'::.'%###|' `%###@|;|%$%$@#&|;::::` '|%%%%%$%|%|;';$##@|'. |######&' .:|$%: :&@|'. !####%. `::;:!$@######&%%%%%!' ':;&##|: '$##%:. :&##@####@$;. .. `$| :; !#####| '|%: `` ... !####! . ..:&#@@@@##@&||$; :&####|' !####&@@&; ...`.'%@##@@#@@&!` :&&!. !###&' :||:.` !%' ``:$######@@@&&@@@&@##$;``.... |@@@@########!' !#######@$||!: ';!;;;!&###&|||||||||||%&##@!`. !###&||%!!!: .:;` `;;%####$;:;;;;;;;;;;;::. '||||||&#####%!;;$##!` `%#&:.`:!||||||%@#@%;::;;;' ;@@: .. .%###|. `:::' .:!;'`':'` `$####! ':;;;;!%@@&%%%|;` `;%&###|: .%##|.. '$##@@@@@@#&:...`.. `$#$' !##%` ..`.`:%@@! '%@$:''. .`|####|... .........`:%###@#@@@|` ....`%#####|: !###@&! .`.```':!&##@&&&&$: '&#%. !#&' ````. .```:%&&&&&@#####@!':|$&&$&&&&&&&&&@##|`````. !@@@#######!' :&#########@$||||: `::::;;;;;!!;;;:;$###$' .'` |#@|. .:;;:. `%####%:''':::::` `!||&##$;;;:::. ;##|: .%#@$%$%%%%%$@###$::::::'. ...`;|!::!&##@$%|||!' .%##&%%$%' `'. :&####! .':::'::%@&$%%!` .!!':;$###%: :&#############@|. . '$##################&;..!@###@#######%'. .!#####! . `$#####@|``;&|!&####|: |####&%' .''''':|@###@$$$$$$%;. |####%` .|#@;. .;$$$%$&$$$$$$&######$:..:|%$$$$$$$&&&&@######&;'''. ;$&########|: |#######@%;;` '!|!||$#######&|!!!;;;!!!;`.!#####@: .;|!!|&#$' `:'':;;$######################################%!|!!!!!;. .`;|&######@####%: |############$!''''..';$&&&&@########################$;'!;`:@#&:``'|$@######@@@@&&&&&&&@#######@&&&&&&&&&&&@@&&&&$|:. .`''$########@&@####%: |###&%$&#################@%;' .. `|@############$: `%@###########$` `%%:. . :@######| !#####################@$%&##########%: |#######################################@&&@######################@@&@#######################################################################%: */ #define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; namespace pufanyi { inline char gc() { static const int L = 233333; static char sxd[L], *sss = sxd, *ttt = sxd; if (sss == ttt) { ttt = (sss = sxd) + fread(sxd, 1, L, stdin); if (sss == ttt) { return EOF; } } return *sss++; } #ifndef _AT_HOME #define dd c = gc() #else #define dd c = getchar() #endif inline char readalpha() { char dd; for (; !isalpha(c); dd) ; return c; } inline char readchar() { char dd; for (; c == ' '; dd) ; return c; } template <class T> inline bool read(T &x) { bool flg = false; char dd; x = 0; for (; !isdigit(c); dd) { if (c == '-') { flg = true; } else if (c == EOF) { return false; } } for (; isdigit(c); dd) { x = (x << 1) + (x << 3) + (c ^ 48); } if (flg) { x = -x; } return true; } #undef dd template <class T> inline void write(T x) { if (x < 0) { putchar('-'); x = -x; } if (x < 10) { putchar(x | 48); return; } write(x / 10); putchar((x % 10) | 48); } template <class T> inline void writesp(T x) { write(x); putchar(' '); } template <class T> inline void writeln(T x) { write(x); puts(""); } typedef long long LL; const int maxn = 200005; int n, m; int aa[maxn]; inline bool check(int x) { int lim = x << 1; for (int l = lim + 1, r = n << 1; l < r; ++l, --r) { if (aa[l] + aa[r] < m) { return false; } } return true; } int Main() { read(n), read(m); for (int i = 1; i <= n << 1; ++i) { read(aa[i]); } sort(aa + 1, aa + n + 1); int l = 0, r = n; while (l < r) { int mid = (l + r) >> 1; if (check(mid)) { r = mid; } else { l = mid + 1; } } int ans = 0; int lim = l << 1; // cout << "lim = " << lim << endl; for (int l = 1, r = lim; l < r; ++l, --r) { ans = max(ans, (aa[l] + aa[r]) % m); } for (int l = lim + 1, r = n << 1; l < r; ++l, --r) { ans = max(ans, (aa[l] + aa[r]) % m); } writeln(ans); return 0; } } // namespace pufanyi int main() { return pufanyi::Main(); }
/* ` ` ` ` ` ` ` ` `!!!;' ` '%$@########################&&%:. ` .%###################################%. ` .`|######################################% ` .!@###############################################$' ` .!@#########################@@@#########################&;. ` :@##################@@@&&@@@$!!%&@@@@@@@###################&' ` :&################@@@&$%%||||!!:'':;!!||%|!%&@@#################%` ` |###############@@&&$%|!;;::::':'''':::;;!!|%%%$&&@###############$` ` :&#############@&$%||||!;'````````````'''```'':::'':!|$@@###############; ` :@#############@$$%|!;;;;:'``````...```...`...`'':::''';|%$$$&############&' ` |##############&$$$%||!!;:'`````..````....`...```''::::;!!||$&&@@###########&' ` !##############@$%|!!!;::'''`````...``.....`````````'''::::;;::!|%$&############| ` :@##########@&%!:'`::;;:'``....```....... .``....````````````'':;!|%$@############; ` ;##########@%;```...`'''`... ..... ................ .`. `:!!!!%%%&#########| ` ;##########&|:.`'`. ..`... ....... ..... .. ..... ... .'':!!:.`''!@#########|. ` !##########|'`.;!` . ...... .. . .... .::'`. .. .`'|@########@: ` ;##########%'`'%! .. . . .. .```. ';:`..``.`':|@########@: ` !##########$:;$&; . `|%;. `;||;::`.``';;. .;!: `;:`';|$#########@!. ` !##########@$&@|. ...... .`':!|;` !$|%%'!##$' `|####$:`:;:!&$:. '$&!';!!||%&############; ` `$#############&: `!!'`:;;;||%@&!'!&&$;.|##%`.|#####%`'$@$&##%` .:||;;;;%@##############! ` :@#############|. .!&@|;%@@@@@&@@#@&@#@&@############@@#####@: .`'%@%!!&###############! ` :@############@; :&@!;$###@|%|!$@@######################@%` .;|!;!|%@###############! ` :@############@: `$#$%#@@##&@################@$$$&$%|!' `%#@|;':|&###############! ` !##########@$%: |####@&######$;. ..`'` ;@##############! ` !##########! ;#########|. `;` ;###############! ` ;##########; `%######; '$###&: `%@############&' ` !########@: .'. .:;` .|%: !##########&' ` !########@: ;#########@: ` !######%. !##&;. . `%&!` '&###&' !#########! ` |#######;.%###! `!&###@|;;%@###%. ';;|&$:;;` |#%. .%###%$###! ` !#######| `%#&' |##&$####&: !##########; `%#####%.!#|. .%@: ;###;`%##! ` !#$!$##! :@#! .|###$'. ;##|. :&#@; .``::` ;@|. :@#@: `$#| ` :&&|&##; :&#! :&##; .%##! !&' ;@##! |#! ` |@@##@; .`%#! '$##; ;##$` :@! .|##@; :&! ` !&|&##%:'. :&! :@#%. .%##; |&!. `|@! `$! ` '$%%###&;. '&&' `%##&' |##@&: ...;&&&@; .;&#|':;$&: ` .|######&; '$@@@@@@@@#| :&######%` ` !#####&: '$#####@: ` '$#####@: ;#####$` ` '&####%. `` '$#####; ` !#####$' |@: .:%|;;;;!$#####@#| '&###$: ` :&####&: ;####################@: ':` `%###@: ` ;#####@%:. `'';|@######$` ` `$######@|` !#&||@#####$` ` :&######@%'. .`''''` .';!|%@#@$$@####&: ` |######@|'. ;##$!!%@##########################@: '$####; ` :&#####$;''.`%#########&' `|@$: .%###@; ` :@####@; |#@##&$; `|%' .|####! ` !####@; . |####! ` :@###@|` . `|!. |####%. ` .|####! `;$@%|!!!!!%&&@#$;. !#####| ` .%####&: '%&@@@|` '&#####| ` .%#####|. :&######%` ` :|||;` !#######; .%#####@@#####@$;. ` `$#############&%!%#####|. :@####%:..'!&######@; ` `$#############|`..'%#######! ;####&;. .'%#######! ` .|##############@!` .'%#########%'. '%#####%` :@#######@%;:. ` ;%|;. !############%::;' `!&############@&&@#######@%' !###########&' ` !################$' .:' '|&######################$:. :@#############@@@@@@; ` ';$##&;:&###########$` :|$@################%:. !#####################@; ` '%####@$!:. `%#########! .:!%&@#######@%!;'. |##############%!$@####! ` .|#######&;'. . |#######%. .':;!!!!!!;`... .|############|. :$@@####%. ` !####&$&@#@!:'. ;#####%` .`';;'... ..''``. !##########%` ''':$######$` ` ;#####@$$;`%&:. `%####; .:;;:'':;||!:` !#########! :&#@@####! ` '%######@######! !! :$@$` ...`.'::`.. '$######@!` '|$$&!!@#######@!. ` '$#########@&$$@######@: ;: . `' .... ...``. `$######&' '!;`'!@######&&########$' ` ;############@#@@@@@$|%@###$` `!!.;' . :!. .%#####!. .;::&####|`..` ..;@########!' |########&|;'``..`:' ..!##%:. ;; `. .|###|` `'|###@&$|` .. .`|&&@#######%: |###@#@@#&|:`.`';;:;!!!;:;''!$##&;'. .'%; .;&###&|$! '$; .|$:;|` ...;&###$' .... :||%&########%: |#######@$;!%%:``` .!@###&|` :|'!########@#! ;@! :@####%'. `|@###&: ..`:::%$$&$$$&@##@@@##|: |########$;::'` .`. `%#####%!: .. !#####%` !#%. !; '%; !#############&: `::`.```. .':. :$@&&&###|: !####@%:::;;:::::` ......... '. !#######%;;';; `%#&' ;&: `;``$@!%########&&##&|::::'. ':. `!%@@######|: !#####%;;::. ...... ....`.. .. '::!|&########$';%`.'` .;%: !#$';$%|&$!&##########$' `';;;;!&##&%||||||%;` .:|&###@###|: |#######|`... `|$&&$$!`.... ;$: :&#@: `'''``. .%########&' .%#@&$%$#####$` ....`:%&@@@@@@&&@@!`. .`'%@#######|' |######@@$: .`..`!@&$&&&&: ;@#######@@#$%@######&$; '%@##%!@###@&&@####%. `!&@@@@@$:..`..``.``... `|&####@@##!' ;###&|;::!&#&%%%%: .'::::;|$&&$%|'..;%%&#######%;$########@&#####%` '|@###; '%####$;::::::` '!|%%%%%%%%%&#$:'::.'%###|' `%###@|;|%$%$@#&|;::::` '|%%%%%$%|%|;';$##@|'. |######&' .:|$%: :&@|'. !####%. `::;:!$@######&%%%%%!' ':;&##|: '$##%:. :&##@####@$;. .. `$| :; !#####| '|%: `` ... !####! . ..:&#@@@@##@&||$; :&####|' !####&@@&; ...`.'%@##@@#@@&!` :&&!. !###&' :||:.` !%' ``:$######@@@&&@@@&@##$;``.... |@@@@########!' !#######@$||!: ';!;;;!&###&|||||||||||%&##@!`. !###&||%!!!: .:;` `;;%####$;:;;;;;;;;;;;::. '||||||&#####%!;;$##!` `%#&:.`:!||||||%@#@%;::;;;' ;@@: .. .%###|. `:::' .:!;'`':'` `$####! ':;;;;!%@@&%%%|;` `;%&###|: .%##|.. '$##@@@@@@#&:...`.. `$#$' !##%` ..`.`:%@@! '%@$:''. .`|####|... .........`:%###@#@@@|` ....`%#####|: !###@&! .`.```':!&##@&&&&$: '&#%. !#&' ````. .```:%&&&&&@#####@!':|$&&$&&&&&&&&&@##|`````. !@@@#######!' :&#########@$||||: `::::;;;;;!!;;;:;$###$' .'` |#@|. .:;;:. `%####%:''':::::` `!||&##$;;;:::. ;##|: .%#@$%$%%%%%$@###$::::::'. ...`;|!::!&##@$%|||!' .%##&%%$%' `'. :&####! .':::'::%@&$%%!` .!!':;$###%: :&#############@|. . '$##################&;..!@###@#######%'. .!#####! . `$#####@|``;&|!&####|: |####&%' .''''':|@###@$$$$$$%;. |####%` .|#@;. .;$$$%$&$$$$$$&######$:..:|%$$$$$$$&&&&@######&;'''. ;$&########|: |#######@%;;` '!|!||$#######&|!!!;;;!!!;`.!#####@: .;|!!|&#$' `:'':;;$######################################%!|!!!!!;. .`;|&######@####%: |############$!''''..';$&&&&@########################$;'!;`:@#&:``'|$@######@@@@&&&&&&&@#######@&&&&&&&&&&&@@&&&&$|:. .`''$########@&@####%: |###&%$&#################@%;' .. `|@############$: `%@###########$` `%%:. . :@######| !#####################@$%&##########%: |#######################################@&&@######################@@&@#######################################################################%: */ #define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; namespace pufanyi { inline char gc() { static const int L = 233333; static char sxd[L], *sss = sxd, *ttt = sxd; if (sss == ttt) { ttt = (sss = sxd) + fread(sxd, 1, L, stdin); if (sss == ttt) { return EOF; } } return *sss++; } #ifndef _AT_HOME #define dd c = gc() #else #define dd c = getchar() #endif inline char readalpha() { char dd; for (; !isalpha(c); dd) ; return c; } inline char readchar() { char dd; for (; c == ' '; dd) ; return c; } template <class T> inline bool read(T &x) { bool flg = false; char dd; x = 0; for (; !isdigit(c); dd) { if (c == '-') { flg = true; } else if (c == EOF) { return false; } } for (; isdigit(c); dd) { x = (x << 1) + (x << 3) + (c ^ 48); } if (flg) { x = -x; } return true; } #undef dd template <class T> inline void write(T x) { if (x < 0) { putchar('-'); x = -x; } if (x < 10) { putchar(x | 48); return; } write(x / 10); putchar((x % 10) | 48); } template <class T> inline void writesp(T x) { write(x); putchar(' '); } template <class T> inline void writeln(T x) { write(x); puts(""); } typedef long long LL; const int maxn = 200005; int n, m; int aa[maxn]; inline bool check(int x) { int lim = x << 1; for (int l = lim + 1, r = n << 1; l < r; ++l, --r) { if (aa[l] + aa[r] < m) { return false; } } return true; } int Main() { read(n), read(m); for (int i = 1; i <= n << 1; ++i) { read(aa[i]); } sort(aa + 1, aa + (n << 1) + 1); int l = 0, r = n; while (l < r) { int mid = (l + r) >> 1; if (check(mid)) { r = mid; } else { l = mid + 1; } } int ans = 0; int lim = l << 1; // cout << "lim = " << lim << endl; for (int l = 1, r = lim; l < r; ++l, --r) { ans = max(ans, (aa[l] + aa[r]) % m); } for (int l = lim + 1, r = n << 1; l < r; ++l, --r) { ans = max(ans, (aa[l] + aa[r]) % m); } writeln(ans); return 0; } } // namespace pufanyi int main() { return pufanyi::Main(); }
[ "call.arguments.change" ]
904,858
904,859
u420065047
cpp
p03093
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define fi first #define se second using vint = vector<int>; using pint = pair<int, int>; using vpint = vector<pint>; template <typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; } template <class A, class B> ostream &operator<<(ostream &ost, const pair<A, B> &p) { ost << "{" << p.first << "," << p.second << "}"; return ost; } template <class T> ostream &operator<<(ostream &ost, const vector<T> &v) { ost << "{"; for (int i = 0; i < v.size(); i++) { if (i) ost << ","; ost << v[i]; } ost << "}"; return ost; } inline int topbit(unsigned long long x) { return x ? 63 - __builtin_clzll(x) : -1; } inline int popcount(unsigned long long x) { return __builtin_popcountll(x); } inline int parity(unsigned long long x) { return __builtin_parity(x); } int N, M; int A[222222]; const int INF = 1001001001; // p<=X[i] Z[i]<=q<=y[i] int X[222222], Y[222222], Z[222222]; int accX[222222], accY[222222], accZ[222222]; bool check(int x) { rep(i, 2 * N) { int k = lower_bound(A, A + 2 * N, x + 1 - A[i]) - A - 1; X[i] = (i + k + 1) / 2; } rep(i, 2 * N) { int k = lower_bound(A, A + 2 * N, M + x + 1 - A[i]) - A - 1; Y[i] = (i + k + 1) / 2; k = lower_bound(A, A + 2 * N, M - A[i]) - A; Z[i] = (i + k + 1 + 1) / 2; } accX[0] = INF; rep(i, 2 * N) accX[i + 1] = min(accX[i], X[i]); accY[2 * N] = INF; accZ[2 * N] = -INF; for (int i = 2 * N - 1; i >= 0; i--) { accY[i] = min(accY[i + 1], Y[i]); accZ[i] = max(accZ[i + 1], Z[i]); } for (int i = 0; i <= 2 * N; i += 2) { int p = i / 2; int q = (2 * N + i) / 2; if (p > accX[i + 1]) continue; if (q > accY[i]) continue; if (q < accZ[i]) continue; return true; } return false; } signed main() { cin >> N >> M; rep(i, 2 * N) cin >> A[i]; sort(A, A + 2 * N); int lb = -1, ub = M - 1; while (ub - lb > 1) { int mid = (ub + lb) / 2; if (check(mid)) ub = mid; else lb = mid; } cout << ub << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define fi first #define se second using vint = vector<int>; using pint = pair<int, int>; using vpint = vector<pint>; template <typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; } template <class A, class B> ostream &operator<<(ostream &ost, const pair<A, B> &p) { ost << "{" << p.first << "," << p.second << "}"; return ost; } template <class T> ostream &operator<<(ostream &ost, const vector<T> &v) { ost << "{"; for (int i = 0; i < v.size(); i++) { if (i) ost << ","; ost << v[i]; } ost << "}"; return ost; } inline int topbit(unsigned long long x) { return x ? 63 - __builtin_clzll(x) : -1; } inline int popcount(unsigned long long x) { return __builtin_popcountll(x); } inline int parity(unsigned long long x) { return __builtin_parity(x); } int N, M; int A[222222]; const int INF = 1001001001; // p<=X[i] Z[i]<=q<=y[i] int X[222222], Y[222222], Z[222222]; int accX[222222], accY[222222], accZ[222222]; bool check(int x) { rep(i, 2 * N) { int k = lower_bound(A, A + 2 * N, x + 1 - A[i]) - A - 1; X[i] = (i + k + 1) / 2; } rep(i, 2 * N) { int k = lower_bound(A, A + 2 * N, M + x + 1 - A[i]) - A - 1; Y[i] = (i + k + 1) / 2; k = lower_bound(A, A + 2 * N, M - A[i]) - A; Z[i] = (i + k + 1 + 1) / 2; } accX[0] = INF; rep(i, 2 * N) accX[i + 1] = min(accX[i], X[i]); accY[2 * N] = INF; accZ[2 * N] = -INF; for (int i = 2 * N - 1; i >= 0; i--) { accY[i] = min(accY[i + 1], Y[i]); accZ[i] = max(accZ[i + 1], Z[i]); } for (int i = 0; i <= 2 * N; i += 2) { int p = i / 2; int q = (2 * N + i) / 2; if (p > accX[i]) continue; if (q > accY[i]) continue; if (q < accZ[i]) continue; return true; } return false; } signed main() { cin >> N >> M; rep(i, 2 * N) cin >> A[i]; sort(A, A + 2 * N); int lb = -1, ub = M - 1; while (ub - lb > 1) { int mid = (ub + lb) / 2; if (check(mid)) ub = mid; else lb = mid; } cout << ub << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
904,867
904,868
u685892567
cpp
p03093
#include <bits/stdc++.h> using namespace std; const int N = 200010; int n, a[N], m; bool check(int x) { for (int i = x * 2 + 1; i <= 2 * n; i++) if (a[i] + a[2 * n - i + 2 * x + 1] < m) return false; return true; } int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= 2 * n; i++) scanf("%d", &a[i]); sort(a + 1, a + 1 + n); int l = 0, r = n, ans = 0; while (l <= r) { int mid = (l + r) / 2; if (check(mid)) r = (ans = mid) - 1; else l = mid + 1; } int mmax = 0; for (int i = 1; i <= ans; i++) mmax = max(mmax, a[i] + a[2 * ans - i + 1]); for (int i = 2 * ans + 1; i <= 2 * n; i++) mmax = max(mmax, a[i] + a[2 * n - i + 2 * ans + 1] - m); printf("%d\n", mmax); }
#include <bits/stdc++.h> using namespace std; const int N = 200010; int n, a[N], m; bool check(int x) { for (int i = x * 2 + 1; i <= 2 * n; i++) if (a[i] + a[2 * n - i + 2 * x + 1] < m) return false; return true; } int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= 2 * n; i++) scanf("%d", &a[i]); sort(a + 1, a + 1 + 2 * n); int l = 0, r = n, ans = 0; while (l <= r) { int mid = (l + r) / 2; if (check(mid)) r = (ans = mid) - 1; else l = mid + 1; } int mmax = 0; for (int i = 1; i <= ans; i++) mmax = max(mmax, a[i] + a[2 * ans - i + 1]); for (int i = 2 * ans + 1; i <= 2 * n; i++) mmax = max(mmax, a[i] + a[2 * n - i + 2 * ans + 1] - m); printf("%d\n", mmax); }
[ "expression.operation.binary.add" ]
904,881
904,882
u365377749
cpp
p03093
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define uint unsigned #define pii pair<int, int> #define pll pair<ll, ll> #define PB push_back #define fi first #define se second #define For(i, j, k) for (int i = (int)(j); i <= (int)(k); i++) #define Rep(i, j, k) for (int i = (int)(j); i >= (int)(k); i--) #define CLR(a, v) memset(a, v, sizeof(a)); #define CPY(a, b) memcpy(a, b, sizeof(a)); using namespace std; const int N = 200005; int n, m, a[N]; bool check(int mid) { for (int l = mid * 2 - 1, r = 2 * n; l <= r; l++, r--) if (a[l] + a[r] < m) return 0; return 1; } int main() { scanf("%d%d", &n, &m); For(i, 1, n * 2) scanf("%d", &a[i]); sort(a + 1, a + n + 1); int l = 1, r = n, ans = n + 1; while (l <= r) { int mid = (l + r) / 2; if (check(mid)) ans = mid, r = mid - 1; else l = mid + 1; } int mx = 0; for (int l = 1, r = ans * 2 - 2; l <= r; l++, r--) mx = max(mx, a[l] + a[r]); for (int l = ans * 2 - 1, r = 2 * n; l <= r; l++, r--) mx = max(mx, a[l] + a[r] - m); printf("%d", mx); }
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define uint unsigned #define pii pair<int, int> #define pll pair<ll, ll> #define PB push_back #define fi first #define se second #define For(i, j, k) for (int i = (int)(j); i <= (int)(k); i++) #define Rep(i, j, k) for (int i = (int)(j); i >= (int)(k); i--) #define CLR(a, v) memset(a, v, sizeof(a)); #define CPY(a, b) memcpy(a, b, sizeof(a)); using namespace std; const int N = 200005; int n, m, a[N]; bool check(int mid) { for (int l = mid * 2 - 1, r = 2 * n; l <= r; l++, r--) if (a[l] + a[r] < m) return 0; return 1; } int main() { scanf("%d%d", &n, &m); For(i, 1, n * 2) scanf("%d", &a[i]); sort(a + 1, a + 2 * n + 1); int l = 1, r = n, ans = n + 1; while (l <= r) { int mid = (l + r) / 2; if (check(mid)) ans = mid, r = mid - 1; else l = mid + 1; } int mx = 0; for (int l = 1, r = ans * 2 - 2; l <= r; l++, r--) mx = max(mx, a[l] + a[r]); for (int l = ans * 2 - 1, r = 2 * n; l <= r; l++, r--) mx = max(mx, a[l] + a[r] - m); printf("%d", mx); }
[ "expression.operation.binary.add" ]
904,884
904,885
u408603320
cpp
p03093
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, M, a[2 * N]; int main() { scanf("%d%d", &n, &M); for (int i = 1; i <= 2 * n; ++i) scanf("%d", a + i); sort(a + 1, a + 1 + 2 * n); int b = 0; for (int i = 2 * n, j = 0; i; --i) { while (j < i && a[i] + a[j] < M) ++j; b = max(b, j + !(i - j & 1) - (2 * n - i)); } int ans = 0; for (int i = b; i < n + b - i; ++i) ans = max(ans, a[i] + a[n + b - i] - M); for (int i = 1; i < b - i; ++i) ans = max(ans, a[i] + a[b - i]); printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, M, a[2 * N]; int main() { scanf("%d%d", &n, &M); for (int i = 1; i <= 2 * n; ++i) scanf("%d", a + i); sort(a + 1, a + 1 + 2 * n); int b = 0; for (int i = 2 * n, j = 0; i; --i) { while (j < i && a[i] + a[j] < M) ++j; b = max(b, j + !(i - j & 1) - (2 * n - i)); } int ans = 0; for (int i = b; i < 2 * n + b - i; ++i) ans = max(ans, a[i] + a[2 * n + b - i] - M); for (int i = 1; i < b - i; ++i) ans = max(ans, a[i] + a[b - i]); printf("%d\n", ans); return 0; }
[ "control_flow.loop.for.condition.change", "assignment.change" ]
904,886
904,887
u760178976
cpp
p03093
#include <bits/stdc++.h> #define fo(i, x, y) for (int i = x, B = y; i <= B; i++) #define ff(i, x, y) for (int i = x, B = y; i < B; i++) #define fd(i, x, y) for (int i = x, B = y; i >= B; i--) #define ll long long #define pp printf #define hh pp("\n") using namespace std; const int N = 2e5 + 5; int n, mo, a[N], as; int calc(int m) { int ans = 0; fo(i, 1, m) ans = max(ans, (a[i] + a[2 * m - i + 1]) % mo); fo(i, 1, n - m) ans = max(ans, (a[m + i] + a[2 * n - i + 1]) % mo); return ans; } int main() { scanf("%d %d", &n, &mo); fo(i, 1, 2 * n) scanf("%d", &a[i]); sort(a + 1, a + 2 * n + 1); int as = 0; for (int l = 0, r = n; l <= r;) { int m = l + r >> 1; int ye = 1; fo(i, 1, n - m) if (a[2 * m + i] + a[2 * n - i + 1] < mo) ye = 0; if (ye) { as = m; r = m - 1; continue; } l = m + 1; } int ans = calc(as); if (as < n) ans = min(ans, calc(as + 1)); pp("%d\n", ans); }
#include <bits/stdc++.h> #define fo(i, x, y) for (int i = x, B = y; i <= B; i++) #define ff(i, x, y) for (int i = x, B = y; i < B; i++) #define fd(i, x, y) for (int i = x, B = y; i >= B; i--) #define ll long long #define pp printf #define hh pp("\n") using namespace std; const int N = 2e5 + 5; int n, mo, a[N], as; int calc(int m) { int ans = 0; fo(i, 1, m) ans = max(ans, (a[i] + a[2 * m - i + 1]) % mo); fo(i, 1, n - m) ans = max(ans, (a[2 * m + i] + a[2 * n - i + 1]) % mo); return ans; } int main() { scanf("%d %d", &n, &mo); fo(i, 1, 2 * n) scanf("%d", &a[i]); sort(a + 1, a + 2 * n + 1); int as = 0; for (int l = 0, r = n; l <= r;) { int m = l + r >> 1; int ye = 1; fo(i, 1, n - m) if (a[2 * m + i] + a[2 * n - i + 1] < mo) ye = 0; if (ye) { as = m; r = m - 1; continue; } l = m + 1; } int ans = calc(as); if (as < n) ans = min(ans, calc(as + 1)); pp("%d\n", ans); }
[ "assignment.change" ]
904,891
904,892
u173123334
cpp
p03093
#include <bits/stdc++.h> using std::max; using std::min; int n, m, a[200005], ans = 0, Ans; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n * 2; i++) scanf("%d", &a[i]); std::sort(a + 1, a + 2 * n + 1); int l = 0, r = n; while (l <= r) { int mid = (l + r) >> 1; bool f = true; int t = mid << 1; int ans = 0; if (f) for (int i = t + 1, j = 2 * n; i < j; i++, j--) if (a[i] + a[j] < m) { f = false; break; } if (f) { Ans = l; r = mid - 1; } else l = mid + 1; } int t = Ans * 2; for (int i = 1; i <= Ans; i++) ans = max(ans, a[i] + a[t - i + 1]); for (int i = t + 1, j = 2 * n; i < j; i++, j--) ans = max(ans, a[i] + a[j] - m); printf("%d\n", ans); }
#include <bits/stdc++.h> using std::max; using std::min; int n, m, a[200005], ans = 0, Ans; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n * 2; i++) scanf("%d", &a[i]); std::sort(a + 1, a + 2 * n + 1); int l = 0, r = n; while (l <= r) { int mid = (l + r) >> 1; bool f = true; int t = mid << 1; int ans = 0; if (f) for (int i = t + 1, j = 2 * n; i < j; i++, j--) if (a[i] + a[j] < m) { f = false; break; } if (f) { Ans = mid; r = mid - 1; } else l = mid + 1; } // Ans=l; int t = Ans * 2; for (int i = 1; i <= Ans; i++) ans = max(ans, a[i] + a[t - i + 1]); for (int i = t + 1, j = 2 * n; i < j; i++, j--) ans = max(ans, a[i] + a[j] - m); printf("%d\n", ans); }
[ "assignment.value.change", "identifier.change" ]
904,899
904,900
u754587701
cpp
p03093
#include <bits/stdc++.h> using std::max; using std::min; int n, m, a[40005], ans = 0, Ans; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n * 2; i++) scanf("%d", &a[i]); std::sort(a + 1, a + 2 * n + 1); int l = 0, r = n; while (l <= r) { int mid = (l + r) >> 1; bool f = true; int t = mid << 1; int ans = 0; if (f) for (int i = t + 1, j = 2 * n; i < j; i++, j--) if (a[i] + a[j] < m) { f = false; break; } if (f) { Ans = l; r = mid - 1; } else l = mid + 1; } int t = Ans * 2; for (int i = 1; i <= Ans; i++) ans = max(ans, a[i] + a[t - i + 1]); for (int i = t + 1, j = 2 * n; i < j; i++, j--) ans = max(ans, a[i] + a[j] - m); printf("%d\n", ans); }
#include <bits/stdc++.h> using std::max; using std::min; int n, m, a[200005], ans = 0, Ans; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n * 2; i++) scanf("%d", &a[i]); std::sort(a + 1, a + 2 * n + 1); int l = 0, r = n; while (l <= r) { int mid = (l + r) >> 1; bool f = true; int t = mid << 1; int ans = 0; if (f) for (int i = t + 1, j = 2 * n; i < j; i++, j--) if (a[i] + a[j] < m) { f = false; break; } if (f) { Ans = mid; r = mid - 1; } else l = mid + 1; } // Ans=l; int t = Ans * 2; for (int i = 1; i <= Ans; i++) ans = max(ans, a[i] + a[t - i + 1]); for (int i = t + 1, j = 2 * n; i < j; i++, j--) ans = max(ans, a[i] + a[j] - m); printf("%d\n", ans); }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "assignment.value.change", "identifier.change" ]
904,901
904,900
u754587701
cpp
p03091
#include <algorithm> #include <assert.h> #include <bitset> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <memory.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_set> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define Fi first #define Se second #define pb(x) push_back(x) #define szz(x) (int)x.size() #define rep(i, n) for (int i = 0; i < n; i++) #define all(x) x.begin(), x.end() typedef tuple<int, int, int> t3; int n, m; int deg[100010]; vector<pii> E[100010]; t3 edge[100010]; int chk[100010]; void dfs(int x, int st) { chk[x] = 1; t3 e = edge[x]; int a, b, idx; tie(a, b, idx) = e; if (st == b) swap(a, b); int f = -1; for (int i = 0; i < szz(E[b]); i++) if (E[b][i].Fi == a) f = i; f ^= 1; if (chk[E[b][f].Se] == 0) dfs(E[b][f].Se, b); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int x, y; scanf("%d%d", &x, &y); deg[x]++; deg[y]++; E[x].pb(pii(y, i)); E[y].pb(pii(x, i)); edge[i] = t3(x, y, i); } for (int i = 1; i <= n; i++) if (deg[i] & 1) { puts("No"); return 0; } for (int i = 1; i <= n; i++) if (deg[i] >= 6) { puts("Yes"); return 0; } int ans = 0; for (int i = 1; i <= n; i++) if (deg[i] == 4) ++ans; if (ans >= 3) puts("Yes"); else if (ans == 1) puts("No"); else { int fa = -1, fb = -1; for (int i = 1; i <= n; i++) if (deg[i] == 4) { if (fa == -1) fa = i; else fb = i; } int ok = 0; rep(a, 3) { rep(b, 3) { int cc = 0; memset(chk, 0, sizeof chk); for (int i = 1; i <= m; i++) if (chk[i] == 0) { ++cc; dfs(i, get<0>(edge[i])); } if (cc >= 3) ok = 1; rotate(E[fa].begin() + 1, E[fa].begin() + 2, E[fa].begin() + 4); } rotate(E[fb].begin() + 1, E[fb].begin() + 2, E[fb].begin() + 4); } printf("%s\n", ok ? "Yes" : "No"); } return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <memory.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_set> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define Fi first #define Se second #define pb(x) push_back(x) #define szz(x) (int)x.size() #define rep(i, n) for (int i = 0; i < n; i++) #define all(x) x.begin(), x.end() typedef tuple<int, int, int> t3; int n, m; int deg[100010]; vector<pii> E[100010]; t3 edge[100010]; int chk[100010]; void dfs(int x, int st) { chk[x] = 1; t3 e = edge[x]; int a, b, idx; tie(a, b, idx) = e; if (st == b) swap(a, b); int f = -1; for (int i = 0; i < szz(E[b]); i++) if (E[b][i].Fi == a) f = i; f ^= 1; if (chk[E[b][f].Se] == 0) dfs(E[b][f].Se, b); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int x, y; scanf("%d%d", &x, &y); deg[x]++; deg[y]++; E[x].pb(pii(y, i)); E[y].pb(pii(x, i)); edge[i] = t3(x, y, i); } for (int i = 1; i <= n; i++) if (deg[i] & 1) { puts("No"); return 0; } for (int i = 1; i <= n; i++) if (deg[i] >= 6) { puts("Yes"); return 0; } int ans = 0; for (int i = 1; i <= n; i++) if (deg[i] == 4) ++ans; if (ans >= 3) puts("Yes"); else if (ans <= 1) puts("No"); else { int fa = -1, fb = -1; for (int i = 1; i <= n; i++) if (deg[i] == 4) { if (fa == -1) fa = i; else fb = i; } int ok = 0; rep(a, 3) { rep(b, 3) { int cc = 0; memset(chk, 0, sizeof chk); for (int i = 1; i <= m; i++) if (chk[i] == 0) { ++cc; dfs(i, get<0>(edge[i])); } if (cc >= 3) ok = 1; rotate(E[fa].begin() + 1, E[fa].begin() + 2, E[fa].begin() + 4); } rotate(E[fb].begin() + 1, E[fb].begin() + 2, E[fb].begin() + 4); } printf("%s\n", ok ? "Yes" : "No"); } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
904,911
904,912
u479082130
cpp
p03092
#include <bits/stdc++.h> #define int long long using namespace std; int n, a, b, num[5007], dp[5007][5007], res = 1e18; int read() { int num = 0; char c = getchar(); while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = getchar(); return num; } signed main() { n = read(); a = read(); b = read(); for (int i = 1; i <= n; i++) num[i] = read(); memset(dp, 0x3f, sizeof dp); dp[0][0] = 0; for (int i = 1; i <= n; i++) for (int j = 0; j <= i; j++) if (num[i] > j) { dp[i][j] = min(dp[i][j], dp[i - 1][j] + a); dp[i][num[i]] = min(dp[i][num[i]], dp[i - 1][j]); } else dp[i][j] = min(dp[i][j], dp[i - 1][j] + b); for (int i = 0; i <= n; i++) res = min(res, dp[n][i]); cout << res << endl; return 0; }
#include <bits/stdc++.h> #define int long long using namespace std; int n, a, b, num[5007], dp[5007][5007], res = 1e18; int read() { int num = 0; char c = getchar(); while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = getchar(); return num; } signed main() { n = read(); a = read(); b = read(); for (int i = 1; i <= n; i++) num[i] = read(); memset(dp, 0x3f, sizeof dp); dp[0][0] = 0; for (int i = 1; i <= n; i++) for (int j = 0; j <= n; j++) if (num[i] > j) { dp[i][j] = min(dp[i][j], dp[i - 1][j] + a); dp[i][num[i]] = min(dp[i][num[i]], dp[i - 1][j]); } else dp[i][j] = min(dp[i][j], dp[i - 1][j] + b); for (int i = 0; i <= n; i++) res = min(res, dp[n][i]); cout << res << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
904,925
904,926
u816631826
cpp
p03092
// minamoto #include <bits/stdc++.h> #define R register #define fp(i, a, b) for (R int i = (a), I = (b) + 1; i < I; ++i) #define fd(i, a, b) for (R int i = (a), I = (b)-1; i > I; --i) #define go(u) for (int i = head[u], v = e[i].v; i; i = e[i].nx, v = e[i].v) template <class T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } template <class T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } using namespace std; typedef long long ll; const int N = 5005; ll f[N], res, ret; int a[N], n, A, B; int main() { // freopen("testdata.in","r",stdin); scanf("%d%d%d", &n, &A, &B); fp(i, 1, n) scanf("%d", &a[i]); ++n, a[n] = n; fp(i, 1, n) { f[i] = 1e18, ret = 0; fd(j, i - 1, 0) a[j] < a[i] ? (cmin(f[i], f[j] = ret), ret += B) : ret += A; } printf("%lld\n", f[n]); return 0; }
// minamoto #include <bits/stdc++.h> #define R register #define fp(i, a, b) for (R int i = (a), I = (b) + 1; i < I; ++i) #define fd(i, a, b) for (R int i = (a), I = (b)-1; i > I; --i) #define go(u) for (int i = head[u], v = e[i].v; i; i = e[i].nx, v = e[i].v) template <class T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } template <class T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } using namespace std; typedef long long ll; const int N = 5005; ll f[N], res, ret; int a[N], n, A, B; int main() { // freopen("testdata.in","r",stdin); scanf("%d%d%d", &n, &A, &B); fp(i, 1, n) scanf("%d", &a[i]); ++n, a[n] = n; fp(i, 1, n) { f[i] = 1e18, ret = 0; fd(j, i - 1, 0) a[j] < a[i] ? (cmin(f[i], f[j] + ret), ret += B) : ret += A; } printf("%lld\n", f[n]); return 0; }
[ "call.arguments.change" ]
904,933
904,934
u561765782
cpp
p03092
#include <bits/stdc++.h> #define RI register int typedef long long LL; #define int LL #define FILEIO(name) \ freopen(name ".in", "r", stdin), freopen(name ".out", "w", stdout); using namespace std; char buf[1000000], *p1 = buf, *p2 = buf; inline char gc() { if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin); return p1 == p2 ? EOF : *(p1++); } template <class T> inline void read(T &n) { n = 0; RI ch = gc(), f; while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc(); f = (ch == '-' ? ch = gc(), -1 : 1); while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc(); n *= f; } int const MAXN = 5005; int a[MAXN]; int f[MAXN][MAXN]; signed main() { #ifdef LOCAL FILEIO("a"); #endif int n, A, B; read(n), read(A), read(B); for (RI i = 1; i <= n; ++i) read(a[i]); memset(f, 0x3f, sizeof(f)); f[0][0] = 0; for (RI i = 1; i <= n; ++i) for (RI j = 0; j <= n; ++j) if (a[i] > j) { f[i][j] = min(f[i][j], f[i - 1][j] + A); f[i][a[i]] = min(f[i][a[i]], f[i - 1][j]); } else { f[i][j] = min(f[i][j], f[i - 1][j] + B); // f[i][a[i]] = min(f[i][a[i]], f[i - 1][j] + A); } int ans = 0x7f7f7f7f7f7f7f7f; for (RI i = 0; i <= n; ++i) ans = min(ans, f[n][i]); printf("%d\n", ans); cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl; return 0; } // created by Daniel yuan
#include <bits/stdc++.h> #define RI register int typedef long long LL; #define int LL #define FILEIO(name) \ freopen(name ".in", "r", stdin), freopen(name ".out", "w", stdout); using namespace std; char buf[1000000], *p1 = buf, *p2 = buf; inline char gc() { if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin); return p1 == p2 ? EOF : *(p1++); } template <class T> inline void read(T &n) { n = 0; RI ch = gc(), f; while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc(); f = (ch == '-' ? ch = gc(), -1 : 1); while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc(); n *= f; } int const MAXN = 5005; int a[MAXN]; int f[MAXN][MAXN]; signed main() { #ifdef LOCAL FILEIO("a"); #endif int n, A, B; read(n), read(A), read(B); for (RI i = 1; i <= n; ++i) read(a[i]); memset(f, 0x3f, sizeof(f)); f[0][0] = 0; for (RI i = 1; i <= n; ++i) for (RI j = 0; j <= n; ++j) if (a[i] > j) { f[i][j] = min(f[i][j], f[i - 1][j] + A); f[i][a[i]] = min(f[i][a[i]], f[i - 1][j]); } else { f[i][j] = min(f[i][j], f[i - 1][j] + B); // f[i][a[i]] = min(f[i][a[i]], f[i - 1][j] + A); } int ans = 0x7f7f7f7f7f7f7f7f; for (RI i = 0; i <= n; ++i) ans = min(ans, f[n][i]); printf("%lld\n", ans); cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl; return 0; } // created by Daniel yuan
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
904,940
904,941
u465426617
cpp
p03092
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 5e3 + 10; int N, P[MAX_N], pre2d[MAX_N][MAX_N]; ll A, B, F[MAX_N]; int count(int x1, int x2, int y1, int y2) { return pre2d[x2][y2] - pre2d[x2][y1 - 1] - pre2d[x1 - 1][y2] + pre2d[x1 - 1][y1 - 1]; } int main() { scanf("%d%lld%lld", &N, &A, &B); for (int i = 1; i <= N; i++) scanf("%d", &P[i]); P[0] = 0; P[N + 1] = N + 1; for (int i = 1; i <= N; i++) { pre2d[i][P[i]] = 1; } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) pre2d[i][j] += pre2d[i][j - 1]; } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) pre2d[i][j] += pre2d[i - 1][j]; } for (int i = 1; i <= N + 1; i++) { F[i] = LLONG_MAX; for (int j = 0; j < i; j++) { if (P[j] > P[i]) continue; ll v = F[j]; int tot = i - j - 1, heavy; if (A >= B) { heavy = count(j + 1, i - 1, i, N); } else { heavy = count(j + 1, i - 1, 1, j); } v += max(A, B) * heavy + min(A, B) * (tot - heavy); F[i] = min(F[i], v); } } printf("%lld\n", F[N + 1]); }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 5e3 + 10; int N, P[MAX_N], pre2d[MAX_N][MAX_N]; ll A, B, F[MAX_N]; int count(int x1, int x2, int y1, int y2) { return pre2d[x2][y2] - pre2d[x2][y1 - 1] - pre2d[x1 - 1][y2] + pre2d[x1 - 1][y1 - 1]; } int main() { scanf("%d%lld%lld", &N, &A, &B); for (int i = 1; i <= N; i++) scanf("%d", &P[i]); P[0] = 0; P[N + 1] = N + 1; for (int i = 1; i <= N; i++) { pre2d[i][P[i]] = 1; } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) pre2d[i][j] += pre2d[i][j - 1]; } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) pre2d[i][j] += pre2d[i - 1][j]; } for (int i = 1; i <= N + 1; i++) { F[i] = LLONG_MAX; for (int j = 0; j < i; j++) { if (P[j] > P[i]) continue; ll v = F[j]; int tot = i - j - 1, heavy; if (A >= B) { heavy = count(j + 1, i - 1, P[i], N); } else { heavy = count(j + 1, i - 1, 1, P[j]); } v += max(A, B) * heavy + min(A, B) * (tot - heavy); F[i] = min(F[i], v); } } printf("%lld\n", F[N + 1]); }
[ "call.arguments.change" ]
904,944
904,945
u557835351
cpp
p03092
/* shiftʵÖÊÉÏÊǰÑÒ»¸öÔªËØÍùÇ°ÒÆ»òÕßÍùºóÒÆ ¿¼ÂÇÈç¹ûÈ·¶¨Ò»Ð©ÔªËز»¶¯µÄ»°£¨ÏÔÈ»ËüÃǵÄϱêºÍÖµ¶¼µ¥Ôö£©£¬ÄÇô¶ÔÓÚÏàÁÚÁ½¸öÈ·¶¨²»¶¯µÄÔªËØaºÍbÖ®¼äµÄÔªËØx£¬»áÓÐÈçÏÂÊ£º (1)P[x] < P[a]£¬ÄÇôÐèÒª°ÑP[x]ÍùÇ°ÒÆ (2)P[b] < P[x]£¬ÄÇôÐèÒª°ÑP[x]ÍùºóÒÆ (3)ʣϵÄËùÓÐP[a] < P[x] < P[b]µÄÔªËØ£¬¿ÉÒÔÈ«ÓÃmin(A, B)µÄ´ú¼ÛÅźÃÐò Ö±½Ódp¼´¿É */ #include <algorithm> #include <cstdio> #include <cstring> using namespace std; const int Max_N(5050); typedef long long int LL; int N, P[Max_N], Pre[Max_N][Max_N], Suf[Max_N][Max_N]; LL F[Max_N][Max_N], A, B; inline void upd(LL &a, LL b) { a = min(a, b); } int main() { scanf("%d%lld%lld", &N, &A, &B); for (int i = 1; i <= N; ++i) scanf("%d", P + i), Pre[i][P[i]] = Suf[i][P[i]] = 1; for (int i = 1; i <= N; ++i) { for (int j = 1; j <= N + 1; ++j) Pre[i][j] += Pre[i][j - 1]; for (int j = N; j >= 0; --j) Suf[i][j] += Suf[i][j + 1]; for (int j = 1; j <= N; ++j) Pre[i][j] += Pre[i - 1][j], Suf[i][j] += Suf[i - 1][j]; } memset(F, 0X3F, sizeof(F)), F[0][0] = 0LL; P[0] = 0, P[N + 1] = N + 1; for (int i = 1; i <= N + 1; ++i) for (int j = 0, t; j <= i - 1; ++j) { upd(F[i][j], F[i - 1][j]); if (P[j] < P[i]) { t = (i - 1) - j; t -= (Pre[i - 1][P[j]] - Pre[j][P[j]]) + (Suf[i - 1][P[i]] - Suf[j][P[i]]); upd(F[i][i], F[i - 1][j] + (Pre[i - 1][P[j]] - Pre[j][P[j]]) * B + (Suf[i - 1][P[i]] - Suf[j][P[i]]) * A + t * min(A, B)); } } printf("%d", F[N + 1][N + 1]); return 0; }
/* shiftʵÖÊÉÏÊǰÑÒ»¸öÔªËØÍùÇ°ÒÆ»òÕßÍùºóÒÆ ¿¼ÂÇÈç¹ûÈ·¶¨Ò»Ð©ÔªËز»¶¯µÄ»°£¨ÏÔÈ»ËüÃǵÄϱêºÍÖµ¶¼µ¥Ôö£©£¬ÄÇô¶ÔÓÚÏàÁÚÁ½¸öÈ·¶¨²»¶¯µÄϱêaºÍbÖ®¼äµÄϱêx(a < x < b)£¬»áÓÐÈçÏÂÊ£º (1)P[x] < P[a]£¬ÄÇôÐèÒª°ÑP[x]ÍùÇ°ÒÆ (2)P[b] < P[x]£¬ÄÇôÐèÒª°ÑP[x]ÍùºóÒÆ (3)ʣϵÄËùÓÐP[a] < P[x] < P[b]µÄÔªËØ£¬¿ÉÒÔÈ«ÓÃmin(A, B)µÄ´ú¼ÛÅźÃÐò Ö±½Ódp¼´¿É */ #include <algorithm> #include <cstdio> #include <cstring> using namespace std; const int Max_N(5050); typedef long long int LL; int N, P[Max_N], Pre[Max_N][Max_N], Suf[Max_N][Max_N]; LL F[Max_N][Max_N], A, B; inline void upd(LL &a, LL b) { a = min(a, b); } int main() { scanf("%d%lld%lld", &N, &A, &B); for (int i = 1; i <= N; ++i) scanf("%d", P + i), Pre[i][P[i]] = Suf[i][P[i]] = 1; for (int i = 1; i <= N; ++i) { for (int j = 1; j <= N + 1; ++j) Pre[i][j] += Pre[i][j - 1]; for (int j = N; j >= 0; --j) Suf[i][j] += Suf[i][j + 1]; for (int j = 1; j <= N; ++j) Pre[i][j] += Pre[i - 1][j], Suf[i][j] += Suf[i - 1][j]; } memset(F, 0X3F, sizeof(F)), F[0][0] = 0LL; P[0] = 0, P[N + 1] = N + 1; for (int i = 1; i <= N + 1; ++i) for (int j = 0, t; j <= i - 1; ++j) { upd(F[i][j], F[i - 1][j]); if (P[j] < P[i]) { t = (i - 1) - j; t -= (Pre[i - 1][P[j]] - Pre[j][P[j]]) + (Suf[i - 1][P[i]] - Suf[j][P[i]]); upd(F[i][i], F[i - 1][j] + (Pre[i - 1][P[j]] - Pre[j][P[j]]) * B + (Suf[i - 1][P[i]] - Suf[j][P[i]]) * A + t * min(A, B)); } } printf("%lld", F[N + 1][N + 1]); return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
904,951
904,952
u710399266
cpp
p03092
// copy from https://atcoder.jp/contests/agc037/submissions/7059910 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define mem(x, v) memset(x, v, sizeof(x)) #define Rep(i, a, b) for (register int i = (a); i <= int(b); ++i) #define rep(i, a, b) for (register int i = (a); i < int(b); ++i) #define Dep(i, a, b) for (register int i = (a); i >= int(b); --i) #define gc getchar #define pc putchar #define fi first #define se second inline ll read() { ll x = 0, f = 1; char c = gc(); for (; !isdigit(c); c = gc()) if (c == '-') f = -1; for (; isdigit(c); c = gc()) x = (x << 1) + (x << 3) + (c ^ 48); return x * f; } inline void write(ll x) { if (x < 0) x = -x, pc('-'); if (x >= 10) write(x / 10); putchar(x % 10 + '0'); } inline void writeln(ll x) { write(x); pc('\n'); } inline void wri(ll x) { write(x); pc(' '); } const int maxn = 5005; int dp[maxn][maxn], a[maxn]; int n, A, B, ans; int main() { n = read(), A = read(), B = read(); ans = 1ll << 30; Rep(i, 1, n) a[i] = read(); memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; Rep(i, 1, n) Rep(j, 0, n) { if (a[i] > j) dp[i][j] = min(dp[i][j], dp[i - 1][j] + A), dp[i][a[i]] = min(dp[i][a[i]], dp[i - 1][j]); else dp[i][j] = min(dp[i][j], dp[i - 1][j] + B); } Rep(i, 0, n) ans = min(ans, dp[n][i]); writeln(ans); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define mem(x, v) memset(x, v, sizeof(x)) #define Rep(i, a, b) for (register int i = (a); i <= int(b); ++i) #define rep(i, a, b) for (register int i = (a); i < int(b); ++i) #define Dep(i, a, b) for (register int i = (a); i >= int(b); --i) #define gc getchar #define pc putchar #define fi first #define se second inline ll read() { ll x = 0, f = 1; char c = gc(); for (; !isdigit(c); c = gc()) if (c == '-') f = -1; for (; isdigit(c); c = gc()) x = (x << 1) + (x << 3) + (c ^ 48); return x * f; } inline void write(ll x) { if (x < 0) x = -x, pc('-'); if (x >= 10) write(x / 10); putchar(x % 10 + '0'); } inline void writeln(ll x) { write(x); pc('\n'); } inline void wri(ll x) { write(x); pc(' '); } const int maxn = 5005; ll dp[maxn][maxn], a[maxn]; ll n, A, B, ans; int main() { n = read(), A = read(), B = read(); ans = 1ll << 60; Rep(i, 1, n) a[i] = read(); memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; Rep(i, 1, n) Rep(j, 0, n) { if (a[i] > j) dp[i][j] = min(dp[i][j], dp[i - 1][j] + A), dp[i][a[i]] = min(dp[i][a[i]], dp[i - 1][j]); else dp[i][j] = min(dp[i][j], dp[i - 1][j] + B); } Rep(i, 0, n) ans = min(ans, dp[n][i]); writeln(ans); return 0; }
[ "variable_declaration.type.change", "literal.number.change", "assignment.value.change", "expression.operation.binary.change" ]
904,956
904,957
u454243544
cpp
p03092
#include <bits/stdc++.h> #define LL long long #define pa pair<int, int> using namespace std; const int N = 5001; const int inf = 2147483647; int _max(int x, int y) { return x > y ? x : y; } LL _min(LL x, LL y) { return x < y ? x : y; } inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar(); return x * f; } void put(int x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) put(x / 10); putchar(x % 10 + '0'); } int a[N]; LL f[N][N]; int main() { int n = read(), A = read(), B = read(); for (int i = 1; i <= n; i++) a[i] = read(); memset(f, 63, sizeof(f)); f[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { if (a[i] > j) { f[i][j] = _min(f[i][j], f[i - 1][j] + A); f[i][a[i]] = _min(f[i][a[i]], f[i - 1][j]); } else f[i][a[i]] = _min(f[i][a[i]], f[i - 1][j] + B); } } LL ans = f[0][1]; for (int i = 0; i <= n; i++) ans = _min(ans, f[n][i]); printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> #define LL long long #define pa pair<int, int> using namespace std; const int N = 5001; const int inf = 2147483647; int _max(int x, int y) { return x > y ? x : y; } LL _min(LL x, LL y) { return x < y ? x : y; } inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar(); return x * f; } void put(int x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) put(x / 10); putchar(x % 10 + '0'); } int a[N]; LL f[N][N]; int main() { int n = read(), A = read(), B = read(); for (int i = 1; i <= n; i++) a[i] = read(); memset(f, 63, sizeof(f)); f[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { if (a[i] > j) { f[i][j] = _min(f[i][j], f[i - 1][j] + A); f[i][a[i]] = _min(f[i][a[i]], f[i - 1][j]); } else f[i][j] = _min(f[i][a[i]], f[i - 1][j] + B); } } LL ans = f[0][1]; for (int i = 0; i <= n; i++) ans = _min(ans, f[n][i]); printf("%lld\n", ans); return 0; }
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
904,966
904,967
u255836250
cpp
p03092
#include <bits/stdc++.h> using namespace std; const int N = 5678; const long long llinf = 1e18; int n, a, b, p[N]; long long dp[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> a >> b; for (int i = 1; i <= n; ++i) { cin >> p[i]; } ++n; p[n] = n; fill(dp + 1, dp + n + 1, llinf); for (int i = 0; i < n; ++i) { int foo = n + 1; long long cost = 0; for (int j = i + 1; j <= n; ++j) { if (p[j] > p[i]) { if (p[j] > foo) { break; } dp[j] = min(dp[j], dp[i] + cost); foo = min(foo, p[j]); } if (p[j] < p[i]) { cost += b; } else { cost += a; } } } cout << dp[n] << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 5678; const long long llinf = 1e18; int n, a, b, p[N]; long long dp[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> a >> b; for (int i = 1; i <= n; ++i) { cin >> p[i]; } ++n; p[n] = n; fill(dp + 1, dp + n + 1, llinf); for (int i = 0; i < n; ++i) { int foo = n + 1; long long cost = 0; for (int j = i + 1; j <= n; ++j) { if (p[j] > p[i]) { if (p[j] < foo) { dp[j] = min(dp[j], dp[i] + cost); } foo = min(foo, p[j]); } if (p[j] < p[i]) { cost += b; } else { cost += a; } } } cout << dp[n] << '\n'; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
904,968
904,969
u303142406
cpp
p03091
#include <bits/stdc++.h> using namespace std; #define ll long long const ll mod = 1e9 + 7; #define N 100010 int fa[N], du[N]; int a[N], b[N]; vector<int> d4; int get_fa(int x) { return fa[x] == x ? x : fa[x] = get_fa(fa[x]); } int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d%d", &a[i], &b[i]); du[a[i]]++, du[b[i]]++; } for (int i = 1; i <= n; i++) if (du[i] % 2) { printf("NO\n"); return 0; } for (int i = 1; i <= n; i++) if (du[i] >= 6) { printf("YES\n"); return 0; } else if (du[i] == 4) d4.push_back(i); if (d4.size() >= 3) printf("YES\n"); else if (d4.size() < 2) printf("NO\n"); else { for (int i = 1; i <= n; i++) fa[i] = i; for (int i = 1; i <= m; i++) { if (a[i] == d4[0] || b[i] == d4[0]) continue; fa[get_fa(a[i])] = fa[get_fa(b[i])]; } int cnt = 0; for (int i = 1; i <= n; i++) { if (fa[i] == i) cnt++; } if (cnt >= 3) printf("YES\n"); else printf("NO\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long const ll mod = 1e9 + 7; #define N 100010 int fa[N], du[N]; int a[N], b[N]; vector<int> d4; int get_fa(int x) { return fa[x] == x ? x : fa[x] = get_fa(fa[x]); } int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d%d", &a[i], &b[i]); du[a[i]]++, du[b[i]]++; } for (int i = 1; i <= n; i++) if (du[i] % 2) { printf("No\n"); return 0; } for (int i = 1; i <= n; i++) if (du[i] >= 6) { printf("Yes\n"); return 0; } else if (du[i] == 4) d4.push_back(i); if (d4.size() >= 3) printf("Yes\n"); else if (d4.size() < 2) printf("No\n"); else { for (int i = 1; i <= n; i++) fa[i] = i; for (int i = 1; i <= m; i++) { if (a[i] == d4[0] || b[i] == d4[0]) continue; fa[get_fa(a[i])] = fa[get_fa(b[i])]; } int cnt = 0; for (int i = 1; i <= n; i++) { if (fa[i] == i) cnt++; } if (cnt >= 3) printf("Yes\n"); else printf("No\n"); } return 0; }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
905,009
905,010
u820628270
cpp
p03091
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> G[100000]; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } int v4(0), v6(0); for (int i = 0; i < N; i++) { if (G[i].size() >= 6) { v6++; break; } else if (G[i].size() >= 4) { v4++; } if (G[i].size() % 2 == 1) { v4 = -1e6; v6 = -1e6; } } if (v6 > 0 || v4 >= 3) { cout << "Yes" << endl; } else if (v4 == 2) { int a, b; for (int i = 0; i < N; i++) { if (G[i].size() == 4) { b = i; break; } } for (int i = b + 1; i < N; i++) { if (G[i].size() == 4) { a = i; break; } } // aからbへの経路の数をカウントする. queue<int> q; q.push(a); int d[100000] = {}; d[a] = 1; while (!q.empty()) { int v = q.front(); q.pop(); for (int j = 0; j < G[v].size(); j++) { int u = G[v][j]; if (u != b && d[u] == 0) { q.push(u); d[u] = 1; } else if (u == b) { d[b]++; } } } if (d[b] == 2) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { cout << "No" << endl; } return 0; }
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> G[100000]; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } int v4(0), v6(0); for (int i = 0; i < N; i++) { if (G[i].size() >= 6) { v6++; } else if (G[i].size() == 4) { v4++; } if (G[i].size() % 2 == 1) { v4 = -1e6; v6 = -1e6; } } if (v6 > 0 || v4 >= 3) { cout << "Yes" << endl; } else if (v4 == 2) { int a, b; for (int i = 0; i < N; i++) { if (G[i].size() == 4) { a = i; break; } } for (int i = a + 1; i < N; i++) { if (G[i].size() == 4) { b = i; break; } } // aからbへの経路の数をカウントする. queue<int> q; q.push(a); int d[100000] = {}; d[a] = 1; while (!q.empty()) { int v = q.front(); q.pop(); for (int j = 0; j < G[v].size(); j++) { int u = G[v][j]; if (u != b && d[u] == 0) { q.push(u); d[u] = 1; } else if (u == b) { d[b]++; } } } if (d[b] == 2) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { cout << "No" << endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.variable.change", "identifier.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change" ]
905,011
905,012
u989740992
cpp
p03091
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> G[100000]; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } int v4(0), v6(0); for (int i = 0; i < N; i++) { if (G[i].size() >= 6) { v6++; break; } else if (G[i].size() >= 4) { v4++; } else if (G[i].size() % 2 == 1) { v4 = -1e6; v6 = -1e6; } } if (v6 > 0 || v4 >= 3) { cout << "Yes" << endl; } else if (v4 == 2) { int a, b; for (int i = 0; i < N; i++) { if (G[i].size() == 4) { b = i; break; } } for (int i = a + 1; i < N; i++) { if (G[i].size() == 4) { a = i; break; } } // aからbへの経路の数をカウントする. queue<int> q; q.push(a); int d[100000] = {}; d[a] = 1; while (!q.empty()) { int v = q.front(); q.pop(); for (int j = 0; j < G[v].size(); j++) { int u = G[v][j]; if (u != b && d[u] == 0) { q.push(u); d[u] = 1; } else if (u == b) { d[b]++; } } } if (d[b] == 2) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { cout << "No" << endl; } return 0; }
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> G[100000]; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } int v4(0), v6(0); for (int i = 0; i < N; i++) { if (G[i].size() >= 6) { v6++; } else if (G[i].size() == 4) { v4++; } if (G[i].size() % 2 == 1) { v4 = -1e6; v6 = -1e6; } } if (v6 > 0 || v4 >= 3) { cout << "Yes" << endl; } else if (v4 == 2) { int a, b; for (int i = 0; i < N; i++) { if (G[i].size() == 4) { a = i; break; } } for (int i = a + 1; i < N; i++) { if (G[i].size() == 4) { b = i; break; } } // aからbへの経路の数をカウントする. queue<int> q; q.push(a); int d[100000] = {}; d[a] = 1; while (!q.empty()) { int v = q.front(); q.pop(); for (int j = 0; j < G[v].size(); j++) { int u = G[v][j]; if (u != b && d[u] == 0) { q.push(u); d[u] = 1; } else if (u == b) { d[b]++; } } } if (d[b] == 2) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { cout << "No" << endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.branch.if.replace.add", "control_flow.branch.else_if.replace.remove", "assignment.variable.change", "identifier.change" ]
905,013
905,012
u989740992
cpp
p03091
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> G[100000]; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } int v4(0), v6(0); for (int i = 0; i < N; i++) { if (G[i].size() >= 6) { v6++; break; } else if (G[i].size() >= 4) { v4++; } else if (G[i].size() % 2 == 1) { v4 = -1e6; v6 = -1e6; } } if (v6 > 0 || v4 >= 3) { cout << "Yes" << endl; } else if (v4 == 2) { int a, b; for (int i = 0; i < N; i++) { if (G[i].size() == 4) { a = i; break; } } for (int i = a + 1; i < N; i++) { if (G[i].size() == 4) { b = i; break; } } // aからbへの経路の数をカウントする. queue<int> q; q.push(a); int d[100000] = {}; d[a] = 1; while (!q.empty()) { int v = q.front(); q.pop(); for (int j = 0; j < G[v].size(); j++) { int u = G[v][j]; if (u != b && d[u] == 0) { q.push(u); d[u] = 1; } else if (u == b) { d[b]++; } } } if (d[b] == 2) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { cout << "No" << endl; } return 0; }
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> G[100000]; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } int v4(0), v6(0); for (int i = 0; i < N; i++) { if (G[i].size() >= 6) { v6++; } else if (G[i].size() == 4) { v4++; } if (G[i].size() % 2 == 1) { v4 = -1e6; v6 = -1e6; } } if (v6 > 0 || v4 >= 3) { cout << "Yes" << endl; } else if (v4 == 2) { int a, b; for (int i = 0; i < N; i++) { if (G[i].size() == 4) { a = i; break; } } for (int i = a + 1; i < N; i++) { if (G[i].size() == 4) { b = i; break; } } // aからbへの経路の数をカウントする. queue<int> q; q.push(a); int d[100000] = {}; d[a] = 1; while (!q.empty()) { int v = q.front(); q.pop(); for (int j = 0; j < G[v].size(); j++) { int u = G[v][j]; if (u != b && d[u] == 0) { q.push(u); d[u] = 1; } else if (u == b) { d[b]++; } } } if (d[b] == 2) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { cout << "No" << endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.branch.if.replace.add", "control_flow.branch.else_if.replace.remove" ]
905,014
905,012
u989740992
cpp
p03091
#include <bits/stdc++.h> #define _ (*istream_iterator<int>(cin)) #define em emplace using namespace std; const int N = 1e5 + 10; set<int> g[N]; int deg[N]; int dfs(int u, int p, int s, int t) { if (u == s && u != p) return -1; if (u == t) return 1; for (auto i = g[u].begin(); i != g[u].end();) { int v = *i; i = g[u].erase(i); if (v == p) continue; int d = dfs(v, u, s, t); if (d) return d; } return 0; } int main() { int n = _; int m = _; for (; m--;) { int u = _, v = _; g[u].em(v); g[v].em(u); deg[u]++; deg[v]++; } int d6 = 0, d1 = 0, d4 = 0, a = 0, b; for (int i = 1; i <= n; i++) { if (deg[i] <= 6) d6++; if (deg[i] == 4) d4++, (a ? b : a) = i; if (deg[i] & 1) d1++; } if (d1) { cout << "No"; return 0; } if (d6) { cout << "Yes"; return 0; } if (d4 > 2) { cout << "Yes"; return 0; } if (d4 < 2) { cout << "No"; return 0; } else if (dfs(a, a, a, b) + dfs(a, a, a, b) + dfs(a, a, a, b) == 1) { cout << "Yes"; } else { cout << "No"; } return 0; }
#include <bits/stdc++.h> #define _ (*istream_iterator<int>(cin)) #define em emplace using namespace std; const int N = 1e5 + 10; set<int> g[N]; int deg[N]; int dfs(int u, int p, int s, int t) { if (u == s && u != p) return -1; if (u == t) return 1; for (auto i = g[u].begin(); i != g[u].end();) { int v = *i; i = g[u].erase(i); if (v == p) continue; int d = dfs(v, u, s, t); if (d) return d; } return 0; } int main() { int n = _; int m = _; for (; m--;) { int u = _, v = _; g[u].em(v); g[v].em(u); deg[u]++; deg[v]++; } int d6 = 0, d1 = 0, d4 = 0, a = 0, b; for (int i = 1; i <= n; i++) { if (deg[i] >= 6) d6++; if (deg[i] == 4) d4++, (a ? b : a) = i; if (deg[i] & 1) d1++; } if (d1) { cout << "No"; return 0; } if (d6) { cout << "Yes"; return 0; } if (d4 > 2) { cout << "Yes"; return 0; } if (d4 < 2) { cout << "No"; return 0; } if (dfs(a, a, a, b) + dfs(a, a, a, b) + dfs(a, a, a, b) == 1) { cout << "Yes"; } else { cout << "No"; } return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.branch.if.replace.add", "control_flow.branch.else_if.replace.remove" ]
905,015
905,016
u080609335
cpp
p03091
#include <bits/stdc++.h> using namespace std; int N, M, ap[100009]; bool dp[20]; vector<int> h, v[100009]; int cnt2 = 0, ever6 = 0; void dfs(int nod) { ap[nod] = 1; ever6 |= (v[nod].size() > 4); if (v[nod].size() > 2) cnt2++; for (auto it : v[nod]) if (ap[it] == 0) dfs(it); } void delEdge(int x, int y) { for (auto it = v[x].begin(); it != v[x].end(); it++) if (*it == y) { v[x].erase(it); break; } for (auto it = v[y].begin(); it != v[y].end(); it++) if (*it == x) { v[y].erase(it); break; } } void addEdge(int x, int y) { v[x].push_back(y); v[y].push_back(x); } int main() { // freopen ("input", "r", stdin); // freopen ("output", "w", stdout); scanf("%d %d", &N, &M); while (M--) { int x, y; scanf("%d %d", &x, &y); addEdge(x, y); } for (int i = 1; i <= N; i++) if (v[i].empty() & 1) { printf("No\n"); return 0; } dfs(1); bool ok = 0; if (ever6) ok = 1; else if (cnt2 >= 3) ok = 1; else if (cnt2 == 2) { int A = -1, B = -1; for (int i = 1; i <= N; i++) if (v[i].size() > 2) { if (A == -1) A = i; else B = i; } vector<int> curr = v[A]; for (int i = 0; i < 4; i++) for (int j = i + 1; j < 4; j++) { delEdge(A, curr[i]), delEdge(A, curr[j]); memset(ap, 0, sizeof(ap)); dfs(A); if (ap[B] == 0) { ok = 1; i = j = 4; break; } addEdge(A, curr[i]), addEdge(A, curr[j]); } } if (ok) printf("Yes\n"); else printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int N, M, ap[100009]; bool dp[20]; vector<int> h, v[100009]; int cnt2 = 0, ever6 = 0; void dfs(int nod) { ap[nod] = 1; ever6 |= (v[nod].size() > 4); if (v[nod].size() > 2) cnt2++; for (auto it : v[nod]) if (ap[it] == 0) dfs(it); } void delEdge(int x, int y) { for (auto it = v[x].begin(); it != v[x].end(); it++) if (*it == y) { v[x].erase(it); break; } for (auto it = v[y].begin(); it != v[y].end(); it++) if (*it == x) { v[y].erase(it); break; } } void addEdge(int x, int y) { v[x].push_back(y); v[y].push_back(x); } int main() { // freopen ("input", "r", stdin); // freopen ("output", "w", stdout); scanf("%d %d", &N, &M); while (M--) { int x, y; scanf("%d %d", &x, &y); addEdge(x, y); } for (int i = 1; i <= N; i++) if (v[i].size() & 1) { printf("No\n"); return 0; } dfs(1); bool ok = 0; if (ever6) ok = 1; else if (cnt2 >= 3) ok = 1; else if (cnt2 == 2) { int A = -1, B = -1; for (int i = 1; i <= N; i++) if (v[i].size() > 2) { if (A == -1) A = i; else B = i; } vector<int> curr = v[A]; for (int i = 0; i < 4; i++) for (int j = i + 1; j < 4; j++) { delEdge(A, curr[i]), delEdge(A, curr[j]); memset(ap, 0, sizeof(ap)); dfs(A); if (ap[B] == 0) { ok = 1; i = j = 4; break; } addEdge(A, curr[i]), addEdge(A, curr[j]); } } if (ok) printf("Yes\n"); else printf("No\n"); return 0; }
[ "call.function.change", "control_flow.branch.if.condition.change" ]
905,021
905,022
u098930106
cpp
p03091
#include <bits/stdc++.h> using namespace std; int N, M, ap[100009]; bool dp[20]; vector<int> h, v[100009]; int cnt2 = 0, ever6 = 0; void dfs(int nod) { ap[nod] = 1; ever6 |= (v[nod].size() > 6); if (v[nod].size() > 2) cnt2++; for (auto it : v[nod]) if (ap[it] == 0) dfs(it); } void delEdge(int x, int y) { for (auto it = v[x].begin(); it != v[x].end(); it++) if (*it == y) { v[x].erase(it); break; } for (auto it = v[y].begin(); it != v[y].end(); it++) if (*it == x) { v[y].erase(it); break; } } void addEdge(int x, int y) { v[x].push_back(y); v[y].push_back(x); } int main() { // freopen ("input", "r", stdin); // freopen ("output", "w", stdout); scanf("%d %d", &N, &M); while (M--) { int x, y; scanf("%d %d", &x, &y); addEdge(x, y); } for (int i = 1; i <= N; i++) if (v[i].empty() & 1) { printf("No\n"); return 0; } dfs(1); bool ok = 0; if (ever6) ok = 1; else if (cnt2 >= 3) ok = 1; else if (cnt2 == 2) { int A = -1, B = -1; for (int i = 1; i <= N; i++) if (v[i].size() > 2) { if (A == -1) A = i; else B = i; } vector<int> curr = v[A]; for (int i = 0; i < 4; i++) for (int j = i + 1; j < 4; j++) { delEdge(A, curr[i]), delEdge(A, curr[j]); memset(ap, 0, sizeof(ap)); dfs(A); if (ap[B] == 0) { ok = 1; i = j = 4; break; } addEdge(A, curr[i]), addEdge(A, curr[j]); } } if (ok) printf("Yes\n"); else printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int N, M, ap[100009]; bool dp[20]; vector<int> h, v[100009]; int cnt2 = 0, ever6 = 0; void dfs(int nod) { ap[nod] = 1; ever6 |= (v[nod].size() > 4); if (v[nod].size() > 2) cnt2++; for (auto it : v[nod]) if (ap[it] == 0) dfs(it); } void delEdge(int x, int y) { for (auto it = v[x].begin(); it != v[x].end(); it++) if (*it == y) { v[x].erase(it); break; } for (auto it = v[y].begin(); it != v[y].end(); it++) if (*it == x) { v[y].erase(it); break; } } void addEdge(int x, int y) { v[x].push_back(y); v[y].push_back(x); } int main() { // freopen ("input", "r", stdin); // freopen ("output", "w", stdout); scanf("%d %d", &N, &M); while (M--) { int x, y; scanf("%d %d", &x, &y); addEdge(x, y); } for (int i = 1; i <= N; i++) if (v[i].size() & 1) { printf("No\n"); return 0; } dfs(1); bool ok = 0; if (ever6) ok = 1; else if (cnt2 >= 3) ok = 1; else if (cnt2 == 2) { int A = -1, B = -1; for (int i = 1; i <= N; i++) if (v[i].size() > 2) { if (A == -1) A = i; else B = i; } vector<int> curr = v[A]; for (int i = 0; i < 4; i++) for (int j = i + 1; j < 4; j++) { delEdge(A, curr[i]), delEdge(A, curr[j]); memset(ap, 0, sizeof(ap)); dfs(A); if (ap[B] == 0) { ok = 1; i = j = 4; break; } addEdge(A, curr[i]), addEdge(A, curr[j]); } } if (ok) printf("Yes\n"); else printf("No\n"); return 0; }
[ "literal.number.change", "assignment.value.change", "expression.operation.binary.change", "call.function.change", "control_flow.branch.if.condition.change" ]
905,023
905,022
u098930106
cpp
p03091
#include <bits/stdc++.h> using namespace std; #define inf 2000000000 // 1e17 // 0-indexed template <class T> struct Dinic { struct edge { int to; T cap; int rev; }; vector<vector<edge>> lst; vector<int> completed; vector<int> dist; Dinic(int n = 1) { // if 1-indexed //++n; lst.resize(n); completed.resize(n); dist.resize(n); } bool add(int start, int goal, T capacity) { lst[start].push_back((edge){goal, capacity, (int)lst[goal].size()}); lst[goal].push_back((edge){start, 0, (int)lst[start].size() - 1}); return 1; } // dist = time from start to now number void distbfs(int start) { fill(dist.begin(), dist.end(), -1); queue<int> bfsqu; dist[start] = 0; bfsqu.push(start); while (bfsqu.size() > 0) { int now = bfsqu.front(); bfsqu.pop(); for (int i = 0; i < lst[now].size(); ++i) { edge *nowe = &lst[now][i]; if (nowe->cap > 0 && dist[nowe->to] < 0) { dist[nowe->to] = dist[now] + 1; bfsqu.push(nowe->to); } } } } T pathdfs(int now, int goal, T nf) { if (now == goal) return nf; for (int &i = completed[now]; i < lst[now].size(); ++i) { edge *e = &lst[now][i]; if (e->cap > 0 && dist[now] < dist[e->to]) { T ans = pathdfs(e->to, goal, min(nf, e->cap)); if (ans > 0) { e->cap -= ans; lst[e->to][e->rev].cap += ans; return ans; } } } return 0; } T solve(int start, int goal) { T ans = 0, nf = 0; while (1) { // bfs distbfs(start); // cannnot go to goal from start if (dist[goal] < 0) return ans; // reset fill(completed.begin(), completed.end(), 0); while ((nf = pathdfs(start, goal, inf)) > 0) ans += nf; } return -1; } }; int n, m; Dinic<int> din; vector<int> lst; bool solve(); int main() { cin >> n >> m; din = Dinic<int>(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; --a, --b; din.add(a, b, 1); din.add(b, a, 1); } if (solve()) cout << "Yes" << endl; else cout << "No" << endl; return 0; } bool solve() { bool ch = 0; for (int i = 0; i < n; ++i) { if ((din.lst[i].size() / 2) % 2 == 0) return 0; if (din.lst[i].size() / 2 >= 6) ch = 1; else if (din.lst[i].size() / 2 >= 4) lst.push_back(i); } if (ch) return 1; return lst.size() >= 3 || (lst.size() == 2 && din.solve(lst[0], lst[1]) == 2); }
#include <bits/stdc++.h> using namespace std; #define inf 2000000000 // 1e17 // 0-indexed template <class T> struct Dinic { struct edge { int to; T cap; int rev; }; vector<vector<edge>> lst; vector<int> completed; vector<int> dist; Dinic(int n = 1) { // if 1-indexed //++n; lst.resize(n); completed.resize(n); dist.resize(n); } bool add(int start, int goal, T capacity) { lst[start].push_back((edge){goal, capacity, (int)lst[goal].size()}); lst[goal].push_back((edge){start, 0, (int)lst[start].size() - 1}); return 1; } // dist = time from start to now number void distbfs(int start) { fill(dist.begin(), dist.end(), -1); queue<int> bfsqu; dist[start] = 0; bfsqu.push(start); while (bfsqu.size() > 0) { int now = bfsqu.front(); bfsqu.pop(); for (int i = 0; i < lst[now].size(); ++i) { edge *nowe = &lst[now][i]; if (nowe->cap > 0 && dist[nowe->to] < 0) { dist[nowe->to] = dist[now] + 1; bfsqu.push(nowe->to); } } } } T pathdfs(int now, int goal, T nf) { if (now == goal) return nf; for (int &i = completed[now]; i < lst[now].size(); ++i) { edge *e = &lst[now][i]; if (e->cap > 0 && dist[now] < dist[e->to]) { T ans = pathdfs(e->to, goal, min(nf, e->cap)); if (ans > 0) { e->cap -= ans; lst[e->to][e->rev].cap += ans; return ans; } } } return 0; } T solve(int start, int goal) { T ans = 0, nf = 0; while (1) { // bfs distbfs(start); // cannnot go to goal from start if (dist[goal] < 0) return ans; // reset fill(completed.begin(), completed.end(), 0); while ((nf = pathdfs(start, goal, inf)) > 0) ans += nf; } return -1; } }; int n, m; Dinic<int> din; vector<int> lst; bool solve(); int main() { cin >> n >> m; din = Dinic<int>(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; --a, --b; din.add(a, b, 1); din.add(b, a, 1); } if (solve()) cout << "Yes" << endl; else cout << "No" << endl; return 0; } bool solve() { bool ch = 0; for (int i = 0; i < n; ++i) { if ((din.lst[i].size() / 2) % 2 == 1) return 0; if (din.lst[i].size() / 2 >= 6) ch = 1; else if (din.lst[i].size() / 2 >= 4) lst.push_back(i); } if (ch) return 1; return lst.size() >= 3 || (lst.size() == 2 && din.solve(lst[0], lst[1]) == 2); }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
905,027
905,028
u269963329
cpp
p03091
#include <bits/stdc++.h> using namespace std; #define inf 2000000000 // 1e17 // 0-indexed template <class T> struct Dinic { struct edge { int to; T cap; int rev; }; vector<vector<edge>> lst; vector<int> completed; vector<int> dist; Dinic(int n = 1) { // if 1-indexed //++n; lst.resize(n); completed.resize(n); dist.resize(n); } bool add(int start, int goal, T capacity) { lst[start].push_back((edge){goal, capacity, (int)lst[goal].size()}); lst[goal].push_back((edge){start, 0, (int)lst[start].size() - 1}); return 1; } // dist = time from start to now number void distbfs(int start) { fill(dist.begin(), dist.end(), -1); queue<int> bfsqu; dist[start] = 0; bfsqu.push(start); while (bfsqu.size() > 0) { int now = bfsqu.front(); bfsqu.pop(); for (int i = 0; i < lst[now].size(); ++i) { edge *nowe = &lst[now][i]; if (nowe->cap > 0 && dist[nowe->to] < 0) { dist[nowe->to] = dist[now] + 1; bfsqu.push(nowe->to); } } } } T pathdfs(int now, int goal, T nf) { if (now == goal) return nf; for (int &i = completed[now]; i < lst[now].size(); ++i) { edge *e = &lst[now][i]; if (e->cap > 0 && dist[now] < dist[e->to]) { T ans = pathdfs(e->to, goal, min(nf, e->cap)); if (ans > 0) { e->cap -= ans; lst[e->to][e->rev].cap += ans; return ans; } } } return 0; } T solve(int start, int goal) { T ans = 0, nf = 0; while (1) { // bfs distbfs(start); // cannnot go to goal from start if (dist[goal] < 0) return ans; // reset fill(completed.begin(), completed.end(), 0); while ((nf = pathdfs(start, goal, inf)) > 0) ans += nf; } return -1; } }; int n, m; Dinic<int> din; vector<int> lst; bool solve(); int main() { cin >> n >> m; din = Dinic<int>(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; --a, --b; din.add(a, b, 1); din.add(b, a, 1); } if (solve()) cout << "Yes" << endl; else cout << "No" << endl; return 0; } bool solve() { bool ch = 0; for (int i = 0; i < n; ++i) { if (din.lst[i].size() % 2 == 1) return 0; if (din.lst[i].size() / 2 >= 6) ch = 1; else if (din.lst[i].size() / 2 >= 4) lst.push_back(i); } if (ch) return 1; return lst.size() >= 3 || (lst.size() == 2 && din.solve(lst[0], lst[1]) == 2); }
#include <bits/stdc++.h> using namespace std; #define inf 2000000000 // 1e17 // 0-indexed template <class T> struct Dinic { struct edge { int to; T cap; int rev; }; vector<vector<edge>> lst; vector<int> completed; vector<int> dist; Dinic(int n = 1) { // if 1-indexed //++n; lst.resize(n); completed.resize(n); dist.resize(n); } bool add(int start, int goal, T capacity) { lst[start].push_back((edge){goal, capacity, (int)lst[goal].size()}); lst[goal].push_back((edge){start, 0, (int)lst[start].size() - 1}); return 1; } // dist = time from start to now number void distbfs(int start) { fill(dist.begin(), dist.end(), -1); queue<int> bfsqu; dist[start] = 0; bfsqu.push(start); while (bfsqu.size() > 0) { int now = bfsqu.front(); bfsqu.pop(); for (int i = 0; i < lst[now].size(); ++i) { edge *nowe = &lst[now][i]; if (nowe->cap > 0 && dist[nowe->to] < 0) { dist[nowe->to] = dist[now] + 1; bfsqu.push(nowe->to); } } } } T pathdfs(int now, int goal, T nf) { if (now == goal) return nf; for (int &i = completed[now]; i < lst[now].size(); ++i) { edge *e = &lst[now][i]; if (e->cap > 0 && dist[now] < dist[e->to]) { T ans = pathdfs(e->to, goal, min(nf, e->cap)); if (ans > 0) { e->cap -= ans; lst[e->to][e->rev].cap += ans; return ans; } } } return 0; } T solve(int start, int goal) { T ans = 0, nf = 0; while (1) { // bfs distbfs(start); // cannnot go to goal from start if (dist[goal] < 0) return ans; // reset fill(completed.begin(), completed.end(), 0); while ((nf = pathdfs(start, goal, inf)) > 0) ans += nf; } return -1; } }; int n, m; Dinic<int> din; vector<int> lst; bool solve(); int main() { cin >> n >> m; din = Dinic<int>(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; --a, --b; din.add(a, b, 1); din.add(b, a, 1); } if (solve()) cout << "Yes" << endl; else cout << "No" << endl; return 0; } bool solve() { bool ch = 0; for (int i = 0; i < n; ++i) { if ((din.lst[i].size() / 2) % 2 == 1) return 0; if (din.lst[i].size() / 2 >= 6) ch = 1; else if (din.lst[i].size() / 2 >= 4) lst.push_back(i); } if (ch) return 1; return lst.size() >= 3 || (lst.size() == 2 && din.solve(lst[0], lst[1]) == 2); }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
905,029
905,028
u269963329
cpp
p03091
#include <bits/stdc++.h> #include <type_traits> using namespace std; using ll = int64_t; #define int ll #define FOR(i, a, b) for (int i = int(a); i < int(b); i++) #define REP(i, b) FOR(i, 0, b) #define MP make_pair #define PB push_back #define EB emplace_back #define ALL(x) x.begin(), x.end() auto &errStream = cerr; #ifdef LOCAL #define cerr (cerr << "-- line " << __LINE__ << " -- ") #else class CerrDummy { } cerrDummy; template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) { return cd; } using charTDummy = char; using traitsDummy = char_traits<charTDummy>; CerrDummy &operator<<(CerrDummy &cd, basic_ostream<charTDummy, traitsDummy> &( basic_ostream<charTDummy, traitsDummy> &)) { return cd; } #define cerr cerrDummy #endif #define REACH cerr << "reached" << endl #define DMP(x) cerr << #x << ":" << x << endl #define ZERO(x) memset(x, 0, sizeof(x)) #define ONE(x) memset(x, -1, sizeof(x)) using pi = pair<int, int>; using vi = vector<int>; using ld = long double; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; REP(i, (int)v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } template <int i, class T> void print_tuple(ostream &, const T &) {} template <int i, class T, class H, class... Args> void print_tuple(ostream &os, const T &t) { if (i) os << ","; os << get<i>(t); print_tuple<i + 1, T, Args...>(os, t); } template <class... Args> ostream &operator<<(ostream &os, const tuple<Args...> &t) { os << "("; print_tuple<0, tuple<Args...>, Args...>(os, t); return os << ")"; } ll read() { ll i; scanf("%" SCNd64, &i); return i; } void printSpace() { printf(" "); } void printEoln() { printf("\n"); } void print(ll x, int suc = 1) { printf("%" PRId64, x); if (suc == 1) printEoln(); if (suc == 2) printSpace(); } template <class T> void print(const vector<T> &v) { REP(i, v.size()) print(v[i], i == int(v.size()) - 1 ? 1 : 2); } string readString() { static char buf[3341000]; scanf("%s", buf); return string(buf); } char *readCharArray() { static char buf[3341000]; static int bufUsed = 0; char *ret = buf + bufUsed; scanf("%s", ret); bufUsed += strlen(ret) + 1; return ret; } template <class T, class U> void chmax(T &a, U b) { if (a < b) a = b; } template <class T, class U> void chmin(T &a, U b) { if (b < a) a = b; } template <class T> T Sq(const T &t) { return t * t; } //#define CAPITAL void Yes(bool ex = true) { #ifdef CAPITAL cout << "YES" << endl; #else cout << "Yes" << endl; #endif if (ex) exit(0); } void No(bool ex = true) { #ifdef CAPITAL cout << "NO" << endl; #else cout << "No" << endl; #endif if (ex) exit(0); } const ll infLL = LLONG_MAX / 3; #ifdef int const int inf = infLL; #else const int inf = INT_MAX / 2 - 100; #endif constexpr ll TEN(int n) { return n == 0 ? 1 : TEN(n - 1) * 10; } template <class T> vector<T> Uniqued(const vector<T> &vv) { auto v(vv); sort(ALL(v)); v.erase(unique(ALL(v)), v.end()); return v; } template <class T> void MakeUniqued(vector<T> &v) { sort(ALL(v)); v.erase(unique(ALL(v)), v.end()); } const int Nmax = 100010; vi g[Nmax]; bool vis[Nmax]; void dfs(int v) { if (vis[v]) return; vis[v] = true; for (auto to : g[v]) dfs(to); } signed main() { int n = read(), m = read(); REP(i, m) { int a = read() - 1, b = read() - 1; g[a].PB(b); g[b].PB(a); } { bool ok = true; int mx = 0; REP(i, n) { int d = g[i].size(); if (d % 2) ok = false; chmax(mx, d); } if (!ok) No(); if (mx >= 6) Yes(); } int cnt = 0; REP(i, n) if (g[i].size() == 4) cnt++; if (cnt >= 3) Yes(); if (cnt == 1) No(); int a = -1, b = -1; REP(i, n) if (g[i].size() == 4) { if (a == -1) a = i; else b = i; } vis[a] = true; dfs(b); REP(i, n) if (!vis[i]) Yes(); No(); }
#include <bits/stdc++.h> #include <type_traits> using namespace std; using ll = int64_t; #define int ll #define FOR(i, a, b) for (int i = int(a); i < int(b); i++) #define REP(i, b) FOR(i, 0, b) #define MP make_pair #define PB push_back #define EB emplace_back #define ALL(x) x.begin(), x.end() auto &errStream = cerr; #ifdef LOCAL #define cerr (cerr << "-- line " << __LINE__ << " -- ") #else class CerrDummy { } cerrDummy; template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) { return cd; } using charTDummy = char; using traitsDummy = char_traits<charTDummy>; CerrDummy &operator<<(CerrDummy &cd, basic_ostream<charTDummy, traitsDummy> &( basic_ostream<charTDummy, traitsDummy> &)) { return cd; } #define cerr cerrDummy #endif #define REACH cerr << "reached" << endl #define DMP(x) cerr << #x << ":" << x << endl #define ZERO(x) memset(x, 0, sizeof(x)) #define ONE(x) memset(x, -1, sizeof(x)) using pi = pair<int, int>; using vi = vector<int>; using ld = long double; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; REP(i, (int)v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } template <int i, class T> void print_tuple(ostream &, const T &) {} template <int i, class T, class H, class... Args> void print_tuple(ostream &os, const T &t) { if (i) os << ","; os << get<i>(t); print_tuple<i + 1, T, Args...>(os, t); } template <class... Args> ostream &operator<<(ostream &os, const tuple<Args...> &t) { os << "("; print_tuple<0, tuple<Args...>, Args...>(os, t); return os << ")"; } ll read() { ll i; scanf("%" SCNd64, &i); return i; } void printSpace() { printf(" "); } void printEoln() { printf("\n"); } void print(ll x, int suc = 1) { printf("%" PRId64, x); if (suc == 1) printEoln(); if (suc == 2) printSpace(); } template <class T> void print(const vector<T> &v) { REP(i, v.size()) print(v[i], i == int(v.size()) - 1 ? 1 : 2); } string readString() { static char buf[3341000]; scanf("%s", buf); return string(buf); } char *readCharArray() { static char buf[3341000]; static int bufUsed = 0; char *ret = buf + bufUsed; scanf("%s", ret); bufUsed += strlen(ret) + 1; return ret; } template <class T, class U> void chmax(T &a, U b) { if (a < b) a = b; } template <class T, class U> void chmin(T &a, U b) { if (b < a) a = b; } template <class T> T Sq(const T &t) { return t * t; } //#define CAPITAL void Yes(bool ex = true) { #ifdef CAPITAL cout << "YES" << endl; #else cout << "Yes" << endl; #endif if (ex) exit(0); } void No(bool ex = true) { #ifdef CAPITAL cout << "NO" << endl; #else cout << "No" << endl; #endif if (ex) exit(0); } const ll infLL = LLONG_MAX / 3; #ifdef int const int inf = infLL; #else const int inf = INT_MAX / 2 - 100; #endif constexpr ll TEN(int n) { return n == 0 ? 1 : TEN(n - 1) * 10; } template <class T> vector<T> Uniqued(const vector<T> &vv) { auto v(vv); sort(ALL(v)); v.erase(unique(ALL(v)), v.end()); return v; } template <class T> void MakeUniqued(vector<T> &v) { sort(ALL(v)); v.erase(unique(ALL(v)), v.end()); } const int Nmax = 100010; vi g[Nmax]; bool vis[Nmax]; void dfs(int v) { if (vis[v]) return; vis[v] = true; for (auto to : g[v]) dfs(to); } signed main() { int n = read(), m = read(); REP(i, m) { int a = read() - 1, b = read() - 1; g[a].PB(b); g[b].PB(a); } { bool ok = true; int mx = 0; REP(i, n) { int d = g[i].size(); if (d % 2) ok = false; chmax(mx, d); } if (!ok) No(); if (mx >= 6) Yes(); } int cnt = 0; REP(i, n) if (g[i].size() == 4) cnt++; if (cnt >= 3) Yes(); if (cnt <= 1) No(); int a = -1, b = -1; REP(i, n) if (g[i].size() == 4) { if (a == -1) a = i; else b = i; } vis[a] = true; dfs(b); REP(i, n) if (!vis[i]) Yes(); No(); }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
905,037
905,038
u354336886
cpp
p03091
#include <bits/stdc++.h> #include <type_traits> using namespace std; using ll = int64_t; #define int ll #define FOR(i, a, b) for (int i = int(a); i < int(b); i++) #define REP(i, b) FOR(i, 0, b) #define MP make_pair #define PB push_back #define EB emplace_back #define ALL(x) x.begin(), x.end() auto &errStream = cerr; #ifdef LOCAL #define cerr (cerr << "-- line " << __LINE__ << " -- ") #else class CerrDummy { } cerrDummy; template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) { return cd; } using charTDummy = char; using traitsDummy = char_traits<charTDummy>; CerrDummy &operator<<(CerrDummy &cd, basic_ostream<charTDummy, traitsDummy> &( basic_ostream<charTDummy, traitsDummy> &)) { return cd; } #define cerr cerrDummy #endif #define REACH cerr << "reached" << endl #define DMP(x) cerr << #x << ":" << x << endl #define ZERO(x) memset(x, 0, sizeof(x)) #define ONE(x) memset(x, -1, sizeof(x)) using pi = pair<int, int>; using vi = vector<int>; using ld = long double; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; REP(i, (int)v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } template <int i, class T> void print_tuple(ostream &, const T &) {} template <int i, class T, class H, class... Args> void print_tuple(ostream &os, const T &t) { if (i) os << ","; os << get<i>(t); print_tuple<i + 1, T, Args...>(os, t); } template <class... Args> ostream &operator<<(ostream &os, const tuple<Args...> &t) { os << "("; print_tuple<0, tuple<Args...>, Args...>(os, t); return os << ")"; } ll read() { ll i; scanf("%" SCNd64, &i); return i; } void printSpace() { printf(" "); } void printEoln() { printf("\n"); } void print(ll x, int suc = 1) { printf("%" PRId64, x); if (suc == 1) printEoln(); if (suc == 2) printSpace(); } template <class T> void print(const vector<T> &v) { REP(i, v.size()) print(v[i], i == int(v.size()) - 1 ? 1 : 2); } string readString() { static char buf[3341000]; scanf("%s", buf); return string(buf); } char *readCharArray() { static char buf[3341000]; static int bufUsed = 0; char *ret = buf + bufUsed; scanf("%s", ret); bufUsed += strlen(ret) + 1; return ret; } template <class T, class U> void chmax(T &a, U b) { if (a < b) a = b; } template <class T, class U> void chmin(T &a, U b) { if (b < a) a = b; } template <class T> T Sq(const T &t) { return t * t; } //#define CAPITAL void Yes(bool ex = true) { #ifdef CAPITAL cout << "YES" << endl; #else cout << "Yes" << endl; #endif if (ex) exit(0); } void No(bool ex = true) { #ifdef CAPITAL cout << "NO" << endl; #else cout << "No" << endl; #endif if (ex) exit(0); } const ll infLL = LLONG_MAX / 3; #ifdef int const int inf = infLL; #else const int inf = INT_MAX / 2 - 100; #endif constexpr ll TEN(int n) { return n == 0 ? 1 : TEN(n - 1) * 10; } template <class T> vector<T> Uniqued(const vector<T> &vv) { auto v(vv); sort(ALL(v)); v.erase(unique(ALL(v)), v.end()); return v; } template <class T> void MakeUniqued(vector<T> &v) { sort(ALL(v)); v.erase(unique(ALL(v)), v.end()); } const int Nmax = 100010; vi g[Nmax]; bool vis[Nmax]; void dfs(int v) { if (vis[v]) return; vis[v] = true; for (auto to : g[v]) dfs(to); } signed main() { int n = read(), m = read(); REP(i, m) { int a = read() - 1, b = read() - 1; g[a].PB(b); g[b].PB(a); } { bool ok = true; int mx = 0; REP(i, n) { int d = g[i].size(); if (d % 2) ok = false; chmax(mx, d); } if (!ok) No(); if (mx >= 6) Yes(); } int cnt = 0; REP(i, n) if (g[i].size() == 4) cnt++; if (cnt >= 3) Yes(); if (cnt == 1) No(); int a = -1, b = -1; REP(i, n) if (g[i].size() == 2) { if (a == -1) a = i; else b = i; } vis[a] = true; dfs(b); REP(i, n) if (!vis[i]) Yes(); No(); }
#include <bits/stdc++.h> #include <type_traits> using namespace std; using ll = int64_t; #define int ll #define FOR(i, a, b) for (int i = int(a); i < int(b); i++) #define REP(i, b) FOR(i, 0, b) #define MP make_pair #define PB push_back #define EB emplace_back #define ALL(x) x.begin(), x.end() auto &errStream = cerr; #ifdef LOCAL #define cerr (cerr << "-- line " << __LINE__ << " -- ") #else class CerrDummy { } cerrDummy; template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) { return cd; } using charTDummy = char; using traitsDummy = char_traits<charTDummy>; CerrDummy &operator<<(CerrDummy &cd, basic_ostream<charTDummy, traitsDummy> &( basic_ostream<charTDummy, traitsDummy> &)) { return cd; } #define cerr cerrDummy #endif #define REACH cerr << "reached" << endl #define DMP(x) cerr << #x << ":" << x << endl #define ZERO(x) memset(x, 0, sizeof(x)) #define ONE(x) memset(x, -1, sizeof(x)) using pi = pair<int, int>; using vi = vector<int>; using ld = long double; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; REP(i, (int)v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } template <int i, class T> void print_tuple(ostream &, const T &) {} template <int i, class T, class H, class... Args> void print_tuple(ostream &os, const T &t) { if (i) os << ","; os << get<i>(t); print_tuple<i + 1, T, Args...>(os, t); } template <class... Args> ostream &operator<<(ostream &os, const tuple<Args...> &t) { os << "("; print_tuple<0, tuple<Args...>, Args...>(os, t); return os << ")"; } ll read() { ll i; scanf("%" SCNd64, &i); return i; } void printSpace() { printf(" "); } void printEoln() { printf("\n"); } void print(ll x, int suc = 1) { printf("%" PRId64, x); if (suc == 1) printEoln(); if (suc == 2) printSpace(); } template <class T> void print(const vector<T> &v) { REP(i, v.size()) print(v[i], i == int(v.size()) - 1 ? 1 : 2); } string readString() { static char buf[3341000]; scanf("%s", buf); return string(buf); } char *readCharArray() { static char buf[3341000]; static int bufUsed = 0; char *ret = buf + bufUsed; scanf("%s", ret); bufUsed += strlen(ret) + 1; return ret; } template <class T, class U> void chmax(T &a, U b) { if (a < b) a = b; } template <class T, class U> void chmin(T &a, U b) { if (b < a) a = b; } template <class T> T Sq(const T &t) { return t * t; } //#define CAPITAL void Yes(bool ex = true) { #ifdef CAPITAL cout << "YES" << endl; #else cout << "Yes" << endl; #endif if (ex) exit(0); } void No(bool ex = true) { #ifdef CAPITAL cout << "NO" << endl; #else cout << "No" << endl; #endif if (ex) exit(0); } const ll infLL = LLONG_MAX / 3; #ifdef int const int inf = infLL; #else const int inf = INT_MAX / 2 - 100; #endif constexpr ll TEN(int n) { return n == 0 ? 1 : TEN(n - 1) * 10; } template <class T> vector<T> Uniqued(const vector<T> &vv) { auto v(vv); sort(ALL(v)); v.erase(unique(ALL(v)), v.end()); return v; } template <class T> void MakeUniqued(vector<T> &v) { sort(ALL(v)); v.erase(unique(ALL(v)), v.end()); } const int Nmax = 100010; vi g[Nmax]; bool vis[Nmax]; void dfs(int v) { if (vis[v]) return; vis[v] = true; for (auto to : g[v]) dfs(to); } signed main() { int n = read(), m = read(); REP(i, m) { int a = read() - 1, b = read() - 1; g[a].PB(b); g[b].PB(a); } { bool ok = true; int mx = 0; REP(i, n) { int d = g[i].size(); if (d % 2) ok = false; chmax(mx, d); } if (!ok) No(); if (mx >= 6) Yes(); } int cnt = 0; REP(i, n) if (g[i].size() == 4) cnt++; if (cnt >= 3) Yes(); if (cnt <= 1) No(); int a = -1, b = -1; REP(i, n) if (g[i].size() == 4) { if (a == -1) a = i; else b = i; } vis[a] = true; dfs(b); REP(i, n) if (!vis[i]) Yes(); No(); }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "literal.number.change" ]
905,039
905,038
u354336886
cpp
p03091
#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; } vector<ll> G[101010]; void answer(bool flag) { cout << (flag ? "Yes" : "No") << endl; exit(0); } vector<bool> visited(101010, false); bool dfs(ll now, ll par, ll x, ll y) { if (now == y) return false; if (now == x && visited[now]) return true; if (visited[now]) return false; visited[now] = true; bool res = false; REP(i, G[now].size()) { ll next = G[now][i]; if (next == par) continue; res = (res || dfs(next, now, x, y)); } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N >> M; REP(i, M) { ll a, b; cin >> a >> b; a--, b--; G[a].push_back(b); G[b].push_back(a); } bool flag = true; REP(i, N) { if (G[i].size() % 2 != 0) flag = false; } if (!flag) { answer(false); } vector<ll> four; REP(i, N) { if (G[i].size() > 5) answer(true); if (G[i].size() == 4) four.push_back(i); } if (four.size() > 2) answer(true); if (four.size() == 1) answer(false); ll x = four[0]; ll y = four[1]; answer(dfs(x, -1, x, y)); 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; } vector<ll> G[101010]; void answer(bool flag) { cout << (flag ? "Yes" : "No") << endl; exit(0); } vector<bool> visited(101010, false); bool dfs(ll now, ll par, ll x, ll y) { if (now == y) return false; if (now == x && visited[now]) return true; if (visited[now]) return false; visited[now] = true; bool res = false; REP(i, G[now].size()) { ll next = G[now][i]; if (next == par) continue; res = (res || dfs(next, now, x, y)); } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N >> M; REP(i, M) { ll a, b; cin >> a >> b; a--, b--; G[a].push_back(b); G[b].push_back(a); } bool flag = true; REP(i, N) { if (G[i].size() % 2 != 0) flag = false; } if (!flag) { answer(false); } vector<ll> four; REP(i, N) { if (G[i].size() > 5) answer(true); if (G[i].size() == 4) four.push_back(i); } if (four.size() > 2) answer(true); if (four.size() < 2) answer(false); ll x = four[0]; ll y = four[1]; answer(dfs(x, -1, x, y)); return 0; }
[]
905,047
905,048
u895971408
cpp
p03091
#include <bits/stdc++.h> #define ll long long #define fornum(A, B, C) for (A = B; A < C; A++) #define mp make_pair #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ///////////////////////////////////////////////////// #define MOD (ll)(1e9 + 7) ll N, M; ll i, j, a; vector<ll> rv[101010]; vector<ll> r4; int main() { scanf("%lld%lld", &N, &M); fornum(i, 0, M) { ll a, b; scanf("%lld%lld", &a, &b); rv[a].push_back(b); rv[b].push_back(a); } a = 1; fornum(i, 0, N) { if (rv[i + 1].size() % 2) { a = 0; break; } if (rv[i + 1].size() == 4) { r4.push_back(i + 1); } if (rv[i + 1].size() >= 6) { a = 2; break; } } if (a == 2 || (a == 1 && r4.size() >= 3)) { printf("Yes"); } else if (a == 0 || r4.size() < 2) { printf("No"); } else if (r4.size() == 2) { ll a = r4[0]; ll b = r4[1]; fornum(i, 0, rv[a].size()) { ll ib = a; ll ii = rv[a][i]; while (ii != a && ii != b) { fornum(j, 0, 2) { if (rv[ii][j] != ib) break; } ib = ii; ii = rv[ii][j]; } if (ii == a) { printf("Yes"); return 0; } } printf("No"); } return 0; }
#include <bits/stdc++.h> #define ll long long #define fornum(A, B, C) for (A = B; A < C; A++) #define mp make_pair #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ///////////////////////////////////////////////////// #define MOD (ll)(1e9 + 7) ll N, M; ll i, j, a; vector<ll> rv[101010]; vector<ll> r4; int main() { scanf("%lld%lld", &N, &M); fornum(i, 0, M) { ll a, b; scanf("%lld%lld", &a, &b); rv[a].push_back(b); rv[b].push_back(a); } a = 1; fornum(i, 0, N) { if (rv[i + 1].size() % 2) { a = 0; break; } if (rv[i + 1].size() == 4) { r4.push_back(i + 1); } if (rv[i + 1].size() >= 6) { a = 2; } } if (a == 2 || (a == 1 && r4.size() >= 3)) { printf("Yes"); } else if (a == 0 || r4.size() < 2) { printf("No"); } else if (r4.size() == 2) { ll a = r4[0]; ll b = r4[1]; fornum(i, 0, rv[a].size()) { ll ib = a; ll ii = rv[a][i]; while (ii != a && ii != b) { fornum(j, 0, 2) { if (rv[ii][j] != ib) break; } ib = ii; ii = rv[ii][j]; } if (ii == a) { printf("Yes"); return 0; } } printf("No"); } return 0; }
[]
905,064
905,065
u259396003
cpp
p03091
#include <bits/stdc++.h> using namespace std; #define int long long int INF = 1e9 + 7; signed main() { int n, m, a, b; cin >> n >> m; vector<int> hen[n]; for (int i = 0; i < m; i++) { cin >> a >> b; hen[a - 1].push_back(b - 1); hen[b - 1].push_back(a - 1); } vector<int> hen4; int t = 0; int y = 0; for (int i = 0; i < n; i++) { if (hen[i].size() % 2 != 0) { y = -1; // cout<<"No "; break; } if (hen[i].size() >= 6) { t = 1; break; } if (hen[i].size() == 4) { hen4.push_back(i); } } if ((hen4.size() > 2 || t == 1) && y != -1) cout << "Yes"; else { if (y == -1 || hen4.size() < 2) cout << "No"; else { for (int i = 0; i < 4; i++) { int k0 = hen4[0]; int k = hen[hen4[0]][i]; while (k != hen4[0] && k != hen4[1]) { if (k0 == hen[k][0]) { k0 = k; k = hen[k][1]; } else { k0 = k; k = hen[k][0]; } } if (k == hen4[0]) t = 1; } if (t == 1) cout << "Yes"; else cout << "No"; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long int INF = 1e9 + 7; signed main() { int n, m, a, b; cin >> n >> m; vector<int> hen[n]; for (int i = 0; i < m; i++) { cin >> a >> b; hen[a - 1].push_back(b - 1); hen[b - 1].push_back(a - 1); } vector<int> hen4; int t = 0; int y = 0; for (int i = 0; i < n; i++) { if (hen[i].size() % 2 != 0) { y = -1; // cout<<"No "; break; } if (hen[i].size() >= 6) { t = 1; } if (hen[i].size() == 4) { hen4.push_back(i); } } if ((hen4.size() > 2 || t == 1) && y != -1) cout << "Yes"; else { if (y == -1 || hen4.size() < 2) cout << "No"; else { for (int i = 0; i < 4; i++) { int k0 = hen4[0]; int k = hen[hen4[0]][i]; while (k != hen4[0] && k != hen4[1]) { if (k0 == hen[k][0]) { k0 = k; k = hen[k][1]; } else { k0 = k; k = hen[k][0]; } } if (k == hen4[0]) t = 1; } if (t == 1) cout << "Yes"; else cout << "No"; } } return 0; }
[]
905,075
905,076
u651317892
cpp
p03091
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<ll> vl; typedef vector<pair<ll, ll>> vp; #define rep(i, n) for (ll i = 0; i < ll(n); i++) const ll INF = 99999999999999999; ll a, b, c, d, e, f, ans = 0, xx, yy; vl s; vl g[200000]; void dfs(int x, int y) { if (x == yy) { s.push_back(-1); return; } if (x == xx && y > -1) { s.push_back(1); return; } if (x == xx) { dfs(g[x][0], x); dfs(g[x][1], x); dfs(g[x][2], x); dfs(g[x][3], x); } else { dfs(g[x][0] + g[x][1] - y, x); } return; } int main() { ll n, m; c = 0; d = 0; e = 0; cin >> n >> m; vl x(n + 1, 0); vl k; for (int i = 0; i < m; i++) { cin >> a >> b; x[a]++; x[b]++; g[a].push_back(b); g[b].push_back(a); } for (int i = 1; i < n + 1; i++) { if (x[i] % 2 != 0) c = -1; else { if (x[i] == 4) { d++; k.push_back(i); } if (x[i] == 6) e++; } } if (c == 0 && d == 2 && e == 0) { xx = k[0]; yy = k[1]; dfs(xx, -1); if (s[0] + s[1] + s[2] + s[3] == 0) cout << "Yes" << endl; else cout << "No" << endl; } else { if (c == 0 && (d > 2 || e > 1)) cout << "Yes" << endl; else cout << "No" << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<ll> vl; typedef vector<pair<ll, ll>> vp; #define rep(i, n) for (ll i = 0; i < ll(n); i++) const ll INF = 99999999999999999; ll a, b, c, d, e, f, ans = 0, xx, yy; vl s; vl g[200000]; void dfs(int x, int y) { if (x == yy) { s.push_back(-1); return; } if (x == xx && y > -1) { s.push_back(1); return; } if (x == xx) { dfs(g[x][0], x); dfs(g[x][1], x); dfs(g[x][2], x); dfs(g[x][3], x); } else { dfs(g[x][0] + g[x][1] - y, x); } return; } int main() { ll n, m; c = 0; d = 0; e = 0; cin >> n >> m; vl x(n + 1, 0); vl k; for (int i = 0; i < m; i++) { cin >> a >> b; x[a]++; x[b]++; g[a].push_back(b); g[b].push_back(a); } for (int i = 1; i < n + 1; i++) { if (x[i] % 2 != 0) c = -1; else { if (x[i] == 4) { d++; k.push_back(i); } if (x[i] == 6) e++; } } if (c == 0 && d == 2 && e == 0) { xx = k[0]; yy = k[1]; dfs(xx, -1); if (s[0] + s[1] + s[2] + s[3] == 0) cout << "Yes" << endl; else cout << "No" << endl; } else { if (c == 0 && (d > 2 || e > 0)) cout << "Yes" << endl; else cout << "No" << endl; } }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
905,079
905,080
u268571052
cpp
p03091
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <vector> #define rep(i, s, n) for (int i = (s); (n) > i; i++) #define REP(i, n) rep(i, 0, n) #define RANGE(x, a, b) ((a) <= (x) && (x) < (b)) #define DUPLE(a, b, c, d) \ (RANGE(a, c, d) || RANGE(b, c, d) || RANGE(c, a, b) || RANGE(d, a, b)) #define INCLU(a, b, c, d) (RANGE(a, c, d) && (b, c, d)) #define PW(x) ((x) * (x)) #define ALL(x) (x).begin(), (x).end() #define RALL(x) (x).rbegin(), (x).rend() #define MODU 1000000007LL #define bitcheck(a, b) ((a >> b) & 1) #define bitset(a, b) (a |= (1 << b)) #define bitunset(a, b) (a &= ~(1 << b)) #define MP(a, b) make_pair((a), (b)) #define Manh(a, b) (abs((a).first-(b).first) + abs((a).second - ((b).second)) #define pritnf printf #define scnaf scanf #define itn int #define PI 3.141592653589 #define izryt bool using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } pll Dir[8] = { //移動 {0, 1}, {-1, 0}, {1, 0}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; //[a, b) #define Getsum(ar, a, b) (ar[b] - ar[a]) #define INF 10000000000000000LL #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) struct Edge { int from, to; ll w; bool operator<(const Edge &rhs) const { return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to)); } }; typedef vector<set<Edge>> Graph; void connect(Graph &g, int f, int t, ll w = 1) { g[f].insert({f, t, w}); g[t].insert({t, f, w}); } void erase(Graph &g, int f, int t) { g[f].erase({f, t, 1LL}); g[t].erase({t, f, 1LL}); } signed main(void) { int n, m; cin >> n >> m; vector<int> cou(n); Graph g(n); REP(i, m) { int a, b; cin >> a >> b; a--, b--; cou[a]++; cou[b]++; connect(g, a, b); } int fc = 0, sc = 0; REP(i, n) { if (cou[i] >= 4) fc++; if (cou[i] >= 6) sc++; if (cou[i] % 2) { cout << "No" << endl; return 0; } } if (fc >= 2 || sc >= 1) { if (fc > 2 || sc >= 1) cout << "Yes" << endl; if (fc == 2) { while (1) { int st = -1, c; REP(i, n) { if (cou[i] == 4 && g[i].size() > 0) { c = i, st = i; break; } } if (st == -1) return 0; do { int nx; if (g[c].begin()->to != c) nx = g[c].begin()->to; else nx = g[c].rbegin()->to; erase(g, c, nx); c = nx; } while (cou[c] != 4); if (st == c) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } } else { cout << "No" << endl; } return 0; }
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <vector> #define rep(i, s, n) for (int i = (s); (n) > i; i++) #define REP(i, n) rep(i, 0, n) #define RANGE(x, a, b) ((a) <= (x) && (x) < (b)) #define DUPLE(a, b, c, d) \ (RANGE(a, c, d) || RANGE(b, c, d) || RANGE(c, a, b) || RANGE(d, a, b)) #define INCLU(a, b, c, d) (RANGE(a, c, d) && (b, c, d)) #define PW(x) ((x) * (x)) #define ALL(x) (x).begin(), (x).end() #define RALL(x) (x).rbegin(), (x).rend() #define MODU 1000000007LL #define bitcheck(a, b) ((a >> b) & 1) #define bitset(a, b) (a |= (1 << b)) #define bitunset(a, b) (a &= ~(1 << b)) #define MP(a, b) make_pair((a), (b)) #define Manh(a, b) (abs((a).first-(b).first) + abs((a).second - ((b).second)) #define pritnf printf #define scnaf scanf #define itn int #define PI 3.141592653589 #define izryt bool using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } pll Dir[8] = { //移動 {0, 1}, {-1, 0}, {1, 0}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; //[a, b) #define Getsum(ar, a, b) (ar[b] - ar[a]) #define INF 10000000000000000LL #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) struct Edge { int from, to; ll w; bool operator<(const Edge &rhs) const { return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to)); } }; typedef vector<set<Edge>> Graph; void connect(Graph &g, int f, int t, ll w = 1) { g[f].insert({f, t, w}); g[t].insert({t, f, w}); } void erase(Graph &g, int f, int t) { g[f].erase({f, t, 1LL}); g[t].erase({t, f, 1LL}); } signed main(void) { int n, m; cin >> n >> m; vector<int> cou(n); Graph g(n); REP(i, m) { int a, b; cin >> a >> b; a--, b--; cou[a]++; cou[b]++; connect(g, a, b); } int fc = 0, sc = 0; REP(i, n) { if (cou[i] >= 4) fc++; if (cou[i] >= 6) sc++; if (cou[i] % 2) { cout << "No" << endl; return 0; } } if (fc >= 2 || sc >= 1) { if (fc > 2 || sc >= 1) cout << "Yes" << endl; else if (fc == 2) { while (1) { int st = -1, c; REP(i, n) { if (cou[i] == 4 && g[i].size() > 0) { c = i, st = i; break; } } if (st == -1) break; do { int nx; if (g[c].begin()->to != c) nx = g[c].begin()->to; else nx = g[c].rbegin()->to; erase(g, c, nx); c = nx; } while (cou[c] != 4); if (st == c) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } } else { cout << "No" << endl; } return 0; }
[ "control_flow.branch.else_if.replace.add", "control_flow.branch.if.replace.remove", "control_flow.return.remove", "control_flow.break.add" ]
905,083
905,082
u152129372
cpp
p03093
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, mod, a[N]; int calcmin(int l, int r) { int Min = mod << 1; for (int _l = l, _r = r; _l <= _r; _l++, _r--) { // printf("__ %d %d %d [%d\n",_l,_r,a[_l]+a[_r],Min); Min = min(Min, a[_l] + a[_r]); } return Min; } int main() { scanf("%d%d", &n, &mod); n <<= 1; for (int i = 1; i <= n; i++) { scanf("%d", a + i); } sort(a + 1, a + 1 + n); int l = 0, r = (n >> 1) - 1, pos = n << 1 | 1; // pos - n while (l <= r) { int mid = l + r >> 1; // printf("[] %d %d\n",mid<<1|1,calcmin(mid<<1|1,n)); if (calcmin(mid << 1 | 1, n) >= mod) { pos = mid << 1 | 1; r = mid - 1; } else { l = mid + 1; } } // printf("__ %d\n",pos); int res = 0; for (int i = 1; i <= pos - 1; i++) { res = max(res, a[i] + a[pos - i]); } for (int i = pos; i <= n; i++) { // printf("%d %d %d\n",n+pos,i,n+pos-i); res = max(res, (a[i] + a[n + pos - i]) % mod); } cout << res; return 0; } /* 3 10 0 2 3 4 5 9 */
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, mod, a[N]; int calcmin(int l, int r) { int Min = mod << 1; for (int _l = l, _r = r; _l <= _r; _l++, _r--) { // printf("__ %d %d %d [%d\n",_l,_r,a[_l]+a[_r],Min); Min = min(Min, a[_l] + a[_r]); } return Min; } int main() { scanf("%d%d", &n, &mod); n <<= 1; for (int i = 1; i <= n; i++) { scanf("%d", a + i); } sort(a + 1, a + 1 + n); int l = 0, r = (n >> 1) - 1, pos = n | 1; // pos - n while (l <= r) { int mid = l + r >> 1; // printf("[] %d %d\n",mid<<1|1,calcmin(mid<<1|1,n)); if (calcmin(mid << 1 | 1, n) >= mod) { pos = mid << 1 | 1; r = mid - 1; } else { l = mid + 1; } } // printf("__ %d\n",pos); int res = 0; for (int i = 1; i <= pos - 1; i++) { res = max(res, a[i] + a[pos - i]); } for (int i = pos; i <= n; i++) { // printf("%d %d %d\n",n+pos,i,n+pos-i); res = max(res, (a[i] + a[n + pos - i]) % mod); } cout << res; return 0; } /* 3 10 0 2 3 4 5 9 */
[ "expression.operation.binary.remove" ]
905,107
905,108
u076784075
cpp
p03093
#include <bits/stdc++.h> #define ll long long #define uint unsigned #define ull unsigned ll #define db double #define pii pair<int, int> #define pll pair<ll, ll> #define pli pair<ll, int> #define vi vector<int> #define vpi vector<pii> #define IT iterator #define PB push_back #define MK make_pair #define LB lower_bound #define UB upper_bound #define y1 wzpakking #define fi first #define se second #define BG begin #define ED end #define For(i, j, k) for (int i = (int)(j); i <= (int)(k); i++) #define Rep(i, j, k) for (int i = (int)(j); i >= (int)(k); i--) #define CLR(a, v) memset(a, v, sizeof(a)) #define CPY(a, b) memcpy(a, b, sizeof(a)) #define sqr(x) (1ll * x * x) #define LS3 k * 2, l, mid #define RS3 k * 2 + 1, mid + 1, r #define LS5 k * 2, l, mid, x, y #define RS5 k * 2 + 1, mid + 1, r, x, y #define GET \ pushdown(k); \ int mid = (l + r) / 2 #define inf (1 << 30) using namespace std; const int N = 200005; int n, mo, res, a[N]; bool check(int d) { for (int l = 2 * n - d + 1, r = 2 * n; l <= r; l++, r--) if (a[l] + a[r] < mo) return 0; return 1; } int main() { scanf("%d%d", &n, &mo); For(i, 1, 2 * n) scanf("%d", &a[i]); sort(a + 1, a + n + 1); int l = 1, r = n, ans = 0; while (l <= r) { int mid = (l + r) / 2; if (check(mid * 2)) ans = mid, l = mid + 1; else r = mid - 1; } ans *= 2; for (int l = 1, r = 2 * n - ans; l <= r; ++l, --r) res = max(res, a[l] + a[r]); for (int l = 2 * n - ans + 1, r = 2 * n; l <= r; ++l, --r) res = max(res, a[l] + a[r] - mo); printf("%d\n", res); }
#include <bits/stdc++.h> #define ll long long #define uint unsigned #define ull unsigned ll #define db double #define pii pair<int, int> #define pll pair<ll, ll> #define pli pair<ll, int> #define vi vector<int> #define vpi vector<pii> #define IT iterator #define PB push_back #define MK make_pair #define LB lower_bound #define UB upper_bound #define y1 wzpakking #define fi first #define se second #define BG begin #define ED end #define For(i, j, k) for (int i = (int)(j); i <= (int)(k); i++) #define Rep(i, j, k) for (int i = (int)(j); i >= (int)(k); i--) #define CLR(a, v) memset(a, v, sizeof(a)) #define CPY(a, b) memcpy(a, b, sizeof(a)) #define sqr(x) (1ll * x * x) #define LS3 k * 2, l, mid #define RS3 k * 2 + 1, mid + 1, r #define LS5 k * 2, l, mid, x, y #define RS5 k * 2 + 1, mid + 1, r, x, y #define GET \ pushdown(k); \ int mid = (l + r) / 2 #define inf (1 << 30) using namespace std; const int N = 200005; int n, mo, res, a[N]; bool check(int d) { for (int l = 2 * n - d + 1, r = 2 * n; l <= r; l++, r--) if (a[l] + a[r] < mo) return 0; return 1; } int main() { scanf("%d%d", &n, &mo); For(i, 1, 2 * n) scanf("%d", &a[i]); sort(a + 1, a + 2 * n + 1); int l = 1, r = n, ans = 0; while (l <= r) { int mid = (l + r) / 2; if (check(mid * 2)) ans = mid, l = mid + 1; else r = mid - 1; } ans *= 2; for (int l = 1, r = 2 * n - ans; l <= r; ++l, --r) res = max(res, a[l] + a[r]); for (int l = 2 * n - ans + 1, r = 2 * n; l <= r; ++l, --r) res = max(res, a[l] + a[r] - mo); printf("%d\n", res); }
[ "expression.operation.binary.add" ]
905,109
905,110
u579191570
cpp
p03093
#include <bits/stdc++.h> using namespace std; int N, M; int a[500005]; bool check1(int Now) { int L = 1, R = Now; while (a[L] + a[R] < M && L < R) L++, R--; if (a[L] + a[R] >= M) return false; return true; } bool check2(int Now) { int L = Now + 1, R = N; while (a[L] + a[R] >= M && L < R) L++, R--; if (a[L] + a[R] < M) return false; return true; } int main() { scanf("%d%d", &N, &M); N *= 2; for (int i = 1; i <= N; i++) scanf("%d", &a[i]); sort(a + 1, a + N + 1); int l = 0, r = N, ans; while (l <= r) { int mid = (l + r) >> 1; if (check2(mid) && check1(mid)) r = mid - 1, ans = mid; else if (!check1(mid)) r = mid - 1; else l = mid + 1; } if (ans % 2) ans++; int L = ans + 1, R = N, anss = 0; while (L <= R) anss = max((a[L] + a[R]) % M, anss), L++, R--; L = 1, R = anss; while (L <= R) anss = max((a[L] + a[R]) % M, anss), L++, R--; printf("%d", anss); return 0; }
#include <bits/stdc++.h> using namespace std; int N, M; int a[500005]; bool check1(int Now) { int L = 1, R = Now; while (a[L] + a[R] < M && L < R) L++, R--; if (a[L] + a[R] >= M) return false; return true; } bool check2(int Now) { int L = Now + 1, R = N; while (a[L] + a[R] >= M && L < R) L++, R--; if (a[L] + a[R] < M) return false; return true; } int main() { scanf("%d%d", &N, &M); N *= 2; for (int i = 1; i <= N; i++) scanf("%d", &a[i]); sort(a + 1, a + N + 1); int l = 0, r = N, ans; while (l <= r) { int mid = (l + r) >> 1; if (check2(mid) && check1(mid)) r = mid - 1, ans = mid; else if (!check1(mid)) r = mid - 1; else l = mid + 1; } if (ans % 2) ans++; int L = ans + 1, R = N, anss = 0; while (L <= R) anss = max((a[L] + a[R]) % M, anss), L++, R--; L = 1, R = ans; while (L <= R) anss = max((a[L] + a[R]) % M, anss), L++, R--; printf("%d", anss); return 0; }
[ "assignment.value.change", "identifier.change" ]
905,111
905,112
u490732536
cpp
p03093
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vector<long long>> vvll; typedef vector<pair<int, int>> vpii; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; #define INF 1000000000 #define MOD 1000000007 #define EPSILON 0.00001 #define f first #define s second #define pb push_back #define mp make_pair #define p_q priority_queue #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define RFOR(i, a, b) for (int i = (a); i >= b; i--) #define MN 200005 int n, m; int a[MN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; F0R(i, n) { cin >> a[i]; } sort(a, a + n); int l = -1, r = n; while (l + 1 < r) { int mid = (l + r) / 2; bool ok = true; FOR(i, mid, n - 1) { if (a[i] + a[n - 1 + mid - i] < m) { ok = false; break; } } if (ok) { r = mid; } else { l = mid; } } if (r % 2 == 1) r++; int ans = 0; F0R(i, r - 1) { ans = max(ans, a[i] + a[r - 1 - i]); } FOR(i, r, n - 1) { ans = max(ans, a[i] + a[n - 1 + r - i] - m); } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vector<long long>> vvll; typedef vector<pair<int, int>> vpii; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; #define INF 1000000000 #define MOD 1000000007 #define EPSILON 0.00001 #define f first #define s second #define pb push_back #define mp make_pair #define p_q priority_queue #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define RFOR(i, a, b) for (int i = (a); i >= b; i--) #define MN 200005 int n, m; int a[MN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; n *= 2; F0R(i, n) { cin >> a[i]; } sort(a, a + n); int l = -1, r = n; while (l + 1 < r) { int mid = (l + r) / 2; bool ok = true; FOR(i, mid, n - 1) { if (a[i] + a[n - 1 + mid - i] < m) { ok = false; break; } } if (ok) { r = mid; } else { l = mid; } } if (r % 2 == 1) r++; int ans = 0; F0R(i, r - 1) { ans = max(ans, a[i] + a[r - 1 - i]); } FOR(i, r, n - 1) { ans = max(ans, a[i] + a[n - 1 + r - i] - m); } cout << ans << "\n"; return 0; }
[ "assignment.add" ]
905,115
905,116
u396284099
cpp
p03093
#include <bits/stdc++.h> using namespace std; int num[200005]; bool check(int n, int m, int s) { int r = 0, d1 = 2 * n; for (int i = 2 * n; i > 0; i--) { while (r < 2 * n && num[r + 1] + num[i] <= s) r++; if (!r) d1 = min(d1, i - 1); else d1 = min(d1, r + i - 1); } r = 0; int d2 = 2 * n; for (int i = 2 * n; i > 0; i--) { while (r < 2 * n && num[r + 1] + num[i] <= s + m) r++; if (!r) d2 = min(d2, i - 1); else if (r < 2 * n) d2 = min(d2, r + i - 2 * n); } int l = 2 * n + 1, d3 = 1; for (int i = 1; i <= 2 * n; i++) { while (l > 1 && num[l - 1] + num[i] >= m) l--; if (l > 2 * n) d3 = max(d3, i + 1); else d3 = max(d3, l + i - 2 * n); } for (int i = 0; i <= 2 * n; i += 2) if (i <= d1 && i + 1 <= d2 && i + 1 >= d3) return 1; return 0; } int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= 2 * n; i++) scanf("%d", &num[i]); sort(num + 1, num + 2 * n + 1); int l = 0, r = 0; for (int i = 1; i <= n; i++) r = max(r, (num[i] + num[2 * n - i]) % m); while (l < r) { int mid = ((l + r) >> 1); if (check(n, m, mid)) r = mid; else l = mid + 1; } printf("%d\n", l); return 0; }
#include <bits/stdc++.h> using namespace std; int num[200005]; bool check(int n, int m, int s) { int r = 0, d1 = 2 * n; for (int i = 2 * n; i > 0; i--) { while (r < 2 * n && num[r + 1] + num[i] <= s) r++; if (!r) d1 = min(d1, i - 1); else d1 = min(d1, r + i - 1); } r = 0; int d2 = 2 * n; for (int i = 2 * n; i > 0; i--) { while (r < 2 * n && num[r + 1] + num[i] <= s + m) r++; if (!r) d2 = min(d2, i - 1); else if (r < 2 * n) d2 = min(d2, r + i - 2 * n); } int l = 2 * n + 1, d3 = 1; for (int i = 1; i <= 2 * n; i++) { while (l > 1 && num[l - 1] + num[i] >= m) l--; if (l > 2 * n) d3 = max(d3, i + 1); else d3 = max(d3, l + i - 2 * n); } for (int i = 0; i <= 2 * n; i += 2) if (i <= d1 && i + 1 <= d2 && i + 1 >= d3) return 1; return 0; } int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= 2 * n; i++) scanf("%d", &num[i]); sort(num + 1, num + 2 * n + 1); int l = 0, r = 0; for (int i = 1; i <= n; i++) r = max(r, (num[i] + num[2 * n - i + 1]) % m); while (l < r) { int mid = ((l + r) >> 1); if (check(n, m, mid)) r = mid; else l = mid + 1; } printf("%d\n", l); return 0; }
[ "assignment.change" ]
905,117
905,118
u966630585
cpp
p03093
#include <bits/stdc++.h> using namespace std; const int N = 200050; int a[N]; int main() { int n, m, i; scanf("%i %i", &n, &m); for (i = 1; i <= 2 * n; i++) scanf("%i", &a[i]); sort(a + 1, a + 1 + n); int top = n, bot = 0, mid, ans; while (top >= bot) { mid = top + bot >> 1; bool ok = 1; for (int i = 1; i <= n - mid; i++) { int x = a[2 * n - i + 1], y = a[mid * 2 + i]; if (x + y < m) ok = 0; } if (ok) top = mid - 1, ans = mid; else bot = mid + 1; } int sol = 0; for (int i = 1; i <= ans; i++) { int x = a[i], y = a[2 * ans - i + 1]; sol = max(sol, x + y); } for (int i = 1; i <= n - ans; i++) { int x = a[2 * n - i + 1], y = a[ans * 2 + i]; sol = max(sol, x + y - m); } printf("%i\n", sol); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 200050; int a[N]; int main() { int n, m, i; scanf("%i %i", &n, &m); for (i = 1; i <= 2 * n; i++) scanf("%i", &a[i]); sort(a + 1, a + 1 + 2 * n); int top = n, bot = 0, mid, ans; while (top >= bot) { mid = top + bot >> 1; bool ok = 1; for (int i = 1; i <= n - mid; i++) { int x = a[2 * n - i + 1], y = a[mid * 2 + i]; if (x + y < m) ok = 0; } if (ok) top = mid - 1, ans = mid; else bot = mid + 1; } int sol = 0; for (int i = 1; i <= ans; i++) { int x = a[i], y = a[2 * ans - i + 1]; sol = max(sol, x + y); } for (int i = 1; i <= n - ans; i++) { int x = a[2 * n - i + 1], y = a[ans * 2 + i]; sol = max(sol, x + y - m); } printf("%i\n", sol); return 0; }
[ "expression.operation.binary.add" ]
905,125
905,126
u939096624
cpp
p03094
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; inline int add(int a, int b) { a += b; return a >= MOD ? a - MOD : a; } inline int mul(int a, int b) { return 1LL * a * b % MOD; } int inv[1 << 20]; int main() { int n, als = 0; scanf("%d", &n); inv[1] = 1; for (int i = 2; i <= n; i++) inv[i] = mul(MOD - MOD / i, inv[MOD % i]); for (int i = 1, pi = 1; i <= n; i++) pi = mul(pi, inv[3]), als = add(als, mul(pi, inv[n - i + 1])); printf("%d\n", mul(als, inv[n])); return 0; }
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; inline int add(int a, int b) { a += b; return a >= MOD ? a - MOD : a; } inline int mul(int a, int b) { return 1LL * a * b % MOD; } int inv[1 << 20]; int main() { int n, als = 0; scanf("%d", &n); inv[1] = 1; for (int i = 2; i <= max(n, 3); i++) inv[i] = mul(MOD - MOD / i, inv[MOD % i]); for (int i = 1, pi = 1; i <= n; i++) pi = mul(pi, inv[3]), als = add(als, mul(pi, inv[n - i + 1])); printf("%d\n", mul(als, inv[n])); return 0; }
[ "control_flow.loop.for.condition.change", "call.add", "call.arguments.add" ]
905,136
905,137
u140310696
cpp
p03094
#include <bits/stdc++.h> typedef long long int int64; static const int64 mod = 1000000007LL; int64 dp[1000003][3]; int64 fac[1000003], inv[1000003], invfac[1000003]; int n; int64 choice(int a, int b) { return fac[a] * invfac[b] % mod * invfac[a - b] % mod; } int main() { scanf("%d", &n); fac[0] = fac[1] = invfac[0] = invfac[1] = inv[1] = 1; for (int i = 2; i <= 1000000; ++i) { fac[i] = (fac[i - 1] * i) % mod; inv[i] = (mod - mod / i) * inv[mod % i] % mod; invfac[i] = (invfac[i - 1] * inv[i]) % mod; } dp[0][0] = 1; for (int i = 0; i < n; ++i) { for (int k = 0; k < 3; ++k) for (int l = 0; l < 3; ++l) if (k != l) { dp[i + 1][l] = (dp[i + 1][l] + dp[i][k]) % mod; } } int64 ans = 0; for (int i = 1; i <= n; ++i) { ans += choice(n, i) * dp[i][1] % mod * inv[i] % mod; } for (int i = 0; i < n; ++i) { ans = ans * inv[3] % mod; } ans = ans * inv[n] % mod; printf("%lld\n", ans); }
#include <bits/stdc++.h> typedef long long int int64; static const int64 mod = 1000000007LL; int64 dp[1000003][3]; int64 fac[1000003], inv[1000003], invfac[1000003]; int n; int64 choice(int a, int b) { return fac[a] * invfac[b] % mod * invfac[a - b] % mod; } int main() { scanf("%d", &n); fac[0] = fac[1] = invfac[0] = invfac[1] = inv[1] = 1; for (int i = 2; i <= 1000000; ++i) { fac[i] = (fac[i - 1] * i) % mod; inv[i] = (mod - mod / i) * inv[mod % i] % mod; invfac[i] = (invfac[i - 1] * inv[i]) % mod; } dp[0][0] = 1; for (int i = 0; i < n; ++i) { for (int k = 0; k < 3; ++k) for (int l = 0; l < 3; ++l) if (k != l) { dp[i + 1][l] = (dp[i + 1][l] + dp[i][k]) % mod; } } int64 ans = 0; for (int i = 1; i <= n; ++i) { ans += choice(n, i) * dp[i][1] % mod * inv[i] % mod; } ans %= mod; for (int i = 0; i < n; ++i) { ans = ans * inv[3] % mod; } ans = ans * inv[n] % mod; printf("%lld\n", ans); }
[ "assignment.add" ]
905,138
905,139
u339802099
cpp
p03094
#include <bits/stdc++.h> #define ll long long template <class T> inline void read(T &x) { x = 0; register char c = getchar(); register bool f = 0; while (!isdigit(c)) f ^= c == '-', c = getchar(); while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); if (f) x = -x; } const int N = 1e5 + 10, mod = 1e9 + 7; int n, ans, f[N], g[N][3], fc[N], fi[N], vi[N]; inline int inc(int a, int b) { return (a += b) >= mod ? a - mod : a; } inline int binom(int n, int m) { return (ll)fc[n] * fi[m] % mod * fi[n - m] % mod; } inline int fpow(int a, int b) { int s = 1; for (; b; b >>= 1, a = (ll)a * a % mod) if (b & 1) s = (ll)s * a % mod; return s; } int main() { std::cin >> n; g[1][0] = fi[0] = fi[1] = vi[0] = vi[1] = fc[0] = fc[1] = 1; for (int i = 2; i <= n; i++) fc[i] = (ll)fc[i - 1] * i % mod; for (int i = 2; i <= n; i++) vi[i] = (ll)(mod - mod / i) * vi[mod % i] % mod; for (int i = 2; i <= n; i++) fi[i] = (ll)fi[i - 1] * vi[i] % mod; for (int i = 2; i <= n + 1; i++) { g[i][0] = inc(g[i - 1][1], g[i - 1][2]); g[i][1] = inc(g[i - 1][0], g[i - 1][2]); g[i][2] = inc(g[i - 1][0], g[i - 1][1]); // printf("> %d %d %d\n",g[i][0],g[i][1],g[i][2]); } for (int i = 1; i <= n; i++) f[i] = (ll)g[i + 1][1] * binom(n, i) % mod; for (int i = 1; i <= n; i++) ans = (ans + (ll)f[i] * vi[i]) % mod; // for(int i=1;i<=n;i++)std::cout<<f[i]<<" \n"[i==n]; // std::cout<<ans<<std::endl; std::cout << (ll)ans * fpow((ll)n * fpow(3, n) % mod, mod - 2) % mod << std::endl; }
#include <bits/stdc++.h> #define ll long long template <class T> inline void read(T &x) { x = 0; register char c = getchar(); register bool f = 0; while (!isdigit(c)) f ^= c == '-', c = getchar(); while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); if (f) x = -x; } const int N = 1e6 + 10, mod = 1e9 + 7; int n, ans, f[N], g[N][3], fc[N], fi[N], vi[N]; inline int inc(int a, int b) { return (a += b) >= mod ? a - mod : a; } inline int binom(int n, int m) { return (ll)fc[n] * fi[m] % mod * fi[n - m] % mod; } inline int fpow(int a, int b) { int s = 1; for (; b; b >>= 1, a = (ll)a * a % mod) if (b & 1) s = (ll)s * a % mod; return s; } int main() { std::cin >> n; g[1][0] = fi[0] = fi[1] = vi[0] = vi[1] = fc[0] = fc[1] = 1; for (int i = 2; i <= n; i++) fc[i] = (ll)fc[i - 1] * i % mod; for (int i = 2; i <= n; i++) vi[i] = (ll)(mod - mod / i) * vi[mod % i] % mod; for (int i = 2; i <= n; i++) fi[i] = (ll)fi[i - 1] * vi[i] % mod; for (int i = 2; i <= n + 1; i++) { g[i][0] = inc(g[i - 1][1], g[i - 1][2]); g[i][1] = inc(g[i - 1][0], g[i - 1][2]); g[i][2] = inc(g[i - 1][0], g[i - 1][1]); // printf("> %d %d %d\n",g[i][0],g[i][1],g[i][2]); } for (int i = 1; i <= n; i++) f[i] = (ll)g[i + 1][1] * binom(n, i) % mod; for (int i = 1; i <= n; i++) ans = (ans + (ll)f[i] * vi[i]) % mod; // for(int i=1;i<=n;i++)std::cout<<f[i]<<" \n"[i==n]; // std::cout<<ans<<std::endl; std::cout << (ll)ans * fpow((ll)n * fpow(3, n) % mod, mod - 2) % mod << std::endl; }
[ "literal.number.change", "expression.operation.binary.change" ]
905,140
905,141
u806711698
cpp
p03094
#include "bits/stdc++.h" using namespace std; #define MOD 100000007 #define MAX 1000002 int n; long long int k[MAX]; long long int ppow(long long int i, long long int j) { long long int res = 1; while (j) { if (j & 1LL) { res *= i; if (res >= MOD) res %= MOD; } i *= i; i %= MOD; j >>= 1LL; } return res; } long long int rv[MAX]; long long int C(int a, int b) { long long int w = k[a]; long long int d = rv[b] * rv[a - b]; d %= MOD; w *= d; w %= MOD; return w; } long long int p[MAX]; long long int dp[MAX][3]; int main() { cin >> n; dp[0][0] = 1; for (int i = 0; i + 1 < MAX; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { if (j != k) { dp[i + 1][k] += dp[i][j]; dp[i + 1][k] %= MOD; } } } } k[0] = 1; for (int i = 1; i < MAX; i++) { k[i] = k[i - 1] * i; k[i] %= MOD; } rv[0] = 1; for (int i = 1; i < MAX; i++) { rv[i] = ppow(k[i], MOD - 2); } long long int ALL = 1; for (int i = 1; i < n; i++) { ALL *= 3LL; ALL %= MOD; } ALL = ppow(ALL, MOD - 2); p[0] = 1; for (int i = 1; i < MAX; i++) { p[i] = p[i - 1]; p[i] *= 2LL; p[i] %= MOD; } long long int WW = 0; for (int i = 1; i <= n; i++) { long long int way = C(n, i); way *= ALL; way %= MOD; way *= dp[i][1]; way %= MOD; long long int E = ppow(3, MOD - 2); // E *= i; // E %= MOD; E *= ppow(n, MOD - 2); E %= MOD; // E *= ppow(i, MOD - 2); // E %= MOD; E *= ppow(i, MOD - 2); E %= MOD; way *= E; way %= MOD; WW += way; WW %= MOD; } printf("%lld\n", WW); return 0; }
#include "bits/stdc++.h" using namespace std; #define MOD 1000000007 #define MAX 1000002 int n; long long int k[MAX]; long long int ppow(long long int i, long long int j) { long long int res = 1; while (j) { if (j & 1LL) { res *= i; if (res >= MOD) res %= MOD; } i *= i; i %= MOD; j >>= 1LL; } return res; } long long int rv[MAX]; long long int C(int a, int b) { long long int w = k[a]; long long int d = rv[b] * rv[a - b]; d %= MOD; w *= d; w %= MOD; return w; } long long int p[MAX]; long long int dp[MAX][3]; int main() { cin >> n; dp[0][0] = 1; for (int i = 0; i + 1 < MAX; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { if (j != k) { dp[i + 1][k] += dp[i][j]; dp[i + 1][k] %= MOD; } } } } k[0] = 1; for (int i = 1; i < MAX; i++) { k[i] = k[i - 1] * i; k[i] %= MOD; } rv[0] = 1; for (int i = 1; i < MAX; i++) { rv[i] = ppow(k[i], MOD - 2); } long long int ALL = 1; for (int i = 1; i < n; i++) { ALL *= 3LL; ALL %= MOD; } ALL = ppow(ALL, MOD - 2); p[0] = 1; for (int i = 1; i < MAX; i++) { p[i] = p[i - 1]; p[i] *= 2LL; p[i] %= MOD; } long long int WW = 0; for (int i = 1; i <= n; i++) { long long int way = C(n, i); way *= ALL; way %= MOD; way *= dp[i][1]; way %= MOD; long long int E = ppow(3, MOD - 2); // E *= i; // E %= MOD; E *= ppow(n, MOD - 2); E %= MOD; // E *= ppow(i, MOD - 2); // E %= MOD; E *= ppow(i, MOD - 2); E %= MOD; way *= E; way %= MOD; WW += way; WW %= MOD; } printf("%lld\n", WW); return 0; }
[ "preprocessor.define.value.change", "literal.integer.change" ]
905,144
905,145
u466917094
cpp
p03094
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; const int P = 1e9 + 7; const int inv3 = (P + 1) / 3; typedef long long ll; typedef long double ld; typedef unsigned long long ull; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; x *= f; } template <typename T> void write(T x) { if (x < 0) x = -x, putchar('-'); if (x > 9) write(x / 10); putchar(x % 10 + '0'); } template <typename T> void writeln(T x) { write(x); puts(""); } int inv[MAXN]; int main() { int ans = 0, n; read(n), inv[1] = 1; for (int i = 2; i <= n; i++) inv[i] = (P - 1ll * (P / i) * inv[P % i]) % P; for (int i = 1, mul = inv3; i <= n; i++, mul = 1ll * mul * inv3 % P) ans = (ans + 1ll * inv[n] * inv[n - i + 1] % P * mul % P) % P; writeln(ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; const int P = 1e9 + 7; const int inv3 = (P + 1) / 3; typedef long long ll; typedef long double ld; typedef unsigned long long ull; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; x *= f; } template <typename T> void write(T x) { if (x < 0) x = -x, putchar('-'); if (x > 9) write(x / 10); putchar(x % 10 + '0'); } template <typename T> void writeln(T x) { write(x); puts(""); } int inv[MAXN]; int main() { int ans = 0, n; read(n), inv[1] = 1; for (int i = 2; i <= n; i++) inv[i] = (P - 1ll * (P / i) * inv[P % i] % P) % P; for (int i = 1, mul = inv3; i <= n; i++, mul = 1ll * mul * inv3 % P) ans = (ans + 1ll * inv[n] * inv[n - i + 1] % P * mul) % P; writeln(ans); return 0; }
[ "assignment.change", "expression.operation.binary.remove" ]
905,147
905,148
u744755176
cpp
p03094
#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; ll mo = 1000000007; ll modpow(ll a, ll n = mo - 2) { ll r = 1; a %= mo; while (n) r = r * ((n % 2) ? a : 1) % mo, a = a * a % mo, n >>= 1; return r; } ll comb(ll N_, ll C_) { const int NUM_ = 400001; static ll fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1]; if (fact[0] == 0) { inv[1] = fact[0] = factr[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo; for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i % mo, factr[i] = factr[i - 1] * inv[i] % mo; } if (C_ < 0 || C_ > N_) return 0; return factr[C_] * fact[N_] % mo * factr[N_ - C_] % mo; } ll pat[101010][3]; ll F[101010], G[101010]; void solve() { int i, j, k, l, r, x, y; string s; cin >> N; pat[0][0] = 1; FOR(i, N) { pat[i + 1][0] = (pat[i][1] + pat[i][2]) % mo; pat[i + 1][1] = (pat[i][0] + pat[i][2]) % mo; pat[i + 1][2] = (pat[i][0] + pat[i][1]) % mo; } ll p3 = modpow(modpow(3, N - 1)); ll ret = 0; for (i = 1; i <= N; i++) { F[i] = (pat[i - 1][0] + pat[i - 1][2]) * comb(N, i) % mo * p3 % mo; G[i] = modpow(3LL * N * i % mo); ret += F[i] * G[i] % mo; } cout << ret % mo << 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; ll mo = 1000000007; ll modpow(ll a, ll n = mo - 2) { ll r = 1; a %= mo; while (n) r = r * ((n % 2) ? a : 1) % mo, a = a * a % mo, n >>= 1; return r; } ll comb(ll N_, ll C_) { const int NUM_ = 1400001; static ll fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1]; if (fact[0] == 0) { inv[1] = fact[0] = factr[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo; for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i % mo, factr[i] = factr[i - 1] * inv[i] % mo; } if (C_ < 0 || C_ > N_) return 0; return factr[C_] * fact[N_] % mo * factr[N_ - C_] % mo; } ll pat[1010100][3]; ll F[1010100], G[1010100]; void solve() { int i, j, k, l, r, x, y; string s; cin >> N; pat[0][0] = 1; FOR(i, N) { pat[i + 1][0] = (pat[i][1] + pat[i][2]) % mo; pat[i + 1][1] = (pat[i][0] + pat[i][2]) % mo; pat[i + 1][2] = (pat[i][0] + pat[i][1]) % mo; } ll p3 = modpow(modpow(3, N - 1)); ll ret = 0; for (i = 1; i <= N; i++) { F[i] = (pat[i - 1][0] + pat[i - 1][2]) * comb(N, i) % mo * p3 % mo; G[i] = modpow(3LL * N * i % mo); ret += F[i] * G[i] % mo; } cout << ret % mo << 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; }
[ "literal.number.change", "variable_declaration.value.change", "variable_declaration.array_dimensions.change" ]
905,149
905,150
u452725238
cpp
p03095
#include <bits/stdc++.h> #define D 1000000007 using namespace std; using ll = long long; int main() { int n; cin >> n; string s; cin >> s; ll ans = 1; ll alpha[26]; for (int i = 0; i < n; i++) { alpha[s[i] - 'a']++; alpha[s[i] - 'a'] %= D; } for (int i = 0; i < 26; i++) { ans *= (alpha[i] + 1); ans %= D; } ans = ans - 1; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define D 1000000007 using namespace std; using ll = long long; int main() { int n; cin >> n; string s; cin >> s; ll ans = 1; ll alpha[26] = {0}; for (int i = 0; i < n; i++) { alpha[s[i] - 'a']++; alpha[s[i] - 'a'] %= D; } for (int i = 0; i < 26; i++) { ans *= (alpha[i] + 1); ans %= D; } ans = ans - 1; cout << ans << endl; return 0; }
[ "variable_declaration.value.change" ]
905,157
905,158
u277318398
cpp
p03095
#include <bits/stdc++.h> //{ START using namespace std; #define int int64_t #define rep(i, a, n) for (int i = (a); i < (n); ++i) #define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i) #define arep(i, x) for (auto &&i : (x)) #define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i) #define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i) //降順はgreater<T>() #define all(x) (x).begin(), (x).end() #define rv(s) reverse((s).begin(), (s).end()) // gcd lcmはそのままok #define gcd(a, b) __gcd(a, b) #define bits(n) (1LL << (n)) #define pcnt(x) __builtin_popcountll(x) //配列内等要素削除 #define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end()) #define Fixed(n) fixed << setprecision(n) //総和 #define sowa(n) (((n) * ((n) + 1)) / 2) #define updiv(a, b) ((a + b - 1) / b) #define cauto const auto & using P = pair<int, int>; using Graph = vector<vector<P>>; template <class T> //昇順 using min_heap = priority_queue<T, vector<T>, greater<T>>; template <class T> //降順 using max_heap = priority_queue<T>; template <class A, class B> using umap = unordered_map<A, B>; template <class A> using uset = unordered_set<A>; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { //多次元初期化 std::fill((T *)array, (T *)(array + N), val); } template <class A, class B> bool chmax(A &a, const B &b) { //最大値更新 返り値はbool if (a < b) { a = b; return 1; } return 0; } template <class A, class B> bool chmin(A &a, const B &b) { //最小値更新 返り値はbool if (b < a) { a = b; return 1; } return 0; } int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1}; constexpr int INF = 0x3f3f3f3f; constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int mod1 = 1e9 + 7; constexpr int mod2 = 998244353; //} END signed main(void) { cin.tie(nullptr); ios_base::sync_with_stdio(false); int n; cin >> n; vector<int> x(27, 0); string s; cin >> s; int ans = 1; rep(i, 0, n) x[s[i] - 'a']++; rep(i, 0, n) { if (x[i] != 0) { ans *= (x[i] + 1); ans %= mod1; } } cout << ans - 1 << '\n'; return 0; }
#include <bits/stdc++.h> //{ START using namespace std; #define int int64_t #define rep(i, a, n) for (int i = (a); i < (n); ++i) #define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i) #define arep(i, x) for (auto &&i : (x)) #define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i) #define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i) //降順はgreater<T>() #define all(x) (x).begin(), (x).end() #define rv(s) reverse((s).begin(), (s).end()) // gcd lcmはそのままok #define gcd(a, b) __gcd(a, b) #define bits(n) (1LL << (n)) #define pcnt(x) __builtin_popcountll(x) //配列内等要素削除 #define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end()) #define Fixed(n) fixed << setprecision(n) //総和 #define sowa(n) (((n) * ((n) + 1)) / 2) #define updiv(a, b) ((a + b - 1) / b) #define cauto const auto & using P = pair<int, int>; using Graph = vector<vector<P>>; template <class T> //昇順 using min_heap = priority_queue<T, vector<T>, greater<T>>; template <class T> //降順 using max_heap = priority_queue<T>; template <class A, class B> using umap = unordered_map<A, B>; template <class A> using uset = unordered_set<A>; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { //多次元初期化 std::fill((T *)array, (T *)(array + N), val); } template <class A, class B> bool chmax(A &a, const B &b) { //最大値更新 返り値はbool if (a < b) { a = b; return 1; } return 0; } template <class A, class B> bool chmin(A &a, const B &b) { //最小値更新 返り値はbool if (b < a) { a = b; return 1; } return 0; } int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1}; constexpr int INF = 0x3f3f3f3f; constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int mod1 = 1e9 + 7; constexpr int mod2 = 998244353; //} END signed main(void) { cin.tie(nullptr); ios_base::sync_with_stdio(false); int n; cin >> n; vector<int> x(27, 0); string s; cin >> s; int ans = 1; rep(i, 0, n) x[s[i] - 'a']++; rep(i, 0, 26) { if (x[i] != 0) { ans *= (x[i] + 1); ans %= mod1; } } cout << ans - 1 << '\n'; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change" ]
905,164
905,165
u600244905
cpp
p03095
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define irep(i, n) for (int i = (n); i >= 0; i++) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1 << 30; const int MOD = 129 + 7; int main() { string s; int n; cin >> n >> s; map<char, int> d; rep(i, n) { d[s[i]]++; } ll ans = 1; rep(i, 26) { char c = 'a' + i; if (d[c] == 0) continue; ans *= (d[c] + 1); ans %= MOD; } ans--; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define irep(i, n) for (int i = (n); i >= 0; i++) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1 << 30; const int MOD = 1e9 + 7; int main() { string s; int n; cin >> n >> s; map<char, int> d; rep(i, n) { d[s[i]]++; } ll ans = 1; rep(i, 26) { char c = 'a' + i; if (d[c] == 0) continue; ans *= (d[c] + 1); ans %= MOD; } ans--; cout << ans << endl; return 0; }
[ "literal.number.change", "expression.operation.binary.change" ]
905,192
905,193
u309168663
cpp
p03095
#include <iostream> #include <string> #include <vector> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<ll> vec(26, 0); for (int i = 0; i < n; ++i) { char c; cin >> c; ++vec[c - 'a']; } ll ans = 1; for (int i = 0; i < n; ++i) ans = (ans * (vec[i] + 1)) % 1000000007; cout << ans - 1 << endl; }
#include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<ll> vec(26, 0); for (int i = 0; i < n; ++i) { char c; cin >> c; ++vec[c - 'a']; } ll ans = 1; for (int i = 0; i < 26; ++i) ans = (ans * (vec[i] + 1)) % 1000000007; cout << ans - 1 << endl; }
[ "identifier.replace.remove", "literal.replace.add", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
905,194
905,195
u549438788
cpp
p03095
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ #include <bits/stdc++.h> //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") // here!!! // define int long long !!!!! #define int long long // define int long long !!!!! #define mod (int)((1e9) + 7) // constexpr int mod = 998244353ll; typedef long long ll; #ifdef int #define inf (int)(3e18) #else #define inf (int)(5e8) #endif #define intt long long #define itn long long #define P pair<long long, long long> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define rev_rep(i, n) for (int i = n - 1; i >= 0; i--) #define REV_REP(i, n) for (int i = n; i >= 1; i--) #define ALL(v) v.begin(), v.end() #define smallpriority_queue(x) priority_queue<x, vector<x>, greater<x>> using namespace std; // Library //モッドパウ inline int modpow(int x, int y, int m = mod) { int res = 1; while (y) { if (y & 1) { res *= x; res %= m; } x = x * x % m; y /= 2; } return res; } int mypow(int x, int y) { int res = 1; while (y) { if (y % 2) { res *= x; } x = x * x; y /= 2; } return res; } // is the number (x) a prime number? bool prime(int x) { if (!x || x == 1) { return false; } for (int i = 2; i * i <= x; i++) { if (!(x % i)) { return false; } } return true; } // saidai-kouyakusuu inline int gcd(int x, int y) { if (!y) { return x; } return gcd(y, x % y); } // number of keta int keta(int x) { int ans = 0; while (x) { x /= 10; ans++; } return ans; } // sum of keta int ketasum(int x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } inline int lcm(int x, int y) { int ans = x / gcd(x, y) * y; return ans; } int twobeki(int x) { int ans = 0; while (1) { if (!(x & 1)) { ans++; x >>= 1; } else { break; } } return ans; } template <class T, class U> inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; } template <class T, class U> inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; } void Yes() { cout << "Yes" << endl; } void No() { cout << "No" << endl; } void YES() { cout << "YES" << endl; } void NO() { cout << "NO" << endl; } #define fin(i) scanf("%lld", &i) #define fout(i) printf("%lld", i) #define fendl printf("\n") int kai(int x, int y) { int res = 1; for (int i = x - y + 1; i <= x; i++) { res *= i; res %= mod; } return res; } int comb(int x, int y) { if (y > x) return 0; // cout<<kai(x, y)<<' '<<modpow(kai(y, y), mod - 2)<<endl; return kai(x, y) * modpow(kai(y, y), mod - 2) % mod; } // Library-End #define vecin(v) \ for (int i = 0; i < v.size(); i++) \ scanf("%lld", &v[i]); #define vecout(v) \ { \ for (int i = 0; i < (int)v.size(); i++) \ printf("%lld ", v[i]); \ printf("\n"); \ } template <typename T> class kaageSegTree { protected: unsigned int n = 1, rank = 0; std::vector<T> node; T nodee; virtual T nodef(const T &, const T &) const = 0; public: kaageSegTree(unsigned int m, T init, T nodee) : nodee(nodee) { while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) node[i] = init; } kaageSegTree(const std::vector<T> &initvec, T nodee) : nodee(nodee) { unsigned int m = initvec.size(); while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) { if (i - n < m) node[i] = initvec[i - n]; } } virtual void update(int i, T x) { i += n; node[i] = x; while (i != 1) { i >>= 1; node[i] = nodef(node[2 * i], node[2 * i + 1]); } } virtual T query(int l, int r) { l += n; r += n; T ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } virtual T operator[](const int &x) { return node[n + x]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; class RSQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return lhs + rhs; } public: RSQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, 0) {} RSQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, 0) {} }; class RMiQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::min(lhs, rhs); } public: RMiQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, inf) {} RMiQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, inf) {} }; class RMaQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::max(lhs, rhs); } public: RMaQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, -inf) {} RMaQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, -inf) {} }; template <typename T, typename U> class IntervalSegTree : public kaageSegTree<T> { protected: using kaageSegTree<T>::n; using kaageSegTree<T>::rank; using kaageSegTree<T>::node; using kaageSegTree<T>::nodef; using kaageSegTree<T>::nodee; std::vector<U> lazy; std::vector<bool> lazyflag; std::vector<int> width; virtual void lazyf(U &, const U &) = 0; virtual void updf(T &, const U &, const unsigned int &) = 0; void eval(int k) { for (int i = rank; i > 0; i--) { int nk = k >> i; if (lazyflag[nk]) { updf(node[2 * nk], lazy[nk], width[2 * nk]); updf(node[2 * nk + 1], lazy[nk], width[2 * nk + 1]); if (lazyflag[2 * nk]) lazyf(lazy[2 * nk], lazy[nk]); else lazy[2 * nk] = lazy[nk]; if (lazyflag[2 * nk + 1]) lazyf(lazy[2 * nk + 1], lazy[nk]); else lazy[2 * nk + 1] = lazy[nk]; lazyflag[2 * nk] = lazyflag[2 * nk + 1] = true; lazyflag[nk] = false; } } } public: IntervalSegTree(unsigned int m, T init, T nodee) : kaageSegTree<T>(m, init, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } IntervalSegTree(T nodee, const std::vector<T> &initvec) : kaageSegTree<T>(initvec, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } void update(int i, U x) { i += n; eval(i); updf(node[i], x, width[i]); if (lazyflag[i]) lazyf(lazy[i], x); else { lazyflag[i] = true; lazy[i] = x; } while (i /= 2) node[i] = nodef(node[2 * i], node[2 * i + 1]); } void update(int l, int r, U x) { l += n; r += n; int nl = l, nr = r; while (!(nl & 1)) nl >>= 1; while (!(nr & 1)) nr >>= 1; nr--; eval(nl); eval(nr); while (l < r) { if (l & 1) { updf(node[l], x, width[l]); if (lazyflag[l]) lazyf(lazy[l], x); else { lazyflag[l] = true; lazy[l] = x; } l++; } if (r & 1) { r--; updf(node[r], x, width[r]); if (lazyflag[r]) lazyf(lazy[r], x); else { lazyflag[r] = true; lazy[r] = x; } } l >>= 1; r >>= 1; } while (nl >>= 1) node[nl] = nodef(node[2 * nl], node[2 * nl + 1]); while (nr >>= 1) node[nr] = nodef(node[2 * nr], node[2 * nr + 1]); } T query(int l, int r) { l += n; r += n; eval(l); eval(r - 1); int ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } T operator[](const int &x) { eval(n + x); return node[n + x]; } T queryForAll() { return node[1]; } }; class RAQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += width * b; } public: RAQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMaQ(unsigned int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = width * b; } public: RUQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMaQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; ////SegTree // template <class T> // class SegTree { // int n; // 葉の数 // vector<T> node; // データを格納するvector // T def; // 初期値かつ単位元 // function<T(T, T)> operation; // 区間クエリで使う処理 // function<T(T, T)> update; // 点更新で使う処理 // // // 区間[a,b)の総和。ノードk=[l,r)に着目している。 // T _query(int a, int b, int k, int l, int r) { // if (r <= a || b <= l) return def; // 交差しない // if (a <= l && r <= b) // return node[k]; // a,l,r,bの順で完全に含まれる // else { // T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 // T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 // return operation(c1, c2); // } // } // // public: // // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数, // // _update:更新関数 // SegTree(size_t _n, T _def, function<T(T, T)> _operation, // function<T(T, T)> _update) // : def(_def), operation(_operation), update(_update) { // n = 1; // while (n < _n) { // n *= 2; // } // node = vector<T>(2 * n , def); // } // // // 場所i(0-indexed)の値をxで更新 // void change(int i, T x) { // i += n - 1; // node[i] = update(node[i], x); // while (i > 0) { // i = (i - 1) / 2; // node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]); // } // } // // // [a, b)の区間クエリを実行 // T query(int a, int b) { // return _query(a, b, 0, 0, n); // } // // // 添字でアクセス // T operator[](int i) { // return node[i + n - 1]; // } //}; template <class T> class SegTree { int n; vector<T> node; T def; function<T(T, T)> operation; function<T(T, T)> update; public: SegTree(unsigned int _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } node = vector<T>(n * 2, def); } SegTree(vector<int> &initvec, function<T(T, T)> _operation, function<T(T, T)> _update) : operation(_operation), update(_update) { n = 1; while (n < initvec.size()) { n *= 2; } node = vector<T>(n * 2, def); for (int i = n; i < n + initvec.size(); i++) { node[i] = initvec[i - n]; } for (int i = n - 1; i >= 1; i--) { node[i] = operation(node[i * 2], node[i * 2 + 1]); } } void change(int i, T x) { i += n; node[i] = update(node[i], x); while (i >= 1) { i >>= 1; node[i] = operation(node[i * 2], node[i * 2 + 1]); } } T query(int l, int r) { l += n; r += n; T rx = def, lx = def; while (l < r) { if (l & 1) { lx = operation(lx, node[l]); l++; } if (r & 1) { r--; rx = operation(node[r], rx); } l >>= 1; r >>= 1; } return operation(lx, rx); } T operator[](const int &x) { return node[x - n]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; #define R_MIN ([](long long a, long long b) { return min(a, b); }) #define R_MAX ([](long long a, long long b) { return max(a, b); }) #define R_SUM ([](long long a, long long b) { return a + b; }) #define NORMAL_UPDATE ([](long long a, long long b) { return b; }) #define ADD_UPDATE ([](long long a, long long b) { return a + b; }) #define MINUS_UPDATE ([](long long a, long long b) { return a - b; } class Union_Find { vector<int> par; vector<int> rankmy; vector<int> ookisa; public: Union_Find(int size) { par = vector<int>(size); rankmy = vector<int>(size); ookisa = vector<int>(size); for (int i = 0; i < size; i++) { par[i] = i; ookisa[i] = 1; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } if (rankmy[x] < rankmy[y]) { par[x] = y; ookisa[y] += ookisa[x]; ookisa[x] = 0; } else { par[y] = x; ookisa[x] += ookisa[y]; ookisa[y] = 0; if (rankmy[x] == rankmy[y]) { rankmy[x]++; } } } int size(int i) { i = find(i); return ookisa[i]; } bool same(int x, int y) { return find(x) == find(y); } }; class BIT { vector<int> data; int size = 0; public: BIT(int _size) { data = vector<int>(_size + 1); size = _size; } void add(int i, int x) { while (i <= size) { data[i] += x; i += i & -i; } } int sum(int i) { assert(i <= size); int s = 0; while (i > 0) { s += data[i]; i -= i & -i; } return s; } int lower_bound(int x) { if (x <= 0) { return 0; } else { int i = 0; int r = 1; while (r < size) r = r << 1; for (int len = r; len > 0; len = len >> 1) { if (i + len < size && data[i + len] < x) { x -= data[i + len]; i += len; } } return i + 1; } } }; // Union-Find-End int perm[2000005]; void init_perm() { perm[0] = 1; REP(i, 2000004) { perm[i] = perm[i - 1] * i % mod; } } int nCk(int x, int y) { if (y > x) { return 0; } if (x < 0) { return 0; } return perm[x] * modpow(perm[x - y], mod - 2) % mod * modpow(perm[y], mod - 2) % mod; } double kyori(pair<int, int> f, pair<int, int> s) { double ans = 0; double t = fabs(f.first - s.first); double y = fabs(f.second - s.second); ans = sqrt(t * t + y * y); return ans; } inline string stringmax(string &x, string &y) { if (x.size() > y.size()) { return x; } if (x.size() < y.size()) { return y; } rep(i, x.size()) { if (x[i] > y[i]) { return x; } if (x[i] < y[i]) { return y; } } return x; } vector<int> RollingHash(string &s, string &t) { vector<int> ans; __int128 h = 0, hamod = 0, ki = 0, kim = 0, hikaku = 0, one = 0; one = 1; ki = 1000000007ll; hamod = (one << 61) - 1; kim = 1; rep(i, t.size()) { hikaku *= ki; h *= ki; kim *= ki; hikaku += t[i]; h += s[i]; hikaku %= hamod; h %= hamod; kim %= hamod; } rep(i, (int)s.size() - (int)t.size() + 1) { if (h == hikaku) { ans.emplace_back(i); } h *= ki; h %= hamod; h += s[i + (int)t.size()]; h %= hamod; h += hamod; h -= s[i] * kim % hamod; h %= hamod; } return ans; } struct edge { int to; int length; edge(int _to, int _length) { to = _to; length = _length; } }; vector<int> djkstra(vector<vector<edge>> &road, int start) { vector<int> kyo(road.size(), inf); smallpriority_queue(P) q; q.push({0, start}); kyo[start] = 0; while (q.size()) { int x = q.top().second; itn now = q.top().first; q.pop(); if (kyo[x] < now) { continue; } for (auto &i : road[x]) { if (kyo[i.to] > now + i.length) { kyo[i.to] = now + i.length; q.push({kyo[i.to], i.to}); } } } return kyo; } #define endl "\n" // interactive の時に注意!!! #define Endl "\n" // interactive の時に注意!!! #define printd cout << fixed << setprecision(10) #define rrep(i, f, s) for (int i = f; i < s; i++) #define RREP(i, f, s) for (int i = f; i <= s; i++) int n, ans; string s; int cnt[43]; signed main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cin >> n >> s; rep(i, n) { cnt[s[i] - 'a']++; } ans = 1; rep(i, n) { ans *= (cnt[i] + 1) % mod; ans %= mod; } cout << ((ans + mod) - 1) % mod << endl; }
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ #include <bits/stdc++.h> //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") // here!!! // define int long long !!!!! #define int long long // define int long long !!!!! #define mod (int)((1e9) + 7) // constexpr int mod = 998244353ll; typedef long long ll; #ifdef int #define inf (int)(3e18) #else #define inf (int)(5e8) #endif #define intt long long #define itn long long #define P pair<long long, long long> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define rev_rep(i, n) for (int i = n - 1; i >= 0; i--) #define REV_REP(i, n) for (int i = n; i >= 1; i--) #define ALL(v) v.begin(), v.end() #define smallpriority_queue(x) priority_queue<x, vector<x>, greater<x>> using namespace std; // Library //モッドパウ inline int modpow(int x, int y, int m = mod) { int res = 1; while (y) { if (y & 1) { res *= x; res %= m; } x = x * x % m; y /= 2; } return res; } int mypow(int x, int y) { int res = 1; while (y) { if (y % 2) { res *= x; } x = x * x; y /= 2; } return res; } // is the number (x) a prime number? bool prime(int x) { if (!x || x == 1) { return false; } for (int i = 2; i * i <= x; i++) { if (!(x % i)) { return false; } } return true; } // saidai-kouyakusuu inline int gcd(int x, int y) { if (!y) { return x; } return gcd(y, x % y); } // number of keta int keta(int x) { int ans = 0; while (x) { x /= 10; ans++; } return ans; } // sum of keta int ketasum(int x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } inline int lcm(int x, int y) { int ans = x / gcd(x, y) * y; return ans; } int twobeki(int x) { int ans = 0; while (1) { if (!(x & 1)) { ans++; x >>= 1; } else { break; } } return ans; } template <class T, class U> inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; } template <class T, class U> inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; } void Yes() { cout << "Yes" << endl; } void No() { cout << "No" << endl; } void YES() { cout << "YES" << endl; } void NO() { cout << "NO" << endl; } #define fin(i) scanf("%lld", &i) #define fout(i) printf("%lld", i) #define fendl printf("\n") int kai(int x, int y) { int res = 1; for (int i = x - y + 1; i <= x; i++) { res *= i; res %= mod; } return res; } int comb(int x, int y) { if (y > x) return 0; // cout<<kai(x, y)<<' '<<modpow(kai(y, y), mod - 2)<<endl; return kai(x, y) * modpow(kai(y, y), mod - 2) % mod; } // Library-End #define vecin(v) \ for (int i = 0; i < v.size(); i++) \ scanf("%lld", &v[i]); #define vecout(v) \ { \ for (int i = 0; i < (int)v.size(); i++) \ printf("%lld ", v[i]); \ printf("\n"); \ } template <typename T> class kaageSegTree { protected: unsigned int n = 1, rank = 0; std::vector<T> node; T nodee; virtual T nodef(const T &, const T &) const = 0; public: kaageSegTree(unsigned int m, T init, T nodee) : nodee(nodee) { while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) node[i] = init; } kaageSegTree(const std::vector<T> &initvec, T nodee) : nodee(nodee) { unsigned int m = initvec.size(); while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) { if (i - n < m) node[i] = initvec[i - n]; } } virtual void update(int i, T x) { i += n; node[i] = x; while (i != 1) { i >>= 1; node[i] = nodef(node[2 * i], node[2 * i + 1]); } } virtual T query(int l, int r) { l += n; r += n; T ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } virtual T operator[](const int &x) { return node[n + x]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; class RSQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return lhs + rhs; } public: RSQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, 0) {} RSQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, 0) {} }; class RMiQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::min(lhs, rhs); } public: RMiQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, inf) {} RMiQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, inf) {} }; class RMaQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::max(lhs, rhs); } public: RMaQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, -inf) {} RMaQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, -inf) {} }; template <typename T, typename U> class IntervalSegTree : public kaageSegTree<T> { protected: using kaageSegTree<T>::n; using kaageSegTree<T>::rank; using kaageSegTree<T>::node; using kaageSegTree<T>::nodef; using kaageSegTree<T>::nodee; std::vector<U> lazy; std::vector<bool> lazyflag; std::vector<int> width; virtual void lazyf(U &, const U &) = 0; virtual void updf(T &, const U &, const unsigned int &) = 0; void eval(int k) { for (int i = rank; i > 0; i--) { int nk = k >> i; if (lazyflag[nk]) { updf(node[2 * nk], lazy[nk], width[2 * nk]); updf(node[2 * nk + 1], lazy[nk], width[2 * nk + 1]); if (lazyflag[2 * nk]) lazyf(lazy[2 * nk], lazy[nk]); else lazy[2 * nk] = lazy[nk]; if (lazyflag[2 * nk + 1]) lazyf(lazy[2 * nk + 1], lazy[nk]); else lazy[2 * nk + 1] = lazy[nk]; lazyflag[2 * nk] = lazyflag[2 * nk + 1] = true; lazyflag[nk] = false; } } } public: IntervalSegTree(unsigned int m, T init, T nodee) : kaageSegTree<T>(m, init, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } IntervalSegTree(T nodee, const std::vector<T> &initvec) : kaageSegTree<T>(initvec, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } void update(int i, U x) { i += n; eval(i); updf(node[i], x, width[i]); if (lazyflag[i]) lazyf(lazy[i], x); else { lazyflag[i] = true; lazy[i] = x; } while (i /= 2) node[i] = nodef(node[2 * i], node[2 * i + 1]); } void update(int l, int r, U x) { l += n; r += n; int nl = l, nr = r; while (!(nl & 1)) nl >>= 1; while (!(nr & 1)) nr >>= 1; nr--; eval(nl); eval(nr); while (l < r) { if (l & 1) { updf(node[l], x, width[l]); if (lazyflag[l]) lazyf(lazy[l], x); else { lazyflag[l] = true; lazy[l] = x; } l++; } if (r & 1) { r--; updf(node[r], x, width[r]); if (lazyflag[r]) lazyf(lazy[r], x); else { lazyflag[r] = true; lazy[r] = x; } } l >>= 1; r >>= 1; } while (nl >>= 1) node[nl] = nodef(node[2 * nl], node[2 * nl + 1]); while (nr >>= 1) node[nr] = nodef(node[2 * nr], node[2 * nr + 1]); } T query(int l, int r) { l += n; r += n; eval(l); eval(r - 1); int ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } T operator[](const int &x) { eval(n + x); return node[n + x]; } T queryForAll() { return node[1]; } }; class RAQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += width * b; } public: RAQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMaQ(unsigned int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = width * b; } public: RUQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMaQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; ////SegTree // template <class T> // class SegTree { // int n; // 葉の数 // vector<T> node; // データを格納するvector // T def; // 初期値かつ単位元 // function<T(T, T)> operation; // 区間クエリで使う処理 // function<T(T, T)> update; // 点更新で使う処理 // // // 区間[a,b)の総和。ノードk=[l,r)に着目している。 // T _query(int a, int b, int k, int l, int r) { // if (r <= a || b <= l) return def; // 交差しない // if (a <= l && r <= b) // return node[k]; // a,l,r,bの順で完全に含まれる // else { // T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 // T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 // return operation(c1, c2); // } // } // // public: // // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数, // // _update:更新関数 // SegTree(size_t _n, T _def, function<T(T, T)> _operation, // function<T(T, T)> _update) // : def(_def), operation(_operation), update(_update) { // n = 1; // while (n < _n) { // n *= 2; // } // node = vector<T>(2 * n , def); // } // // // 場所i(0-indexed)の値をxで更新 // void change(int i, T x) { // i += n - 1; // node[i] = update(node[i], x); // while (i > 0) { // i = (i - 1) / 2; // node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]); // } // } // // // [a, b)の区間クエリを実行 // T query(int a, int b) { // return _query(a, b, 0, 0, n); // } // // // 添字でアクセス // T operator[](int i) { // return node[i + n - 1]; // } //}; template <class T> class SegTree { int n; vector<T> node; T def; function<T(T, T)> operation; function<T(T, T)> update; public: SegTree(unsigned int _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } node = vector<T>(n * 2, def); } SegTree(vector<int> &initvec, function<T(T, T)> _operation, function<T(T, T)> _update) : operation(_operation), update(_update) { n = 1; while (n < initvec.size()) { n *= 2; } node = vector<T>(n * 2, def); for (int i = n; i < n + initvec.size(); i++) { node[i] = initvec[i - n]; } for (int i = n - 1; i >= 1; i--) { node[i] = operation(node[i * 2], node[i * 2 + 1]); } } void change(int i, T x) { i += n; node[i] = update(node[i], x); while (i >= 1) { i >>= 1; node[i] = operation(node[i * 2], node[i * 2 + 1]); } } T query(int l, int r) { l += n; r += n; T rx = def, lx = def; while (l < r) { if (l & 1) { lx = operation(lx, node[l]); l++; } if (r & 1) { r--; rx = operation(node[r], rx); } l >>= 1; r >>= 1; } return operation(lx, rx); } T operator[](const int &x) { return node[x - n]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; #define R_MIN ([](long long a, long long b) { return min(a, b); }) #define R_MAX ([](long long a, long long b) { return max(a, b); }) #define R_SUM ([](long long a, long long b) { return a + b; }) #define NORMAL_UPDATE ([](long long a, long long b) { return b; }) #define ADD_UPDATE ([](long long a, long long b) { return a + b; }) #define MINUS_UPDATE ([](long long a, long long b) { return a - b; } class Union_Find { vector<int> par; vector<int> rankmy; vector<int> ookisa; public: Union_Find(int size) { par = vector<int>(size); rankmy = vector<int>(size); ookisa = vector<int>(size); for (int i = 0; i < size; i++) { par[i] = i; ookisa[i] = 1; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } if (rankmy[x] < rankmy[y]) { par[x] = y; ookisa[y] += ookisa[x]; ookisa[x] = 0; } else { par[y] = x; ookisa[x] += ookisa[y]; ookisa[y] = 0; if (rankmy[x] == rankmy[y]) { rankmy[x]++; } } } int size(int i) { i = find(i); return ookisa[i]; } bool same(int x, int y) { return find(x) == find(y); } }; class BIT { vector<int> data; int size = 0; public: BIT(int _size) { data = vector<int>(_size + 1); size = _size; } void add(int i, int x) { while (i <= size) { data[i] += x; i += i & -i; } } int sum(int i) { assert(i <= size); int s = 0; while (i > 0) { s += data[i]; i -= i & -i; } return s; } int lower_bound(int x) { if (x <= 0) { return 0; } else { int i = 0; int r = 1; while (r < size) r = r << 1; for (int len = r; len > 0; len = len >> 1) { if (i + len < size && data[i + len] < x) { x -= data[i + len]; i += len; } } return i + 1; } } }; // Union-Find-End int perm[2000005]; void init_perm() { perm[0] = 1; REP(i, 2000004) { perm[i] = perm[i - 1] * i % mod; } } int nCk(int x, int y) { if (y > x) { return 0; } if (x < 0) { return 0; } return perm[x] * modpow(perm[x - y], mod - 2) % mod * modpow(perm[y], mod - 2) % mod; } double kyori(pair<int, int> f, pair<int, int> s) { double ans = 0; double t = fabs(f.first - s.first); double y = fabs(f.second - s.second); ans = sqrt(t * t + y * y); return ans; } inline string stringmax(string &x, string &y) { if (x.size() > y.size()) { return x; } if (x.size() < y.size()) { return y; } rep(i, x.size()) { if (x[i] > y[i]) { return x; } if (x[i] < y[i]) { return y; } } return x; } vector<int> RollingHash(string &s, string &t) { vector<int> ans; __int128 h = 0, hamod = 0, ki = 0, kim = 0, hikaku = 0, one = 0; one = 1; ki = 1000000007ll; hamod = (one << 61) - 1; kim = 1; rep(i, t.size()) { hikaku *= ki; h *= ki; kim *= ki; hikaku += t[i]; h += s[i]; hikaku %= hamod; h %= hamod; kim %= hamod; } rep(i, (int)s.size() - (int)t.size() + 1) { if (h == hikaku) { ans.emplace_back(i); } h *= ki; h %= hamod; h += s[i + (int)t.size()]; h %= hamod; h += hamod; h -= s[i] * kim % hamod; h %= hamod; } return ans; } struct edge { int to; int length; edge(int _to, int _length) { to = _to; length = _length; } }; vector<int> djkstra(vector<vector<edge>> &road, int start) { vector<int> kyo(road.size(), inf); smallpriority_queue(P) q; q.push({0, start}); kyo[start] = 0; while (q.size()) { int x = q.top().second; itn now = q.top().first; q.pop(); if (kyo[x] < now) { continue; } for (auto &i : road[x]) { if (kyo[i.to] > now + i.length) { kyo[i.to] = now + i.length; q.push({kyo[i.to], i.to}); } } } return kyo; } #define endl "\n" // interactive の時に注意!!! #define Endl "\n" // interactive の時に注意!!! #define printd cout << fixed << setprecision(10) #define rrep(i, f, s) for (int i = f; i < s; i++) #define RREP(i, f, s) for (int i = f; i <= s; i++) int n, ans; string s; int cnt[43]; signed main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cin >> n >> s; rep(i, n) { cnt[s[i] - 'a']++; } ans = 1; rep(i, 26) { ans *= (cnt[i] + 1) % mod; ans %= mod; } cout << ((ans + mod) - 1) % mod << endl; }
[]
905,219
905,220
u943070796
cpp
p03095
#define _GLIBCXX_DEBUG #include <algorithm> //next_permutation #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define dec(n) cout << fixed << setprecision(n); #define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define small "abcdefghijklmnopqrstuvwxyz" using namespace std; using ll = long long; using P = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } const ll MOD = 1000000007; const ll MAX = 2000001; ll mod(ll a) { return a % MOD; } ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } ll fac[MAX], finv[MAX], inv[MAX]; void nCrprep() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll nCr(ll n, ll r) { if (n < r) return 0; if (n < 0 || r < 0) return 0; return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD; } ll nCrcheep(ll n, ll r) { if (r == 0) return 1; else if (r == 1) return n; else return nCrcheep(n - 1, r - 1) * n / r; } vector<pair<ll, ll>> prime_factorize(ll n) { vector<pair<ll, ll>> res; for (ll i = 2; i * i <= n; i++) { if (n % i != 0) continue; ll ex = 0; while (n % i == 0) { ex++; n /= i; } res.push_back({i, ex}); } if (n != 1) res.push_back({n, 1}); return res; } int main() { ll n; cin >> n; string s; cin >> s; vl num(26); ll ans = 1; rep(i, n) { rep(j, 26) { if (small[j] == s[i]) { num[j]++; } } } rep(i, n) { ans *= num[i] + 1; ans = mod(ans); } cout << ans - 1 << endl; }
#define _GLIBCXX_DEBUG #include <algorithm> //next_permutation #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define dec(n) cout << fixed << setprecision(n); #define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define small "abcdefghijklmnopqrstuvwxyz" using namespace std; using ll = long long; using P = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } const ll MOD = 1000000007; const ll MAX = 2000001; ll mod(ll a) { return a % MOD; } ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } ll fac[MAX], finv[MAX], inv[MAX]; void nCrprep() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll nCr(ll n, ll r) { if (n < r) return 0; if (n < 0 || r < 0) return 0; return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD; } ll nCrcheep(ll n, ll r) { if (r == 0) return 1; else if (r == 1) return n; else return nCrcheep(n - 1, r - 1) * n / r; } vector<pair<ll, ll>> prime_factorize(ll n) { vector<pair<ll, ll>> res; for (ll i = 2; i * i <= n; i++) { if (n % i != 0) continue; ll ex = 0; while (n % i == 0) { ex++; n /= i; } res.push_back({i, ex}); } if (n != 1) res.push_back({n, 1}); return res; } int main() { ll n; cin >> n; string s; cin >> s; vl num(27); ll ans = 1; rep(i, n) { rep(j, 27) { if (small[j] == s[i]) { num[j]++; } } } rep(i, 27) { ans *= num[i] + 1; ans = mod(ans); } cout << ans - 1 << endl; }
[ "literal.number.change", "call.arguments.change" ]
905,227
905,228
u434398296
cpp
p03095
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define REP(i, N) for (int i = 0; i < (int)N; i++) #define FOR(i, a, b) for (int i = a; i < (int)b; i++) #define ALL(x) (x).begin(), (x).end() #define INF (1 << 30) #define LLINF (1LL << 62) #define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__) constexpr int MOD = 1000000007; using ll = long long; using Pii = pair<int, int>; using Pll = pair<ll, ll>; inline int popcount(ll x) { return __builtin_popcountll(x); } inline int div2num(ll x) { return __builtin_ctzll(x); } inline bool bit(ll x, int b) { return (x >> b) & 1; } template <class T> string to_string(T s); template <class S, class T> string to_string(pair<S, T> p); string to_string(string s) { return s; } string to_string(const char s[]) { return to_string(string(s)); } template <class T> string to_string(T v) { if (v.empty()) return "{}"; string ret = "{"; for (auto x : v) ret += to_string(x) + ","; ret.back() = '}'; return ret; } template <class S, class T> string to_string(pair<S, T> p) { return "{" + to_string(p.first) + ":" + to_string(p.second) + "}"; } void debug() { cerr << endl; } template <class Head, class... Tail> void debug(Head head, Tail... tail) { cerr << to_string(head) << " "; debug(tail...); } struct IO { #ifdef _WIN32 inline char getchar_unlocked() { return getchar(); } inline void putchar_unlocked(char c) { putchar(c); } #endif std::string separator = " "; template <class T> inline void read(T &x) { char c; do { c = getchar_unlocked(); } while (c != '-' && (c < '0' || '9' < c)); bool minus = 0; if (c == '-') { minus = 1; c = getchar_unlocked(); } x = 0; while ('0' <= c && c <= '9') { x *= 10; x += c - '0'; c = getchar_unlocked(); } if (minus) x = -x; } inline void read(std::string &x) { char c; do { c = getchar_unlocked(); } while (c == ' ' || c == '\n'); x.clear(); do { x += c; c = getchar_unlocked(); } while (c != ' ' && c != '\n' && c != EOF); } template <class T> inline void read(std::vector<T> &v) { for (auto &x : v) read(x); } template <class S, class T> inline void read(std::pair<S, T> &p) { read(p.first); read(p.second); } template <class Head, class... Tail> inline void read(Head &head, Tail &...tail) { read(head); read(tail...); } template <class T> inline void write(T x) { char buf[32]; int p = 0; if (x < 0) { x = -x; putchar_unlocked('-'); } if (x == 0) putchar_unlocked('0'); while (x > 0) { buf[p++] = (x % 10) + '0'; x /= 10; } while (p) { putchar_unlocked(buf[--p]); } } inline void write(std::string x) { for (char c : x) putchar_unlocked(c); } inline void write(const char s[]) { for (int i = 0; s[i] != 0; ++i) putchar_unlocked(s[i]); } template <class T> inline void write(std::vector<T> v) { if (v.empty()) return; for (auto itr = v.begin(); itr + 1 != v.end(); ++itr) { write(*itr); write(separator); } write(v.back()); } template <class Head, class... Tail> inline void write(Head head, Tail... tail) { write(head); write(separator); write(tail...); } template <class Head, class... Tail> inline void writeln(Head head, Tail... tail) { write(head, tail...); write("\n"); } void set_separator(std::string s) { separator = s; } } io; struct Prime { int n; vector<int> table; vector<int> primes; Prime(int _n = 100000) { n = _n + 1; table.resize(n, -1); table[0] = 0; table[1] = -1; for (int i = 2; i * i < n; ++i) { if (table[i] == -1) { for (int j = i * i; j < n; j += i) { table[j] = i; } } } } void enumerate_primes() { primes.clear(); for (int i = 2; i < n; ++i) { if (table[i] == -1) primes.push_back(i); } } vector<pair<long long, int>> prime_factor(long long x) { map<long long, int> mp; long long div = 2; int p = 0; while (n <= x && div * div <= x) { if (x % div == 0) { mp[div]++; x /= div; } else { if (p + 1 < primes.size()) { div = primes[++p]; } else { div++; } } } if (x < n) { while (table[x] != -1) { mp[table[x]]++; x /= table[x]; } } if (x > 1) mp[x]++; vector<pair<long long, int>> ret; for (auto p : mp) ret.push_back(p); return ret; } }; template <int MOD = 1000000007> struct Math { vector<long long> fact, factinv, inv; Math(int n = 100000) { fact.resize(n + 1); factinv.resize(n + 1); inv.resize(n + 1); fact[0] = fact[1] = 1; factinv[0] = factinv[1] = 1; inv[1] = 1; for (int i = 2; i <= n; ++i) { fact[i] = fact[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; factinv[i] = factinv[i - 1] * inv[i] % MOD; } } long long C(int n, int r) { if (n < r || n < 0 || r < 0) { return 0; } else { return fact[n] * (factinv[r] * factinv[n - r] % MOD) % MOD; } } long long P(int n, int r) { if (n < r || n < 0 || r < 0) { return 0; } else { return fact[n] * factinv[n - r] % MOD; } } long long H(int n, int r) { return C(n + r - 1, r); } }; struct UnionFind { vector<int> data; vector<vector<int>> groups; UnionFind(int n) : data(n, -1) {} int root(int v) { return data[v] < 0 ? v : data[v] = root(data[v]); } bool unite(int u, int v) { if ((u = root(u)) == (v = root(v))) { return 1; } else { if (-data[u] < -data[v]) swap(u, v); data[u] += data[v]; data[v] = u; return 0; } } int size(int v) { return -data[root(v)]; } void make_groups() { map<int, vector<int>> mp; for (int i = 0; i < data.size(); ++i) mp[root(i)].push_back(i); groups.clear(); for (auto p : mp) groups.push_back(p.second); } }; namespace phc { long long modpow(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % MOD; a = a * a % MOD; n >>= 1; } return res; } long long modinv(long long a) { long long b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= MOD; if (u < 0) u += MOD; return u; } long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } } // namespace phc template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<MOD>; constexpr int dy[4] = {-1, 0, 1, 0}, dx[4] = {0, -1, 0, 1}; int main() { int N; string S; io.read(N, S); int ct[256]; REP(i, N) ct[S[i]]++; ll ans = 1; for (char c = 'a'; c <= 'z'; c += 1) ans = ans * (ct[c] + 1) % MOD; io.writeln((ans + MOD - 1) % MOD); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define REP(i, N) for (int i = 0; i < (int)N; i++) #define FOR(i, a, b) for (int i = a; i < (int)b; i++) #define ALL(x) (x).begin(), (x).end() #define INF (1 << 30) #define LLINF (1LL << 62) #define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__) constexpr int MOD = 1000000007; using ll = long long; using Pii = pair<int, int>; using Pll = pair<ll, ll>; inline int popcount(ll x) { return __builtin_popcountll(x); } inline int div2num(ll x) { return __builtin_ctzll(x); } inline bool bit(ll x, int b) { return (x >> b) & 1; } template <class T> string to_string(T s); template <class S, class T> string to_string(pair<S, T> p); string to_string(string s) { return s; } string to_string(const char s[]) { return to_string(string(s)); } template <class T> string to_string(T v) { if (v.empty()) return "{}"; string ret = "{"; for (auto x : v) ret += to_string(x) + ","; ret.back() = '}'; return ret; } template <class S, class T> string to_string(pair<S, T> p) { return "{" + to_string(p.first) + ":" + to_string(p.second) + "}"; } void debug() { cerr << endl; } template <class Head, class... Tail> void debug(Head head, Tail... tail) { cerr << to_string(head) << " "; debug(tail...); } struct IO { #ifdef _WIN32 inline char getchar_unlocked() { return getchar(); } inline void putchar_unlocked(char c) { putchar(c); } #endif std::string separator = " "; template <class T> inline void read(T &x) { char c; do { c = getchar_unlocked(); } while (c != '-' && (c < '0' || '9' < c)); bool minus = 0; if (c == '-') { minus = 1; c = getchar_unlocked(); } x = 0; while ('0' <= c && c <= '9') { x *= 10; x += c - '0'; c = getchar_unlocked(); } if (minus) x = -x; } inline void read(std::string &x) { char c; do { c = getchar_unlocked(); } while (c == ' ' || c == '\n'); x.clear(); do { x += c; c = getchar_unlocked(); } while (c != ' ' && c != '\n' && c != EOF); } template <class T> inline void read(std::vector<T> &v) { for (auto &x : v) read(x); } template <class S, class T> inline void read(std::pair<S, T> &p) { read(p.first); read(p.second); } template <class Head, class... Tail> inline void read(Head &head, Tail &...tail) { read(head); read(tail...); } template <class T> inline void write(T x) { char buf[32]; int p = 0; if (x < 0) { x = -x; putchar_unlocked('-'); } if (x == 0) putchar_unlocked('0'); while (x > 0) { buf[p++] = (x % 10) + '0'; x /= 10; } while (p) { putchar_unlocked(buf[--p]); } } inline void write(std::string x) { for (char c : x) putchar_unlocked(c); } inline void write(const char s[]) { for (int i = 0; s[i] != 0; ++i) putchar_unlocked(s[i]); } template <class T> inline void write(std::vector<T> v) { if (v.empty()) return; for (auto itr = v.begin(); itr + 1 != v.end(); ++itr) { write(*itr); write(separator); } write(v.back()); } template <class Head, class... Tail> inline void write(Head head, Tail... tail) { write(head); write(separator); write(tail...); } template <class Head, class... Tail> inline void writeln(Head head, Tail... tail) { write(head, tail...); write("\n"); } void set_separator(std::string s) { separator = s; } } io; struct Prime { int n; vector<int> table; vector<int> primes; Prime(int _n = 100000) { n = _n + 1; table.resize(n, -1); table[0] = 0; table[1] = -1; for (int i = 2; i * i < n; ++i) { if (table[i] == -1) { for (int j = i * i; j < n; j += i) { table[j] = i; } } } } void enumerate_primes() { primes.clear(); for (int i = 2; i < n; ++i) { if (table[i] == -1) primes.push_back(i); } } vector<pair<long long, int>> prime_factor(long long x) { map<long long, int> mp; long long div = 2; int p = 0; while (n <= x && div * div <= x) { if (x % div == 0) { mp[div]++; x /= div; } else { if (p + 1 < primes.size()) { div = primes[++p]; } else { div++; } } } if (x < n) { while (table[x] != -1) { mp[table[x]]++; x /= table[x]; } } if (x > 1) mp[x]++; vector<pair<long long, int>> ret; for (auto p : mp) ret.push_back(p); return ret; } }; template <int MOD = 1000000007> struct Math { vector<long long> fact, factinv, inv; Math(int n = 100000) { fact.resize(n + 1); factinv.resize(n + 1); inv.resize(n + 1); fact[0] = fact[1] = 1; factinv[0] = factinv[1] = 1; inv[1] = 1; for (int i = 2; i <= n; ++i) { fact[i] = fact[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; factinv[i] = factinv[i - 1] * inv[i] % MOD; } } long long C(int n, int r) { if (n < r || n < 0 || r < 0) { return 0; } else { return fact[n] * (factinv[r] * factinv[n - r] % MOD) % MOD; } } long long P(int n, int r) { if (n < r || n < 0 || r < 0) { return 0; } else { return fact[n] * factinv[n - r] % MOD; } } long long H(int n, int r) { return C(n + r - 1, r); } }; struct UnionFind { vector<int> data; vector<vector<int>> groups; UnionFind(int n) : data(n, -1) {} int root(int v) { return data[v] < 0 ? v : data[v] = root(data[v]); } bool unite(int u, int v) { if ((u = root(u)) == (v = root(v))) { return 1; } else { if (-data[u] < -data[v]) swap(u, v); data[u] += data[v]; data[v] = u; return 0; } } int size(int v) { return -data[root(v)]; } void make_groups() { map<int, vector<int>> mp; for (int i = 0; i < data.size(); ++i) mp[root(i)].push_back(i); groups.clear(); for (auto p : mp) groups.push_back(p.second); } }; namespace phc { long long modpow(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % MOD; a = a * a % MOD; n >>= 1; } return res; } long long modinv(long long a) { long long b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= MOD; if (u < 0) u += MOD; return u; } long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } } // namespace phc template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<MOD>; constexpr int dy[4] = {-1, 0, 1, 0}, dx[4] = {0, -1, 0, 1}; int main() { int N; string S; io.read(N, S); int ct[256] = {}; REP(i, N) ct[S[i]]++; ll ans = 1; for (char c = 'a'; c <= 'z'; c += 1) ans = ans * (ct[c] + 1) % MOD; io.writeln((ans + MOD - 1) % MOD); return 0; }
[ "variable_declaration.value.change" ]
905,229
905,230
u656771711
cpp
p03095
#include <bits/stdc++.h> #define int long long #define ll long long #define rep(i, n) for (int i = 0; i < n; i++) #define INF (((ll)1 << 31) - 1) #define eps LDBL_EPSILON #define moder (1000000007) #define pie 3.141592653589793238462643383279 #define P std::pair<int, int> #define prique priority_queue #define ggr \ getchar(); \ getchar(); \ return 0; using namespace std; int n; string s; int a[26]; int dp[26]; signed main() { cin >> n >> s; rep(i, n) { a[s[i] - 'a']++; } int ans = 1; rep(i, n) { ans *= (a[i] + 1); ans %= moder; } cout << ans - 1 << endl; return 0; }
#include <bits/stdc++.h> #define int long long #define ll long long #define rep(i, n) for (int i = 0; i < n; i++) #define INF (((ll)1 << 31) - 1) #define eps LDBL_EPSILON #define moder (1000000007) #define pie 3.141592653589793238462643383279 #define P std::pair<int, int> #define prique priority_queue #define ggr \ getchar(); \ getchar(); \ return 0; using namespace std; int n; string s; int a[26]; int dp[26]; signed main() { cin >> n >> s; rep(i, n) { a[s[i] - 'a']++; } int ans = 1; rep(i, 26) { ans *= (a[i] + 1); ans %= moder; } cout << ans - 1 << endl; return 0; }
[]
905,240
905,241
u379822620
cpp
p03095
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e9 + 7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int N; string S; cin >> N >> S; int cnt[26] = {}; for (int i = 0; i < S.size(); i++) { cnt[S[i] - 'a']++; } int ans = 1; for (int i = 0; i < 26; i++) { ans *= cnt[i]; ans = ans % INF; } cout << ans - 1 << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e9 + 7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int N; string S; cin >> N >> S; int cnt[26] = {}; for (int i = 0; i < S.size(); i++) { cnt[S[i] - 'a']++; } int ans = 1; for (int i = 0; i < 26; i++) { ans *= (cnt[i] + 1); ans = ans % INF; } cout << ans - 1 << endl; }
[]
905,242
905,243
u237390401
cpp