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
p03096
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)x.size()) template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; const int inf = 1LL << 60; const int mod = 1e9 + 7; const double eps = 1e-9; /*{ 1 2 3 1 2 }*/ signed main() { int n; cin >> n; vi c(n); rep(i, 0, n) cin >> c[i]; vi dp(n + 1); vi prev(n + 1, -1); dp[0] = 1; rep(i, 1, n + 1) { (dp[i] += dp[i - 1]) %= mod; int &p = prev[c[i - 1]]; if (p != -1 and i - p > 1) { (dp[i] += dp[p]) %= mod; } p = i; } cout << dp[n] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)x.size()) template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; const int inf = 1LL << 60; const int mod = 1e9 + 7; const double eps = 1e-9; /*{ 1 2 3 1 2 }*/ signed main() { int n; cin >> n; vi c(n); rep(i, 0, n) cin >> c[i]; vi dp(n + 1); vi prev(200001, -1); dp[0] = 1; rep(i, 1, n + 1) { (dp[i] += dp[i - 1]) %= mod; int &p = prev[c[i - 1]]; if (p != -1 and i - p > 1) { (dp[i] += dp[p]) %= mod; } p = i; } cout << dp[n] << endl; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,205
907,206
u057866967
cpp
p03096
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int mod = 1000000007; void solve(); int main(void) { int N; cin >> N; int C[N + 1] = {}; rep(i, N) cin >> C[i + 1]; ll dp[N + 1][2]; int prev_c[N + 1] = {}; // prev_c[i]: 色c_iが一番最近に現れた場所 dp[0][0] = 0; dp[0][1] = 0; dp[1][0] = 1; dp[1][1] = 0; prev_c[C[1]] = 1; for (int i = 2; i <= N; i++) { // dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % mod; // dp[i][1] = (dp[prev_c[C[i]]][0] + dp[prev_c[C[i]]][1]) % mod; //基本はこの遷移でいいけど、隣接してる時が危ない -> //1個前をそのままコピーすればいい if (C[i] == C[i - 1]) { dp[i][0] = dp[i - 1][0]; dp[i][1] = dp[i - 1][1]; } else { dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod; dp[i][1] = (dp[prev_c[C[i]]][0] + dp[prev_c[C[i]]][1]) % mod; } prev_c[C[i]] = i; } cout << (dp[N][0] + dp[N][1]) % mod << endl; return 0; } void solve() {}
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int mod = 1000000007; void solve(); int main(void) { int N; cin >> N; int C[N + 1] = {}; rep(i, N) cin >> C[i + 1]; ll dp[N + 1][2]; int prev_c[200001] = {}; // prev_c[i]: 色iが一番最近に現れた場所 dp[0][0] = 0; dp[0][1] = 0; dp[1][0] = 1; dp[1][1] = 0; prev_c[C[1]] = 1; for (int i = 2; i <= N; i++) { // dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % mod; // dp[i][1] = (dp[prev_c[C[i]]][0] + dp[prev_c[C[i]]][1]) % mod; //基本はこの遷移でいいけど、隣接してる時が危ない -> //1個前をそのままコピーすればいい if (C[i] == C[i - 1]) { dp[i][0] = dp[i - 1][0]; dp[i][1] = dp[i - 1][1]; } else { dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod; dp[i][1] = (dp[prev_c[C[i]]][0] + dp[prev_c[C[i]]][1]) % mod; } prev_c[C[i]] = i; } cout << (dp[N][0] + dp[N][1]) % mod << endl; return 0; } void solve() {}
[ "identifier.replace.remove", "literal.replace.add", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,211
907,212
u882620594
cpp
p03096
#include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; using ll = long long; constexpr ll infl = 10000000000000000LL; constexpr int inf = 1000000000; int main() { int n; cin >> n; vector<int> c(n); for (int i = 0; i < n; ++i) { cin >> c[i]; --c[i]; } if (n <= 2) { cout << 1 << endl; return 0; } vector<int> idx(n, -1); idx[c[0]] = 0; idx[c[1]] = 1; vector<ll> dp(n); dp[0] = dp[1] = 1; constexpr ll mod = 1000000007LL; for (int i = 2; i < n; ++i) { dp[i] = dp[i - 1]; if (idx[c[i]] != -1 && idx[c[i]] + 2 <= i) { dp[i] += dp[idx[c[i]]]; dp[i] %= mod; } idx[c[i]] = i; } cout << dp.back() << endl; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; using ll = long long; constexpr ll infl = 10000000000000000LL; constexpr int inf = 1000000000; int main() { int n; cin >> n; vector<int> c(n); for (int i = 0; i < n; ++i) { cin >> c[i]; --c[i]; } if (n <= 2) { cout << 1 << endl; return 0; } vector<int> idx(200001, -1); idx[c[0]] = 0; idx[c[1]] = 1; vector<ll> dp(n); dp[0] = dp[1] = 1; constexpr ll mod = 1000000007LL; for (int i = 2; i < n; ++i) { dp[i] = dp[i - 1]; if (idx[c[i]] != -1 && idx[c[i]] + 2 <= i) { dp[i] += dp[idx[c[i]]]; dp[i] %= mod; } idx[c[i]] = i; } cout << dp.back() << endl; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change" ]
907,217
907,218
u577747009
cpp
p03096
//#define _AOJ_ /*vvv> zzzzzI .---. zzuzuI .vgggg&,. +++++= dAC:|I .WbbWo JMM9^```?TMB` ..&gNNg,. gggggggJ, qgggggggg] (&&&&&&&&[ c+OA&J, (&&&&&&+J, .cJeAA&-. (&&&&&&&&x .&AA&=-. +++++= dTqk|I Xpbpbp JM#` (M#^ ?MMp MM| +TMN. JMF ' |yk ` dVY 7Vk, Vy XV cVf ?Y! JM V$ ` +++++= dcf:|I Xppppp dMN .MM+ .MM MM| MM] JMMMMMM+ |@tqkoh) ,y0 (V$ yyyyyyyV7 VV JMWyZWr TWVVVVW&, ++++++ d7qk|0 Xppppp ^HMN, _.db WMm, .MMF MM| ..MM` JMF . |yk .WV&. .XW' yy 4yn. jyn +. JM #S `++++` ?ZZZX= ?WWWW= -THMMMMH9^ (TMMMMM9! MMMMMMM"" JMMMMMMMME |UU. ?TUUUUY= UU. (UU- ^7TUUUV7! JUUUUUUUU 7TUNKO*/ // Ricty Diminished #include "bits/stdc++.h" using namespace std; typedef long long lint; typedef vector<lint> liv; //#define rep(i,n) for(int i=0;i<n;++i) #define all(v) v.begin(), v.end() #define pb push_back #define _vcppunko4(tuple) _getname4 tuple #define _getname4(_1, _2, _3, _4, name, ...) name #define _getname3(_1, _2, _3, name, ...) name #define _trep2(tuple) _rep2 tuple #define _trep3(tuple) _rep3 tuple #define _trep4(tuple) _rep4 tuple #define _rep1(n) for (lint i = 0; i < n; ++i) #define _rep2(i, n) for (lint i = 0; i < n; ++i) #define _rep3(i, a, b) for (lint i = a; i < b; ++i) #define _rep4(i, a, b, c) for (lint i = a; i < b; i += c) #define _trrep2(tuple) _rrep2 tuple #define _trrep3(tuple) _rrep3 tuple #define _trrep4(tuple) _rrep4 tuple #define _rrep1(n) for (lint i = n - 1; i >= 0; --i) #define _rrep2(i, n) for (lint i = n - 1; i >= 0; --i) #define _rrep3(i, a, b) for (lint i = b - 1; i >= a; --i) #define _rrep4(i, a, b, c) \ for (lint i = a + (b - a - 1) / c * c; i >= a; i -= c) template <class T> istream &operator>>(istream &is, vector<T> &vec); template <class T, size_t size> istream &operator>>(istream &is, array<T, size> &vec); template <class T, class L> istream &operator>>(istream &is, pair<T, L> &p); template <class T> ostream &operator<<(ostream &os, vector<T> &vec); template <class T, class L> ostream &operator<<(ostream &os, pair<T, L> &p); template <class T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } template <class T, class L> istream &operator>>(istream &is, pair<T, L> &p) { is >> p.first; is >> p.second; return is; } // template<class T> // ostream& operator<<(ostream& os,vector<T>& vec){ // os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; } template<class T> // ostream& operator<<(ostream& os,deque<T>& deq){ // os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; } template <class T, class L> ostream &operator<<(ostream &os, pair<T, L> &p) { os << p.first << " " << p.second; return os; } inline void in() {} template <class Head, class... Tail> inline void in(Head &&head, Tail &&...tail) { cin >> head; in(move(tail)...); } template <class T> inline bool out(T t) { cout << t << '\n'; return 0; } inline bool out() { cout << '\n'; return 0; } template <class Head, class... Tail> inline bool out(Head head, Tail... tail) { cout << head << ' '; out(move(tail)...); return 0; } #define rep(...) \ _vcppunko4((__VA_ARGS__, _trep4, _trep3, _trep2, _rep1))((__VA_ARGS__)) #define rrep(...) \ _vcppunko4((__VA_ARGS__, _trrep4, _trrep3, _trrep2, _rrep1))((__VA_ARGS__)) #define each(v) for (auto &i : v) #define lin(...) \ lint __VA_ARGS__; \ in(__VA_ARGS__) #define stin(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define vin(type, name, size) \ vector<type> name(size); \ in(name) #define fi e.first #define se e.second #define YES(c) cout << ((c) ? "YES\n" : "NO\n"), 0 #define Yes(c) cout << ((c) ? "Yes\n" : "No\n"), 0 #define o(p) cout << p << endl, 0 #define sp(p) cout << p << " " #define no(p) cout << p #ifdef __ENV_TQK__ #define deb(p) cout << p << endl, 0 #else #define deb(p) 0 #endif #define dd(n) cout << fixed << setprecision(n) // mint #define md_tmp template <uint_fast64_t md = 1000000007> md_tmp class mint { using u64 = uint_fast64_t; public: u64 a; constexpr mint(const u64 x = 0) noexcept : a(x % md) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr mint operator+(const mint rhs) const noexcept { return mint(*this) += rhs; } constexpr mint operator-(const mint rhs) const noexcept { return mint(*this) -= rhs; } constexpr mint operator*(const mint rhs) const noexcept { return mint(*this) *= rhs; } constexpr mint operator^(const lint rhs) const noexcept { return mint(*this) ^= rhs; } constexpr mint operator/(const mint rhs) const noexcept { return mint(*this) /= rhs; } constexpr mint &operator+=(const mint rhs) noexcept { a += rhs.a; if (a >= md) a -= md; return *this; } constexpr mint &operator-=(const mint rhs) noexcept { if (a < rhs.a) a += md; a -= rhs.a; return *this; } constexpr mint &operator*=(const mint rhs) noexcept { a = a * rhs.a % md; return *this; } constexpr mint &operator^=(const lint rhs) noexcept { if (!rhs) return *this = 1; u64 exp = rhs - 1; mint base = this->a; while (exp) { if (exp & 1) *this *= base; base *= base; exp >>= 1; } return *this; } constexpr mint &operator/=(const mint rhs) noexcept { a = (*this * (rhs ^ (md - 2))).a; return *this; } }; md_tmp istream &operator>>(istream &os, mint<md> &m) { os >> m.a, m.a %= md; return os; } md_tmp ostream &operator<<(ostream &os, const mint<md> &m) { return os << m.a; } md_tmp mint<md> ncr(lint n, lint r) { if (n < r || n < 0 || r < 0) return mint<md>(0); mint<md> ncr_res = 1, ncr_div = 1; rep(r) ncr_res *= (n - i), ncr_div *= (r - i); return ncr_res / ncr_div; } #ifndef _AOJ_ mint<> operator"" m(unsigned long long n) { return mint<>(n); } mint<998244353> operator"" m9(unsigned long long n) { return mint<998244353>(n); } mint<1000003> operator"" m3(unsigned long long n) { return mint<1000003>(n); } #endif using mi = mint<>; // P class P { public: lint f, s; constexpr P(lint a, lint b) : f(a), s(b){}; constexpr P() : f(0), s(0){}; }; istream &operator>>(istream &is, P &p) { is >> p.f >> p.s; return is; } ostream &operator<<(ostream &os, const P &p) { return os << p.f << " " << p.s << endl; } bool operator<(const P &l, const P &r) { return (l.f - r.f ? l.f < r.f : l.s < r.s); } bool operator>(const P &l, const P &r) { return (l.f - r.f ? l.f > r.f : l.s > r.s); } struct C { lint f, s, t; }; bool operator<(const C &l, const C &r) { return l.t < r.t; } bool operator>(const C &l, const C &r) { return l.t > r.t; } #define linf 1152921504606846976 #define inf linf // INT_MAX #define MAXN 200100 #define md_1e9_7 1000000007 #define md_998244353 998244353 //#define mod md_1e9_7 const int d4[5] = {0, 1, 0, -1, 0}; int main() { lin(n); vin(lint, a, n); a.erase(unique(all(a)), a.end()); n = a.size(); vector<mi> dp(n + 1), sum(n + 1); dp[0] = 1; rep(n) { dp[i + 1] = sum[a[i]] += dp[i]; } o(dp[n]); } // sub-EOF
//#define _AOJ_ /*vvv> zzzzzI .---. zzuzuI .vgggg&,. +++++= dAC:|I .WbbWo JMM9^```?TMB` ..&gNNg,. gggggggJ, qgggggggg] (&&&&&&&&[ c+OA&J, (&&&&&&+J, .cJeAA&-. (&&&&&&&&x .&AA&=-. +++++= dTqk|I Xpbpbp JM#` (M#^ ?MMp MM| +TMN. JMF ' |yk ` dVY 7Vk, Vy XV cVf ?Y! JM V$ ` +++++= dcf:|I Xppppp dMN .MM+ .MM MM| MM] JMMMMMM+ |@tqkoh) ,y0 (V$ yyyyyyyV7 VV JMWyZWr TWVVVVW&, ++++++ d7qk|0 Xppppp ^HMN, _.db WMm, .MMF MM| ..MM` JMF . |yk .WV&. .XW' yy 4yn. jyn +. JM #S `++++` ?ZZZX= ?WWWW= -THMMMMH9^ (TMMMMM9! MMMMMMM"" JMMMMMMMME |UU. ?TUUUUY= UU. (UU- ^7TUUUV7! JUUUUUUUU 7TUNKO*/ // Ricty Diminished #include "bits/stdc++.h" using namespace std; typedef long long lint; typedef vector<lint> liv; //#define rep(i,n) for(int i=0;i<n;++i) #define all(v) v.begin(), v.end() #define pb push_back #define _vcppunko4(tuple) _getname4 tuple #define _getname4(_1, _2, _3, _4, name, ...) name #define _getname3(_1, _2, _3, name, ...) name #define _trep2(tuple) _rep2 tuple #define _trep3(tuple) _rep3 tuple #define _trep4(tuple) _rep4 tuple #define _rep1(n) for (lint i = 0; i < n; ++i) #define _rep2(i, n) for (lint i = 0; i < n; ++i) #define _rep3(i, a, b) for (lint i = a; i < b; ++i) #define _rep4(i, a, b, c) for (lint i = a; i < b; i += c) #define _trrep2(tuple) _rrep2 tuple #define _trrep3(tuple) _rrep3 tuple #define _trrep4(tuple) _rrep4 tuple #define _rrep1(n) for (lint i = n - 1; i >= 0; --i) #define _rrep2(i, n) for (lint i = n - 1; i >= 0; --i) #define _rrep3(i, a, b) for (lint i = b - 1; i >= a; --i) #define _rrep4(i, a, b, c) \ for (lint i = a + (b - a - 1) / c * c; i >= a; i -= c) template <class T> istream &operator>>(istream &is, vector<T> &vec); template <class T, size_t size> istream &operator>>(istream &is, array<T, size> &vec); template <class T, class L> istream &operator>>(istream &is, pair<T, L> &p); template <class T> ostream &operator<<(ostream &os, vector<T> &vec); template <class T, class L> ostream &operator<<(ostream &os, pair<T, L> &p); template <class T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } template <class T, class L> istream &operator>>(istream &is, pair<T, L> &p) { is >> p.first; is >> p.second; return is; } // template<class T> // ostream& operator<<(ostream& os,vector<T>& vec){ // os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; } template<class T> // ostream& operator<<(ostream& os,deque<T>& deq){ // os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; } template <class T, class L> ostream &operator<<(ostream &os, pair<T, L> &p) { os << p.first << " " << p.second; return os; } inline void in() {} template <class Head, class... Tail> inline void in(Head &&head, Tail &&...tail) { cin >> head; in(move(tail)...); } template <class T> inline bool out(T t) { cout << t << '\n'; return 0; } inline bool out() { cout << '\n'; return 0; } template <class Head, class... Tail> inline bool out(Head head, Tail... tail) { cout << head << ' '; out(move(tail)...); return 0; } #define rep(...) \ _vcppunko4((__VA_ARGS__, _trep4, _trep3, _trep2, _rep1))((__VA_ARGS__)) #define rrep(...) \ _vcppunko4((__VA_ARGS__, _trrep4, _trrep3, _trrep2, _rrep1))((__VA_ARGS__)) #define each(v) for (auto &i : v) #define lin(...) \ lint __VA_ARGS__; \ in(__VA_ARGS__) #define stin(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define vin(type, name, size) \ vector<type> name(size); \ in(name) #define fi e.first #define se e.second #define YES(c) cout << ((c) ? "YES\n" : "NO\n"), 0 #define Yes(c) cout << ((c) ? "Yes\n" : "No\n"), 0 #define o(p) cout << p << endl, 0 #define sp(p) cout << p << " " #define no(p) cout << p #ifdef __ENV_TQK__ #define deb(p) cout << p << endl, 0 #else #define deb(p) 0 #endif #define dd(n) cout << fixed << setprecision(n) // mint #define md_tmp template <uint_fast64_t md = 1000000007> md_tmp class mint { using u64 = uint_fast64_t; public: u64 a; constexpr mint(const u64 x = 0) noexcept : a(x % md) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr mint operator+(const mint rhs) const noexcept { return mint(*this) += rhs; } constexpr mint operator-(const mint rhs) const noexcept { return mint(*this) -= rhs; } constexpr mint operator*(const mint rhs) const noexcept { return mint(*this) *= rhs; } constexpr mint operator^(const lint rhs) const noexcept { return mint(*this) ^= rhs; } constexpr mint operator/(const mint rhs) const noexcept { return mint(*this) /= rhs; } constexpr mint &operator+=(const mint rhs) noexcept { a += rhs.a; if (a >= md) a -= md; return *this; } constexpr mint &operator-=(const mint rhs) noexcept { if (a < rhs.a) a += md; a -= rhs.a; return *this; } constexpr mint &operator*=(const mint rhs) noexcept { a = a * rhs.a % md; return *this; } constexpr mint &operator^=(const lint rhs) noexcept { if (!rhs) return *this = 1; u64 exp = rhs - 1; mint base = this->a; while (exp) { if (exp & 1) *this *= base; base *= base; exp >>= 1; } return *this; } constexpr mint &operator/=(const mint rhs) noexcept { a = (*this * (rhs ^ (md - 2))).a; return *this; } }; md_tmp istream &operator>>(istream &os, mint<md> &m) { os >> m.a, m.a %= md; return os; } md_tmp ostream &operator<<(ostream &os, const mint<md> &m) { return os << m.a; } md_tmp mint<md> ncr(lint n, lint r) { if (n < r || n < 0 || r < 0) return mint<md>(0); mint<md> ncr_res = 1, ncr_div = 1; rep(r) ncr_res *= (n - i), ncr_div *= (r - i); return ncr_res / ncr_div; } #ifndef _AOJ_ mint<> operator"" m(unsigned long long n) { return mint<>(n); } mint<998244353> operator"" m9(unsigned long long n) { return mint<998244353>(n); } mint<1000003> operator"" m3(unsigned long long n) { return mint<1000003>(n); } #endif using mi = mint<>; // P class P { public: lint f, s; constexpr P(lint a, lint b) : f(a), s(b){}; constexpr P() : f(0), s(0){}; }; istream &operator>>(istream &is, P &p) { is >> p.f >> p.s; return is; } ostream &operator<<(ostream &os, const P &p) { return os << p.f << " " << p.s << endl; } bool operator<(const P &l, const P &r) { return (l.f - r.f ? l.f < r.f : l.s < r.s); } bool operator>(const P &l, const P &r) { return (l.f - r.f ? l.f > r.f : l.s > r.s); } struct C { lint f, s, t; }; bool operator<(const C &l, const C &r) { return l.t < r.t; } bool operator>(const C &l, const C &r) { return l.t > r.t; } #define linf 1152921504606846976 #define inf linf // INT_MAX #define MAXN 200100 #define md_1e9_7 1000000007 #define md_998244353 998244353 //#define mod md_1e9_7 const int d4[5] = {0, 1, 0, -1, 0}; int main() { lin(n); vin(lint, a, n); a.erase(unique(all(a)), a.end()); n = a.size(); vector<mi> dp(n + 1), sum(200200); dp[0] = 1; rep(n) { dp[i + 1] = sum[a[i]] += dp[i]; } o(dp[n]); } // sub-EOF
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,225
907,226
u675296835
cpp
p03096
//#define _AOJ_ /*vvv> zzzzzI .---. zzuzuI .vgggg&,. +++++= dAC:|I .WbbWo JMM9^```?TMB` ..&gNNg,. gggggggJ, qgggggggg] (&&&&&&&&[ c+OA&J, (&&&&&&+J, .cJeAA&-. (&&&&&&&&x .&AA&=-. +++++= dTqk|I Xpbpbp JM#` (M#^ ?MMp MM| +TMN. JMF ' |yk ` dVY 7Vk, Vy XV cVf ?Y! JM V$ ` +++++= dcf:|I Xppppp dMN .MM+ .MM MM| MM] JMMMMMM+ |@tqkoh) ,y0 (V$ yyyyyyyV7 VV JMWyZWr TWVVVVW&, ++++++ d7qk|0 Xppppp ^HMN, _.db WMm, .MMF MM| ..MM` JMF . |yk .WV&. .XW' yy 4yn. jyn +. JM #S `++++` ?ZZZX= ?WWWW= -THMMMMH9^ (TMMMMM9! MMMMMMM"" JMMMMMMMME |UU. ?TUUUUY= UU. (UU- ^7TUUUV7! JUUUUUUUU 7TUNKO*/ // Ricty Diminished #include "bits/stdc++.h" using namespace std; typedef long long lint; typedef vector<lint> liv; //#define rep(i,n) for(int i=0;i<n;++i) #define all(v) v.begin(), v.end() #define pb push_back #define _vcppunko4(tuple) _getname4 tuple #define _getname4(_1, _2, _3, _4, name, ...) name #define _getname3(_1, _2, _3, name, ...) name #define _trep2(tuple) _rep2 tuple #define _trep3(tuple) _rep3 tuple #define _trep4(tuple) _rep4 tuple #define _rep1(n) for (lint i = 0; i < n; ++i) #define _rep2(i, n) for (lint i = 0; i < n; ++i) #define _rep3(i, a, b) for (lint i = a; i < b; ++i) #define _rep4(i, a, b, c) for (lint i = a; i < b; i += c) #define _trrep2(tuple) _rrep2 tuple #define _trrep3(tuple) _rrep3 tuple #define _trrep4(tuple) _rrep4 tuple #define _rrep1(n) for (lint i = n - 1; i >= 0; --i) #define _rrep2(i, n) for (lint i = n - 1; i >= 0; --i) #define _rrep3(i, a, b) for (lint i = b - 1; i >= a; --i) #define _rrep4(i, a, b, c) \ for (lint i = a + (b - a - 1) / c * c; i >= a; i -= c) template <class T> istream &operator>>(istream &is, vector<T> &vec); template <class T, size_t size> istream &operator>>(istream &is, array<T, size> &vec); template <class T, class L> istream &operator>>(istream &is, pair<T, L> &p); template <class T> ostream &operator<<(ostream &os, vector<T> &vec); template <class T, class L> ostream &operator<<(ostream &os, pair<T, L> &p); template <class T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } template <class T, class L> istream &operator>>(istream &is, pair<T, L> &p) { is >> p.first; is >> p.second; return is; } // template<class T> // ostream& operator<<(ostream& os,vector<T>& vec){ // os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; } template<class T> // ostream& operator<<(ostream& os,deque<T>& deq){ // os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; } template <class T, class L> ostream &operator<<(ostream &os, pair<T, L> &p) { os << p.first << " " << p.second; return os; } inline void in() {} template <class Head, class... Tail> inline void in(Head &&head, Tail &&...tail) { cin >> head; in(move(tail)...); } template <class T> inline bool out(T t) { cout << t << '\n'; return 0; } inline bool out() { cout << '\n'; return 0; } template <class Head, class... Tail> inline bool out(Head head, Tail... tail) { cout << head << ' '; out(move(tail)...); return 0; } #define rep(...) \ _vcppunko4((__VA_ARGS__, _trep4, _trep3, _trep2, _rep1))((__VA_ARGS__)) #define rrep(...) \ _vcppunko4((__VA_ARGS__, _trrep4, _trrep3, _trrep2, _rrep1))((__VA_ARGS__)) #define each(v) for (auto &i : v) #define lin(...) \ lint __VA_ARGS__; \ in(__VA_ARGS__) #define stin(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define vin(type, name, size) \ vector<type> name(size); \ in(name) #define fi e.first #define se e.second #define YES(c) cout << ((c) ? "YES\n" : "NO\n"), 0 #define Yes(c) cout << ((c) ? "Yes\n" : "No\n"), 0 #define o(p) cout << p << endl, 0 #define sp(p) cout << p << " " #define no(p) cout << p #ifdef __ENV_TQK__ #define deb(p) cout << p << endl, 0 #else #define deb(p) 0 #endif #define dd(n) cout << fixed << setprecision(n) // mint #define md_tmp template <uint_fast64_t md = 1000000007> md_tmp class mint { using u64 = uint_fast64_t; public: u64 a; constexpr mint(const u64 x = 0) noexcept : a(x % md) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr mint operator+(const mint rhs) const noexcept { return mint(*this) += rhs; } constexpr mint operator-(const mint rhs) const noexcept { return mint(*this) -= rhs; } constexpr mint operator*(const mint rhs) const noexcept { return mint(*this) *= rhs; } constexpr mint operator^(const lint rhs) const noexcept { return mint(*this) ^= rhs; } constexpr mint operator/(const mint rhs) const noexcept { return mint(*this) /= rhs; } constexpr mint &operator+=(const mint rhs) noexcept { a += rhs.a; if (a >= md) a -= md; return *this; } constexpr mint &operator-=(const mint rhs) noexcept { if (a < rhs.a) a += md; a -= rhs.a; return *this; } constexpr mint &operator*=(const mint rhs) noexcept { a = a * rhs.a % md; return *this; } constexpr mint &operator^=(const lint rhs) noexcept { if (!rhs) return *this = 1; u64 exp = rhs - 1; mint base = this->a; while (exp) { if (exp & 1) *this *= base; base *= base; exp >>= 1; } return *this; } constexpr mint &operator/=(const mint rhs) noexcept { a = (*this * (rhs ^ (md - 2))).a; return *this; } }; md_tmp istream &operator>>(istream &os, mint<md> &m) { os >> m.a, m.a %= md; return os; } md_tmp ostream &operator<<(ostream &os, const mint<md> &m) { return os << m.a; } md_tmp mint<md> ncr(lint n, lint r) { if (n < r || n < 0 || r < 0) return mint<md>(0); mint<md> ncr_res = 1, ncr_div = 1; rep(r) ncr_res *= (n - i), ncr_div *= (r - i); return ncr_res / ncr_div; } #ifndef _AOJ_ mint<> operator"" m(unsigned long long n) { return mint<>(n); } mint<998244353> operator"" m9(unsigned long long n) { return mint<998244353>(n); } mint<1000003> operator"" m3(unsigned long long n) { return mint<1000003>(n); } #endif using mi = mint<>; // P class P { public: lint f, s; constexpr P(lint a, lint b) : f(a), s(b){}; constexpr P() : f(0), s(0){}; }; istream &operator>>(istream &is, P &p) { is >> p.f >> p.s; return is; } ostream &operator<<(ostream &os, const P &p) { return os << p.f << " " << p.s << endl; } bool operator<(const P &l, const P &r) { return (l.f - r.f ? l.f < r.f : l.s < r.s); } bool operator>(const P &l, const P &r) { return (l.f - r.f ? l.f > r.f : l.s > r.s); } struct C { lint f, s, t; }; bool operator<(const C &l, const C &r) { return l.t < r.t; } bool operator>(const C &l, const C &r) { return l.t > r.t; } #define linf 1152921504606846976 #define inf linf // INT_MAX #define MAXN 200100 #define md_1e9_7 1000000007 #define md_998244353 998244353 //#define mod md_1e9_7 const int d4[5] = {0, 1, 0, -1, 0}; int main() { lin(n); vin(lint, a, n); a.erase(unique(all(a)), a.end()); a.shrink_to_fit(); n = a.size(); vector<mi> dp(n + 1), sum(n + 1); dp[0] = 1; rep(n) { dp[i + 1] = sum[a[i]] += dp[i]; } o(dp[n]); } // sub-EOF
//#define _AOJ_ /*vvv> zzzzzI .---. zzuzuI .vgggg&,. +++++= dAC:|I .WbbWo JMM9^```?TMB` ..&gNNg,. gggggggJ, qgggggggg] (&&&&&&&&[ c+OA&J, (&&&&&&+J, .cJeAA&-. (&&&&&&&&x .&AA&=-. +++++= dTqk|I Xpbpbp JM#` (M#^ ?MMp MM| +TMN. JMF ' |yk ` dVY 7Vk, Vy XV cVf ?Y! JM V$ ` +++++= dcf:|I Xppppp dMN .MM+ .MM MM| MM] JMMMMMM+ |@tqkoh) ,y0 (V$ yyyyyyyV7 VV JMWyZWr TWVVVVW&, ++++++ d7qk|0 Xppppp ^HMN, _.db WMm, .MMF MM| ..MM` JMF . |yk .WV&. .XW' yy 4yn. jyn +. JM #S `++++` ?ZZZX= ?WWWW= -THMMMMH9^ (TMMMMM9! MMMMMMM"" JMMMMMMMME |UU. ?TUUUUY= UU. (UU- ^7TUUUV7! JUUUUUUUU 7TUNKO*/ // Ricty Diminished #include "bits/stdc++.h" using namespace std; typedef long long lint; typedef vector<lint> liv; //#define rep(i,n) for(int i=0;i<n;++i) #define all(v) v.begin(), v.end() #define pb push_back #define _vcppunko4(tuple) _getname4 tuple #define _getname4(_1, _2, _3, _4, name, ...) name #define _getname3(_1, _2, _3, name, ...) name #define _trep2(tuple) _rep2 tuple #define _trep3(tuple) _rep3 tuple #define _trep4(tuple) _rep4 tuple #define _rep1(n) for (lint i = 0; i < n; ++i) #define _rep2(i, n) for (lint i = 0; i < n; ++i) #define _rep3(i, a, b) for (lint i = a; i < b; ++i) #define _rep4(i, a, b, c) for (lint i = a; i < b; i += c) #define _trrep2(tuple) _rrep2 tuple #define _trrep3(tuple) _rrep3 tuple #define _trrep4(tuple) _rrep4 tuple #define _rrep1(n) for (lint i = n - 1; i >= 0; --i) #define _rrep2(i, n) for (lint i = n - 1; i >= 0; --i) #define _rrep3(i, a, b) for (lint i = b - 1; i >= a; --i) #define _rrep4(i, a, b, c) \ for (lint i = a + (b - a - 1) / c * c; i >= a; i -= c) template <class T> istream &operator>>(istream &is, vector<T> &vec); template <class T, size_t size> istream &operator>>(istream &is, array<T, size> &vec); template <class T, class L> istream &operator>>(istream &is, pair<T, L> &p); template <class T> ostream &operator<<(ostream &os, vector<T> &vec); template <class T, class L> ostream &operator<<(ostream &os, pair<T, L> &p); template <class T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } template <class T, class L> istream &operator>>(istream &is, pair<T, L> &p) { is >> p.first; is >> p.second; return is; } // template<class T> // ostream& operator<<(ostream& os,vector<T>& vec){ // os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; } template<class T> // ostream& operator<<(ostream& os,deque<T>& deq){ // os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; } template <class T, class L> ostream &operator<<(ostream &os, pair<T, L> &p) { os << p.first << " " << p.second; return os; } inline void in() {} template <class Head, class... Tail> inline void in(Head &&head, Tail &&...tail) { cin >> head; in(move(tail)...); } template <class T> inline bool out(T t) { cout << t << '\n'; return 0; } inline bool out() { cout << '\n'; return 0; } template <class Head, class... Tail> inline bool out(Head head, Tail... tail) { cout << head << ' '; out(move(tail)...); return 0; } #define rep(...) \ _vcppunko4((__VA_ARGS__, _trep4, _trep3, _trep2, _rep1))((__VA_ARGS__)) #define rrep(...) \ _vcppunko4((__VA_ARGS__, _trrep4, _trrep3, _trrep2, _rrep1))((__VA_ARGS__)) #define each(v) for (auto &i : v) #define lin(...) \ lint __VA_ARGS__; \ in(__VA_ARGS__) #define stin(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define vin(type, name, size) \ vector<type> name(size); \ in(name) #define fi e.first #define se e.second #define YES(c) cout << ((c) ? "YES\n" : "NO\n"), 0 #define Yes(c) cout << ((c) ? "Yes\n" : "No\n"), 0 #define o(p) cout << p << endl, 0 #define sp(p) cout << p << " " #define no(p) cout << p #ifdef __ENV_TQK__ #define deb(p) cout << p << endl, 0 #else #define deb(p) 0 #endif #define dd(n) cout << fixed << setprecision(n) // mint #define md_tmp template <uint_fast64_t md = 1000000007> md_tmp class mint { using u64 = uint_fast64_t; public: u64 a; constexpr mint(const u64 x = 0) noexcept : a(x % md) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr mint operator+(const mint rhs) const noexcept { return mint(*this) += rhs; } constexpr mint operator-(const mint rhs) const noexcept { return mint(*this) -= rhs; } constexpr mint operator*(const mint rhs) const noexcept { return mint(*this) *= rhs; } constexpr mint operator^(const lint rhs) const noexcept { return mint(*this) ^= rhs; } constexpr mint operator/(const mint rhs) const noexcept { return mint(*this) /= rhs; } constexpr mint &operator+=(const mint rhs) noexcept { a += rhs.a; if (a >= md) a -= md; return *this; } constexpr mint &operator-=(const mint rhs) noexcept { if (a < rhs.a) a += md; a -= rhs.a; return *this; } constexpr mint &operator*=(const mint rhs) noexcept { a = a * rhs.a % md; return *this; } constexpr mint &operator^=(const lint rhs) noexcept { if (!rhs) return *this = 1; u64 exp = rhs - 1; mint base = this->a; while (exp) { if (exp & 1) *this *= base; base *= base; exp >>= 1; } return *this; } constexpr mint &operator/=(const mint rhs) noexcept { a = (*this * (rhs ^ (md - 2))).a; return *this; } }; md_tmp istream &operator>>(istream &os, mint<md> &m) { os >> m.a, m.a %= md; return os; } md_tmp ostream &operator<<(ostream &os, const mint<md> &m) { return os << m.a; } md_tmp mint<md> ncr(lint n, lint r) { if (n < r || n < 0 || r < 0) return mint<md>(0); mint<md> ncr_res = 1, ncr_div = 1; rep(r) ncr_res *= (n - i), ncr_div *= (r - i); return ncr_res / ncr_div; } #ifndef _AOJ_ mint<> operator"" m(unsigned long long n) { return mint<>(n); } mint<998244353> operator"" m9(unsigned long long n) { return mint<998244353>(n); } mint<1000003> operator"" m3(unsigned long long n) { return mint<1000003>(n); } #endif using mi = mint<>; // P class P { public: lint f, s; constexpr P(lint a, lint b) : f(a), s(b){}; constexpr P() : f(0), s(0){}; }; istream &operator>>(istream &is, P &p) { is >> p.f >> p.s; return is; } ostream &operator<<(ostream &os, const P &p) { return os << p.f << " " << p.s << endl; } bool operator<(const P &l, const P &r) { return (l.f - r.f ? l.f < r.f : l.s < r.s); } bool operator>(const P &l, const P &r) { return (l.f - r.f ? l.f > r.f : l.s > r.s); } struct C { lint f, s, t; }; bool operator<(const C &l, const C &r) { return l.t < r.t; } bool operator>(const C &l, const C &r) { return l.t > r.t; } #define linf 1152921504606846976 #define inf linf // INT_MAX #define MAXN 200100 #define md_1e9_7 1000000007 #define md_998244353 998244353 //#define mod md_1e9_7 const int d4[5] = {0, 1, 0, -1, 0}; int main() { lin(n); vin(lint, a, n); a.erase(unique(all(a)), a.end()); a.shrink_to_fit(); n = a.size(); vector<mi> dp(n + 1), sum(200200); dp[0] = 1; rep(n) { dp[i + 1] = sum[a[i]] += dp[i]; } o(dp[n]); } // sub-EOF
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,227
907,228
u675296835
cpp
p03096
#include <algorithm> // minmax, sort, swap #include <climits> // INT_MIN, LLONG_MIN #include <cmath> // long, trig, pow #include <cstdio> // printf, scanf #include <deque> // deque #include <functional> // std::function<void(int)> #include <iomanip> // cout<<setprecision(n) #include <iostream> // cin, cout, cerr, clog #include <map> // key-value pairs sorted by keys #include <numeric> // iota, accumulate, inner_product #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, stoi, to_string #include <unordered_map> // hashed by keys #include <unordered_set> // hashed by keys #include <vector> // vector #define rep(i, n) for (int i = 0; i < (n); i++) #define ENDL '\n' #define print(i) std::cout << (i) << '\n' #define int long long // at least int64 > 9*10^18 #define all(v) (v).begin(), (v).end() /* libraries */ #define dump1(v) \ for (auto i : v) \ std::cout << i << ' '; \ std::cout << "\n"; #define dump2(v) \ for (auto i : v) { \ for (auto j : i) \ std::cout << j << ' '; \ std::cout << "\n"; \ } const int MOD = 1e9 + 7; signed main() { int n; std::cin >> n; std::vector<int> c; rep(i, n) { int a; std::cin >> a; if (i == 0) c.emplace_back(a); else if (c.back() != a) c.emplace_back(a); } n = c.size(); std::vector<int> dp(n, 0); std::map<int, std::vector<int>> map; dp[0] = 1; map[c[0]].emplace_back(0); for (int i = 1; i < n; i++) { int sum = dp[i - 1]; if (!map[c[i]].empty()) { int x = map[c[i]].back(); sum += dp[x]; sum %= MOD; } dp[i] = sum; map[c[i]].emplace_back(i); } dump1(dp); print(dp[n - 1]); return 0; }
#include <algorithm> // minmax, sort, swap #include <climits> // INT_MIN, LLONG_MIN #include <cmath> // long, trig, pow #include <cstdio> // printf, scanf #include <deque> // deque #include <functional> // std::function<void(int)> #include <iomanip> // cout<<setprecision(n) #include <iostream> // cin, cout, cerr, clog #include <map> // key-value pairs sorted by keys #include <numeric> // iota, accumulate, inner_product #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, stoi, to_string #include <unordered_map> // hashed by keys #include <unordered_set> // hashed by keys #include <vector> // vector #define rep(i, n) for (int i = 0; i < (n); i++) #define ENDL '\n' #define print(i) std::cout << (i) << '\n' #define int long long // at least int64 > 9*10^18 #define all(v) (v).begin(), (v).end() /* libraries */ #define dump1(v) \ for (auto i : v) \ std::cout << i << ' '; \ std::cout << "\n"; #define dump2(v) \ for (auto i : v) { \ for (auto j : i) \ std::cout << j << ' '; \ std::cout << "\n"; \ } const int MOD = 1e9 + 7; signed main() { int n; std::cin >> n; std::vector<int> c; rep(i, n) { int a; std::cin >> a; if (i == 0) c.emplace_back(a); else if (c.back() != a) c.emplace_back(a); } n = c.size(); std::vector<int> dp(n, 0); std::map<int, std::vector<int>> map; dp[0] = 1; map[c[0]].emplace_back(0); for (int i = 1; i < n; i++) { int sum = dp[i - 1]; if (!map[c[i]].empty()) { int x = map[c[i]].back(); sum += dp[x]; sum %= MOD; } dp[i] = sum; map[c[i]].emplace_back(i); } print(dp[n - 1]); return 0; }
[ "call.remove" ]
907,233
907,234
u128456980
cpp
p03096
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; typedef vector<cd> vcd; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define f0x(i, a, b) for (int i = (a); i < (b); i++) #define fax(i, a) for (int i = 0; i < (a); i++) #define faxd(i, a, b) for (int i = (b)-1; i >= (a); i--) #define f0xd(i, a) for (int i = (a)-1; i >= 0; i--) #define trav(a, x) for (auto &a : x) #define mp make_pair #define pb push_back #define f first #define s second #define lb lower_bound #define ub upper_bound #define sz(x) (int)x.size() #define all(x) begin(x), end(x) #define rsz resize const int MOD = 1000000007; // 998244353 const ll INF = 1e18; const int MX = 200005; const ld PI = 4 * atan((ld)1); template <class T> void ckmin(T &a, T b) { a = min(a, b); } template <class T> void ckmax(T &a, T b) { a = max(a, b); } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll C[MX]; ll dp[MX]; map<ll, int> dpCnt; vl vals; // dp[i] = sum of dp[C[i]] so far + int main() { int N; cin >> N; fax(i, N) { cin >> C[i]; } fax(i, N - 1) { if (C[i] == C[i + 1]) { continue; } else { vals.pb(C[i]); } } vals.pb(C[N - 1]); dp[0] = 1; dpCnt[C[0]] = 1; f0x(i, 1, sz(vals)) { dp[i] = dp[i - 1] + dpCnt[C[i]]; dp[i] %= MOD; dpCnt[C[i]] = dp[i]; } cout << dp[sz(vals) - 1] % MOD << "\n"; }
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; typedef vector<cd> vcd; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define f0x(i, a, b) for (int i = (a); i < (b); i++) #define fax(i, a) for (int i = 0; i < (a); i++) #define faxd(i, a, b) for (int i = (b)-1; i >= (a); i--) #define f0xd(i, a) for (int i = (a)-1; i >= 0; i--) #define trav(a, x) for (auto &a : x) #define mp make_pair #define pb push_back #define f first #define s second #define lb lower_bound #define ub upper_bound #define sz(x) (int)x.size() #define all(x) begin(x), end(x) #define rsz resize const int MOD = 1000000007; // 998244353 const ll INF = 1e18; const int MX = 200005; const ld PI = 4 * atan((ld)1); template <class T> void ckmin(T &a, T b) { a = min(a, b); } template <class T> void ckmax(T &a, T b) { a = max(a, b); } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll C[MX]; ll dp[MX]; map<ll, int> dpCnt; vl vals; // dp[i] = sum of dp[C[i]] so far + int main() { int N; cin >> N; fax(i, N) { cin >> C[i]; } fax(i, N - 1) { if (C[i] == C[i + 1]) { continue; } else { vals.pb(C[i]); } } vals.pb(C[N - 1]); dp[0] = 1; dpCnt[C[0]] = 1; f0x(i, 1, sz(vals)) { dp[i] = dp[i - 1] + dpCnt[vals[i]]; dp[i] %= MOD; dpCnt[vals[i]] = dp[i]; } cout << dp[sz(vals) - 1] % MOD << "\n"; }
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change", "assignment.variable.change" ]
907,237
907,238
u728498447
cpp
p03096
#include <bits/stdc++.h> using namespace std; int main() { const int mod = 1000000007; int n, patterns = 1, prev = 0; cin >> n; vector<int> p(n + 1); for (int i = 0; i < n; i++) { int c, w; cin >> c; if (c == prev) continue; w = (patterns + p.at(c)) % mod; patterns = w; p.at(c) = w; prev = c; } cout << patterns << endl; }
#include <bits/stdc++.h> using namespace std; int main() { const int mod = 1000000007; int n, patterns = 1, prev = 0; cin >> n; vector<int> p(200001); for (int i = 0; i < n; i++) { int c, w; cin >> c; if (c == prev) continue; w = (patterns + p.at(c)) % mod; patterns = w; p.at(c) = w; prev = c; } cout << patterns << endl; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,243
907,244
u697658632
cpp
p03096
#include <bits/stdc++.h> #define maxn 200010 #define mod 1000000007 using namespace std; int a[maxn], f[maxn], sum[maxn]; int main() { int n, cur = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); if (cur == 0 || x != a[cur]) a[++cur] = x; } f[0] = 1; for (int i = 1; i <= n; i++) { sum[a[i]] = (sum[a[i]] + f[i - 1]) % mod; f[i] = sum[a[i]]; } printf("%d\n", f[n]); return 0; }
#include <bits/stdc++.h> #define maxn 200010 #define mod 1000000007 using namespace std; int a[maxn], f[maxn], sum[maxn]; int main() { int n, cur = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); if (cur == 0 || x != a[cur]) a[++cur] = x; } f[0] = 1; for (int i = 1; i <= cur; i++) { sum[a[i]] = (sum[a[i]] + f[i - 1]) % mod; f[i] = sum[a[i]]; } printf("%d\n", f[cur]); return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "variable_access.subscript.index.change", "call.arguments.change", "io.output.change" ]
907,265
907,266
u276642373
cpp
p03096
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; typedef long long ll; int main() { ll N; cin >> N; vector<ll> C; for (int i = 0; i < N; i++) { int c; cin >> c; if (i == 0) { C.emplace_back(c); } else if (C.back() != c) { C.emplace_back(c); } } vector<ll> dp(200010, 0LL); dp[0] = 1LL; vector<ll> num(N + 1, 0); for (int i = 0; i < C.size(); i++) { dp[i] += num[C[i]]; dp[i] %= mod; if (i == 0) { num[C[i]] = 1LL; } else { num[C[i]] += dp[i - 1]; } if (i > 0) dp[i] += dp[i - 1]; dp[i] %= mod; } cout << dp[C.size() - 1] << endl; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; typedef long long ll; int main() { ll N; cin >> N; vector<ll> C; for (int i = 0; i < N; i++) { int c; cin >> c; if (i == 0) { C.emplace_back(c); } else if (C.back() != c) { C.emplace_back(c); } } vector<ll> dp(200010, 0LL); dp[0] = 1LL; vector<ll> num(200010, 0); for (int i = 0; i < C.size(); i++) { dp[i] += num[C[i]]; dp[i] %= mod; if (i == 0) { num[C[i]] = 1LL; } else { num[C[i]] += dp[i - 1]; } if (i > 0) dp[i] += dp[i - 1]; dp[i] %= mod; } cout << dp[C.size() - 1] << endl; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,267
907,268
u413492096
cpp
p03096
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; ll const MOD = 1e9 + 7; int main() { int N; cin >> N; vi C; for (int i = 0; i < N; ++i) { int c; cin >> c; C.push_back(c); } ll dp[N]; ll c_cum[N + 1]; memset(c_cum, 0, sizeof(c_cum)); dp[0] = 1; c_cum[C[0]] = 1; if (N != 1) { for (int i = 1; i < N; ++i) { if (C[i - 1] != C[i]) (c_cum[C[i]] += dp[i - 1]) %= MOD; dp[i] = c_cum[C[i]]; } } cout << dp[N - 1] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; ll const MOD = 1e9 + 7; int main() { int N; cin >> N; vi C; for (int i = 0; i < N; ++i) { int c; cin >> c; C.push_back(c); } ll dp[200010]; ll c_cum[200010]; memset(c_cum, 0, sizeof(c_cum)); dp[0] = 1; c_cum[C[0]] = 1; if (N != 1) { for (int i = 1; i < N; ++i) { if (C[i - 1] != C[i]) (c_cum[C[i]] += dp[i - 1]) %= MOD; dp[i] = c_cum[C[i]]; } } cout << dp[N - 1] << endl; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "variable_declaration.array_dimensions.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,278
907,279
u826487371
cpp
p03096
#include <bits/stdc++.h> using namespace std; #define reps(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) reps(i, 0, n) int N; int mod = 1000000007; int main() { int mx = 200000; cin >> N; vector<int> memoi(N, 0); vector<int> memoans(mx, 0); unsigned int ans = 1; int nowc; rep(i, N) { cin >> nowc; int fir = memoi[nowc], sec = memoans[nowc]; if (sec != 0 && fir != i - 1) { ans += sec; ans = ans % mod; } memoi[nowc] = i; memoans[nowc] = ans; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define reps(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) reps(i, 0, n) int N; int mod = 1000000007; int main() { int mx = 200000; cin >> N; vector<int> memoi(mx, 0); vector<int> memoans(mx, 0); unsigned int ans = 1; int nowc; rep(i, N) { cin >> nowc; int fir = memoi[nowc], sec = memoans[nowc]; if (sec != 0 && fir != i - 1) { ans += sec; ans = ans % mod; } memoi[nowc] = i; memoans[nowc] = ans; } cout << ans << endl; }
[ "identifier.change", "call.arguments.change" ]
907,281
907,282
u016531517
cpp
p03096
#include <bits/stdc++.h> using namespace std; #define reps(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) reps(i, 0, n) int N; int mod = 1000000007; int main() { int mx = 200000; cin >> N; vector<int> memoi(N, 0); vector<int> memoans(mx, 0); unsigned int ans = 1; int nowc; rep(i, N) { cin >> nowc; int fir = memoi[nowc], sec = memoans[nowc]; if (sec != 0 && fir != i - 1) { ans += sec; ans = ans % mod; } memoi[nowc] = i; memoans[nowc] = ans; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define reps(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) reps(i, 0, n) int N; int mod = 1000000007; int main() { int mx = 300000; cin >> N; vector<int> memoi(mx, 0); vector<int> memoans(mx, 0); unsigned int ans = 1; int nowc; rep(i, N) { cin >> nowc; int fir = memoi[nowc], sec = memoans[nowc]; if (sec != 0 && fir != i - 1) { ans += sec; ans = ans % mod; } memoi[nowc] = i; memoans[nowc] = ans; } cout << ans << endl; }
[ "literal.number.change", "variable_declaration.value.change", "identifier.change", "call.arguments.change" ]
907,281
907,283
u016531517
cpp
p03096
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define getchar getchar_unlocked #define putchar putchar_unlocked #define pb push_back #define mp make_pair #define Would #define you #define please int getint() { char C; while (!isdigit(C = getchar())) ; int A = C - '0'; while (isdigit(C = getchar())) A = A * 10 + C - '0'; return A; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; N = getint(); int A[200001] = {}; int mae = 0; ll kotae = 1; ll mod = 1e9 + 7; rep(i, N) { int C; C = getint(); if (mae != C) kotae = (kotae + A[C]) % mod; A[C] = kotae; mae = C; } Would you please return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define getchar getchar_unlocked #define putchar putchar_unlocked #define pb push_back #define mp make_pair #define Would #define you #define please int getint() { char C; while (!isdigit(C = getchar())) ; int A = C - '0'; while (isdigit(C = getchar())) A = A * 10 + C - '0'; return A; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; N = getint(); int A[200001] = {}; int mae = 0; ll kotae = 1; ll mod = 1e9 + 7; rep(i, N) { int C; C = getint(); if (mae != C) kotae = (kotae + A[C]) % mod; A[C] = kotae; mae = C; } co(kotae); Would you please return 0; }
[ "call.add" ]
907,286
907,287
u096883693
cpp
p03096
#include <iostream> #include <vector> int main() { long long mod = 1000000007; int n; std::vector<int> aList; std::vector<int> colorList; std::vector<long long> dpList; std::cin >> n; aList.resize(n); colorList.resize(n + 1, -1); dpList.resize(n, 0); for (int i = 0; i < n; i++) std::cin >> aList[i]; dpList[0] = 1; colorList[aList[0]] = 0; for (int i = 1; i < n; i++) { dpList[i] = dpList[i - 1]; if (aList[i] != aList[i - 1]) if (colorList[aList[i]] >= 0) dpList[i] = (dpList[i] + dpList[colorList[aList[i]]]) % mod; colorList[aList[i]] = i; } std::cout << dpList[n - 1] << std::endl; return 0; }
#include <iostream> #include <vector> int main() { long long mod = 1000000007; int n; std::vector<int> aList; std::vector<int> colorList; std::vector<long long> dpList; std::cin >> n; aList.resize(n); colorList.resize(200001, -1); dpList.resize(n, 0); for (int i = 0; i < n; i++) std::cin >> aList[i]; dpList[0] = 1; colorList[aList[0]] = 0; for (int i = 1; i < n; i++) { dpList[i] = dpList[i - 1]; if (aList[i] != aList[i - 1]) if (colorList[aList[i]] >= 0) dpList[i] = (dpList[i] + dpList[colorList[aList[i]]]) % mod; colorList[aList[i]] = i; } std::cout << dpList[n - 1] << std::endl; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,302
907,303
u865621256
cpp
p03096
#include <iostream> #include <vector> int main() { long long mod = 1000000007; int n; std::vector<int> aList; std::vector<int> colorList; std::vector<long long> dpList; std::cin >> n; aList.resize(n); colorList.resize(n + 1, -1); dpList.resize(n, 0); for (int i = 0; i < n; i++) std::cin >> aList[i]; dpList[0] = 1; colorList[aList[0]] = 0; for (int i = 1; i < n; i++) { dpList[i] = dpList[i - 1]; if (aList[i] == aList[i - 1]) continue; if (colorList[aList[i]] >= 0) dpList[i] = (dpList[i] + dpList[colorList[aList[i]]]) % mod; colorList[aList[i]] = i; } std::cout << dpList[n - 1] << std::endl; return 0; }
#include <iostream> #include <vector> int main() { long long mod = 1000000007; int n; std::vector<int> aList; std::vector<int> colorList; std::vector<long long> dpList; std::cin >> n; aList.resize(n); colorList.resize(200001, -1); dpList.resize(n, 0); for (int i = 0; i < n; i++) std::cin >> aList[i]; dpList[0] = 1; colorList[aList[0]] = 0; for (int i = 1; i < n; i++) { dpList[i] = dpList[i - 1]; if (aList[i] != aList[i - 1]) if (colorList[aList[i]] >= 0) dpList[i] = (dpList[i] + dpList[colorList[aList[i]]]) % mod; colorList[aList[i]] = i; } std::cout << dpList[n - 1] << std::endl; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
907,304
907,303
u865621256
cpp
p03096
// i ll be the king #include <bits/stdc++.h> #define ll long long int #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define input(arr, n) \ for (ll i1 = 0; i1 < n; i1++) \ cin >> arr[i1] #define rep(n) for (ll i2 = 0; i2 < n; i2++) #define vmp(v, a, b) v.push_back(make_pair(a, b)) #define si(a) scanf("%lld", &a) #define pi(a) printf("%lld", a) #define aset(a, n, k) \ for (ll i3 = 0; i3 < n; i3++) \ a[i3] = k; #define mod 1000000007 #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ tree_order_statistics_node_update> using namespace std; int main() { sync; ll n; cin >> n; ll a[n]; input(a, n); map<ll, ll> mp; ll ans = 0, val = 0; vector<ll> arr; for (ll i = 0; i < n - 1; i++) if (a[i] != a[i + 1]) arr.push_back(a[i]); arr.push_back(a[n - 1]); for (ll i = 0; i < n; i++) { val = ans; if (mp[arr[i]]) ans = (ans + mp[arr[i]]) % mod; mp[arr[i]] = (mp[arr[i]] + 1 + val) % mod; } cout << ans + 1; }
// i ll be the king #include <bits/stdc++.h> #define ll long long int #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define input(arr, n) \ for (ll i1 = 0; i1 < n; i1++) \ cin >> arr[i1] #define rep(n) for (ll i2 = 0; i2 < n; i2++) #define vmp(v, a, b) v.push_back(make_pair(a, b)) #define si(a) scanf("%lld", &a) #define pi(a) printf("%lld", a) #define aset(a, n, k) \ for (ll i3 = 0; i3 < n; i3++) \ a[i3] = k; #define mod 1000000007 #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ tree_order_statistics_node_update> using namespace std; int main() { sync; ll n; cin >> n; ll a[n]; input(a, n); map<ll, ll> mp; ll ans = 0, val = 0; vector<ll> arr; for (ll i = 0; i < n - 1; i++) if (a[i] != a[i + 1]) arr.push_back(a[i]); arr.push_back(a[n - 1]); for (ll i = 0; i < arr.size(); i++) { val = ans; if (mp[arr[i]]) ans = (ans + mp[arr[i]]) % mod; mp[arr[i]] = (mp[arr[i]] + 1 + val) % mod; } cout << ans + 1; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.change", "call.add" ]
907,305
907,306
u181228520
cpp
p03096
#include <iostream> #include <vector> using namespace std; int N; int mod = 1e9 + 7; int main() { cin >> N; vector<long long> dp(N + 1, 1); vector<int> p(N + 1, -1); // p[i]: 最後の色iの位置 int c; cin >> c; p[c] = 1; dp[0] = 1; for (int i = 1; i < N; i++) { cin >> c; dp[i] = dp[i - 1]; if (p[c] > 0 && p[c] != i) { dp[i] += dp[p[c] - 1]; dp[i] %= mod; } p[c] = i + 1; } cout << dp[N - 1] << endl; }
#include <iostream> #include <vector> using namespace std; int N; int mod = 1e9 + 7; int main() { cin >> N; vector<long long> dp(N + 1, 1); vector<int> p(2e5 + 1, -1); // p[i]: 最後の色iの位置 int c; cin >> c; p[c] = 1; dp[0] = 1; for (int i = 1; i < N; i++) { cin >> c; dp[i] = dp[i - 1]; if (p[c] > 0 && p[c] != i) { dp[i] += dp[p[c] - 1]; dp[i] %= mod; } p[c] = i + 1; } cout << dp[N - 1] << endl; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change" ]
907,307
907,308
u430527172
cpp
p03096
#include <bits/stdc++.h> #define N 200010 using namespace std; const int p = 1e9 + 7; int n, cnt, x, a[N], pre; int dp[N], ans[N]; inline int read() { int x = 0, sgn = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1; for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return sgn * x; } int main() { n = read(); pre = -100; for (int i = 1; i <= n; i++) { x = read(); if (x == pre) continue; pre = x; a[++cnt] = x; } dp[1] = 1; ans[a[1]] = 1; for (int i = 2; i <= n; i++) { dp[i] = (dp[i - 1] + ans[a[i]]) % p; ans[a[i]] = dp[i]; } printf("%d", dp[n]); return 0; }
#include <bits/stdc++.h> #define N 200010 using namespace std; const int p = 1e9 + 7; int n, cnt, x, a[N], pre; long long dp[N], ans[N]; inline int read() { int x = 0, sgn = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1; for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return sgn * x; } int main() { n = read(); pre = -100; for (int i = 1; i <= n; i++) { x = read(); if (x == pre) continue; pre = x; a[++cnt] = x; } dp[1] = 1; ans[a[1]] = 1; for (int i = 2; i <= cnt; i++) { dp[i] = (dp[i - 1] + ans[a[i]]) % p; ans[a[i]] = dp[i]; } printf("%d", dp[cnt]); return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "variable_access.subscript.index.change", "call.arguments.change", "io.output.change" ]
907,311
907,312
u416562035
cpp
p03096
#include <bits/stdc++.h> #define N 100010 using namespace std; const int p = 1e9 + 7; int n, cnt, x, a[N], pre; int dp[N], ans[N]; inline int read() { int x = 0, sgn = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1; for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return sgn * x; } int main() { n = read(); pre = -100; for (int i = 1; i <= n; i++) { x = read(); if (x == pre) continue; pre = x; a[++cnt] = x; } dp[1] = 1; ans[a[1]] = 1; for (int i = 2; i <= n; i++) { dp[i] = (dp[i - 1] + ans[a[i]]) % p; ans[a[i]] = dp[i]; } printf("%d", dp[n]); return 0; }
#include <bits/stdc++.h> #define N 200010 using namespace std; const int p = 1e9 + 7; int n, cnt, x, a[N], pre; long long dp[N], ans[N]; inline int read() { int x = 0, sgn = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1; for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return sgn * x; } int main() { n = read(); pre = -100; for (int i = 1; i <= n; i++) { x = read(); if (x == pre) continue; pre = x; a[++cnt] = x; } dp[1] = 1; ans[a[1]] = 1; for (int i = 2; i <= cnt; i++) { dp[i] = (dp[i - 1] + ans[a[i]]) % p; ans[a[i]] = dp[i]; } printf("%d", dp[cnt]); return 0; }
[ "preprocessor.define.value.change", "literal.integer.change", "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "variable_access.subscript.index.change", "call.a...
907,313
907,312
u416562035
cpp
p03096
#include <bits/stdc++.h> using namespace std::literals::string_literals; using i64 = long long; using std::cin; using std::cout; using std::endl; int main() { int n; scanf("%d", &n); std::vector<int> c(n); for (int i = 0; i < n; i++) { scanf("%d", &c[i]); c[i]--; } const int M = 2e5 + 10; std::vector<int> latte(n, -1); std::vector<int> vec(M, -1); for (int i = 0; i < n; i++) { if (latte[c[i]] != -1 and latte[c[i]] + 1 != i) { vec[latte[c[i]]] = i; } latte[c[i]] = i; } const int MOD = 1e9 + 7; std::vector<int> dp(n + 1, 0); dp[0] = 1; for (int i = 0; i < n; i++) { (dp[i + 1] += dp[i]) %= MOD; if (vec[i] != -1) (dp[vec[i]] += dp[i]) %= MOD; } printf("%d\n", dp[n]); return 0; }
#include <bits/stdc++.h> using namespace std::literals::string_literals; using i64 = long long; using std::cin; using std::cout; using std::endl; int main() { int n; scanf("%d", &n); std::vector<int> c(n); for (int i = 0; i < n; i++) { scanf("%d", &c[i]); c[i]--; } const int M = 2e5 + 10; std::vector<int> latte(M, -1); std::vector<int> vec(n, -1); for (int i = 0; i < n; i++) { if (latte[c[i]] != -1 and latte[c[i]] + 1 != i) { vec[latte[c[i]]] = i; } latte[c[i]] = i; } const int MOD = 1e9 + 7; std::vector<int> dp(n + 1, 0); dp[0] = 1; for (int i = 0; i < n; i++) { (dp[i + 1] += dp[i]) %= MOD; if (vec[i] != -1) (dp[vec[i]] += dp[i]) %= MOD; } printf("%d\n", dp[n]); return 0; }
[ "identifier.change", "call.arguments.change" ]
907,323
907,324
u424655672
cpp
p03096
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; ///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!! typedef long long ll; typedef long double ld; #define all(a) (a).begin(), (a).end() const ll Mod = 1000000007; const ll mod = 998244353; struct H { ll x, y; bool operator<(const H &b) const { if (x != b.x) return x < b.x; return y < b.y; } bool operator>(const H &b) const { if (x != b.x) return x > b.x; return y > b.y; } bool operator==(const H &b) const { return x == b.x && y == b.y; } bool operator!=(const H &b) const { return (*this) != b; } }; struct P { ll pos, cost; bool operator<(const P &b) const { return cost < b.cost; } bool operator>(const P &b) const { return cost > b.cost; } }; struct B { ll to, cost; }; struct E { ll from, to, cost; bool operator<(const E &b) const { return cost < b.cost; } bool operator>(const E &b) const { return cost > b.cost; } }; template <typename T, typename U> void chmin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> void chmax(T &a, U b) { if (a < b) a = b; } template <typename T> T max_0(T a) { if (a < 0) return 0; return a; } template <typename T> T min_0(T a) { if (a > 0) return 0; return a; } ll read() { ll u; scanf("%lld", &u); return u; } ll gcd(ll i, ll j) { if (i > j) swap(i, j); if (i == 0) return j; return gcd(j % i, i); } ll mod_pow(ll x, ll n, ll p) { ll res = 1; while (n > 0) { if (n & 1) res = res * x % p; x = x * x % p; n >>= 1; } return res; } // x^n%p const ll Inf = 3023372036854775807; const int inf = 1500000000; #define int long long //---------------------------------------------------- int n; int a[300000]; int b[300000]; int c[300000]; signed main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } int m = 0; for (int i = 0; i < n;) { int j = i; while (j < n && a[i] == a[j]) { j++; } b[m++] = a[i]; i = j; } int ans = 1; for (int i = 0; i < m; i++) { ans += c[b[i]]; ans %= Mod; c[b[i]] += ans; c[b[i]] %= Mod; } cout << ans << endl; }
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; ///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!! typedef long long ll; typedef long double ld; #define all(a) (a).begin(), (a).end() const ll Mod = 1000000007; const ll mod = 998244353; struct H { ll x, y; bool operator<(const H &b) const { if (x != b.x) return x < b.x; return y < b.y; } bool operator>(const H &b) const { if (x != b.x) return x > b.x; return y > b.y; } bool operator==(const H &b) const { return x == b.x && y == b.y; } bool operator!=(const H &b) const { return (*this) != b; } }; struct P { ll pos, cost; bool operator<(const P &b) const { return cost < b.cost; } bool operator>(const P &b) const { return cost > b.cost; } }; struct B { ll to, cost; }; struct E { ll from, to, cost; bool operator<(const E &b) const { return cost < b.cost; } bool operator>(const E &b) const { return cost > b.cost; } }; template <typename T, typename U> void chmin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> void chmax(T &a, U b) { if (a < b) a = b; } template <typename T> T max_0(T a) { if (a < 0) return 0; return a; } template <typename T> T min_0(T a) { if (a > 0) return 0; return a; } ll read() { ll u; scanf("%lld", &u); return u; } ll gcd(ll i, ll j) { if (i > j) swap(i, j); if (i == 0) return j; return gcd(j % i, i); } ll mod_pow(ll x, ll n, ll p) { ll res = 1; while (n > 0) { if (n & 1) res = res * x % p; x = x * x % p; n >>= 1; } return res; } // x^n%p const ll Inf = 3023372036854775807; const int inf = 1500000000; #define int long long //---------------------------------------------------- int n; int a[300000]; int b[300000]; int c[300000]; signed main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } int m = 0; for (int i = 0; i < n;) { int j = i; while (j < n && a[i] == a[j]) { j++; } b[m++] = a[i]; i = j; } int ans = 1; for (int i = 0; i < m; i++) { ans += c[b[i]]; ans %= Mod; c[b[i]] = ans; c[b[i]] %= Mod; } cout << ans << endl; }
[ "assignment.value.change" ]
907,333
907,334
u811004127
cpp
p03096
#include <bits/stdc++.h> using namespace std; //#define double long double typedef pair<int, int> ii; typedef pair<int, long long> il; typedef pair<long long, long long> ll; typedef pair<ll, int> lli; typedef pair<long long, int> li; typedef pair<double, double> dd; typedef pair<ii, int> iii; typedef pair<double, int> di; typedef pair<int, ii> iii2; typedef pair<ii, ii> iiii; long long mod = 1000000007LL; long long large = 2000000000000000000LL; int main() { int n; cin >> n; vector<int> c(n, 0); for (int i = 0; i < n; i++) { scanf("%d", &c[i]); c[i]--; } vector<int> cnt(n, 0); vector<int> dp(n, 0); cnt[c[0]] = 1; for (int i = 0; i < n; i++) { dp[i] = cnt[c[i]]; dp[i] %= mod; if (i + 1 < n && c[i] != c[i + 1]) { cnt[c[i + 1]] += dp[i]; cnt[c[i + 1]] %= mod; } } // for(int i=0;i<n;i++) cout<<i<<" "<<dp[i]<<endl; cout << dp[n - 1] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; //#define double long double typedef pair<int, int> ii; typedef pair<int, long long> il; typedef pair<long long, long long> ll; typedef pair<ll, int> lli; typedef pair<long long, int> li; typedef pair<double, double> dd; typedef pair<ii, int> iii; typedef pair<double, int> di; typedef pair<int, ii> iii2; typedef pair<ii, ii> iiii; long long mod = 1000000007LL; long long large = 2000000000000000000LL; int main() { int n; cin >> n; vector<int> c(n, 0); for (int i = 0; i < n; i++) { scanf("%d", &c[i]); c[i]--; } vector<int> cnt(2000010, 0); vector<int> dp(n, 0); cnt[c[0]] = 1; for (int i = 0; i < n; i++) { dp[i] = cnt[c[i]]; dp[i] %= mod; if (i + 1 < n && c[i] != c[i + 1]) { cnt[c[i + 1]] += dp[i]; cnt[c[i + 1]] %= mod; } } // for(int i=0;i<n;i++) cout<<i<<" "<<dp[i]<<endl; cout << dp[n - 1] << endl; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change" ]
907,335
907,336
u837724941
cpp
p03096
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define forn(i, n) for (int i = 0; i < (int)(n); ++i) typedef long long LL; typedef pair<int, int> PII; const int MOD = int(1e9) + 7; int n; int c[200005], d[200005]; int pos[200005]; int main() { scanf("%d", &n); forn(i, n) { scanf("%d", c + i); if (i > 0 && c[i] == c[i - 1]) { --i; --n; } } forn(i, n) { pos[i] = -1; } d[0] = 1; forn(i, n) { int col = c[i]; if (pos[col] != -1) { d[i + 1] = d[pos[col] + 1]; } d[i + 1] = (d[i + 1] + d[i]) % MOD; pos[col] = i; } cout << d[n] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define forn(i, n) for (int i = 0; i < (int)(n); ++i) typedef long long LL; typedef pair<int, int> PII; const int MOD = int(1e9) + 7; int n; int c[200005], d[200005]; int pos[200005]; int main() { scanf("%d", &n); forn(i, n) { scanf("%d", c + i); if (i > 0 && c[i] == c[i - 1]) { --i; --n; } } forn(i, 200005) { pos[i] = -1; } d[0] = 1; forn(i, n) { int col = c[i]; if (pos[col] != -1) { d[i + 1] = d[pos[col] + 1]; } d[i + 1] = (d[i + 1] + d[i]) % MOD; pos[col] = i; } cout << d[n] << endl; return 0; }
[]
907,337
907,338
u155202361
cpp
p03096
#include <bits/stdc++.h> using namespace std; const int MaxN = 2e5 + 25; const int MOD = 1e9 + 7; int dp[MaxN]; int n, a[MaxN]; int sumDP[MaxN]; void add(int &x, int y) { x += y; if (x >= MOD) x -= MOD; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("input.txt", "r", stdin); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; dp[0] = 1; for (int i = 1; i <= n; ++i) { dp[i] = dp[i - 1]; if (a[i] != a[i - 1]) add(dp[i], sumDP[a[i]]); if (a[i] != a[i + 1]) add(sumDP[a[i]], dp[i - 1]); } cout << dp[n] << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; const int MaxN = 2e5 + 25; const int MOD = 1e9 + 7; int dp[MaxN]; int n, a[MaxN]; int sumDP[MaxN]; void add(int &x, int y) { x += y; if (x >= MOD) x -= MOD; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("input.txt", "r", stdin); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } dp[0] = 1; for (int i = 1; i <= n; ++i) { dp[i] = dp[i - 1]; if (a[i] != a[i - 1]) add(dp[i], sumDP[a[i]]); if (a[i] != a[i - 1]) add(sumDP[a[i]], dp[i - 1]); } cout << dp[n] << '\n'; return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
907,341
907,342
u784576081
cpp
p03096
#include <bits/stdc++.h> #define MOD (1000000007) using namespace std; const int N = 2e5 + 10; int f[N], g[N]; int num[N], p; int main() { ios::sync_with_stdio(false), cin.tie(0); int n; cin >> n; int v; for (int i = 0; i < n; i++) { cin >> v; if (num[p] != v) num[++p] = v; } f[0] = 1; for (int i = 1; i <= n; i++) { f[i] = (f[i - 1] + g[num[i]]) % MOD; (g[num[i]] += f[i - 1]) %= MOD; } cout << f[n] << endl; return 0; }
#include <bits/stdc++.h> #define MOD (1000000007) using namespace std; const int N = 2e5 + 10; int f[N], g[N]; int num[N], p; int main() { ios::sync_with_stdio(false), cin.tie(0); int n; cin >> n; int v; for (int i = 0; i < n; i++) { cin >> v; if (num[p] != v) num[++p] = v; } f[0] = 1; for (int i = 1; i <= p; i++) { f[i] = (f[i - 1] + g[num[i]]) % MOD; (g[num[i]] += f[i - 1]) %= MOD; } cout << f[p] << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "variable_access.subscript.index.change", "io.output.change" ]
907,353
907,354
u484351360
cpp
p03096
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) #define ALL(a) a.begin(), a.end() const int MOD = 1e9 + 7; struct mint { int n; mint(int n_ = 0) : n(n_) {} }; mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; } mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; } mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; } mint &operator+=(mint &a, mint b) { return a = a + b; } mint &operator-=(mint &a, mint b) { return a = a - b; } mint &operator*=(mint &a, mint b) { return a = a * b; } int main() { int N; cin >> N; vector<int> C(N); vector<set<int>> st(N); REP(i, N) { cin >> C[i]; st[C[i]].insert(i); } vector<mint> dp(N + 1); dp[0] = 1; for (int i = 0; i < N; i++) { auto it = st[C[i]].upper_bound(i); if (it != st[C[i]].end()) { int j = *it; if (j > i + 1) { dp[j] += dp[i]; } } dp[i + 1] += dp[i]; } cout << dp[N].n << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) #define ALL(a) a.begin(), a.end() const int MOD = 1e9 + 7; struct mint { int n; mint(int n_ = 0) : n(n_) {} }; mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; } mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; } mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; } mint &operator+=(mint &a, mint b) { return a = a + b; } mint &operator-=(mint &a, mint b) { return a = a - b; } mint &operator*=(mint &a, mint b) { return a = a * b; } int main() { int N; cin >> N; vector<int> C(N); vector<set<int>> st(200001); REP(i, N) { cin >> C[i]; st[C[i]].insert(i); } vector<mint> dp(N + 1); dp[0] = 1; for (int i = 0; i < N; i++) { auto it = st[C[i]].upper_bound(i); if (it != st[C[i]].end()) { int j = *it; if (j > i + 1) { dp[j] += dp[i]; } } dp[i + 1] += dp[i]; } cout << dp[N].n << endl; }
[]
907,362
907,363
u006493569
cpp
p03096
#include <bits/stdc++.h> #define maxn 200005 #define ll long long #define ld double #define mod 1000000007 using namespace std; ll dp[maxn]; ll sum[maxn]; int n; int c[maxn]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> c[i]; dp[n + 1] = 1; for (int i = n; i >= 1; i--) { dp[i] = dp[i + 1]; if (c[i] != c[i + 1]) dp[i] = (dp[i] + sum[c[i]]) % mod, sum[c[i]] += dp[i], sum[c[i]] %= mod; // cout<<i<<" "<<dp[i]<<endl; } cout << dp[1] << endl; return 0; } /* 20 10 1 1 13 13 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 */
#include <bits/stdc++.h> #define maxn 200005 #define ll long long #define ld double #define mod 1000000007 using namespace std; ll dp[maxn]; ll sum[maxn]; int n; int c[maxn]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> c[i]; dp[n + 1] = 1; for (int i = n; i >= 1; i--) { dp[i] = dp[i + 1]; if (c[i] != c[i + 1]) dp[i] = (dp[i] + sum[c[i]]) % mod, sum[c[i]] += dp[i + 1], sum[c[i]] %= mod; // cout<<i<<" "<<dp[i]<<endl; } cout << dp[1] << endl; return 0; } /* 20 10 1 1 13 13 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 */
[ "assignment.change" ]
907,364
907,365
u286411981
cpp
p03097
#include <bits/stdc++.h> #define pb push_back #define pll pair<ll, ll> #define mp make_pair #define pyshnapyshnakaa \ ios_base ::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define x first #define y second #pragma GCC optimize("O3") // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") #define plll pair<pair<ll, ll>, ll> #define pllll pair<pair<ll, ll>, pair<ll, ll>> #define psl pair<string, ll> #define pld pair<ld, ld> #define all(a) a.begin(), a.end() #define vvl vector<vector<ll>> #define cld complex<double> typedef long long ll; typedef long double ld; using namespace std; const ll maxn = 1e6 + 100; const ll mod = 1e9 + 7; ll n, m, k, t; ll st2[maxn]; // vector <ll> ANS; ll xr; vector<ll> dfs(ll i, ll to) { if (i == 0) { return {0, 1}; } if ((to & st2[i]) == 0) { vector<ll> ANSL = dfs(i - 1, to); ll to1 = ANSL[1]; vector<ll> ANSR = dfs(i - 1, to1); for (ll q = 0; q < ANSR.size(); q++) { ANSR[q] += st2[i]; } vector<ll> ANS; ANS.pb(ANSL[0]); for (ll q = 0; q < ANSR.size(); q++) { ANS.pb(ANSR[q]); } for (ll q = 1; q < ANSR.size(); q++) { ANS.pb(ANSR[q]); } return ANS; } else { vector<ll> ANSL = dfs(i - 1, 1); vector<ll> ANSR = dfs(i - 1, to ^ 1); for (ll q = 0; q < ANSR.size(); q++) { ANSR[q] += st2[i]; ANSR[q] ^= 1; } vector<ll> ANS; for (ll q = 0; q < ANSL.size(); q++) { ANS.pb(ANSL[q]); } for (ll q = 0; q < ANSR.size(); q++) { ANS.pb(ANSR[q]); } return ANS; } } int main() { pyshnapyshnakaa ll q, w, e, a, b, c; cin >> n >> m >> k; st2[0] = 1; for (q = 1; q < 63; q++) { st2[q] = st2[q - 1] * 2; } if (__builtin_popcount(m) % 2 == __builtin_popcount(k) % 2) { cout << "NO"; return 0; } xr = m ^ k; // ANS.pb(m); vector<ll> ANS = dfs(n - 1, xr); cout << "YES" << endl; for (auto x : ANS) { cout << (x ^ m) << " "; } return 0; }
#include <bits/stdc++.h> #define pb push_back #define pll pair<ll, ll> #define mp make_pair #define pyshnapyshnakaa \ ios_base ::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define x first #define y second #pragma GCC optimize("O3") // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") #define plll pair<pair<ll, ll>, ll> #define pllll pair<pair<ll, ll>, pair<ll, ll>> #define psl pair<string, ll> #define pld pair<ld, ld> #define all(a) a.begin(), a.end() #define vvl vector<vector<ll>> #define cld complex<double> typedef long long ll; typedef long double ld; using namespace std; const ll maxn = 1e6 + 100; const ll mod = 1e9 + 7; ll n, m, k, t; ll st2[maxn]; // vector <ll> ANS; ll xr; vector<ll> dfs(ll i, ll to) { if (i == 0) { return {0, 1}; } if ((to & st2[i]) == 0) { // cout << "CASE 1 " << endl; vector<ll> ANSL = dfs(i - 1, to); ll to1 = ANSL[1]; vector<ll> ANSR = dfs(i - 1, to1); for (ll q = 0; q < ANSR.size(); q++) { ANSR[q] += st2[i]; } vector<ll> ANS; ANS.pb(ANSL[0]); for (ll q = 0; q < ANSR.size(); q++) { ANS.pb(ANSR[q]); } for (ll q = 1; q < ANSR.size(); q++) { ANS.pb(ANSL[q]); } // cout << "OUT" << endl; // for (auto x : ANS) { // cout << x << " "; // } // cout << endl; return ANS; } else { // cout << "CASE 2 " << endl; vector<ll> ANSL = dfs(i - 1, 1); vector<ll> ANSR = dfs(i - 1, to ^ 1); for (ll q = 0; q < ANSR.size(); q++) { ANSR[q] += st2[i]; ANSR[q] ^= 1; } vector<ll> ANS; for (ll q = 0; q < ANSL.size(); q++) { ANS.pb(ANSL[q]); } for (ll q = 0; q < ANSR.size(); q++) { ANS.pb(ANSR[q]); } // cout << "OUT" << endl; // for (auto x : ANS) { // cout << x << " "; // } // cout << endl; return ANS; } } int main() { pyshnapyshnakaa ll q, w, e, a, b, c; cin >> n >> m >> k; st2[0] = 1; for (q = 1; q < 63; q++) { st2[q] = st2[q - 1] * 2; } if (__builtin_popcount(m) % 2 == __builtin_popcount(k) % 2) { cout << "NO"; return 0; } xr = m ^ k; // ANS.pb(m); vector<ll> ANS = dfs(n - 1, xr); cout << "YES" << endl; for (auto x : ANS) { cout << (x ^ m) << " "; } return 0; }
[ "identifier.change", "call.arguments.change" ]
907,370
907,371
u051270344
cpp
p03097
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ALL(obj) (obj).begin(), (obj).end() #define SPEED \ cin.tie(0); \ ios::sync_with_stdio(false); template <class T> using PQ = priority_queue<T>; template <class T> using PQR = priority_queue<T, vector<T>, greater<T>>; constexpr long long MOD = (long long)1e9 + 7; constexpr long long MOD2 = 998244353; constexpr long long HIGHINF = (long long)1e18; constexpr long long LOWINF = (long long)1e15; constexpr long double PI = 3.1415926535897932384626433L; template <class T> vector<T> multivector(size_t N, T init) { return vector<T>(N, init); } template <class... T> auto multivector(size_t N, T... t) { return vector<decltype(multivector(t...))>(N, multivector(t...)); } template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <class T, class U> ostream &operator<<(ostream &o, const map<T, U> &obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; } template <class T> ostream &operator<<(ostream &o, const set<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const multiset<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const vector<T> &obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; } void print(void) { cout << endl; } template <class Head> void print(Head &&head) { cout << head; print(); } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head << " "; print(forward<Tail>(tail)...); } template <class T> void chmax(T &a, const T b) { a = max(a, b); } template <class T> void chmin(T &a, const T b) { a = min(a, b); } std::vector<std::string> split(const std::string &str, const char delemiter) { std::vector<std::string> res; std::stringstream ss(str); std::string buffer; while (std::getline(ss, buffer, delemiter)) res.push_back(buffer); return res; } void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; } void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; } void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; } /* * @title NBase */ class NBase { public: inline static vector<long long> translate(long long X, long long N) { assert(abs(N) > 1); vector<long long> res; while (1) { long long b = (X % abs(N) + abs(N)) % abs(N); res.push_back(b); (X -= b) /= N; if (X == 0) break; } return res; } // Digit Sum inline static constexpr long long digit_sum(long long N, long long K) { long long sum = 0; for (; N > 0; N /= K) sum += N % K; return sum; } }; int main() { int N, A, B, C; cin >> N >> A >> B; C = A ^ B; corner(NBase::digit_sum(C, 2) % 2 == 0, "NO"); vector<vector<int>> vv(N + 1); vv[0] = {0}; for (int i = 1; i <= N; ++i) { int M = vv[i - 1].size(); for (int j = 0; j < M; ++j) vv[i].push_back(2 * vv[i - 1][j]); for (int j = M - 1; 0 <= j; --j) vv[i].push_back(2 * vv[i - 1][j] + 1); } vector<int> bf(N), af; for (int i = 0; i < N; ++i) bf[i] = ((C >> i) & 1); af = bf; sort(ALL(af)); vector<int> idx(N, -1); for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (idx[j] != -1) continue; if (af[i] != bf[j]) continue; idx[j] = i; break; } } int pre = 0, rev = 0; vector<int> cnt; for (int i = N - 1; 0 <= i; --i) { int last = 0; if (!af[i]) last = 1; if (rev) { reverse(ALL(vv[i + last])); for (int x : vv[i + last]) cnt.push_back(pre + x); reverse(ALL(vv[i + last])); } else { for (int x : vv[i + last]) cnt.push_back(pre + x); } if (last) break; pre += (1 << i); rev ^= 1; } vector<int> ans; for (int &x : cnt) { int y = 0; for (int i = 0; i < N; ++i) { int j = idx[i]; int b = ((x >> j) & 1); y ^= (b << i); } ans.push_back(y); } for (int &x : ans) { x ^= A; } cout << "YES" << endl; for (int i = 0; i < ans.size(); ++i) { cout << (i ? " " : "") << ans[i]; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ALL(obj) (obj).begin(), (obj).end() #define SPEED \ cin.tie(0); \ ios::sync_with_stdio(false); template <class T> using PQ = priority_queue<T>; template <class T> using PQR = priority_queue<T, vector<T>, greater<T>>; constexpr long long MOD = (long long)1e9 + 7; constexpr long long MOD2 = 998244353; constexpr long long HIGHINF = (long long)1e18; constexpr long long LOWINF = (long long)1e15; constexpr long double PI = 3.1415926535897932384626433L; template <class T> vector<T> multivector(size_t N, T init) { return vector<T>(N, init); } template <class... T> auto multivector(size_t N, T... t) { return vector<decltype(multivector(t...))>(N, multivector(t...)); } template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <class T, class U> ostream &operator<<(ostream &o, const map<T, U> &obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; } template <class T> ostream &operator<<(ostream &o, const set<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const multiset<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const vector<T> &obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; } void print(void) { cout << endl; } template <class Head> void print(Head &&head) { cout << head; print(); } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head << " "; print(forward<Tail>(tail)...); } template <class T> void chmax(T &a, const T b) { a = max(a, b); } template <class T> void chmin(T &a, const T b) { a = min(a, b); } std::vector<std::string> split(const std::string &str, const char delemiter) { std::vector<std::string> res; std::stringstream ss(str); std::string buffer; while (std::getline(ss, buffer, delemiter)) res.push_back(buffer); return res; } void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; } void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; } void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; } /* * @title NBase */ class NBase { public: inline static vector<long long> translate(long long X, long long N) { assert(abs(N) > 1); vector<long long> res; while (1) { long long b = (X % abs(N) + abs(N)) % abs(N); res.push_back(b); (X -= b) /= N; if (X == 0) break; } return res; } // Digit Sum inline static constexpr long long digit_sum(long long N, long long K) { long long sum = 0; for (; N > 0; N /= K) sum += N % K; return sum; } }; int main() { int N, A, B, C; cin >> N >> A >> B; C = A ^ B; corner(NBase::digit_sum(C, 2) % 2 == 0, "NO"); vector<vector<int>> vv(N + 1); vv[0] = {0}; for (int i = 1; i <= N; ++i) { int M = vv[i - 1].size(); for (int j = 0; j < M; ++j) vv[i].push_back(2 * vv[i - 1][j]); for (int j = M - 1; 0 <= j; --j) vv[i].push_back(2 * vv[i - 1][j] + 1); } vector<int> bf(N), af; for (int i = 0; i < N; ++i) bf[i] = ((C >> i) & 1); af = bf; sort(ALL(af)); vector<int> idx(N, -1); for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (idx[j] != -1) continue; if (af[i] != bf[j]) continue; idx[j] = i; break; } } int pre = 0, rev = 0; vector<int> cnt; for (int i = N - 1; 0 <= i; --i) { int last = 0; if (!af[i] || i == 0) last = 1; if (rev) { reverse(ALL(vv[i + last])); for (int x : vv[i + last]) cnt.push_back(pre + x); reverse(ALL(vv[i + last])); } else { for (int x : vv[i + last]) cnt.push_back(pre + x); } if (last) break; pre += (1 << i); rev ^= 1; } vector<int> ans; for (int &x : cnt) { int y = 0; for (int i = 0; i < N; ++i) { int j = idx[i]; int b = ((x >> j) & 1); y ^= (b << i); } ans.push_back(y); } for (int &x : ans) { x ^= A; } cout << "YES" << endl; for (int i = 0; i < ans.size(); ++i) { cout << (i ? " " : "") << ans[i]; } cout << endl; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
907,372
907,373
u898651494
cpp
p03095
// スタックサイズ: 100MB #include <algorithm> #include <cmath> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef int64_t ll; const ll INF = 1000000000000000000; #define fori(i, a, b) for (ll i = (a); i < (b); ++i) #define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i) #define rep(i, n) fori(i, 0, n) #define vll vector<ll> #define all(v) (v).begin(), (v).end() // mod演算ライブラリ (factset以降に関しては, modは素数限定) ll mod = 1000000007; ll mul_mod(ll a, ll b) { // a * b return ((a % mod) * (b % mod)) % mod; } int main() { ll N; string S; cin >> N; cin >> S; vll alfa(26, 0); rep(i, N) { alfa[S[i] - 'a'] += 1; } ll ans = 1; rep(i, N) { ans = mul_mod(alfa[i] + 1, ans); } cout << ans - 1 << endl; }
// スタックサイズ: 100MB #include <algorithm> #include <cmath> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef int64_t ll; const ll INF = 1000000000000000000; #define fori(i, a, b) for (ll i = (a); i < (b); ++i) #define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i) #define rep(i, n) fori(i, 0, n) #define vll vector<ll> #define all(v) (v).begin(), (v).end() // mod演算ライブラリ (factset以降に関しては, modは素数限定) ll mod = 1000000007; ll mul_mod(ll a, ll b) { // a * b return ((a % mod) * (b % mod)) % mod; } int main() { ll N; string S; cin >> N; cin >> S; vll alfa(26, 0); rep(i, N) { alfa[S[i] - 'a'] += 1; } ll ans = 1; rep(i, 26) { ans = mul_mod(alfa[i] + 1, ans); } cout << ans - 1 << endl; }
[]
907,396
907,397
u511401499
cpp
p03095
#include "bits/stdc++.h" using namespace std; int main() { int N; string S; cin >> N >> S; vector<int> cnt(26); for (int i = 0; i < N; i++) { cnt[S[i] - 'a']++; } long long ans = 1; long long MOD = pow(10, 9) + 7; for (int i = 0; i < 26; i++) { ans *= cnt[i] + 1; ans %= MOD; } if (ans > 0) cout << ans << endl; else cout << pow(10, 9) + 6 << endl; }
#include "bits/stdc++.h" using namespace std; int main() { int N; string S; cin >> N >> S; vector<int> cnt(26); for (int i = 0; i < N; i++) { cnt[S[i] - 'a']++; } long long ans = 1; long long MOD = pow(10, 9) + 7; for (int i = 0; i < 26; i++) { ans *= cnt[i] + 1; ans %= MOD; } if (ans > 0) cout << ans - 1 << endl; else cout << pow(10, 9) + 6 << endl; }
[ "expression.operation.binary.add" ]
907,408
907,409
u365956698
cpp
p03095
//#include "pch.h" #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> #include <bitset> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> #define ll long long #define fri(n) for (i = 0; i < (n); i++) #define frj(n) for (j = 0; j < (n); i++) #define min(p, q) ((p) < (q) ? (p) : (q)) #define max(p, q) ((p) > (q) ? (p) : (q)) #define INF 1000000000000000000 // 10^18 #define INFINT 2000000001 // 2*10^9+1 #define MOD 1000000007 #define MODANOTHER 998244353 #define PI acos(-1) using namespace std; int main(void) { //変数の宣言 int n; char s[100010]; int alphabet[30]; //よく使う変数 int i, j, k, l; int flag = 0; ll int ans = 0; int count = 0; int temp, temp1, temp2; int max, min; int len; int sum = 0; int ok, ng; int r; //データの読み込み scanf("%d", &n); // scanf_s("%d",&n); /* for(i=0;i<n;i++){ // scanf("%d",&number[i].num); scanf_s("%d",&number[i].num); number[i].idnum=i; number[i].a=number[i].num; }*/ scanf("%s", &s); // scanf_s("%s",&s,100010); // printf("nは%dです\n", n); // printf("データの読み込み終了\n"); //実際の処理 for (i = 0; i < n; i++) { alphabet[i] = 1; } for (i = 0; i < n; i++) { alphabet[s[i] - 'a']++; } ans = 1; for (i = 0; i < n; i++) { ans = ans * alphabet[i]; ans = ans % MOD; } // printf("計算部分終了\n"); //出力 printf("%lld", ans - 1); // printf("結果の出力終了\n"); return 0; }
//#include "pch.h" #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> #include <bitset> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> #define ll long long #define fri(n) for (i = 0; i < (n); i++) #define frj(n) for (j = 0; j < (n); i++) #define min(p, q) ((p) < (q) ? (p) : (q)) #define max(p, q) ((p) > (q) ? (p) : (q)) #define INF 1000000000000000000 // 10^18 #define INFINT 2000000001 // 2*10^9+1 #define MOD 1000000007 #define MODANOTHER 998244353 #define PI acos(-1) using namespace std; int main(void) { //変数の宣言 int n; char s[100010]; int alphabet[30]; //よく使う変数 int i, j, k, l; int flag = 0; ll int ans = 0; int count = 0; int temp, temp1, temp2; int max, min; int len; int sum = 0; int ok, ng; int r; //データの読み込み scanf("%d", &n); // scanf_s("%d",&n); /* for(i=0;i<n;i++){ // scanf("%d",&number[i].num); scanf_s("%d",&number[i].num); number[i].idnum=i; number[i].a=number[i].num; }*/ scanf("%s", &s); // scanf_s("%s",&s,100010); // printf("nは%dです\n", n); // printf("データの読み込み終了\n"); //実際の処理 for (i = 0; i < 30; i++) { alphabet[i] = 1; } for (i = 0; i < n; i++) { alphabet[s[i] - 'a']++; } ans = 1; for (i = 0; i < 30; i++) { ans = ans * alphabet[i]; ans = ans % MOD; } // printf("計算部分終了\n"); //出力 printf("%lld", ans - 1); // printf("結果の出力終了\n"); return 0; }
[ "identifier.replace.remove", "literal.replace.add", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
907,410
907,411
u705931757
cpp
p03095
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = int64_t; using ull = uint64_t; constexpr ll INF = 1000000000; /* 1e+9a */ // Residue Class Ring namespace Xelmh_RCR { class RCR { // Residue Class Ring public: static const int64_t MOD = 1000000007; // static const int64_t MOD = 998244353; int64_t val; RCR(int64_t l) : val{l % MOD} {} RCR() : val{0} {} RCR pow(RCR m) const { RCR rv{1}; auto nmul = val; while (m.val > 0) { if ((m.val & 1) == 1) { rv.val *= nmul; rv.val %= MOD; } nmul *= nmul; nmul %= MOD; m.val /= 2; } return rv; } RCR inv() const { /* return Inverse */ return this->pow(MOD - 2); } void operator+=(const RCR &a) { val += a.val; val %= MOD; } void operator-=(const RCR &a) { val -= a.val; val %= MOD; } void operator*=(const RCR &a) { val *= a.val; val %= MOD; } void operator/=(const RCR &a) { val *= a.inv().val; val %= MOD; } }; // supported operator :: + - * / ^ RCR operator+(const RCR &a, const RCR &b) { return (a.val + b.val) % RCR::MOD; } RCR operator-(const RCR &a, const RCR &b) { return (a.val - b.val + RCR::MOD) % RCR::MOD; } RCR operator*(const RCR &a, const RCR &b) { return (a.val * b.val) % RCR::MOD; } RCR operator/(const RCR &a, const RCR &b) { return (a.val * b.inv().val) % RCR::MOD; } RCR operator^(const RCR &a, const RCR &b) { return a.pow(b); } RCR operator==(const RCR &a, const RCR &b) { return a.val == b.val; } RCR operator!=(const RCR &a, const RCR &b) { return a.val != b.val; } // IO std::ostream &operator<<(std::ostream &os, const RCR &m) { return os << m.val; } std::istream &operator>>(std::istream &is, RCR &m) { return is >> m.val; } RCR fact(ll N) { /* N -> N! */ static vector<RCR> cal(1, RCR{1}); if (cal.size() > N) return cal[N]; else { RCR nm = fact(N - 1); assert(cal.size() == N); cal.push_back(nm * N); return cal[N]; } } RCR choice(ll N, ll k) { /* N, k -> N C k */ // N! / k!(N-k!) RCR ans = fact(N) / (fact(k) * fact(N - k)); return ans; } } // namespace Xelmh_RCR using namespace Xelmh_RCR; void solve(istream &cin) { ll N; cin >> N; if (!cin) return; string s; cin >> s; RCR ans = 1; vector<RCR> al(26); for (int i = 0; i < N; ++i) { al[s[i] - 'a'] += 1; } // end i for (auto &&x : al) { if (x.val != 0) ans *= x; } // end ans -= 1; cout << ans << endl; } int main(int argc, char *argv[]) { cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(16) << scientific; solve(cin); return 0; }
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = int64_t; using ull = uint64_t; constexpr ll INF = 1000000000; /* 1e+9a */ // Residue Class Ring namespace Xelmh_RCR { class RCR { // Residue Class Ring public: static const int64_t MOD = 1000000007; // static const int64_t MOD = 998244353; int64_t val; RCR(int64_t l) : val{l % MOD} {} RCR() : val{0} {} RCR pow(RCR m) const { RCR rv{1}; auto nmul = val; while (m.val > 0) { if ((m.val & 1) == 1) { rv.val *= nmul; rv.val %= MOD; } nmul *= nmul; nmul %= MOD; m.val /= 2; } return rv; } RCR inv() const { /* return Inverse */ return this->pow(MOD - 2); } void operator+=(const RCR &a) { val += a.val; val %= MOD; } void operator-=(const RCR &a) { val -= a.val; val %= MOD; } void operator*=(const RCR &a) { val *= a.val; val %= MOD; } void operator/=(const RCR &a) { val *= a.inv().val; val %= MOD; } }; // supported operator :: + - * / ^ RCR operator+(const RCR &a, const RCR &b) { return (a.val + b.val) % RCR::MOD; } RCR operator-(const RCR &a, const RCR &b) { return (a.val - b.val + RCR::MOD) % RCR::MOD; } RCR operator*(const RCR &a, const RCR &b) { return (a.val * b.val) % RCR::MOD; } RCR operator/(const RCR &a, const RCR &b) { return (a.val * b.inv().val) % RCR::MOD; } RCR operator^(const RCR &a, const RCR &b) { return a.pow(b); } RCR operator==(const RCR &a, const RCR &b) { return a.val == b.val; } RCR operator!=(const RCR &a, const RCR &b) { return a.val != b.val; } // IO std::ostream &operator<<(std::ostream &os, const RCR &m) { return os << m.val; } std::istream &operator>>(std::istream &is, RCR &m) { return is >> m.val; } RCR fact(ll N) { /* N -> N! */ static vector<RCR> cal(1, RCR{1}); if (cal.size() > N) return cal[N]; else { RCR nm = fact(N - 1); assert(cal.size() == N); cal.push_back(nm * N); return cal[N]; } } RCR choice(ll N, ll k) { /* N, k -> N C k */ // N! / k!(N-k!) RCR ans = fact(N) / (fact(k) * fact(N - k)); return ans; } } // namespace Xelmh_RCR using namespace Xelmh_RCR; void solve(istream &cin) { ll N; cin >> N; if (!cin) return; string s; cin >> s; RCR ans = 1; vector<RCR> al(26); for (int i = 0; i < N; ++i) { al[s[i] - 'a'] += 1; } // end i for (auto &&x : al) { if (x.val != 0) ans *= x + 1; } // end ans -= 1; cout << ans << endl; } int main(int argc, char *argv[]) { cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(16) << scientific; solve(cin); return 0; }
[ "assignment.change" ]
907,426
907,427
u896838289
cpp
p03095
#include <algorithm> #include <bitset> #include <climits> #include <complex> #include <cstring> #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 <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #define rep(i, m, n) for (int i = int(m); i < int(n); i++) #define all(c) begin(c), end(c) template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } //改造 typedef long long int ll; using namespace std; #define INF (1 << 30) - 1 #define INFl (ll)5e15 #define DEBUG 0 //デバッグする時1にしてね #define dump(x) cerr << #x << " = " << (x) << endl #define MOD 1000000007 //ここから編集する class Solve { public: void input() {} void solve() { input(); int N; cin >> N; string S; cin >> S; vector<ll> cnt(26); for (int i = 0; i < N; ++i) { cnt[S[i] - 'a']++; } ll ans = 1ll; for (int i = 0; i < N; ++i) { ans *= (cnt[i] + 1); ans %= MOD; } ans--; cout << ans << endl; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); Solve().solve(); return 0; }
#include <algorithm> #include <bitset> #include <climits> #include <complex> #include <cstring> #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 <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #define rep(i, m, n) for (int i = int(m); i < int(n); i++) #define all(c) begin(c), end(c) template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } //改造 typedef long long int ll; using namespace std; #define INF (1 << 30) - 1 #define INFl (ll)5e15 #define DEBUG 0 //デバッグする時1にしてね #define dump(x) cerr << #x << " = " << (x) << endl #define MOD 1000000007 //ここから編集する class Solve { public: void input() {} void solve() { input(); int N; cin >> N; string S; cin >> S; vector<ll> cnt(26); for (int i = 0; i < N; ++i) { cnt[S[i] - 'a']++; } ll ans = 1ll; for (int i = 0; i < 26; ++i) { ans *= (cnt[i] + 1); ans %= MOD; } ans--; cout << ans << endl; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); Solve().solve(); return 0; }
[ "identifier.replace.remove", "literal.replace.add", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
907,430
907,431
u003873207
cpp
p03096
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <tuple> #include <utility> #include <vector> #define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i)) using namespace std; using ll = long long; using P = pair<ll, ll>; const ll MOD = 1e9 + 7; const ll INF = (1ll << 60); int main(void) { int n; cin >> n; vector<ll> c(n), dp(n + 1, 1); vector<vector<ll>> s(n + 1, vector<ll>()); for (int i = 0; i < n; i++) { cin >> c[i]; c[i]; s[c[i]].push_back(i); } for (int i = 0; i < n; i++) { int x = lower_bound(s[c[i]].begin(), s[c[i]].end(), i) - s[c[i]].begin(); if (x > 0) { if (s[c[i]][x] - s[c[i]][x - 1] > 1) { dp[i + 1] = dp[i] + dp[s[c[i]][x - 1] + 1]; dp[i + 1] %= MOD; } else { dp[i + 1] = dp[i]; dp[i + 1] %= MOD; } } else { dp[i + 1] = dp[i]; dp[i + 1] %= MOD; } } cout << dp[n] << endl; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <tuple> #include <utility> #include <vector> #define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i)) using namespace std; using ll = long long; using P = pair<ll, ll>; const ll MOD = 1e9 + 7; const ll INF = (1ll << 60); int main(void) { int n; cin >> n; vector<ll> c(n), dp(n + 1, 1); vector<vector<ll>> s(200010, vector<ll>()); for (int i = 0; i < n; i++) { cin >> c[i]; c[i]; s[c[i]].push_back(i); } for (int i = 0; i < n; i++) { int x = lower_bound(s[c[i]].begin(), s[c[i]].end(), i) - s[c[i]].begin(); if (x > 0) { if (s[c[i]][x] - s[c[i]][x - 1] > 1) { dp[i + 1] = dp[i] + dp[s[c[i]][x - 1] + 1]; dp[i + 1] %= MOD; } else { dp[i + 1] = dp[i]; dp[i + 1] %= MOD; } } else { dp[i + 1] = dp[i]; dp[i + 1] %= MOD; } } cout << dp[n] << endl; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,450
907,451
u880221923
cpp
p03096
#include <bits/stdc++.h> #include <cassert> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; /* struct Edge { int to; int weight; Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; */ using Graph = vector<vector<int>>; const long long INF = 1LL << 60; const int INT_INF = 1000000000; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1}; const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } mint p(int n, int k) { return fact[n] * ifact[n - k]; } } c(1000005); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> C(N); for (auto &it : C) { cin >> it; it--; } vector<int> left(N + 2, -1); vector<mint> dp(N + 2, 0); dp[0] = 1; for (int i = 0; i < N; i++) { dp[i + 1] += dp[i]; int c = C[i]; if (left[c] >= 0 && left[c] < i - 1) dp[i + 1] += dp[left[c] + 1]; left[c] = i; } cout << dp[N] << endl; return 0; }
#include <bits/stdc++.h> #include <cassert> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; /* struct Edge { int to; int weight; Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; */ using Graph = vector<vector<int>>; const long long INF = 1LL << 60; const int INT_INF = 1000000000; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1}; const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } mint p(int n, int k) { return fact[n] * ifact[n - k]; } } c(1000005); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> C(N); for (auto &it : C) { cin >> it; it--; } vector<int> left(200001, -1); vector<mint> dp(200001, 0); dp[0] = 1; for (int i = 0; i < N; i++) { dp[i + 1] += dp[i]; int c = C[i]; if (left[c] >= 0 && left[c] < i - 1) dp[i + 1] += dp[left[c] + 1]; left[c] = i; } cout << dp[N] << endl; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,456
907,457
u665871498
cpp
p03096
#include <bits/stdc++.h> #include <cassert> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; /* struct Edge { int to; int weight; Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; */ using Graph = vector<vector<int>>; const long long INF = 1LL << 60; const int INT_INF = 1000000000; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1}; const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } mint p(int n, int k) { return fact[n] * ifact[n - k]; } } c(1000005); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> C(N); for (auto &it : C) { cin >> it; it--; } vector<int> left(N + 1, -1); vector<mint> dp(N + 1, 0); dp[0] = 1; for (int i = 0; i < N; i++) { dp[i + 1] += dp[i]; int c = C[i]; if (left[c] >= 0 && left[c] < i - 1) dp[i + 1] += dp[left[c] + 1]; left[c] = i; } cout << dp[N] << endl; return 0; }
#include <bits/stdc++.h> #include <cassert> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; /* struct Edge { int to; int weight; Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; */ using Graph = vector<vector<int>>; const long long INF = 1LL << 60; const int INT_INF = 1000000000; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1}; const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } mint p(int n, int k) { return fact[n] * ifact[n - k]; } } c(1000005); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> C(N); for (auto &it : C) { cin >> it; it--; } vector<int> left(200001, -1); vector<mint> dp(200001, 0); dp[0] = 1; for (int i = 0; i < N; i++) { dp[i + 1] += dp[i]; int c = C[i]; if (left[c] >= 0 && left[c] < i - 1) dp[i + 1] += dp[left[c] + 1]; left[c] = i; } cout << dp[N] << endl; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,458
907,457
u665871498
cpp
p03096
#include <bits/stdc++.h> #define all(X) (X).begin(), (X).end() #define rall(X) (X).rbegin(), (X).rend() #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define ff first #define ss second #define P 1000000007 #define in(x, a, b) (a <= x && x < b) using namespace std; using ll = long long; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vii> vvii; const ll inf = 1000000001, INF = (ll)1e18 + 1; void solve() { int n; cin >> n; vi c(n); for (int i = 0; i < n; i++) cin >> c[i]; vi prev(n); map<int, int> u; for (int i = 0; i < n; i++) { if (!u[c[i]]) prev[i] = -1; else prev[i] = u[c[i]]; u[c[i]] = i; } vi dp(n, 0); dp[0] = 1; for (int i = 1; i < n; i++) { (dp[i] = dp[i - 1] + (prev[i] == -1 || prev[i] == i - 1 ? 0 : dp[prev[i]])) %= P; } cout << dp[n - 1] << endl; } int main() { ios_base::sync_with_stdio(false); solve(); return 0; }
#include <bits/stdc++.h> #define all(X) (X).begin(), (X).end() #define rall(X) (X).rbegin(), (X).rend() #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define ff first #define ss second #define P 1000000007 #define in(x, a, b) (a <= x && x < b) using namespace std; using ll = long long; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vii> vvii; const ll inf = 1000000001, INF = (ll)1e18 + 1; void solve() { int n; cin >> n; vi c(n); for (int i = 0; i < n; i++) cin >> c[i]; vi prev(n); map<int, int> u; for (int i = 0; i < n; i++) { if (!u.count(c[i])) prev[i] = -1; else prev[i] = u[c[i]]; u[c[i]] = i; } vi dp(n, 0); dp[0] = 1; for (int i = 1; i < n; i++) { (dp[i] = dp[i - 1] + (prev[i] == -1 || prev[i] == i - 1 ? 0 : dp[prev[i]])) %= P; } cout << dp[n - 1] << endl; } int main() { ios_base::sync_with_stdio(false); solve(); return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "call.add" ]
907,459
907,460
u425619511
cpp
p03096
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <unordered_map> #include <vector> #define mod 998244353 #define int long long #define ld long double #define pb push_back #define vi vector<int> #define co(x) cout << x << '\n' #define dbg(x) cerr << #x << " = " << x << '\n' #define bitcount(x) (int)__builtin_popcount(x) #define sz(x) (int)x.size() #define all(a) a.begin(), a.end() #define ff first #define ss second #define pii pair<int, int> #define lcm(a, b) (a * b) / __gcd(a, b) using namespace std; inline void solve() { int n, pre = -1; cin >> n; vector<int> dp(n + 5, 0), c(n + 5, -1); dp[0] = 1; for (int i = 1, x; i <= n; i++) { cin >> x; dp[i] = dp[i - 1]; if (c[x] != -1 and pre != x) dp[i] = dp[c[x]] + dp[i - 1]; c[x] = i; pre = x; dp[i] %= 1000000007; } cout << dp[n] << endl; } signed main() { int n = 1; // cin>>n; while (n--) solve(); return 0; }
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <unordered_map> #include <vector> #define mod 998244353 #define int long long #define ld long double #define pb push_back #define vi vector<int> #define co(x) cout << x << '\n' #define dbg(x) cerr << #x << " = " << x << '\n' #define bitcount(x) (int)__builtin_popcount(x) #define sz(x) (int)x.size() #define all(a) a.begin(), a.end() #define ff first #define ss second #define pii pair<int, int> #define lcm(a, b) (a * b) / __gcd(a, b) using namespace std; inline void solve() { int n, pre = -1; cin >> n; vector<int> dp(200005, 0), c(200005, -1); dp[0] = 1; for (int i = 1, x; i <= n; i++) { cin >> x; dp[i] = dp[i - 1]; if (c[x] != -1 and pre != x) dp[i] = dp[c[x]] + dp[i - 1]; c[x] = i; pre = x; dp[i] %= 1000000007; } cout << dp[n] << endl; } signed main() { int n = 1; // cin>>n; while (n--) solve(); return 0; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
907,463
907,462
u931901821
cpp
p03097
#include <iostream> #include <stdio.h> using namespace std; int B[(1 << 18) + 1], N; void solve(int m, int a, int b) { if (m == 0) return; if (B[m]) { printf("%d %d ", a, b); return; } int bit = B[m & -m]; int s1 = a >> bit & 1, s2 = b >> bit & 1, p; if (s1 != s2) { int q = m ^ (1 << bit); p = q & -q; // if(p==0) printf("\nyyyy"); solve(m ^ (1 << bit), a, a ^ p); solve(m ^ (1 << bit), a ^ p ^ (1 << bit), b); } else { p = B[(a ^ b) & -(a ^ b)]; int q; for (q = 0; q < N; q++) if ((m >> q & 1) && q != p && q != bit) break; if (q != N) { solve(m ^ (1 << bit) ^ (1 << p), a, a ^ (1 << q)); solve(m ^ (1 << bit), a ^ (1 << bit) ^ (1 << q), a ^ (1 << bit) ^ (1 << q) ^ (1 << p)); solve(m ^ (1 << bit) ^ (1 << p), a ^ (1 << p) ^ (1 << q), b); } else { q = (m ^ (1 << bit)) & -(m ^ (1 << bit)); printf("%d %d %d %d ", a, a ^ (1 << bit), a ^ q ^ (1 << bit), b); } } } int main() { int a, b, sum = 0, i; scanf("%d %d %d", &N, &a, &b); for (i = 0; i <= 18; i++) B[1 << i] = i; for (i = 0; i < N; i++) sum += (a >> i & 1) ^ (b >> i & 1); if ((sum & 1) == 0) printf("NO"); else { printf("YES\n"); solve((1 << N) - 1, a, b); } return 0; }
#include <iostream> #include <stdio.h> using namespace std; int B[(1 << 18) + 1], N; void solve(int m, int a, int b) { if (m == 0) return; if (B[m] || m == 1) { printf("%d %d ", a, b); return; } int bit = B[m & -m]; int s1 = a >> bit & 1, s2 = b >> bit & 1, p; if (s1 != s2) { int q = m ^ (1 << bit); p = q & -q; // if(p==0) printf("\nyyyy"); solve(m ^ (1 << bit), a, a ^ p); solve(m ^ (1 << bit), a ^ p ^ (1 << bit), b); } else { p = B[(a ^ b) & -(a ^ b)]; int q; for (q = 0; q < N; q++) if ((m >> q & 1) && q != p && q != bit) break; if (q != N) { solve(m ^ (1 << bit) ^ (1 << p), a, a ^ (1 << q)); solve(m ^ (1 << bit), a ^ (1 << bit) ^ (1 << q), a ^ (1 << bit) ^ (1 << q) ^ (1 << p)); solve(m ^ (1 << bit) ^ (1 << p), a ^ (1 << p) ^ (1 << q), b); } else { q = (m ^ (1 << bit)) & -(m ^ (1 << bit)); printf("%d %d %d %d ", a, a ^ (1 << bit), a ^ q ^ (1 << bit), b); } } } int main() { int a, b, sum = 0, i; scanf("%d %d %d", &N, &a, &b); for (i = 0; i <= 18; i++) B[1 << i] = i; for (i = 0; i < N; i++) sum += (a >> i & 1) ^ (b >> i & 1); if ((sum & 1) == 0) printf("NO"); else { printf("YES\n"); solve((1 << N) - 1, a, b); } return 0; }
[ "control_flow.branch.if.condition.change" ]
907,488
907,489
u931404549
cpp
p03097
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef pair<double, double> pdd; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef pair<int, int> pii; typedef vector<pii> vii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; // const int mod = ; vi solve(int n, int a, int b) { if (n == 1) { assert(a != b); return {a, b}; } assert(a >= 0 && b >= 0 && max(a, b) < (1 << n)); if (a % 2 == b % 2) { vi v1 = solve(n - 1, a / 2, b / 2); vi v2 = solve(n - 1, a / 2, v1[1]); for (int &x : v2) x = 2 * x + (1 - a % 2); v2.insert(v2.begin(), a); for (int i = 1; i < v1.size(); ++i) { v2.push_back(v1[i] * 2 + a % 2); } return v2; } else { int neig = (a / 2) ^ 1; vi v1 = solve(n - 1, a / 2, neig); vi v2 = solve(n - 1, neig, b); for (int &x : v1) x = 2 * x + a % 2; for (int x : v2) v1.push_back(x * 2 + b % 2); return v1; } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n, a, b; cin >> n >> a >> b; if (__builtin_popcount(a ^ b) % 2 == 0) { cout << "NO\n"; return 0; } cout << "YES\n"; vi v = solve(n, a, b); for (int i = 0; i + 1 < v.size(); ++i) { assert(__builtin_popcount(v[i] ^ v[i + 1]) == 1); } for (int x : v) { cout << x << ' '; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef pair<double, double> pdd; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef pair<int, int> pii; typedef vector<pii> vii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; // const int mod = ; vi solve(int n, int a, int b) { if (n == 1) { assert(a != b); return {a, b}; } assert(a >= 0 && b >= 0 && max(a, b) < (1 << n)); if (a % 2 == b % 2) { vi v1 = solve(n - 1, a / 2, b / 2); vi v2 = solve(n - 1, a / 2, v1[1]); for (int &x : v2) x = 2 * x + (1 - a % 2); v2.insert(v2.begin(), a); for (int i = 1; i < v1.size(); ++i) { v2.push_back(v1[i] * 2 + a % 2); } return v2; } else { int neig = (a / 2) ^ 1; vi v1 = solve(n - 1, a / 2, neig); vi v2 = solve(n - 1, neig, b / 2); for (int &x : v1) x = 2 * x + a % 2; for (int x : v2) v1.push_back(x * 2 + b % 2); return v1; } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n, a, b; cin >> n >> a >> b; if (__builtin_popcount(a ^ b) % 2 == 0) { cout << "NO\n"; return 0; } cout << "YES\n"; vi v = solve(n, a, b); for (int i = 0; i + 1 < v.size(); ++i) { assert(__builtin_popcount(v[i] ^ v[i + 1]) == 1); } for (int x : v) { cout << x << ' '; } cout << endl; return 0; }
[ "assignment.change" ]
907,502
907,503
u640230853
cpp
p03098
#include <cstdio> #include <cstring> #define RI register int #define CI const int & using namespace std; const int N = 100005; int n, k; struct permutation { int a[N]; inline permutation(void) { memset(a, 0, sizeof(a)); } inline int &operator[](CI x) { return a[x]; } inline friend permutation operator~(permutation A) { permutation tp; for (RI i = 1; i <= n; ++i) tp[A[i]] = i; return tp; } inline friend permutation operator*(permutation A, permutation B) { permutation C; for (RI i = 1; i <= n; ++i) C[i] = A[B[i]]; return C; } inline friend permutation operator^(permutation A, int p) { permutation t; for (RI i = 1; i <= n; ++i) t[i] = i; for (; p; p >>= 1, A = A * A) if (p & 1) t = t * A; return t; } inline void print(void) { for (RI i = 1; i <= n; ++i) printf("%d ", a[i]); } } a[10], T; int main() { RI i; for (scanf("%d%d", &n, &k), i = 1; i <= n; ++i) scanf("%d", &a[1][i]); for (i = 1; i <= n; ++i) scanf("%d", &a[2][i]); for (i = 3; i <= 6; ++i) a[i] = a[i - 1] * (~a[i - 2]); int d = k / 6, r = k % 6; if (!r) --d, ++r; T = a[2] * (~a[1]) * (~a[2]) * a[1]; return ((T ^ d) * a[r] * ((~T) ^ d)).print(), 0; }
#include <cstdio> #include <cstring> #define RI register int #define CI const int & using namespace std; const int N = 100005; int n, k; struct permutation { int a[N]; inline permutation(void) { memset(a, 0, sizeof(a)); } inline int &operator[](CI x) { return a[x]; } inline friend permutation operator~(permutation A) { permutation tp; for (RI i = 1; i <= n; ++i) tp[A[i]] = i; return tp; } inline friend permutation operator*(permutation A, permutation B) { permutation C; for (RI i = 1; i <= n; ++i) C[i] = A[B[i]]; return C; } inline friend permutation operator^(permutation A, int p) { permutation t; for (RI i = 1; i <= n; ++i) t[i] = i; for (; p; p >>= 1, A = A * A) if (p & 1) t = t * A; return t; } inline void print(void) { for (RI i = 1; i <= n; ++i) printf("%d ", a[i]); } } a[10], T; int main() { RI i; for (scanf("%d%d", &n, &k), i = 1; i <= n; ++i) scanf("%d", &a[1][i]); for (i = 1; i <= n; ++i) scanf("%d", &a[2][i]); for (i = 3; i <= 6; ++i) a[i] = a[i - 1] * (~a[i - 2]); int d = k / 6, r = k % 6; if (!r) --d, r = 6; T = a[2] * (~a[1]) * (~a[2]) * a[1]; return ((T ^ d) * a[r] * ((~T) ^ d)).print(), 0; }
[ "assignment.change" ]
907,517
907,518
u803115645
cpp
p03098
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <queue> using namespace std; #define vi vector<int> int n, k; vi a[15]; int read() { char c = getchar(); int res = 0; while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') res = (res << 1) + (res << 3) + (c ^ 48), c = getchar(); return res; } vi inv(vi a) { vi b; b.resize(n); for (int i = 0; i < n; i++) b[a[i]] = i; return b; } vi mul(vi a, vi b) { vi c; c.resize(n); for (int i = 0; i < n; i++) c[i] = a[b[i]]; return c; } vi ksm(vi x, int n) { vi ans; ans.resize(n); for (int i = 0; i < n; i++) ans[i] = i; while (n) { if (n & 1) ans = mul(ans, x); x = mul(x, x); n >>= 1; } return ans; } int main() { scanf("%d%d", &n, &k); a[1].resize(n); for (int i = 0; i < n; i++) a[1][i] = read(), a[1][i]--; a[2].resize(n); for (int i = 0; i < n; i++) a[2][i] = read(), a[2][i]--; for (int i = 3; i <= 6; i++) a[i] = mul(a[i - 1], inv(a[i - 2])); if (k <= 6) { for (int i = 0; i < n; i++) printf("%d ", a[k][i] + 1); return 0; } vi A = mul(mul(a[2], inv(a[1])), mul(inv(a[2]), a[1])); A = ksm(A, (k - 1) / 6); A = mul(mul(A, a[(k - 1) % 6 + 1]), inv(A)); for (int i = 0; i < n; i++) printf("%d ", A[i] + 1); }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <queue> using namespace std; #define vi vector<int> int n, k; vi a[7]; int read() { char c = getchar(); int res = 0; while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') res = (res << 1) + (res << 3) + (c ^ 48), c = getchar(); return res; } vi inv(vi a) { vi b; b.resize(n); for (int i = 0; i < n; i++) b[a[i]] = i; return b; } vi mul(vi a, vi b) { vi c; c.resize(n); for (int i = 0; i < n; i++) c[i] = a[b[i]]; return c; } vi ksm(vi x, int mi) { vi ans; ans.resize(n); for (int i = 0; i < n; i++) ans[i] = i; while (mi) { if (mi & 1) ans = mul(ans, x); x = mul(x, x); mi >>= 1; } return ans; } int main() { scanf("%d%d", &n, &k); a[1].resize(n); for (int i = 0; i < n; i++) a[1][i] = read(), a[1][i]--; a[2].resize(n); for (int i = 0; i < n; i++) a[2][i] = read(), a[2][i]--; for (int i = 3; i <= 6; i++) a[i] = mul(a[i - 1], inv(a[i - 2])); if (k <= 6) { for (int i = 0; i < n; i++) printf("%d ", a[k][i] + 1); return 0; } vi A = mul(mul(a[2], inv(a[1])), mul(inv(a[2]), a[1])); A = ksm(A, (k - 1) / 6); A = mul(mul(A, a[(k - 1) % 6 + 1]), inv(A)); for (int i = 0; i < n; i++) printf("%d ", A[i] + 1); }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "identifier.change", "control_flow.loop.condition.change", "control_flow.branch.if.condition.change", "assignment.variable.change" ]
907,524
907,525
u562042360
cpp
p03098
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define ALL(c) (c).begin(), (c).end() #ifdef LOCAL #define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl #else #define dump(x) true #endif constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template <class T, class U> void chmin(T &t, const U &u) { if (t > u) t = u; } template <class T, class U> void chmax(T &t, const U &u) { if (t < u) t = u; } 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, v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } V<int> inv(const V<int> &a) { V<int> res(a.size()); rep(i, a.size()) { res[a[i]] = i; } return res; } V<int> comp(const V<int> &a, const V<int> &b) { // a * b V<int> res(a.size()); rep(i, a.size()) { res[i] = a[b[i]]; } return res; } int main() { int N, K; cin >> N >> K; V<int> p(N), q(N); rep(i, N) { cin >> p[i], --p[i]; } rep(i, N) { cin >> q[i], --q[i]; } V<int> id(N); // mod 6 iota(ALL(id), 0); { int cyc = (K - 1) / 6; V<int> base = comp(inv(q), p); base = comp(inv(p), base); base = comp(q, base); while (cyc > 0) { if (cyc & 1) { id = comp(base, id); } base = comp(base, base); cyc /= 2; } } int rem = (K - 1) % 6; p = comp(id, p); p = comp(p, inv(id)); q = comp(id, q); q = comp(q, inv(id)); rep(i, rem) { V<int> nx = comp(q, inv(p)); p = q; q = nx; } rep(i, N) { printf("%d%c", p[i], i == N - 1 ? '\n' : ' '); } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define ALL(c) (c).begin(), (c).end() #ifdef LOCAL #define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl #else #define dump(x) true #endif constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template <class T, class U> void chmin(T &t, const U &u) { if (t > u) t = u; } template <class T, class U> void chmax(T &t, const U &u) { if (t < u) t = u; } 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, v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } V<int> inv(const V<int> &a) { V<int> res(a.size()); rep(i, a.size()) { res[a[i]] = i; } return res; } V<int> comp(const V<int> &a, const V<int> &b) { // a * b V<int> res(a.size()); rep(i, a.size()) { res[i] = a[b[i]]; } return res; } int main() { int N, K; cin >> N >> K; V<int> p(N), q(N); rep(i, N) { cin >> p[i], --p[i]; } rep(i, N) { cin >> q[i], --q[i]; } V<int> id(N); // mod 6 iota(ALL(id), 0); { int cyc = (K - 1) / 6; V<int> base = comp(inv(q), p); base = comp(inv(p), base); base = comp(q, base); while (cyc > 0) { if (cyc & 1) { id = comp(base, id); } base = comp(base, base); cyc /= 2; } } int rem = (K - 1) % 6; p = comp(id, p); p = comp(p, inv(id)); q = comp(id, q); q = comp(q, inv(id)); rep(i, rem) { V<int> nx = comp(q, inv(p)); p = q; q = nx; } rep(i, N) { printf("%d%c", p[i] + 1, i == N - 1 ? '\n' : ' '); } return 0; }
[ "expression.operation.binary.add" ]
907,526
907,527
u742529680
cpp
p03098
#include <bits/stdc++.h> #include <complex> #define pb push_back #define pll pair<ll, ll> #define MOMI using namespace std; #define mp make_pair #define pyshnapyshnakaa \ ios_base ::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #pragma optimize("TKACHENKO-GORYACHENKO") #pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") //#define double long double typedef long long ll; typedef long double ld; using namespace std; const ll maxn = 3e5; ll n, m, k; vector<ll> ID; void vivod(vector<ll> V) { ll q; for (q = 0; q < V.size(); q++) { cout << V[q] << " "; } cout << endl << endl; } vector<ll> mul(vector<ll> A, vector<ll> B) { vector<ll> ANS; ANS.resize(A.size()); ll q; for (q = 0; q < A.size(); q++) { ANS[q] = A[B[q]]; } return ANS; } vector<ll> rev(vector<ll> A) { vector<ll> ANS; ANS.resize(A.size()); ll q; for (q = 0; q < A.size(); q++) { ANS[A[q]] = q; } return ANS; } vector<ll> step(vector<ll> A, ll x) { if (x == 0) { return ID; } if (x % 2 == 1) { return mul(step(A, x - 1), A); } vector<ll> T = step(A, x / 2); return mul(T, T); } int main() { ll q, w, e, t, a, b, c; cin >> n >> k; vector<ll> P, Q; ID.resize(n); for (q = 0; q < n; q++) { ID[q] = q; } P.resize(n); Q.resize(n); for (q = 0; q < n; q++) { cin >> P[q]; P[q]--; } for (q = 0; q < n; q++) { cin >> Q[q]; Q[q]--; } k--; // vivod(P);vivod(Q); vector<ll> W = mul(mul(Q, rev(P)), mul(rev(Q), P)); // vivod(W); // vector <ll> A = mul(mul(P, step(W, (k) / 6)), rev(P)); /// 0, 6, 12, 18, // 24 vector <ll> B = mul(mul(Q, step(W, (k) / 6)), rev(Q)); /// 1, 7, 13, // 19, 25; vector<ll> A = mul(step(W, (k) / 6), mul(P, rev(step(W, k / 6)))); vector<ll> B = mul(step(W, (k) / 6), mul(Q, rev(step(W, k / 6)))); // cout << "A " << endl; vivod(A); // cout << "B " << endl; vivod(B); if (k % 6 == 0) { for (q = 0; q < n; q++) { cout << A[q] << " "; } return 0; } ll i = (k / 6) * 6 + 1; for (; i < k; i++) { vector<ll> C; C.resize(n); for (q = 0; q < n; q++) { C[A[q]] = B[q]; } // vivod(C); A = B; B = C; } for (q = 0; q < n; q++) { cout << B[q] + 1 << " "; } return 0; }
#include <bits/stdc++.h> #include <complex> #define pb push_back #define pll pair<ll, ll> #define MOMI using namespace std; #define mp make_pair #define pyshnapyshnakaa \ ios_base ::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #pragma optimize("TKACHENKO-GORYACHENKO") #pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") //#define double long double typedef long long ll; typedef long double ld; using namespace std; const ll maxn = 3e5; ll n, m, k; vector<ll> ID; void vivod(vector<ll> V) { ll q; for (q = 0; q < V.size(); q++) { cout << V[q] << " "; } cout << endl << endl; } vector<ll> mul(vector<ll> A, vector<ll> B) { vector<ll> ANS; ANS.resize(A.size()); ll q; for (q = 0; q < A.size(); q++) { ANS[q] = A[B[q]]; } return ANS; } vector<ll> rev(vector<ll> A) { vector<ll> ANS; ANS.resize(A.size()); ll q; for (q = 0; q < A.size(); q++) { ANS[A[q]] = q; } return ANS; } vector<ll> step(vector<ll> A, ll x) { if (x == 0) { return ID; } if (x % 2 == 1) { return mul(step(A, x - 1), A); } vector<ll> T = step(A, x / 2); return mul(T, T); } int main() { ll q, w, e, t, a, b, c; cin >> n >> k; vector<ll> P, Q; ID.resize(n); for (q = 0; q < n; q++) { ID[q] = q; } P.resize(n); Q.resize(n); for (q = 0; q < n; q++) { cin >> P[q]; P[q]--; } for (q = 0; q < n; q++) { cin >> Q[q]; Q[q]--; } k--; // vivod(P);vivod(Q); vector<ll> W = mul(mul(Q, rev(P)), mul(rev(Q), P)); // vivod(W); // vector <ll> A = mul(mul(P, step(W, (k) / 6)), rev(P)); /// 0, 6, 12, 18, // 24 vector <ll> B = mul(mul(Q, step(W, (k) / 6)), rev(Q)); /// 1, 7, 13, // 19, 25; vector<ll> A = mul(step(W, (k) / 6), mul(P, rev(step(W, k / 6)))); vector<ll> B = mul(step(W, (k) / 6), mul(Q, rev(step(W, k / 6)))); // cout << "A " << endl; vivod(A); // cout << "B " << endl; vivod(B); if (k % 6 == 0) { for (q = 0; q < n; q++) { cout << A[q] + 1 << " "; } return 0; } ll i = (k / 6) * 6 + 1; for (; i < k; i++) { vector<ll> C; C.resize(n); for (q = 0; q < n; q++) { C[A[q]] = B[q]; } // vivod(C); A = B; B = C; } for (q = 0; q < n; q++) { cout << B[q] + 1 << " "; } return 0; }
[ "expression.operation.binary.add" ]
907,535
907,536
u051270344
cpp
p03098
#include <bits/stdc++.h> #define vi vector<int> using namespace std; vi p, q, a[7]; int n, k, x; vi mul(vi x, vi y) { vi z; for (int i = 0; i < x.size(); i++) z.push_back(x[y[i]]); return z; } vi inv(vi x) { vi y(n); for (int i = 0; i < x.size(); i++) y[x[i]] = i; return y; } vi qpow(vi x, int y) { vi ans(n); for (int i = 0; i < n; i++) ans[i] = i; while (y) { if (y & 1) ans = mul(ans, x); x = mul(x, x); y >>= 1; } return ans; } int main() { scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &x); p.push_back(x - 1); } for (int i = 0; i < n; i++) { scanf("%d", &x); q.push_back(x - 1); } a[1] = p; a[2] = q; for (int i = 3; i <= n; i++) a[i] = mul(a[i - 1], inv(a[i - 2])); if (k <= 6) { for (int i = 0; i < n; i++) printf(i == n - 1 ? "%d\n" : "%d ", a[k][i] + 1); return 0; } vi A = mul(mul(q, inv(p)), mul(inv(q), p)); A = qpow(A, (k - 1) / 6); vi ans = mul(mul(A, a[(k - 1) % 6 + 1]), inv(A)); for (int i = 0; i < n; i++) printf(i == n - 1 ? "%d\n" : "%d ", ans[i] + 1); }
#include <bits/stdc++.h> #define vi vector<int> using namespace std; vi p, q, a[7]; int n, k, x; vi mul(vi x, vi y) { vi z; for (int i = 0; i < x.size(); i++) z.push_back(x[y[i]]); return z; } vi inv(vi x) { vi y(n); for (int i = 0; i < x.size(); i++) y[x[i]] = i; return y; } vi qpow(vi x, int y) { vi ans(n); for (int i = 0; i < n; i++) ans[i] = i; while (y) { if (y & 1) ans = mul(ans, x); x = mul(x, x); y >>= 1; } return ans; } int main() { scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &x); p.push_back(x - 1); } for (int i = 0; i < n; i++) { scanf("%d", &x); q.push_back(x - 1); } a[1] = p; a[2] = q; for (int i = 3; i <= 6; i++) a[i] = mul(a[i - 1], inv(a[i - 2])); if (k <= 6) { for (int i = 0; i < n; i++) printf(i == n - 1 ? "%d\n" : "%d ", a[k][i] + 1); return 0; } vi A = mul(mul(q, inv(p)), mul(inv(q), p)); A = qpow(A, (k - 1) / 6); vi ans = mul(mul(A, a[(k - 1) % 6 + 1]), inv(A)); for (int i = 0; i < n; i++) printf(i == n - 1 ? "%d\n" : "%d ", ans[i] + 1); }
[ "identifier.replace.remove", "literal.replace.add", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
907,541
907,542
u676323984
cpp
p03098
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> inv(vector<int> a) { vector<int> b(n); for (int i = 0; i < n; i++) { b[a[i]] = i; } return b; } vector<int> &operator*=(vector<int> &a, vector<int> b) { vector<int> c(n); for (int i = 0; i < n; i++) { c[i] = a[b[i]]; } a = c; return a; } vector<int> operator*(vector<int> a, vector<int> b) { return a *= b; } void output(vector<int> a) { for (int i = 0; i < n; i++) { printf("%d%c", a[i] + 1, " \n"[i == n - 1]); } } vector<int> power(vector<int> a, int k) { vector<int> res(n); for (int i = 0; i < n; i++) { res[i] = i; } while (k > 0) { if (k & 1) { res *= a; } a *= a; k >>= 1; } return res; } int main() { scanf("%d %d", &n, &m); vector<int> a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); a[i]--; } vector<int> b(n); for (int i = 0; i < n; i++) { scanf("%d", &b[i]); b[i]--; } if (m == 1) { output(a); } else if (m == 2) { output(b); } else { m -= 2; vector<int> A = inv(a); vector<int> B = inv(b); vector<int> res = power(b * A * B * a, m / 6); int rm = m % 6; if (rm == 0) res *= b; if (rm == 1) res *= b * A; if (rm == 2) res *= b * A * B; if (rm == 3) res *= b * A * B * a * B; if (rm == 4) res *= b * A * B * a * a * b; if (rm == 5) res *= b * A * B * a * b * a * B; res *= power(A * b * a * B, m / 6); output(res); } return 0; }
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> inv(vector<int> a) { vector<int> b(n); for (int i = 0; i < n; i++) { b[a[i]] = i; } return b; } vector<int> &operator*=(vector<int> &a, vector<int> b) { vector<int> c(n); for (int i = 0; i < n; i++) { c[i] = a[b[i]]; } a = c; return a; } vector<int> operator*(vector<int> a, vector<int> b) { return a *= b; } void output(vector<int> a) { for (int i = 0; i < n; i++) { printf("%d%c", a[i] + 1, " \n"[i == n - 1]); } } vector<int> power(vector<int> a, int k) { vector<int> res(n); for (int i = 0; i < n; i++) { res[i] = i; } while (k > 0) { if (k & 1) { res *= a; } a *= a; k >>= 1; } return res; } int main() { scanf("%d %d", &n, &m); vector<int> a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); a[i]--; } vector<int> b(n); for (int i = 0; i < n; i++) { scanf("%d", &b[i]); b[i]--; } if (m == 1) { output(a); } else if (m == 2) { output(b); } else { m -= 2; vector<int> A = inv(a); vector<int> B = inv(b); vector<int> res = power(b * A * B * a, m / 6); int rm = m % 6; if (rm == 0) res *= b; if (rm == 1) res *= b * A; if (rm == 2) res *= b * A * B; if (rm == 3) res *= b * A * B * a * B; if (rm == 4) res *= b * A * B * a * a * B; if (rm == 5) res *= b * A * B * a * b * a * B; res *= power(A * b * a * B, m / 6); output(res); } return 0; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
907,543
907,544
u242534780
cpp
p03098
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second #define SZ(x) ((int)x.size()) #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define FORD(i, a, b) for (int i = a; i >= b; --i) using namespace std; typedef long long LL; typedef pair<int, int> pa; typedef vector<int> vec; void getint(int &v) { char ch, fu = 0; for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ; if (ch == '-') fu = 1, ch = getchar(); for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0'; if (fu) v = -v; } int n, k, x; vec ans, a[4], L, R; vec rev(vec v) { vec ans; ans.resize(n + 1); FOR(i, 1, n) ans[v[i]] = i; return ans; } vec mul(vec a, vec b) { vec c; c.clear(); c.pb(0); FOR(i, 1, n) c.pb(b[a[i]]); return c; } vec pw(vec x, int y) { vec t; t.clear(); t.pb(0); FOR(i, 1, n) t.pb(i); for (; y; y >>= 1) { if (y & 1) t = mul(t, x); x = mul(x, x); } return t; } int main() { // a1 0 // rev a1 1 // a2 2 // rev a2 3 cin >> n >> k; a[0].pb(0); FOR(i, 1, n) { getint(x); a[0].pb(x); } a[2].pb(0); FOR(i, 1, n) { getint(x); a[2].pb(x); } a[1] = rev(a[0]); a[3] = rev(a[2]); L = mul(mul(mul(a[3], a[0]), a[2]), a[1]); R = mul(mul(mul(a[0], a[3]), a[1]), a[2]); if (k == 1) { FOR(i, 1, n) printf("%d ", a[1][i]); return 0; } if (k % 6 == 2) { ans = pw(L, k / 6); ans = mul(ans, a[2]); ans = mul(ans, pw(R, k / 6)); } if (k % 6 == 3) { ans = pw(L, k / 6); ans = mul(ans, a[1]); ans = mul(ans, a[2]); ans = mul(ans, pw(R, k / 6)); } if (k % 6 == 4) { ans = pw(L, k / 6); ans = mul(ans, a[3]); ans = mul(ans, a[1]); ans = mul(ans, a[2]); ans = mul(ans, pw(R, k / 6)); } if (k % 6 == 5) { ans = pw(L, k / 6); ans = mul(ans, a[3]); ans = mul(ans, pw(R, k / 6 + 1)); } if (k % 6 == 0) { ans = pw(L, k / 6 - 1); ans = mul(ans, a[3]); ans = mul(ans, a[0]); ans = mul(ans, pw(R, k / 6)); } if (k % 6 == 1) { ans = pw(L, k / 6 - 1); ans = mul(ans, a[3]); ans = mul(ans, a[0]); ans = mul(ans, a[2]); ans = mul(ans, pw(R, k / 6)); } FOR(i, 1, n) printf("%d ", ans[i]); return 0; } /* 0 2 12 312 30312 300312 3020312 302120312 3021120312 30213120312 3021303120312 30213003120312 302130203120312 30213021203120312 302130211203120312 3021302131203120312 302130213031203120312 3021302130031203120312 30213021302031203120312 3021302130212031203120312 30213021302112031203120312 302130213021312031203120312 30213021302130312031203120312 302130213021300312031203120312 3021302130213020312031203120312 302130213021302120312031203120312 3021302130213021120312031203120312 30213021302130213120312031203120312 3021302130213021303120312031203120312 30213021302130213003120312031203120312 */
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second #define SZ(x) ((int)x.size()) #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define FORD(i, a, b) for (int i = a; i >= b; --i) using namespace std; typedef long long LL; typedef pair<int, int> pa; typedef vector<int> vec; void getint(int &v) { char ch, fu = 0; for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ; if (ch == '-') fu = 1, ch = getchar(); for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0'; if (fu) v = -v; } int n, k, x; vec ans, a[4], L, R; vec rev(vec v) { vec ans; ans.resize(n + 1); FOR(i, 1, n) ans[v[i]] = i; return ans; } vec mul(vec a, vec b) { vec c; c.clear(); c.pb(0); FOR(i, 1, n) c.pb(b[a[i]]); return c; } vec pw(vec x, int y) { vec t; t.clear(); t.pb(0); FOR(i, 1, n) t.pb(i); for (; y; y >>= 1) { if (y & 1) t = mul(t, x); x = mul(x, x); } return t; } int main() { // a1 0 // rev a1 1 // a2 2 // rev a2 3 cin >> n >> k; a[0].pb(0); FOR(i, 1, n) { getint(x); a[0].pb(x); } a[2].pb(0); FOR(i, 1, n) { getint(x); a[2].pb(x); } a[1] = rev(a[0]); a[3] = rev(a[2]); L = mul(mul(mul(a[3], a[0]), a[2]), a[1]); R = mul(mul(mul(a[0], a[3]), a[1]), a[2]); if (k == 1) { FOR(i, 1, n) printf("%d ", a[0][i]); return 0; } if (k % 6 == 2) { ans = pw(L, k / 6); ans = mul(ans, a[2]); ans = mul(ans, pw(R, k / 6)); } if (k % 6 == 3) { ans = pw(L, k / 6); ans = mul(ans, a[1]); ans = mul(ans, a[2]); ans = mul(ans, pw(R, k / 6)); } if (k % 6 == 4) { ans = pw(L, k / 6); ans = mul(ans, a[3]); ans = mul(ans, a[1]); ans = mul(ans, a[2]); ans = mul(ans, pw(R, k / 6)); } if (k % 6 == 5) { ans = pw(L, k / 6); ans = mul(ans, a[3]); ans = mul(ans, pw(R, k / 6 + 1)); } if (k % 6 == 0) { ans = pw(L, k / 6 - 1); ans = mul(ans, a[3]); ans = mul(ans, a[0]); ans = mul(ans, pw(R, k / 6)); } if (k % 6 == 1) { ans = pw(L, k / 6 - 1); ans = mul(ans, a[3]); ans = mul(ans, a[0]); ans = mul(ans, a[2]); ans = mul(ans, pw(R, k / 6)); } FOR(i, 1, n) printf("%d ", ans[i]); return 0; } /* 0 2 12 312 30312 300312 3020312 302120312 3021120312 30213120312 3021303120312 30213003120312 302130203120312 30213021203120312 302130211203120312 3021302131203120312 302130213031203120312 3021302130031203120312 30213021302031203120312 3021302130212031203120312 30213021302112031203120312 302130213021312031203120312 30213021302130312031203120312 302130213021300312031203120312 3021302130213020312031203120312 302130213021302120312031203120312 3021302130213021120312031203120312 30213021302130213120312031203120312 3021302130213021303120312031203120312 30213021302130213003120312031203120312 */
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "io.output.change" ]
907,545
907,546
u651830993
cpp
p03098
#include <bits/stdc++.h> #define fi first #define se second #define pii pair<int, int> #define mp make_pair #define pb push_back #define space putchar(' ') #define enter putchar('\n') #define MAXN 100005 #define eps 1e-10 //#define ivorysi using namespace std; typedef long long int64; typedef unsigned int u32; typedef double db; template <class T> void read(T &res) { res = 0; T f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); } res *= f; } template <class T> void out(T x) { if (x < 0) { x = -x; putchar('-'); } if (x >= 10) { out(x / 10); } putchar('0' + x % 10); } int N, K; struct pl { int f[100005]; friend pl operator*(const pl &a, const pl &b) { pl c; for (int i = 1; i <= N; ++i) c.f[i] = a.f[b.f[i]]; return c; } pl inv() { pl c; for (int i = 1; i <= N; ++i) { c.f[f[i]] = i; } return c; } } p, q, iq, ip, s, res, t, ans; void fpow(int c) { for (int i = 1; i <= N; ++i) res.f[i] = i; t = s; while (c) { if (c & 1) res = res * t; t = t * t; c >>= 1; } } void Solve() { read(N); read(K); for (int i = 1; i <= N; ++i) read(p.f[i]); for (int i = 1; i <= N; ++i) read(q.f[i]); ip = p.inv(); iq = q.inv(); s = q * ip * iq * p; fpow((K - 1) / 6); int x = (K - 1) % 6; if (x == 0) { ans = res * p * res.inv(); } else if (x == 1) { ans = res * q * res.inv(); } else if (x == 2) { ans = res * q * ip * res.inv(); } else if (x == 3) { res = res * q; ans = res * ip * res.inv(); } else if (x == 4) { res = res * q * ip; ans = res * iq * res.inv(); } else if (x == 3) { res = res * q * ip; ans = res * iq * p * res.inv(); } for (int i = 1; i <= N; ++i) { out(ans.f[i]); space; } enter; } int main() { #ifdef ivorysi freopen("f1.in", "r", stdin); #endif Solve(); }
#include <bits/stdc++.h> #define fi first #define se second #define pii pair<int, int> #define mp make_pair #define pb push_back #define space putchar(' ') #define enter putchar('\n') #define MAXN 100005 #define eps 1e-10 //#define ivorysi using namespace std; typedef long long int64; typedef unsigned int u32; typedef double db; template <class T> void read(T &res) { res = 0; T f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); } res *= f; } template <class T> void out(T x) { if (x < 0) { x = -x; putchar('-'); } if (x >= 10) { out(x / 10); } putchar('0' + x % 10); } int N, K; struct pl { int f[100005]; friend pl operator*(const pl &a, const pl &b) { pl c; for (int i = 1; i <= N; ++i) c.f[i] = a.f[b.f[i]]; return c; } pl inv() { pl c; for (int i = 1; i <= N; ++i) { c.f[f[i]] = i; } return c; } } p, q, iq, ip, s, res, t, ans; void fpow(int c) { for (int i = 1; i <= N; ++i) res.f[i] = i; t = s; while (c) { if (c & 1) res = res * t; t = t * t; c >>= 1; } } void Solve() { read(N); read(K); for (int i = 1; i <= N; ++i) read(p.f[i]); for (int i = 1; i <= N; ++i) read(q.f[i]); ip = p.inv(); iq = q.inv(); s = q * ip * iq * p; fpow((K - 1) / 6); int x = (K - 1) % 6; if (x == 0) { ans = res * p * res.inv(); } else if (x == 1) { ans = res * q * res.inv(); } else if (x == 2) { ans = res * q * ip * res.inv(); } else if (x == 3) { res = res * q; ans = res * ip * res.inv(); } else if (x == 4) { res = res * q * ip; ans = res * iq * res.inv(); } else if (x == 5) { res = res * q * ip; ans = res * iq * p * res.inv(); } for (int i = 1; i <= N; ++i) { out(ans.f[i]); space; } enter; } int main() { #ifdef ivorysi freopen("f1.in", "r", stdin); #endif Solve(); }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
907,547
907,548
u845980916
cpp
p03098
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector<ll>; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; using vpii = vector<pii>; vi fastexp(const vi &perm, int x) { if (x > 1) { int n = perm.size(); vi halfexp = fastexp(perm, x / 2); vi res(n); for (int i = 0; i < n; ++i) { if (x & 1) res[i] = perm[halfexp[halfexp[i]]]; else res[i] = halfexp[halfexp[i]]; } return res; } assert(x == 1); return perm; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vvi ais(6, vi(n)); for (int i = 0; i < n; ++i) { cin >> ais[0][i]; --ais[0][i]; } for (int i = 0; i < n; ++i) { cin >> ais[1][i]; --ais[1][i]; } for (int j = 2; j < 6; ++j) { for (int i = 0; i < n; ++i) { ais[j][ais[j - 2][i]] = ais[j - 1][i]; } } int lowi = n % 6; if (lowi == 0) lowi = 6; int x = (k - lowi) / 6; vi per(n); for (int i = 0; i < n; ++i) per[i] = ais[3][ais[0][i]]; vi res; if (x == 0) res = ais[lowi - 1]; else { vi perexp = fastexp(per, x); res = vi(n); for (int i = 0; i < n; ++i) { res[perexp[i]] = perexp[ais[lowi - 1][i]]; } } for (int i = 0; i < n; ++i) cout << res[i] + 1 << " "; cout << "\n"; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector<ll>; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; using vpii = vector<pii>; vi fastexp(const vi &perm, int x) { if (x > 1) { int n = perm.size(); vi halfexp = fastexp(perm, x / 2); vi res(n); for (int i = 0; i < n; ++i) { if (x & 1) res[i] = perm[halfexp[halfexp[i]]]; else res[i] = halfexp[halfexp[i]]; } return res; } assert(x == 1); return perm; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vvi ais(6, vi(n)); for (int i = 0; i < n; ++i) { cin >> ais[0][i]; --ais[0][i]; } for (int i = 0; i < n; ++i) { cin >> ais[1][i]; --ais[1][i]; } for (int j = 2; j < 6; ++j) { for (int i = 0; i < n; ++i) { ais[j][ais[j - 2][i]] = ais[j - 1][i]; } } int lowi = k % 6; if (lowi == 0) lowi = 6; int x = (k - lowi) / 6; vi per(n); for (int i = 0; i < n; ++i) per[i] = ais[3][ais[0][i]]; vi res; if (x == 0) res = ais[lowi - 1]; else { vi perexp = fastexp(per, x); res = vi(n); for (int i = 0; i < n; ++i) { res[perexp[i]] = perexp[ais[lowi - 1][i]]; } } for (int i = 0; i < n; ++i) cout << res[i] + 1 << " "; cout << "\n"; }
[ "identifier.change", "expression.operation.binary.change" ]
907,555
907,556
u839511400
cpp
p03098
#include <bits/stdc++.h> #define int long long using namespace std; void print(vector<int> a) { for (int i = 0; i < a.size(); i++) cout << a[i] + 1 << " "; exit(0); } vector<int> rev(vector<int> &a) { int n = a.size(); vector<int> res(n); for (int i = 0; i < n; i++) res[a[i]] = i; return res; } vector<int> mult(vector<int> a, vector<int> b) { int n = a.size(); vector<int> res(n); for (int i = 0; i < n; i++) res[i] = b[a[i]]; return res; } vector<int> pw(vector<int> &a, int d) { if (d == 0) { vector<int> K; for (int i = 0; i < a.size(); i++) K.push_back(i); return K; } if (d == 1) return a; if (d % 2 == 0) { vector<int> res = pw(a, d / 2); return mult(res, res); } return mult(a, pw(a, d - 1)); } vector<int> get(vector<vector<int>> kek, int d) { int n = kek[0].size(); vector<int> cp; for (int i = 0; i < n; i++) cp.push_back(i); for (int i = 0; i < 4; i++) cp = mult(cp, kek[i]); int N = d / 4; cp = pw(cp, N); for (int i = 0; i < (d % 4); i++) cp = mult(cp, kek[i]); return cp; } main() { // freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; vector<int> a(n), b(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) a[i]--; for (int i = 0; i < n; i++) cin >> b[i]; for (int i = 0; i < n; i++) b[i]--; if (k == 1) print(a); if (k == 2) print(b); int deg = ((k - 3) / 3) * 4 + 2; if (k % 3 == 1) deg++; if (k % 3 == 2) deg += 3; vector<int> reva = rev(a), revb = rev(b); vector<vector<int>> revlist = {revb, a, b, reva}; int need = (deg - 1) / 2; vector<int> relax = get(revlist, need); vector<int> R = rev(relax); if (deg % 2 != 0) { if (deg % 8 == 7) relax = mult(relax, mult(a, R)); if (deg % 8 == 1) relax = mult(relax, mult(b, R)); if (deg % 8 == 3) relax = mult(relax, mult(reva, R)); if (deg % 8 == 5) relax = mult(relax, mult(revb, R)); } else { if (deg % 8 == 2) relax = mult(relax, mult(reva, mult(b, R))); if (deg % 8 == 6) relax = mult(relax, mult(revb, mult(a, R))); } print(relax); }
#include <bits/stdc++.h> #define int long long using namespace std; void print(vector<int> a) { for (int i = 0; i < a.size(); i++) cout << a[i] + 1 << " "; exit(0); } vector<int> rev(vector<int> &a) { int n = a.size(); vector<int> res(n); for (int i = 0; i < n; i++) res[a[i]] = i; return res; } vector<int> mult(vector<int> a, vector<int> b) { int n = a.size(); vector<int> res(n); for (int i = 0; i < n; i++) res[i] = b[a[i]]; return res; } vector<int> pw(vector<int> &a, int d) { if (d == 0) { vector<int> K; for (int i = 0; i < a.size(); i++) K.push_back(i); return K; } if (d == 1) return a; if (d % 2 == 0) { vector<int> res = pw(a, d / 2); return mult(res, res); } return mult(a, pw(a, d - 1)); } vector<int> get(vector<vector<int>> kek, int d) { int n = kek[0].size(); vector<int> cp; for (int i = 0; i < n; i++) cp.push_back(i); for (int i = 0; i < 4; i++) cp = mult(cp, kek[i]); int N = d / 4; cp = pw(cp, N); for (int i = 0; i < (d % 4); i++) cp = mult(cp, kek[i]); return cp; } main() { // freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; vector<int> a(n), b(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) a[i]--; for (int i = 0; i < n; i++) cin >> b[i]; for (int i = 0; i < n; i++) b[i]--; if (k == 1) print(a); if (k == 2) print(b); int deg = ((k - 3) / 3) * 4 + 2; if (k % 3 == 1) deg++; if (k % 3 == 2) deg += 3; vector<int> reva = rev(a), revb = rev(b); vector<vector<int>> revlist = {revb, a, b, reva}; int need = (deg - 1) / 2; vector<int> relax = get(revlist, need); vector<int> R = rev(relax); if (deg % 2 != 0) { if (deg % 8 == 7) relax = mult(relax, mult(a, R)); if (deg % 8 == 1) relax = mult(relax, mult(b, R)); if (deg % 8 == 3) relax = mult(relax, mult(reva, R)); if (deg % 8 == 5) relax = mult(relax, mult(revb, R)); } else { if (deg % 8 == 2) relax = mult(relax, mult(reva, mult(b, R))); if (deg % 8 == 6) relax = mult(relax, mult(a, mult(revb, R))); } print(relax); }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
907,557
907,558
u053547321
cpp
p03098
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <tuple> #include <unordered_map> #include <vector> #define all(a) (a).begin(), (a).end() #define sz(a) (int)(a).size() using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef unsigned int uint; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); // default_random_engine generator; // mt19937 rnd(1); vector<int> operator*(const vector<int> &a, const vector<int> &b) { int n = sz(a); vector<int> res(n); for (int i = 0; i < n; ++i) { res[i] = a[b[i]]; } return res; } vector<int> id(int n) { vector<int> res(n); for (int i = 0; i < n; ++i) { res[i] = i; } return res; } vector<int> binPow(vector<int> a, int m) { int n = sz(a); vector<int> res = id(n); for (; m > 0; m >>= 1) { if (m & 1) { res = res * a; } a = a * a; } return res; } vector<int> rev(const vector<int> &a) { int n = sz(a); vector<int> res(n); for (int i = 0; i < n; ++i) { res[a[i]] = i; } return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); vector<int> u = {2, 1, 3, 0}; // vector<int> v = {3, 0, 2, 1}; vector<int> v = {2, 1, 3, 0}; int n, k; cin >> n >> k; vector<int> p(n), q(n); for (int i = 0; i < n; ++i) { cin >> p[i]; --p[i]; } for (int j = 0; j < n; ++j) { cin >> q[j]; --q[j]; } --k; if (k == 0) { for (int el : p) { cout << el << " "; } cout << endl; return 0; } if (k == 1) { for (int el : q) { cout << el << " "; } cout << endl; return 0; } int s = k + (k - 1) / 3; int a = (s + 1) / 2 + 1; int b = (s + 1) / 2 - 1; if (a + b > s) { --a; } vector<vector<int>> perm(4); perm[0] = p; perm[1] = rev(p); perm[2] = q; perm[3] = rev(q); vector<int> f = id(n); vector<int> g = id(n); for (int i = 0; i < 4; ++i) { f = f * perm[u[i]]; g = g * perm[v[i]]; } f = binPow(f, a / 4); g = binPow(g, b / 4); for (int i = 0; i < a % 4; ++i) { f = f * perm[u[i]]; } for (int i = 0; i < b % 4; ++i) { g = g * perm[v[i]]; } vector<int> res = f * rev(g); for (int i = 0; i < n; ++i) { cout << res[i] + 1 << " "; } cout << endl; // int k; // cin >> k; // vector<vector<int>> w; // w.push_back({0}); // w.push_back({2}); // for (int i = 2; i < k; ++i) { // vector<int> nxt = w.back(); // vector<int> arr = w[sz(w) - 2]; // for (int i = 0; i < sz(arr); ++i) { // arr[i] ^= 1; // } // reverse(all(arr)); // for (int i = 0; i < sz(arr); ++i) { // if ((arr[i] ^ nxt.back()) == 1) { // nxt.pop_back(); // } else { // nxt.push_back(arr[i]); // } // } // w.push_back(nxt); // } // vector<int> u = {2, 1, 3, 0}; // vector<int> v = {3, 0, 2, 1}; // for (int i = 0; i < k; ++i) { // int a = 0, b = 0; // for (int j = 0; j < sz(w[i]); ++j) { // if (w[i][j] != u[j % 4]) { // break; // } // ++a; // } // reverse(all(w[i])); // for (int j = 0; j < sz(w[i]); ++j) { // if (w[i][j] != v[j % 4]) { // break; // } // ++b; // } // reverse(all(w[i])); // // cout << i << " " << sz(w[i]) << " " << a << " " << b << endl; // int s = i + (i - 1) / 3; // int aa = (s + 1) / 2 + 1; // int bb = (s + 1) / 2 - 1; // if (i >= 2) { // assert(s == sz(w[i])); // assert(a == aa); // assert(b == bb); // } // // cout << i << " " << s << " " << aa << " " << bb << endl; // } // for (int i = 0; i < k; ++i) { // // if (i % 3 != 1) { // // continue; // // } // for (int el : w[i]) { // cout << el << " "; // } // cout << endl; // } // int n, k; // cin >> n >> k; // vector<vector<int>> a(2, vector<int>(n)); // for (int i = 0; i < 2; ++i) { // for (int j = 0; j < n; ++j) { // cin >> a[i][j]; // --a[i][j]; // } // } // while (sz(a) < k) { // int m = sz(a); // a.push_back(vector<int>(n)); // vector<int> r(n); // for (int i = 0; i < n; ++i) { // r[a[m - 2][i]] = i; // } // for (int i = 0; i < n; ++i) { // a[m][i] = a[m - 1][r[i]]; // } // } // for (int i = 0; i < n; ++i) { // cout << a[k - 1][i] + 1 << " "; // } // cout << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <tuple> #include <unordered_map> #include <vector> #define all(a) (a).begin(), (a).end() #define sz(a) (int)(a).size() using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef unsigned int uint; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); // default_random_engine generator; // mt19937 rnd(1); vector<int> operator*(const vector<int> &a, const vector<int> &b) { int n = sz(a); vector<int> res(n); for (int i = 0; i < n; ++i) { res[i] = a[b[i]]; } return res; } vector<int> id(int n) { vector<int> res(n); for (int i = 0; i < n; ++i) { res[i] = i; } return res; } vector<int> binPow(vector<int> a, int m) { int n = sz(a); vector<int> res = id(n); for (; m > 0; m >>= 1) { if (m & 1) { res = res * a; } a = a * a; } return res; } vector<int> rev(const vector<int> &a) { int n = sz(a); vector<int> res(n); for (int i = 0; i < n; ++i) { res[a[i]] = i; } return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); vector<int> u = {2, 1, 3, 0}; // vector<int> v = {3, 0, 2, 1}; vector<int> v = {2, 1, 3, 0}; int n, k; cin >> n >> k; vector<int> p(n), q(n); for (int i = 0; i < n; ++i) { cin >> p[i]; --p[i]; } for (int j = 0; j < n; ++j) { cin >> q[j]; --q[j]; } --k; if (k == 0) { for (int el : p) { cout << el + 1 << " "; } cout << endl; return 0; } if (k == 1) { for (int el : q) { cout << el + 1 << " "; } cout << endl; return 0; } int s = k + (k - 1) / 3; int a = (s + 1) / 2 + 1; int b = (s + 1) / 2 - 1; if (a + b > s) { --a; } vector<vector<int>> perm(4); perm[0] = p; perm[1] = rev(p); perm[2] = q; perm[3] = rev(q); vector<int> f = id(n); vector<int> g = id(n); for (int i = 0; i < 4; ++i) { f = f * perm[u[i]]; g = g * perm[v[i]]; } f = binPow(f, a / 4); g = binPow(g, b / 4); for (int i = 0; i < a % 4; ++i) { f = f * perm[u[i]]; } for (int i = 0; i < b % 4; ++i) { g = g * perm[v[i]]; } vector<int> res = f * rev(g); for (int i = 0; i < n; ++i) { cout << res[i] + 1 << " "; } cout << endl; // int k; // cin >> k; // vector<vector<int>> w; // w.push_back({0}); // w.push_back({2}); // for (int i = 2; i < k; ++i) { // vector<int> nxt = w.back(); // vector<int> arr = w[sz(w) - 2]; // for (int i = 0; i < sz(arr); ++i) { // arr[i] ^= 1; // } // reverse(all(arr)); // for (int i = 0; i < sz(arr); ++i) { // if ((arr[i] ^ nxt.back()) == 1) { // nxt.pop_back(); // } else { // nxt.push_back(arr[i]); // } // } // w.push_back(nxt); // } // vector<int> u = {2, 1, 3, 0}; // vector<int> v = {3, 0, 2, 1}; // for (int i = 0; i < k; ++i) { // int a = 0, b = 0; // for (int j = 0; j < sz(w[i]); ++j) { // if (w[i][j] != u[j % 4]) { // break; // } // ++a; // } // reverse(all(w[i])); // for (int j = 0; j < sz(w[i]); ++j) { // if (w[i][j] != v[j % 4]) { // break; // } // ++b; // } // reverse(all(w[i])); // // cout << i << " " << sz(w[i]) << " " << a << " " << b << endl; // int s = i + (i - 1) / 3; // int aa = (s + 1) / 2 + 1; // int bb = (s + 1) / 2 - 1; // if (i >= 2) { // assert(s == sz(w[i])); // assert(a == aa); // assert(b == bb); // } // // cout << i << " " << s << " " << aa << " " << bb << endl; // } // for (int i = 0; i < k; ++i) { // // if (i % 3 != 1) { // // continue; // // } // for (int el : w[i]) { // cout << el << " "; // } // cout << endl; // } // int n, k; // cin >> n >> k; // vector<vector<int>> a(2, vector<int>(n)); // for (int i = 0; i < 2; ++i) { // for (int j = 0; j < n; ++j) { // cin >> a[i][j]; // --a[i][j]; // } // } // while (sz(a) < k) { // int m = sz(a); // a.push_back(vector<int>(n)); // vector<int> r(n); // for (int i = 0; i < n; ++i) { // r[a[m - 2][i]] = i; // } // for (int i = 0; i < n; ++i) { // a[m][i] = a[m - 1][r[i]]; // } // } // for (int i = 0; i < n; ++i) { // cout << a[k - 1][i] + 1 << " "; // } // cout << endl; }
[ "expression.operation.binary.add" ]
907,559
907,560
u035969230
cpp
p03098
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef complex<double> point; #define xx real() #define yy imag() #define REP(i, a, b) for (int i = (a); i < (int)(b); i++) #define REPN(i, a, b) for (int i = (a); i <= (int)(b); i++) #define FA(it, x) \ for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++) #define SZ(x) (int)(x).size() #define BE(x) (x).begin(), (x).end() #define SORT(x) sort(BE(x)) #define _1 first #define _2 second #define x1 gray_cat_x1 #define y1 gray_cat_y1 template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } #define file "I1" const double EPS = 1e-9; const double PI = acos(-1.); const int INF = 1e9; const ll MOD = 1e9 + 7; const int MAXN = 1e5 + 5; /*vector<char> s[3]; void output(int ind) { REP(i, 0, SZ(s[ind])) { putchar(s[ind][i]); } putchar('\n'); }*/ int n; int A[MAXN], B[MAXN], a[MAXN], b[MAXN]; int BabA[MAXN], aBAb[MAXN], _left[MAXN], _right[MAXN]; int ans[MAXN]; void output(int *per) { REP(i, 0, n) { printf("%d ", per[i] + 1); } putchar('\n'); } void mul(int *per1, int *per2, int *res) { REP(i, 0, n) { res[i] = per2[per1[i]]; } } int tmp_per[MAXN]; void mul_by(int *per, int *per_by) { REP(i, 0, n) { tmp_per[i] = per[i]; } mul(tmp_per, per_by, per); } int pow_per[MAXN]; void pow_mod(int *per, int st, int *res) { REP(i, 0, n) { res[i] = i; pow_per[i] = per[i]; } for (; st; st /= 2) { if (st & 1) { mul_by(res, pow_per); } REP(i, 0, n) { tmp_per[i] = pow_per[i]; } mul(tmp_per, tmp_per, pow_per); } } void solve() { /*s[1].pb('A'); s[2].pb('B'); output(1); output(2); REP(i, 3, 30) { int ind = i % 3, ind1 = (i + 1) % 3, ind2 = (i + 2) % 3; s[ind] = s[ind2]; for(int i = SZ(s[ind1]) - 1; i >= 0; i--) { char cur = s[ind1][i]; if (cur == s[ind].back()) { s[ind].pop_back(); } else { if (cur <= 'B') { cur += 'b' - 'B'; } else { cur -= 'b' - 'B'; } s[ind].pb(cur); } } output(ind); }*/ int k; scanf("%d%d", &n, &k); REP(i, 0, n) { scanf("%d", &A[i]); A[i]--; a[A[i]] = i; } REP(i, 0, n) { scanf("%d", &B[i]); B[i]--; b[B[i]] = i; } if (k == 1) { output(A); return; } if (k == 2) { output(B); return; } int l1 = (k / 3 * 2 + k % 3); int l2 = ((k - 4) / 3 * 2 + (k - 4) % 3); if (k <= 4) { l2 = 0; } REP(i, 0, n) { BabA[i] = A[i]; } mul_by(BabA, b); mul_by(BabA, a); mul_by(BabA, B); REP(i, 0, n) { aBAb[i] = b[i]; } mul_by(aBAb, A); mul_by(aBAb, B); mul_by(aBAb, a); pow_mod(BabA, l1 / 4, _left); pow_mod(aBAb, l2 / 4, _right); REP(i, 0, n) { ans[i] = _right[i]; } if (l2 % 4 >= 1) { mul_by(ans, b); } if (l2 % 4 >= 2) { mul_by(ans, A); } if (l2 % 4 >= 3) { mul_by(ans, B); } if (l1 % 4 >= 3) { mul_by(ans, b); } if (l1 % 4 >= 2) { mul_by(ans, a); } if (l1 % 4 >= 2) { mul_by(ans, B); } mul_by(ans, _left); output(ans); } int main() { // freopen(file".in", "r", stdin); freopen(file".out", "w", stdout); int t = 1; // cin >> t; while (t--) { solve(); } }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef complex<double> point; #define xx real() #define yy imag() #define REP(i, a, b) for (int i = (a); i < (int)(b); i++) #define REPN(i, a, b) for (int i = (a); i <= (int)(b); i++) #define FA(it, x) \ for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++) #define SZ(x) (int)(x).size() #define BE(x) (x).begin(), (x).end() #define SORT(x) sort(BE(x)) #define _1 first #define _2 second #define x1 gray_cat_x1 #define y1 gray_cat_y1 template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } #define file "I1" const double EPS = 1e-9; const double PI = acos(-1.); const int INF = 1e9; const ll MOD = 1e9 + 7; const int MAXN = 2e5 + 5; /*vector<char> s[3]; void output(int ind) { REP(i, 0, SZ(s[ind])) { putchar(s[ind][i]); } putchar('\n'); }*/ int n; int A[MAXN], B[MAXN], a[MAXN], b[MAXN]; int BabA[MAXN], aBAb[MAXN], _left[MAXN], _right[MAXN]; int ans[MAXN]; void output(int *per) { REP(i, 0, n) { printf("%d ", per[i] + 1); } putchar('\n'); } void mul(int *per1, int *per2, int *res) { REP(i, 0, n) { res[i] = per2[per1[i]]; } } int tmp_per[MAXN]; void mul_by(int *per, int *per_by) { REP(i, 0, n) { tmp_per[i] = per[i]; } mul(tmp_per, per_by, per); } int pow_per[MAXN]; void pow_mod(int *per, int st, int *res) { REP(i, 0, n) { res[i] = i; pow_per[i] = per[i]; } for (; st; st /= 2) { if (st & 1) { mul_by(res, pow_per); } REP(i, 0, n) { tmp_per[i] = pow_per[i]; } mul(tmp_per, tmp_per, pow_per); } } void solve() { /*s[1].pb('A'); s[2].pb('B'); output(1); output(2); REP(i, 3, 30) { int ind = i % 3, ind1 = (i + 1) % 3, ind2 = (i + 2) % 3; s[ind] = s[ind2]; for(int i = SZ(s[ind1]) - 1; i >= 0; i--) { char cur = s[ind1][i]; if (cur == s[ind].back()) { s[ind].pop_back(); } else { if (cur <= 'B') { cur += 'b' - 'B'; } else { cur -= 'b' - 'B'; } s[ind].pb(cur); } } output(ind); }*/ int k; scanf("%d%d", &n, &k); REP(i, 0, n) { scanf("%d", &A[i]); A[i]--; a[A[i]] = i; } REP(i, 0, n) { scanf("%d", &B[i]); B[i]--; b[B[i]] = i; } if (k == 1) { output(A); return; } if (k == 2) { output(B); return; } int l1 = (k / 3 * 2 + k % 3); int l2 = ((k - 4) / 3 * 2 + (k - 4) % 3); if (k <= 4) { l2 = 0; } REP(i, 0, n) { BabA[i] = A[i]; } mul_by(BabA, b); mul_by(BabA, a); mul_by(BabA, B); REP(i, 0, n) { aBAb[i] = b[i]; } mul_by(aBAb, A); mul_by(aBAb, B); mul_by(aBAb, a); pow_mod(BabA, l1 / 4, _left); pow_mod(aBAb, l2 / 4, _right); REP(i, 0, n) { ans[i] = _right[i]; } if (l2 % 4 >= 1) { mul_by(ans, b); } if (l2 % 4 >= 2) { mul_by(ans, A); } if (l2 % 4 >= 3) { mul_by(ans, B); } if (l1 % 4 >= 3) { mul_by(ans, b); } if (l1 % 4 >= 2) { mul_by(ans, a); } if (l1 % 4 >= 1) { mul_by(ans, B); } mul_by(ans, _left); output(ans); } int main() { // freopen(file".in", "r", stdin); freopen(file".out", "w", stdout); int t = 1; // cin >> t; while (t--) { solve(); } }
[ "literal.number.change", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
907,561
907,562
u308650788
cpp
p03098
#define _CRT_SECURE_NO_WARNINGS #pragma comment(linker, "/STACK:256000000") #define _USE_MATH_DEFINES #include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef pair<char, char> pcc; typedef pair<double, double> pdd; #define show(x) cerr << x #define debug(x) show(#x << ": " << (x) << endl) const long double PI = 3.14159265358979323846; const long double eps = 1e-5; const int INF = numeric_limits<int>::max(); const ll LINF = numeric_limits<ll>::max(); const ll mod = 1000 * 1000 * 1000 + 7; vector<int> inv(const vector<int> &a) { int n = a.size(); vector<int> res(n); for (int i = 0; i < n; ++i) res[a[i]] = i; return res; } vector<int> mult(const vector<int> &a, const vector<int> &b) { int n = a.size(); vector<int> res(n); for (int i = 0; i < n; ++i) { res[i] = a[b[i]]; } return res; } vector<int> power(vector<int> a, int n) { int sz = a.size(); vector<int> res(sz); for (int i = 0; i < sz; ++i) res[i] = i; while (n) { if (n & 1) res = mult(res, a); a = mult(a, a); n /= 2; } return res; } void solve() { int n, k; cin >> n >> k; vector<int> p(n), q(n); for (int i = 0; i < n; ++i) { cin >> p[i]; --p[i]; } for (int i = 0; i < n; ++i) { cin >> q[i]; --q[i]; } int tr = 20; if (k < tr) { vector<vector<int>> res(k); res[0] = p; res[1] = q; for (int i = 2; i < k; ++i) res[i] = mult(res[i - 1], inv(res[i - 2])); for (int i = 0; i < n; ++i) { cout << res[k - 1][i] + 1 << " "; } cout << endl; return; } int x = (k + 1) / 6; int r = (k + 1) % 6; vector<int> p1 = mult(mult(q, inv(p)), mult(inv(q), p)); vector<int> p2 = mult(mult(inv(p), q), mult(p, inv(q))); p1 = power(p1, x); int y = x - 1; if (r >= 3) ++y; p2 = power(p2, y); vector<int> p3; if (r == 0) { p3 = inv(q); } if (r == 1) { p3 = mult(p, inv(q)); } if (r == 2) { p3 = mult(q, mult(p, inv(q))); } if (r == 3) { p3 = q; } if (r == 4) { p3 = mult(q, inv(p)); } if (r == 5) { p3 = mult(mult(q, inv(p)), inv(q)); } vector<int> res = mult(p1, mult(p3, p2)); for (int i = 0; i < res.size(); ++i) cout << res[i] + 1 << " "; cout << endl; } //#define LOCAL int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); #ifdef LOCAL freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif solve(); #ifdef LOCAL cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif return 0; }
#define _CRT_SECURE_NO_WARNINGS #pragma comment(linker, "/STACK:256000000") #define _USE_MATH_DEFINES #include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef pair<char, char> pcc; typedef pair<double, double> pdd; #define show(x) cerr << x #define debug(x) show(#x << ": " << (x) << endl) const long double PI = 3.14159265358979323846; const long double eps = 1e-5; const int INF = numeric_limits<int>::max(); const ll LINF = numeric_limits<ll>::max(); const ll mod = 1000 * 1000 * 1000 + 7; vector<int> inv(const vector<int> &a) { int n = a.size(); vector<int> res(n); for (int i = 0; i < n; ++i) res[a[i]] = i; return res; } vector<int> mult(const vector<int> &a, const vector<int> &b) { int n = a.size(); vector<int> res(n); for (int i = 0; i < n; ++i) { res[i] = a[b[i]]; } return res; } vector<int> power(vector<int> a, int n) { int sz = a.size(); vector<int> res(sz); for (int i = 0; i < sz; ++i) res[i] = i; while (n) { if (n & 1) res = mult(res, a); a = mult(a, a); n /= 2; } return res; } void solve() { int n, k; cin >> n >> k; vector<int> p(n), q(n); for (int i = 0; i < n; ++i) { cin >> p[i]; --p[i]; } for (int i = 0; i < n; ++i) { cin >> q[i]; --q[i]; } int tr = 20; if (k < tr) { vector<vector<int>> res(k + 5); res[0] = p; res[1] = q; for (int i = 2; i < k; ++i) res[i] = mult(res[i - 1], inv(res[i - 2])); for (int i = 0; i < n; ++i) { cout << res[k - 1][i] + 1 << " "; } cout << endl; return; } int x = (k + 1) / 6; int r = (k + 1) % 6; vector<int> p1 = mult(mult(q, inv(p)), mult(inv(q), p)); vector<int> p2 = mult(mult(inv(p), q), mult(p, inv(q))); p1 = power(p1, x); int y = x - 1; if (r >= 3) ++y; p2 = power(p2, y); vector<int> p3; if (r == 0) { p3 = inv(q); } if (r == 1) { p3 = mult(p, inv(q)); } if (r == 2) { p3 = mult(q, mult(p, inv(q))); } if (r == 3) { p3 = q; } if (r == 4) { p3 = mult(q, inv(p)); } if (r == 5) { p3 = mult(mult(q, inv(p)), inv(q)); } vector<int> res = mult(p1, mult(p3, p2)); for (int i = 0; i < res.size(); ++i) cout << res[i] + 1 << " "; cout << endl; } //#define LOCAL int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); #ifdef LOCAL freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif solve(); #ifdef LOCAL cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif return 0; }
[ "assignment.change" ]
907,564
907,565
u644276233
cpp
p03098
#include <iostream> using namespace std; int n, k; int a[100001]; int one[100001]; int t[100001]; void cpy(int *u, int *w) { for (int i = 1; i <= n; i++) w[i] = u[i]; } int out(int *u) { for (int i = 1; i <= n; i++) cout << u[i] << ' '; cout << endl; return 0; } void mul(int *u, int *v, int *w) { for (int i = 1; i <= n; i++) t[i] = v[u[i]]; cpy(t, w); } void inv(int *u, int *w) { for (int i = 1; i <= n; i++) t[u[i]] = i; cpy(t, w); } void pw(int *u, int k, int *w) { if (k == 0) { cpy(one, w); return; } if (k % 2 == 1) { pw(u, k - 1, w); mul(w, u, w); } else { pw(u, k / 2, w); mul(w, w, w); } } int p[100001]; int q[100001]; int r[100001]; int s[100001]; int x[100001]; int y[100001]; int invp[100001]; int invq[100001]; int main() { ios::sync_with_stdio(false); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> p[i]; for (int i = 1; i <= n; i++) cin >> q[i]; for (int i = 1; i <= n; i++) one[i] = i; if (k == 1) return out(p); if (k == 2) return out(q); inv(p, invp); inv(q, invq); // out(t);out(invq); if (k % 6 == 1) cpy(p, r); if (k % 6 == 2) cpy(q, r); if (k % 6 == 3) mul(invp, q, r); if (k % 6 == 4) cpy(invp, r); if (k % 6 == 5) cpy(invq, r); if (k % 6 == 0) mul(invq, p, r); // out(r); mul(invq, p, s); mul(s, q, s); mul(s, invp, s); int pl = (2 * k - 4) / 3; pw(s, pl / 4, x); if (pl % 4 >= 1) mul(x, invq, x); if (pl % 4 >= 2) mul(x, p, x); if (pl % 4 >= 3) mul(x, q, x); mul(x, r, y); inv(x, x); mul(y, x, y); out(y); }
#include <iostream> using namespace std; int n, k; int a[100001]; int one[100001]; int t[100001]; void cpy(int *u, int *w) { for (int i = 1; i <= n; i++) w[i] = u[i]; } int out(int *u) { for (int i = 1; i <= n; i++) cout << u[i] << ' '; cout << endl; return 0; } void mul(int *u, int *v, int *w) { for (int i = 1; i <= n; i++) t[i] = v[u[i]]; cpy(t, w); } void inv(int *u, int *w) { for (int i = 1; i <= n; i++) t[u[i]] = i; cpy(t, w); } void pw(int *u, int k, int *w) { if (k == 0) { cpy(one, w); return; } if (k % 2 == 1) { pw(u, k - 1, w); mul(w, u, w); } else { pw(u, k / 2, w); mul(w, w, w); } } int p[100001]; int q[100001]; int r[100001]; int s[100001]; int x[100001]; int y[100001]; int invp[100001]; int invq[100001]; int main() { ios::sync_with_stdio(false); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> p[i]; for (int i = 1; i <= n; i++) cin >> q[i]; for (int i = 1; i <= n; i++) one[i] = i; if (k == 1) return out(p); if (k == 2) return out(q); inv(p, invp); inv(q, invq); // out(t);out(invq); if (k % 6 == 1) cpy(p, r); if (k % 6 == 2) cpy(q, r); if (k % 6 == 3) mul(invp, q, r); if (k % 6 == 4) cpy(invp, r); if (k % 6 == 5) cpy(invq, r); if (k % 6 == 0) mul(p, invq, r); // out(r); mul(invq, p, s); mul(s, q, s); mul(s, invp, s); int pl = (2 * k - 4) / 3; pw(s, pl / 4, x); if (pl % 4 >= 1) mul(x, invq, x); if (pl % 4 >= 2) mul(x, p, x); if (pl % 4 >= 3) mul(x, q, x); mul(x, r, y); inv(x, x); mul(y, x, y); out(y); }
[ "call.arguments.change", "call.arguments.add" ]
907,568
907,569
u707303246
cpp
p03099
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <queue> using namespace std; long long read() { char c = getchar(); long long res = 0; while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') res = (res << 1) + (res << 3) + (c ^ 48), c = getchar(); return res; } int n, m, s, t, h[405], cnt = 1, lx[205], rx[205], ly[205], ry[205], p[405], pre[405]; long long d[405], ans, sum; bool vis[405]; char op[10]; struct Edge { int to, next, d; long long v; } w[100005]; struct node { int x, y; long long v; } a[100005]; struct que { int op, x, v; } b[100005]; void add(int x, int y, int d, long long v) { w[++cnt] = (Edge){y, h[x], d, v}; h[x] = cnt; w[++cnt] = (Edge){x, h[y], 0, -v}; h[y] = cnt; } bool Spfa() { memset(d, 0x3f, sizeof(d)); d[s] = 0; p[s] = 0x3f3f3f3f; p[t] = 0; queue<int> q; q.push(s); while (!q.empty()) { int u = q.front(); q.pop(); vis[u] = 0; for (int i = h[u]; i; i = w[i].next) { int to = w[i].to; if (w[i].d && d[to] > d[u] + w[i].v) { d[to] = d[u] + w[i].v; p[to] = min(p[u], w[i].d); pre[to] = i; if (!vis[to]) q.push(to), vis[to] = 1; } } } return p[t]; } void Solve() { sum += p[t] * d[t]; int now = t; while (now != s) { w[pre[now]].d -= p[t]; w[pre[now] ^ 1].d += p[t]; now = w[pre[now] ^ 1].to; } } void EK() { sum = 0; while (Spfa()) Solve(); } int main() { n = read(); for (int i = 1; i <= n; i++) a[i].x = read(), a[i].y = read(), a[i].v = read(); m = read(); for (int i = 1; i <= m; i++) { scanf("%s", op); if (op[0] == 'L') b[i].op = 1; else if (op[0] == 'R') b[i].op = 2; else if (op[0] == 'D') b[i].op = 3; else b[i].op = 4; b[i].x = read(), b[i].v = read(); } for (int k = 1; k <= n; k++) { memset(h, 0, sizeof(h)); cnt = 1; s = 0, t = 2 * k + 2 * n + 1; for (int i = 1; i <= k; i++) add(s, i, 1, 0), add(i + 2 * n + k, t, 1, 0); memset(lx, 0, sizeof(lx)); memset(rx, 0x3f, sizeof(rx)); memset(ly, 0, sizeof(ly)); memset(ry, 0x3f, sizeof(ry)); for (int i = 1; i <= m; i++) { if (b[i].op == 1) for (int j = b[i].v + 1; j <= k; j++) lx[j] = max(lx[j], b[i].x + 1); else if (b[i].op == 2) for (int j = 1; j <= k - b[i].v; j++) rx[j] = min(rx[j], b[i].x - 1); else if (b[i].op == 3) for (int j = b[i].v + 1; j <= k; j++) ly[j] = max(ly[j], b[i].x + 1); else for (int j = 1; j <= k - b[i].v; j++) ry[j] = min(ry[j], b[i].x - 1); } for (int i = 1; i <= n; i++) add(i + k, i + n + k, 1, a[i].v); for (int i = 1; i <= k; i++) for (int j = 1; j <= n; j++) if (lx[i] <= a[j].x && a[j].x <= rx[i]) add(i, j + k, 1, 0); for (int i = 1; i <= k; i++) for (int j = 1; j <= n; j++) if (ly[i] <= a[j].y && a[j].y <= ry[i]) add(j + k + n, 2 * n + i + k, 1, 0); EK(); ans = max(ans, sum); } printf("%lld\n", ans); }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <queue> using namespace std; long long read() { char c = getchar(); long long res = 0; while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') res = (res << 1) + (res << 3) + (c ^ 48), c = getchar(); return res; } int n, m, s, t, h[405], cnt = 1, lx[205], rx[205], ly[205], ry[205], p[405], pre[405]; long long d[405], ans, sum; bool vis[405]; char op[10]; struct Edge { int to, next, d; long long v; } w[100005]; struct node { int x, y; long long v; } a[100005]; struct que { int op, x, v; } b[100005]; void add(int x, int y, int d, long long v) { w[++cnt] = (Edge){y, h[x], d, v}; h[x] = cnt; w[++cnt] = (Edge){x, h[y], 0, -v}; h[y] = cnt; } bool Spfa() { memset(d, -0x3f, sizeof(d)); d[s] = 0; p[s] = 0x3f3f3f3f; p[t] = 0; queue<int> q; q.push(s); while (!q.empty()) { int u = q.front(); q.pop(); vis[u] = 0; for (int i = h[u]; i; i = w[i].next) { int to = w[i].to; if (w[i].d && d[to] < d[u] + w[i].v) { d[to] = d[u] + w[i].v; p[to] = min(p[u], w[i].d); pre[to] = i; if (!vis[to]) q.push(to), vis[to] = 1; } } } return p[t]; } void Solve() { sum += p[t] * d[t]; int now = t; while (now != s) { w[pre[now]].d -= p[t]; w[pre[now] ^ 1].d += p[t]; now = w[pre[now] ^ 1].to; } } void EK() { sum = 0; while (Spfa()) Solve(); } int main() { n = read(); for (int i = 1; i <= n; i++) a[i].x = read(), a[i].y = read(), a[i].v = read(); m = read(); for (int i = 1; i <= m; i++) { scanf("%s", op); if (op[0] == 'L') b[i].op = 1; else if (op[0] == 'R') b[i].op = 2; else if (op[0] == 'D') b[i].op = 3; else b[i].op = 4; b[i].x = read(), b[i].v = read(); } for (int k = 1; k <= n; k++) { memset(h, 0, sizeof(h)); cnt = 1; s = 0, t = 2 * k + 2 * n + 1; for (int i = 1; i <= k; i++) add(s, i, 1, 0), add(i + 2 * n + k, t, 1, 0); memset(lx, 0, sizeof(lx)); memset(rx, 0x3f, sizeof(rx)); memset(ly, 0, sizeof(ly)); memset(ry, 0x3f, sizeof(ry)); for (int i = 1; i <= m; i++) { if (b[i].op == 1) for (int j = b[i].v + 1; j <= k; j++) lx[j] = max(lx[j], b[i].x + 1); else if (b[i].op == 2) for (int j = 1; j <= k - b[i].v; j++) rx[j] = min(rx[j], b[i].x - 1); else if (b[i].op == 3) for (int j = b[i].v + 1; j <= k; j++) ly[j] = max(ly[j], b[i].x + 1); else for (int j = 1; j <= k - b[i].v; j++) ry[j] = min(ry[j], b[i].x - 1); } for (int i = 1; i <= n; i++) add(i + k, i + n + k, 1, a[i].v); for (int i = 1; i <= k; i++) for (int j = 1; j <= n; j++) if (lx[i] <= a[j].x && a[j].x <= rx[i]) add(i, j + k, 1, 0); for (int i = 1; i <= k; i++) for (int j = 1; j <= n; j++) if (ly[i] <= a[j].y && a[j].y <= ry[i]) add(j + k + n, 2 * n + i + k, 1, 0); EK(); ans = max(ans, sum); } printf("%lld\n", ans); }
[ "expression.operation.unary.arithmetic.add", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
907,579
907,580
u562042360
cpp
p03101
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int H, W, h, w; cin >> H >> W; cin >> h >> W; cout << ((H - h) * (W - w)) << endl; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int H, W, h, w; cin >> H >> W; cin >> h >> w; cout << ((H - h) * (W - w)) << endl; }
[ "identifier.change", "expression.operation.binary.change" ]
907,595
907,596
u879294842
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * W - H * w - w * h; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * W - H * w + w * h; }
[ "misc.opposites", "expression.operator.arithmetic.change", "io.output.change" ]
907,599
907,600
u466865328
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, A, B; cin >> H >> W >> A >> B; cout << (H - A) * (W * B) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, A, B; cin >> H >> W >> A >> B; cout << (H - A) * (W - B) << endl; }
[ "expression.operator.arithmetic.change", "io.output.change" ]
907,617
907,618
u740002394
cpp
p03101
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1e16; const ll mod = 1000000007; #define rep(i, n) for (int i = 0; i < (ll)(n); i++) int main() { ll h, w; cin >> h >> w; ll n, m; cin >> n >> m; ll res = h * w; res -= n * w + m * h; res += n * w; cout << res << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1e16; const ll mod = 1000000007; #define rep(i, n) for (int i = 0; i < (ll)(n); i++) int main() { ll h, w; cin >> h >> w; ll n, m; cin >> n >> m; ll res = h * w; res -= n * w + m * h; res += n * m; cout << res << endl; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
907,623
907,624
u785492958
cpp
p03101
#include <bits/stdc++.h> #define test \ int t; \ cin >> t; \ while (t--) #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); typedef long long ll; using namespace std; int main() { long long a, b, c, d; cin >> a >> b >> c >> d; cout << a * b - ((a - c) * (b - d)) << endl; }
#include <bits/stdc++.h> #define test \ int t; \ cin >> t; \ while (t--) #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); typedef long long ll; using namespace std; int main() { long long a, b, c, d; cin >> a >> b >> c >> d; cout << ((a - c) * (b - d)) << endl; }
[ "expression.operation.binary.remove" ]
907,625
907,626
u446732668
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main(void) { //* int a, b, c, d; cin >> a >> b >> c >> d; //*/ /* vector<int> vec(3); cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ; sort(vec.begin(), vec.end()); //*/ /* if( b / a < c ){ cout << b / a << endl; } else { cout << c << endl; } //*/ cout << (a - c) / (b - d) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { //* int a, b, c, d; cin >> a >> b >> c >> d; //*/ /* vector<int> vec(3); cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ; sort(vec.begin(), vec.end()); //*/ /* if( b / a < c ){ cout << b / a << endl; } else { cout << c << endl; } //*/ cout << (a - c) * (b - d) << endl; return 0; }
[ "expression.operator.arithmetic.change", "io.output.change" ]
907,627
907,628
u316555166
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * H - w * W + h * w << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * W - w * H + h * w << endl; return 0; }
[ "identifier.change", "io.output.change" ]
907,635
907,636
u319965179
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << (H - h) * (W * w) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << (H - h) * (W - w) << endl; return 0; }
[ "expression.operator.arithmetic.change", "io.output.change" ]
907,637
907,638
u381860804
cpp
p03101
#include <iostream> #include <string.h> using namespace std; int main() { int H, W; int h, w; cin >> H >> W; cin >> h, w; int Z, z; Z = H * W; z = h * W + H * w; if (H == h or W == w) { std::cout << 0 << std::endl; } else { int R, r; r = h * w; R = Z - z + r; std::cout << R << std::endl; } }
#include <iostream> #include <string.h> using namespace std; int main() { int H, W; int h, w; cin >> H >> W; cin >> h >> w; int Z, z; Z = H * W; z = h * W + H * w; if (H == h or W == w) { std::cout << 0 << std::endl; } else { int R, r; r = h * w; R = Z - z + r; std::cout << R << std::endl; } }
[]
907,642
907,643
u863311660
cpp
p03101
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << (a - c) * (d - b) << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << (a - c) * (b - d) << endl; }
[ "expression.operation.binary.remove" ]
907,648
907,649
u225777148
cpp
p03101
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<double> vd; typedef vector<ll> vl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; typedef vector<pdd> vdd; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define mem(a, b) memset(a, b, sizeof(a)) #define all(x) (x).begin(), (x).end() #define INF 1000000000000 #define MOD 1000000007 #define PB push_back #define MP make_pair #define F first #define S second inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); } inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a * b) % MOD; } inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a + b) % MOD; } inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; } inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; } inline ll modInverse(ll a) { return modPow(a, MOD - 2); } inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { int n, m; cin >> n >> m; int a, b; cin >> a >> b; cout << m * n - (m * a + b * n) - a * b << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<double> vd; typedef vector<ll> vl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; typedef vector<pdd> vdd; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define mem(a, b) memset(a, b, sizeof(a)) #define all(x) (x).begin(), (x).end() #define INF 1000000000000 #define MOD 1000000007 #define PB push_back #define MP make_pair #define F first #define S second inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); } inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a * b) % MOD; } inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a + b) % MOD; } inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; } inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; } inline ll modInverse(ll a) { return modPow(a, MOD - 2); } inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { int n, m; cin >> n >> m; int a, b; cin >> a >> b; cout << m * n - (m * a + b * n) + a * b << endl; }
[ "misc.opposites", "expression.operator.arithmetic.change", "io.output.change" ]
907,658
907,659
u789323170
cpp
p03101
#include <bits/stdc++.h> #include <vector> using namespace std; int main() { int R, C, r, c; cin >> R >> C; cin >> r >> c; int ans = R * C - (r * C + c * R); cout << ans << endl; return 0; }
#include <bits/stdc++.h> #include <vector> using namespace std; int main() { int R, C, r, c; cin >> R >> C; cin >> r >> c; int ans = R * C - (r * C + (c * R - c * r)); cout << ans << endl; return 0; }
[]
907,668
907,669
u278032600
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << (a - c) * (b - c) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << (a - c) * (b - d) << endl; }
[ "identifier.change", "io.output.change" ]
907,672
907,673
u652660628
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int h, w, i, j; cin >> h >> w >> i >> j; int ans = (h - i) * (w - j); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int h, w, i, j; cin >> h >> w >> i >> j; int ans = (h - i) * (w - j); cout << ans; return 0; }
[]
907,674
907,675
u000770457
cpp
p03101
#include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define all(obj) (obj).begin(), (obj).end() using namespace std; typedef long long ll; int main() { int H, W, h, w; cin >> W >> H >> h >> w; cout << (H - h) * (W - w) << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define all(obj) (obj).begin(), (obj).end() using namespace std; typedef long long ll; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << (H - h) * (W - w) << endl; return 0; }
[ "expression.operation.binary.remove" ]
907,676
907,677
u941353203
cpp
p03101
#include <bits/stdc++.h> #define int long long #define mod 1000000007 #define trace(x) cerr << #x << ": " << x << " " << endl #define tarce(x) cerr << #x << ": " << x << " " << endl #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl #define trace3(x, y, z) \ cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " \ << z << endl #define trace4(a, b, c, d) \ cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \ << c << " | " << #d << ": " << d << endl #define sa(a, n) \ for (int i = 0; i < n; i++) \ cin >> a[i] #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define pb push_back #define inf 2e18 #define scan() \ int n; \ cin >> n; \ int a[n + 1]; \ for (int i = 1; i <= n; i++) \ cin >> a[i] #define scan2() \ int n, k; \ cin >> n >> k; \ int a[n + 1]; \ for (int i = 1; i <= n; i++) \ cin >> a[i] #define print(a, n) \ for (int i = 0; i < n; i++) \ cout << a[i] << ' ' #define mem(a, v) memset(a, v, sizeof(a)) #define pii pair<int, int> #define mkp make_pair using namespace std; #define N 200005 int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, b, c, d; cin >> a >> b >> c >> d; int ans = a * b - (a * d + b * c - c - d); cout << ans << '\n'; }
#include <bits/stdc++.h> #define int long long #define mod 1000000007 #define trace(x) cerr << #x << ": " << x << " " << endl #define tarce(x) cerr << #x << ": " << x << " " << endl #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl #define trace3(x, y, z) \ cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " \ << z << endl #define trace4(a, b, c, d) \ cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \ << c << " | " << #d << ": " << d << endl #define sa(a, n) \ for (int i = 0; i < n; i++) \ cin >> a[i] #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define pb push_back #define inf 2e18 #define scan() \ int n; \ cin >> n; \ int a[n + 1]; \ for (int i = 1; i <= n; i++) \ cin >> a[i] #define scan2() \ int n, k; \ cin >> n >> k; \ int a[n + 1]; \ for (int i = 1; i <= n; i++) \ cin >> a[i] #define print(a, n) \ for (int i = 0; i < n; i++) \ cout << a[i] << ' ' #define mem(a, v) memset(a, v, sizeof(a)) #define pii pair<int, int> #define mkp make_pair using namespace std; #define N 200005 int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, b, c, d; cin >> a >> b >> c >> d; int ans = a * b - (a * d + b * c - c * d); cout << ans << '\n'; }
[ "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
907,678
907,679
u125467827
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W; cin >> H >> W; int h, w; cin >> h >> w; cout << (H - h) * (W - h) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W; cin >> H >> W; int h, w; cin >> h >> w; cout << (H - h) * (W - w) << endl; }
[ "identifier.change", "io.output.change" ]
907,680
907,681
u515131769
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * W - H * w << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * W - H * w + h * w << endl; }
[ "expression.operation.binary.add" ]
907,692
907,693
u834753207
cpp
p03101
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int H, W; cin >> H >> W; int h, w; cin >> h >> w; int ans = 0; ans += H * W; ans -= h * W; ans -= w * H; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int H, W; cin >> H >> W; int h, w; cin >> h >> w; int ans = 0; ans += H * W; ans -= h * W; ans -= w * (H - h); cout << ans; return 0; }
[]
907,694
907,695
u109191542
cpp
p03101
#include <bits/stdc++.h> using namespace std; #define fo(x, n) for (int i = x; i <= n; i++) #define all(x) x.begin(), x.end() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const int MOD = 1e9 + 7; void solve() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * W - w * H - w * h; } int main() { ios::sync_with_stdio(false); cin.tie(0); int T = 1; // cin >> T; fo(1, T) { solve(); } }
#include <bits/stdc++.h> using namespace std; #define fo(x, n) for (int i = x; i <= n; i++) #define all(x) x.begin(), x.end() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const int MOD = 1e9 + 7; void solve() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * W - w * H + w * h; } int main() { ios::sync_with_stdio(false); cin.tie(0); int T = 1; // cin >> T; fo(1, T) { solve(); } }
[ "misc.opposites", "expression.operator.arithmetic.change", "io.output.change" ]
907,696
907,697
u024616993
cpp
p03101
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; int main(void) { int H, W; cin >> H >> W; int h, w; cin >> h >> w; int ans = H * W - h * W - w; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; int main(void) { int H, W; cin >> H >> W; int h, w; cin >> h >> w; int ans = (H - h) * (W - w); cout << ans << endl; return 0; }
[ "expression.operation.binary.remove" ]
907,705
907,706
u905170328
cpp
p03101
#include <bits/stdc++.h> #include <vector> using namespace std; int main(void) { int A, B; int N, M; cin >> A >> B >> N >> M; cout << A * B - (A * N + B * M) + N * M; }
#include <bits/stdc++.h> #include <vector> using namespace std; int main(void) { int A, B; int N, M; cin >> A >> B >> N >> M; cout << A * B - (A * M + B * N) + N * M; }
[ "identifier.change", "io.output.change" ]
907,717
907,718
u994956045
cpp
p03101
#include <bits/stdc++.h> using namespace std; signed main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << (a - b) * (c - d) << "\n"; }
#include <bits/stdc++.h> using namespace std; signed main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << (a - c) * (b - d) << "\n"; }
[ "identifier.change", "io.output.change" ]
907,724
907,725
u652908807
cpp
p03101
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long int ll; #define rep(i, n) for (int i = 0; i < (int)n; i++) int Min(int a, int b, int c) { if (a <= b) { return std::min(a, c); } else return std::min(b, c); } int main(void) { int a, b, c, d; cin >> a >> b >> c >> d; cout << (a - b) * (c - d) << endl; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long int ll; #define rep(i, n) for (int i = 0; i < (int)n; i++) int Min(int a, int b, int c) { if (a <= b) { return std::min(a, c); } else return std::min(b, c); } int main(void) { int a, b, c, d; cin >> a >> b >> c >> d; cout << (a - c) * (b - d) << endl; return 0; }
[ "identifier.change", "io.output.change" ]
907,728
907,729
u467561544
cpp
p03101
#include <iostream> int main() { int W, H; std::cin >> H >> W; int w, h; std::cin >> h >> w; int sum = W * H - w * H + h * W - w * h; std::cout << sum << std::endl; return 0; }
#include <iostream> int main() { int W, H; std::cin >> H >> W; int w, h; std::cin >> h >> w; int sum = W * H - w * H - h * W + w * h; std::cout << sum << std::endl; return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
907,734
907,735
u922974720
cpp
p03101
#include <algorithm> #include <array> #include <iostream> #include <math.h> #include <numeric> #include <unordered_set> #include <vector> using namespace std; using s64 = int64_t; #define rep(i, n) for (int i = 0; i < n; ++i) #define rep2(i, x, n) for (int i = x; i < n; ++i) int main() { int H, W, h, w; cin >> H >> W >> h >> w; int ret = H * W - (H - h) * (W - w); cout << ret << endl; return 0; }
#include <algorithm> #include <array> #include <iostream> #include <math.h> #include <numeric> #include <unordered_set> #include <vector> using namespace std; using s64 = int64_t; #define rep(i, n) for (int i = 0; i < n; ++i) #define rep2(i, x, n) for (int i = x; i < n; ++i) int main() { int H, W, h, w; cin >> H >> W >> h >> w; int ret = (H - h) * (W - w); cout << ret << endl; return 0; }
[ "expression.operation.binary.remove" ]
907,736
907,737
u445401544
cpp
p03101
#include <iostream> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - (H * h + W * w - h * w) << endl; }
#include <iostream> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - (H * w + W * h - h * w) << endl; }
[ "identifier.change", "io.output.change" ]
907,742
907,743
u404145225
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W; cin >> h >> w; cout << h * W + w * H - h * w << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W; cin >> h >> w; cout << W * H - (h * W + w * H - h * w) << endl; return 0; }
[ "expression.operation.binary.add" ]
907,754
907,755
u681869152
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W; cin >> h >> w; cout << h * W + w * H - h * w << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W; cin >> h >> w; cout << W * H - (h * W + w * H - h * w) << endl; return 0; }
[ "expression.operation.binary.add" ]
907,754
907,756
u681869152
cpp
p03101
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int inf = 1001001001; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - H * h - W * w + h * w << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int inf = 1001001001; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - H * w - W * h + h * w << endl; }
[ "identifier.change", "io.output.change" ]
907,761
907,762
u886613668
cpp
p03101
#include <algorithm> #include <cmath> #include <cstdlib> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <stdio.h> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define all(x) (x).begin(), (x).end() using namespace std; //================================================ int a = 0, b = 0, c, d, n, k = 0; string s, t; int main() { int H, h, W, w; cin >> H >> h >> W >> w; cout << (H - h) * (W - w) << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <stdio.h> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define all(x) (x).begin(), (x).end() using namespace std; //================================================ int a = 0, b = 0, c, d, n, k = 0; string s, t; int main() { int H, h, W, w; cin >> H >> W >> h >> w; cout << (H - h) * (W - w) << endl; return 0; }
[ "expression.operation.binary.remove" ]
907,765
907,766
u465760322
cpp
p03101
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using vll = vector<long long>; using sll = set<long long>; template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <typename T> map<T, T> getPrimeFactor(T n) { map<T, T> res; for (T i = 2; i * i <= n; ++i) { while (n % i == 0) { res[i]++; n /= i; } } if (n != 1) res[n] = 1; return res; } template <typename T> bool IsPrimeNumber(T num) { if (num <= 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } return true; } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } #define in(x) cin >> x #define out(x) cout << x #define outn(x) cout << x << '\n' #define outs(x) cout << x << ' ' #define rep(i, s, e) for (ll i = s; i < e; i++) #define repeq(i, s, e) for (ll i = s; i <= e; i++) int main() { ll H, W, h, w; in(H); in(W); in(h); in(w); outn((H - w) * (W - w)); return 0; }
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using vll = vector<long long>; using sll = set<long long>; template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <typename T> map<T, T> getPrimeFactor(T n) { map<T, T> res; for (T i = 2; i * i <= n; ++i) { while (n % i == 0) { res[i]++; n /= i; } } if (n != 1) res[n] = 1; return res; } template <typename T> bool IsPrimeNumber(T num) { if (num <= 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } return true; } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } #define in(x) cin >> x #define out(x) cout << x #define outn(x) cout << x << '\n' #define outs(x) cout << x << ' ' #define rep(i, s, e) for (ll i = s; i < e; i++) #define repeq(i, s, e) for (ll i = s; i <= e; i++) int main() { ll H, W, h, w; in(H); in(W); in(h); in(w); outn((H - h) * (W - w)); return 0; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
907,770
907,771
u757628628
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W; cin >> H >> W; int h, w; cin >> h >> w; cout << (H * W) - (h * H) - (w * W) + (h * w) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W; cin >> H >> W; int h, w; cin >> h >> w; cout << (H * W) - (h * W) - (w * H) + (h * w) << endl; }
[ "identifier.change", "io.output.change" ]
907,774
907,775
u955282280
cpp
p03101
#include <iostream> using namespace std; int main() { int h, w, hb, wb, ans; cin >> h >> w >> hb >> wb; ans = h * w - (hb * h + wb * w - hb * wb); cout << ans << endl; return 0; }
#include <iostream> using namespace std; int main() { int h, w, hb, wb, ans; cin >> h >> w >> hb >> wb; ans = h * w - (hb * w + wb * (h - hb)); cout << ans << endl; return 0; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
907,778
907,779
u608258653
cpp
p03101
//保留所有权利。 #include <algorithm> //辞書順はnext_permutationだよ #include <cmath> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <random> #include <set> #include <sstream> #include <stdio.h> //printするよ #include <string.h> #include <string> #include <time.h> #include <utility> //swapで数値交換するよ #include <vector> // END OF LIBRARIES. #define rt "\n" //改行を最速化させるよ #define rep(i, n) for (int i = 0; i < n; i++) #define rop(i, n) for (int i = 1; i <= n; i++) #define drep(i, n) for (int i = n - 1; 0 <= i; i--) #define drop(i, n) for (int i = n; 0 < i; i--) #define yes(ans) \ if (ans) \ cout << "yes" << rt; \ else \ cout << "no" << rt; #define Yes(ans) \ if (ans) \ cout << "Yes" << rt; \ else \ cout << "No" << rt; #define YES(ans) \ if (ans) \ cout << "YES" << rt; \ else \ cout << "NO" << rt; #define sec(a, b, ans) \ if (ans) \ cout << a << rt; \ else \ cout << b << rt; #define vcin(v) \ for (int i = 0; i < (v).size(); i++) { \ cin >> (v)[i]; \ } #define sort(s) sort(s.begin(), s.end()) #define reve(s) reverse(s.begin(), s.end()) #define asas int ans = 0 #define llcncn llint cnt = 0 #define llasas llint ans = 0 #define cncn int cnt = 0 #define smsm int sum = 0 #define str srting #define v vector #define please return #define AC 0 //おまじないだよ #define Rapid \ cin.tie(0); \ ios::sync_with_stdio(false) // END OF DEFINE. using namespace std; typedef vector<int> vint; typedef vector<string> vstr; typedef vector<char> vcha; typedef vector<double> vdou; typedef long long int llint; typedef pair<int, int> pint; typedef pair<llint, llint> pllint; typedef vector<llint> vllint; typedef vector<pint> vpint; typedef vector<pair<llint, llint>> vpllint; typedef vector<vector<int>> vvint; typedef vector<vector<llint>> vvllint; typedef vector<vector<string>> vvstr; typedef vector<vector<pint>> vvpint; typedef vector<bool> vbool; // printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、s // END OF TYPEDEF. //最大公約数(GCD)を求めるよ //最小公倍数(LCM)は<< A × B ÷ GCD  >>で求まるよ long long GCD(long long a, long long b) { if (b == 0) return a; else return GCD(b, a % b); } long long LCM(long long a, long long b) { return a * b / GCD(a, b); } // for A以上B未満でI探索 for (int I = A; i <= B; i++) // string s = to_string(i); int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0; string s = ""; asas; cncn; int main(void) { cin >> a >> b; cin >> x >> y; sum = a * b - x * a - y * b; sum += x * y; cout << sum << rt; please AC; }
//保留所有权利。 #include <algorithm> //辞書順はnext_permutationだよ #include <cmath> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <random> #include <set> #include <sstream> #include <stdio.h> //printするよ #include <string.h> #include <string> #include <time.h> #include <utility> //swapで数値交換するよ #include <vector> // END OF LIBRARIES. #define rt "\n" //改行を最速化させるよ #define rep(i, n) for (int i = 0; i < n; i++) #define rop(i, n) for (int i = 1; i <= n; i++) #define drep(i, n) for (int i = n - 1; 0 <= i; i--) #define drop(i, n) for (int i = n; 0 < i; i--) #define yes(ans) \ if (ans) \ cout << "yes" << rt; \ else \ cout << "no" << rt; #define Yes(ans) \ if (ans) \ cout << "Yes" << rt; \ else \ cout << "No" << rt; #define YES(ans) \ if (ans) \ cout << "YES" << rt; \ else \ cout << "NO" << rt; #define sec(a, b, ans) \ if (ans) \ cout << a << rt; \ else \ cout << b << rt; #define vcin(v) \ for (int i = 0; i < (v).size(); i++) { \ cin >> (v)[i]; \ } #define sort(s) sort(s.begin(), s.end()) #define reve(s) reverse(s.begin(), s.end()) #define asas int ans = 0 #define llcncn llint cnt = 0 #define llasas llint ans = 0 #define cncn int cnt = 0 #define smsm int sum = 0 #define str srting #define v vector #define please return #define AC 0 //おまじないだよ #define Rapid \ cin.tie(0); \ ios::sync_with_stdio(false) // END OF DEFINE. using namespace std; typedef vector<int> vint; typedef vector<string> vstr; typedef vector<char> vcha; typedef vector<double> vdou; typedef long long int llint; typedef pair<int, int> pint; typedef pair<llint, llint> pllint; typedef vector<llint> vllint; typedef vector<pint> vpint; typedef vector<pair<llint, llint>> vpllint; typedef vector<vector<int>> vvint; typedef vector<vector<llint>> vvllint; typedef vector<vector<string>> vvstr; typedef vector<vector<pint>> vvpint; typedef vector<bool> vbool; // printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、s // END OF TYPEDEF. //最大公約数(GCD)を求めるよ //最小公倍数(LCM)は<< A × B ÷ GCD  >>で求まるよ long long GCD(long long a, long long b) { if (b == 0) return a; else return GCD(b, a % b); } long long LCM(long long a, long long b) { return a * b / GCD(a, b); } // for A以上B未満でI探索 for (int I = A; i <= B; i++) // string s = to_string(i); int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0; string s = ""; asas; cncn; int main(void) { cin >> a >> b; cin >> x >> y; sum = a * b - x * b - y * a; sum += x * y; cout << sum << rt; please AC; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
907,782
907,783
u742306624
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * W - w * h + w * h << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - h * W - w * H + w * h << endl; }
[ "identifier.change", "io.output.change" ]
907,788
907,789
u649915042
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main(void) { int H, W; cin >> H >> W; int h, w; cin >> h >> w; cout << H * W - h * W - w * H + h * W << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int H, W; cin >> H >> W; int h, w; cin >> h >> w; cout << H * W - h * W - w * H + h * w << endl; return 0; }
[ "identifier.change", "io.output.change" ]
907,790
907,791
u917518913
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H - h + W - w << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << (H - h) * (W - w) << endl; return 0; }
[ "io.output.change" ]
907,792
907,793
u652712806
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - (h * H + w * W - h * w) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int H, W, h, w; cin >> H >> W >> h >> w; cout << H * W - (h * W + w * H - h * w) << endl; }
[ "identifier.change", "io.output.change" ]
907,808
907,809
u681084651
cpp
p03101
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int H, W, h, w; cin >> H >> W >> h >> w; int sum = 0; sum = H * w + h * W; sum -= h * w; cout << sum << endl; } signed main() { // while(1) solve(); }
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int H, W, h, w; cin >> H >> W >> h >> w; int sum = 0; sum = H * w + h * W; sum -= h * w; cout << H * W - sum << endl; } signed main() { // while(1) solve(); }
[ "expression.operation.binary.add" ]
907,814
907,815
u134181243
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int H, h, W, w; cin >> H >> h >> W >> w; cout << (H - h) * (W - w) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int H, h, W, w; cin >> H >> h >> W >> w; cout << (H - W) * (h - w) << endl; return 0; }
[ "identifier.change", "io.output.change" ]
907,816
907,817
u805906007
cpp
p03101
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int H, W; cin >> H >> W; int x, y; cin >> x >> y; cout << W * x + H * y - x * y << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int H, W; cin >> H >> W; int x, y; cin >> x >> y; cout << H * W - (W * x + H * y - x * y) << endl; return 0; }
[ "expression.operation.binary.add" ]
907,822
907,823
u904123392
cpp
p03101
#include <bits/stdc++.h> using namespace std; int main() { int h, w, a, b, sum; cin >> h >> w; cin >> a >> b; sum = h * w - (a * h + b * w - a * b); cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int h, w, a, b, sum; cin >> h >> w; cin >> a >> b; sum = h * w - (a * w + b * h - a * b); cout << sum << endl; return 0; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
907,837
907,838
u144029820
cpp