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
8 values
p02927
#include <bits/stdc++.h> using namespace std; int main() { int m, n, num = 0; cin >> m >> n; for (int i = 2; i <= 10; i++) { for (int j = 2; j <= 10; j++) { if (i * 10 + j <= n && i * j <= m) { num++; } } } cout << num; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int m, n, num = 0; cin >> m >> n; for (int i = 2; i < 10; i++) { for (int j = 2; j < 10; j++) { if (i * 10 + j <= n && i * j <= m) { num++; } } } cout << num; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,606
730,607
u931613131
cpp
p02927
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define FOR(i, n) for (int i = 0; i < (n); i++) #define sz(c) ((int)c.size()) #define ten(n) ((int)1e##n) using ll = long long; using Pii = pair<int, int>; using Pll = pair<ll, ll>; template <typename...> static inline int getchar_unlocked(void) { return getchar(); } template <typename...> static inline void putchar_unlocked(int c) { putchar(c); } #define mygc(c) (c) = getchar_unlocked() #define mypc(c) putchar_unlocked(c) void reader(int &x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; } if ('0' <= k && k <= '9') { x = k - '0'; break; } } for (;;) { mygc(k); if (k < '0' || k > '9') break; x = x * 10 + k - '0'; } if (m) x = -x; } void reader(ll &x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; } if ('0' <= k && k <= '9') { x = k - '0'; break; } } for (;;) { mygc(k); if (k < '0' || k > '9') break; x = x * 10 + k - '0'; } if (m) x = -x; } int reader(char c[]) { int i, s = 0; for (;;) { mygc(i); if (i != ' ' && i != '\n' && i != '\r' && i != '\t' && i != EOF) break; } c[s++] = i; for (;;) { mygc(i); if (i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF) break; c[s++] = i; } c[s] = '\0'; return s; } int reader(string &c) { int i; for (;;) { mygc(i); if (i != ' ' && i != '\n' && i != '\r' && i != '\t' && i != EOF) break; } c.push_back(i); for (;;) { mygc(i); if (i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF) break; c.push_back(i); }; return sz(c); } template <class T, class S> void reader(T &x, S &y) { reader(x); reader(y); } template <class T, class S, class U> void reader(T &x, S &y, U &z) { reader(x); reader(y); reader(z); } template <class T, class S, class U, class V> void reader(T &x, S &y, U &z, V &w) { reader(x); reader(y); reader(z); reader(w); } void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x < 0) m = 1, x = -x; while (x) f[s++] = x % 10, x /= 10; if (!s) f[s++] = 0; if (m) mypc('-'); while (s--) mypc(f[s] + '0'); mypc(c); } void writer(ll x, char c) { int s = 0, m = 0; char f[20]; if (x < 0) m = 1, x = -x; while (x) f[s++] = x % 10, x /= 10; if (!s) f[s++] = 0; if (m) mypc('-'); while (s--) mypc(f[s] + '0'); mypc(c); } void writer(const char c[]) { int i; for (i = 0; c[i] != '\0'; i++) mypc(c[i]); } void writer(const string &x, char c) { int i; for (i = 0; x[i] != '\0'; i++) mypc(x[i]); mypc(c); } void writer(const char x[], char c) { int i; for (i = 0; x[i] != '\0'; i++) mypc(x[i]); mypc(c); } template <class T> void writerLn(T x) { writer(x, '\n'); } template <class T, class S> void writerLn(T x, S y) { writer(x, ' '); writer(y, '\n'); } template <class T, class S, class U> void writerLn(T x, S y, U z) { writer(x, ' '); writer(y, ' '); writer(z, '\n'); } template <class T, class S, class U, class V> void writerLn(T x, S y, U z, V v) { writer(x, ' '); writer(y, ' '); writer(z, ' '); writer(v, '\n'); } template <class T> void writerArr(T x[], int n) { if (!n) { mypc('\n'); return; } FOR(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); } template <class T> void writerArr(vector<T> &x) { writerArr(x.data(), (int)x.size()); } template <class T> void chmin(T &a, const T &b) { if (a > b) a = b; } template <class T> void chmax(T &a, const T &b) { if (a < b) a = b; } template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } ll mod_pow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; } template <class T> T extgcd(T a, T b, T &x, T &y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; } ll mod_inv(ll a, ll m) { ll x, y; extgcd<ll>(a, m, x, y); return (m + x % m) % m; } #ifdef _MSC_VER // #ifdef _DEBUG template <typename... Args> void debugPrintf(const char *format, Args const &...args) { fprintf(stderr, format, args...); fflush(stderr); } #else #define debugPrintf(...) #endif int main() { int m, d; reader(m, d); int ans = 0; FOR(d1, 11) FOR(d2, 11) { if (d1 < 2 || d2 < 2) continue; int cd = d1 * 10 + d2; if (cd > d) continue; if (d1 * d2 <= m) ans++; } writerLn(ans); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define FOR(i, n) for (int i = 0; i < (n); i++) #define sz(c) ((int)c.size()) #define ten(n) ((int)1e##n) using ll = long long; using Pii = pair<int, int>; using Pll = pair<ll, ll>; template <typename...> static inline int getchar_unlocked(void) { return getchar(); } template <typename...> static inline void putchar_unlocked(int c) { putchar(c); } #define mygc(c) (c) = getchar_unlocked() #define mypc(c) putchar_unlocked(c) void reader(int &x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; } if ('0' <= k && k <= '9') { x = k - '0'; break; } } for (;;) { mygc(k); if (k < '0' || k > '9') break; x = x * 10 + k - '0'; } if (m) x = -x; } void reader(ll &x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; } if ('0' <= k && k <= '9') { x = k - '0'; break; } } for (;;) { mygc(k); if (k < '0' || k > '9') break; x = x * 10 + k - '0'; } if (m) x = -x; } int reader(char c[]) { int i, s = 0; for (;;) { mygc(i); if (i != ' ' && i != '\n' && i != '\r' && i != '\t' && i != EOF) break; } c[s++] = i; for (;;) { mygc(i); if (i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF) break; c[s++] = i; } c[s] = '\0'; return s; } int reader(string &c) { int i; for (;;) { mygc(i); if (i != ' ' && i != '\n' && i != '\r' && i != '\t' && i != EOF) break; } c.push_back(i); for (;;) { mygc(i); if (i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF) break; c.push_back(i); }; return sz(c); } template <class T, class S> void reader(T &x, S &y) { reader(x); reader(y); } template <class T, class S, class U> void reader(T &x, S &y, U &z) { reader(x); reader(y); reader(z); } template <class T, class S, class U, class V> void reader(T &x, S &y, U &z, V &w) { reader(x); reader(y); reader(z); reader(w); } void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x < 0) m = 1, x = -x; while (x) f[s++] = x % 10, x /= 10; if (!s) f[s++] = 0; if (m) mypc('-'); while (s--) mypc(f[s] + '0'); mypc(c); } void writer(ll x, char c) { int s = 0, m = 0; char f[20]; if (x < 0) m = 1, x = -x; while (x) f[s++] = x % 10, x /= 10; if (!s) f[s++] = 0; if (m) mypc('-'); while (s--) mypc(f[s] + '0'); mypc(c); } void writer(const char c[]) { int i; for (i = 0; c[i] != '\0'; i++) mypc(c[i]); } void writer(const string &x, char c) { int i; for (i = 0; x[i] != '\0'; i++) mypc(x[i]); mypc(c); } void writer(const char x[], char c) { int i; for (i = 0; x[i] != '\0'; i++) mypc(x[i]); mypc(c); } template <class T> void writerLn(T x) { writer(x, '\n'); } template <class T, class S> void writerLn(T x, S y) { writer(x, ' '); writer(y, '\n'); } template <class T, class S, class U> void writerLn(T x, S y, U z) { writer(x, ' '); writer(y, ' '); writer(z, '\n'); } template <class T, class S, class U, class V> void writerLn(T x, S y, U z, V v) { writer(x, ' '); writer(y, ' '); writer(z, ' '); writer(v, '\n'); } template <class T> void writerArr(T x[], int n) { if (!n) { mypc('\n'); return; } FOR(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); } template <class T> void writerArr(vector<T> &x) { writerArr(x.data(), (int)x.size()); } template <class T> void chmin(T &a, const T &b) { if (a > b) a = b; } template <class T> void chmax(T &a, const T &b) { if (a < b) a = b; } template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } ll mod_pow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; } template <class T> T extgcd(T a, T b, T &x, T &y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; } ll mod_inv(ll a, ll m) { ll x, y; extgcd<ll>(a, m, x, y); return (m + x % m) % m; } #ifdef _MSC_VER // #ifdef _DEBUG template <typename... Args> void debugPrintf(const char *format, Args const &...args) { fprintf(stderr, format, args...); fflush(stderr); } #else #define debugPrintf(...) #endif int main() { int m, d; reader(m, d); int ans = 0; FOR(d1, 10) FOR(d2, 10) { if (d1 < 2 || d2 < 2) continue; int cd = d1 * 10 + d2; if (cd > d) continue; if (d1 * d2 <= m) ans++; } writerLn(ans); return 0; }
[ "literal.number.change", "call.arguments.change" ]
730,618
730,619
u279196402
cpp
p02927
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<ll> vl; typedef vector<pair<ll, ll>> vp; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define all(v) v.begin(), v.end() #define inputv(v, n) \ rep(i, n) { \ ll x; \ cin >> x; \ v.push_back(x); \ } const ll INF = 99999999999999; const ll MOD = 1000000007; ll m, d; void input(void) { cin >> m >> d; } void solve(void) { ll ans = 0, a, b; for (ll i = 1; i < d; i++) { a = i % 10; b = i / 10; if (a > 1 && b > 1 && a * b > 0 && a * b < m + 1) { ans++; } } cout << ans << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); input(); solve(); }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<ll> vl; typedef vector<pair<ll, ll>> vp; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define all(v) v.begin(), v.end() #define inputv(v, n) \ rep(i, n) { \ ll x; \ cin >> x; \ v.push_back(x); \ } const ll INF = 99999999999999; const ll MOD = 1000000007; ll m, d; void input(void) { cin >> m >> d; } void solve(void) { ll ans = 0, a, b; for (ll i = 1; i < d + 1; i++) { a = i % 10; b = i / 10; if (a > 1 && b > 1 && a * b > 0 && a * b < m + 1) { ans++; } } cout << ans << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); input(); solve(); }
[ "control_flow.loop.for.condition.change", "misc.off_by_one" ]
730,626
730,627
u268571052
cpp
p02927
/* LANG:C++ PROB: */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> #include <iostream> #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef long long i64; typedef vector<i64> vi64; typedef vector<vi64> vvi64; typedef pair<i64, i64> pi64; typedef double ld; typedef unsigned long long ui64; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // ifstream fin(".in"); // ofstream fout(".in"); i64 m, d; cin >> m >> d; map<i64, i64> mp; i64 ans = 0; ford(i, d) { if (i % 10 > 1 && i / 10 > 1) { mp[(i / 10) * (i % 10)]++; } } for1(i, m) ans += mp[i]; cout << ans; return 0; }
/* LANG:C++ PROB: */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> #include <iostream> #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef long long i64; typedef vector<i64> vi64; typedef vector<vi64> vvi64; typedef pair<i64, i64> pi64; typedef double ld; typedef unsigned long long ui64; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // ifstream fin(".in"); // ofstream fout(".in"); i64 m, d; cin >> m >> d; map<i64, i64> mp; i64 ans = 0; for1(i, d) { if (i % 10 > 1 && i / 10 > 1) { mp[(i / 10) * (i % 10)]++; } } for1(i, m) ans += mp[i]; cout << ans; return 0; }
[ "identifier.change" ]
730,628
730,629
u114047445
cpp
p02927
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { int m, d; cin >> m >> d; int ans = 0; for (int i = 4; i <= m; i++) { for (int j = 22; j < d; j++) { int d1 = j % 10; int d10 = j / 10; if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) ans++; } } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { int m, d; cin >> m >> d; int ans = 0; for (int i = 4; i <= m; i++) { for (int j = 22; j <= d; j++) { int d1 = j % 10; int d10 = j / 10; if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) ans++; } } cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,630
730,631
u735236707
cpp
p02927
#include <bits/stdc++.h> using namespace std; int main() { int m, d, ans, t, o; cin >> m >> d; ans = 0; for (int i = 1; i <= m; i++) { for (int j = 1; j <= d; j++) { t = j / 10; o = j % 10; if (j >= 2 && i >= 2 && t * o == i) { ans++; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int m, d, ans, t, o; cin >> m >> d; ans = 0; for (int i = 1; i <= m; i++) { for (int j = 1; j <= d; j++) { t = j / 10; o = j % 10; if (t >= 2 && o >= 2 && t * o == i) { // cout << i << ' ' << j << endl; ans++; } } } cout << ans << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
730,634
730,635
u026950523
cpp
p02927
#include <bits/stdc++.h> using namespace std; int main() { int m, d, ans, t, o; cin >> m >> d; ans = 0; for (int i = 0; i < m; i++) { for (int j = 0; j < d; j++) { t = j / 10; o = j % 10; if (j >= 2 && i >= 2 && t * o == i) { ans++; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int m, d, ans, t, o; cin >> m >> d; ans = 0; for (int i = 1; i <= m; i++) { for (int j = 1; j <= d; j++) { t = j / 10; o = j % 10; if (t >= 2 && o >= 2 && t * o == i) { // cout << i << ' ' << j << endl; ans++; } } } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "identifier.change", "control_flow.branch.if.condition.change" ]
730,636
730,635
u026950523
cpp
p02927
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep_in(i, s, n) for (int i = (s); i < (int)(n); i++) typedef int64_t ll; int main() { int m, d; cin >> m >> d; int out = 0; rep(i, d) { if (i % 10 >= 2 && i / 10 >= 2 && (i / 10) * (i % 10) <= m) out++; } cout << out << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep_in(i, s, n) for (int i = (s); i < (int)(n); i++) typedef int64_t ll; int main() { int m, d; cin >> m >> d; int out = 0; rep(i, d + 1) { if (i % 10 >= 2 && i / 10 >= 2 && (i / 10) * (i % 10) <= m) out++; } cout << out << endl; }
[ "expression.operation.binary.add" ]
730,639
730,640
u737252485
cpp
p02927
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int iINF = 2147483647 / 2; const long long int llINF = 9223372036854775807 / 2; using namespace std; using ll = long long int; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>; typedef pair<ll, ll> pll; bool paircomp(const pll &a, const pll &b) { if (a.first == b.first) return a.second < b.second; return a.first < b.first; } #define REP(i, n) for (ll i = 0; i < (n); i++) #define RREP(i, n) for (ll i = (n)-1; i >= 0; i--) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define AUTO(i, m) for (auto &i : m) #define ALL(a) (a).begin(), (a).end() #define MAX(vec) *std::max_element(vec.begin(), vec.end()) #define MIN(vec) *std::min_element(vec.begin(), vec.end()) #define ARGMAX(vec) \ std::distance(vec.begin(), std::max_element(vec.begin(), vec.end())) #define ARGMIN(vec) \ std::distance(vec.begin(), std::min_element(vec.begin(), vec.end())) #define REV(T) greater<T>() #define PQ(T) priority_queue<T, vector<T>, greater<T>> #define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c)) #define VVVL(a, b, c, d) \ vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d))) #define SP(a) setprecision(a) #define SQRT(a) sqrt((long double)(a)) #define DPOW(a, b) pow((long double)(a), (long double)(b)) #define UNIQUE(vec) \ do { \ sort(ALL((vec))); \ (vec).erase(std::unique(ALL((vec))), (vec).end()); \ } while (0) ll POW(ll n, ll m) { if (m == 0) { return 1; } else if (m % 2 == 0) { ll tmp = POW(n, m / 2); return (tmp * tmp); } else { return (n * POW(n, m - 1)); } } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll M, D; cin >> M >> D; ll ans = 0; REP(i, M) REP(j, D) { if (j % 10 >= 2 && (j / 10) >= 2 && (j % 10) * (j / 10) == i + 1) { ans++; } } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int iINF = 2147483647 / 2; const long long int llINF = 9223372036854775807 / 2; using namespace std; using ll = long long int; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>; typedef pair<ll, ll> pll; bool paircomp(const pll &a, const pll &b) { if (a.first == b.first) return a.second < b.second; return a.first < b.first; } #define REP(i, n) for (ll i = 0; i < (n); i++) #define RREP(i, n) for (ll i = (n)-1; i >= 0; i--) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define AUTO(i, m) for (auto &i : m) #define ALL(a) (a).begin(), (a).end() #define MAX(vec) *std::max_element(vec.begin(), vec.end()) #define MIN(vec) *std::min_element(vec.begin(), vec.end()) #define ARGMAX(vec) \ std::distance(vec.begin(), std::max_element(vec.begin(), vec.end())) #define ARGMIN(vec) \ std::distance(vec.begin(), std::min_element(vec.begin(), vec.end())) #define REV(T) greater<T>() #define PQ(T) priority_queue<T, vector<T>, greater<T>> #define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c)) #define VVVL(a, b, c, d) \ vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d))) #define SP(a) setprecision(a) #define SQRT(a) sqrt((long double)(a)) #define DPOW(a, b) pow((long double)(a), (long double)(b)) #define UNIQUE(vec) \ do { \ sort(ALL((vec))); \ (vec).erase(std::unique(ALL((vec))), (vec).end()); \ } while (0) ll POW(ll n, ll m) { if (m == 0) { return 1; } else if (m % 2 == 0) { ll tmp = POW(n, m / 2); return (tmp * tmp); } else { return (n * POW(n, m - 1)); } } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll M, D; cin >> M >> D; ll ans = 0; REP(i, M) FOR(j, 1, D + 1) { if (j % 10 >= 2 && (j / 10) >= 2 && (j % 10) * (j / 10) == i + 1) { ans++; } } cout << ans << endl; return 0; }
[ "call.arguments.add" ]
730,643
730,644
u050865477
cpp
p02927
#include <algorithm> // sort #include <cmath> #include <cstdio> #include <iostream> #include <map> // pair #include <numeric> // accumulate(begin,end,初期値) #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; using namespace std; #define FALSE printf("false\n"); #define TRUE printf("true\n"); #define all(x) (x).begin(), (x).end() #define print(x) cout << x << endl; #define rep(i, n) for (int i = 0; i < ((int)(n)); ++i) #define pb push_back #define mp make_pair #define fi first #define se second #define SUM(vec) accumulate(all(vec), 0) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); const ll INF = 1e9 + 7; // 各桁の和 template <typename T> T digit(T num) { T sum = 0; while (num) { sum += num % 10; num /= 10; } return sum; } template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <typename T> T lcm(T a, T b) { T g = gcd(a, b); return a / g * b; } template <typename T> T power(T a, T b) { T tmp = 1; rep(i, b) { tmp *= a; } return tmp; } #define test(a) cout << #a << ':' << a << endl; class tree { public: tree *par; vector<tree *> chi; int cnt; }; int main() { cin.tie(0); ios::sync_with_stdio(0); int m, d; cin >> m >> d; int f = d % 10; int s = d / 10; int ans = 0; for (int i = 1; i <= m; ++i) { if (s < 2) break; for (int j = 2; j < s; ++j) { for (int k = 2; k <= 10; ++k) { if (k < 2 && j == 0) continue; if (i == j * k) ans++; } } for (int j = 2; j <= f; ++j) { if (i == j * s) ans++; } } print(ans) return 0; }
#include <algorithm> // sort #include <cmath> #include <cstdio> #include <iostream> #include <map> // pair #include <numeric> // accumulate(begin,end,初期値) #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; using namespace std; #define FALSE printf("false\n"); #define TRUE printf("true\n"); #define all(x) (x).begin(), (x).end() #define print(x) cout << x << endl; #define rep(i, n) for (int i = 0; i < ((int)(n)); ++i) #define pb push_back #define mp make_pair #define fi first #define se second #define SUM(vec) accumulate(all(vec), 0) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); const ll INF = 1e9 + 7; // 各桁の和 template <typename T> T digit(T num) { T sum = 0; while (num) { sum += num % 10; num /= 10; } return sum; } template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <typename T> T lcm(T a, T b) { T g = gcd(a, b); return a / g * b; } template <typename T> T power(T a, T b) { T tmp = 1; rep(i, b) { tmp *= a; } return tmp; } #define test(a) cout << #a << ':' << a << endl; class tree { public: tree *par; vector<tree *> chi; int cnt; }; int main() { cin.tie(0); ios::sync_with_stdio(0); int m, d; cin >> m >> d; int f = d % 10; int s = d / 10; int ans = 0; for (int i = 4; i <= m; ++i) { if (s < 2) break; for (int j = 2; j < s; ++j) { for (int k = 2; k < 10; ++k) { if (k < 2 && j == 0) continue; if (i == j * k) { ans++; } } } for (int j = 2; j <= f; ++j) { if (i == j * s) { ans++; } } } print(ans) return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,649
730,650
u184572586
cpp
p02927
#include <iostream> using namespace std; int main() { int m, d; cin >> m >> d; int cnt = 0; for (int i = 4; i <= m; ++i) { for (int j = 2; j * 10 <= d; ++j) { if (i % j == 0) { int k = i / j; if (k != 1) { if (j * 10 + k <= d) { // cout << "i:" << i << " j:" << j << endl; cnt++; } } } } } cout << cnt; }
#include <iostream> using namespace std; int main() { int m, d; cin >> m >> d; int cnt = 0; for (int i = 4; i <= m; ++i) { for (int j = 2; j * 10 <= d; ++j) { if (i % j == 0) { int k = i / j; if (k >= 2 && k < 10) { if (j * 10 + k <= d) { // cout << "i:" << i << " j:" << j << endl; cnt++; } } } } } /* 条件 JK<D J*K==M J>=2 K>=2 */ cout << cnt; }
[ "control_flow.loop.for.condition.change", "control_flow.branch.if.condition.change" ]
730,655
730,656
u685650671
cpp
p02927
#include <bits/stdc++.h> using namespace std; #define ls rt << 1 #define rs (rt << 1) + 1 #define PI acos(-1) #define eps 1e-8 #define ll long long #define fuck(x) cout << #x << " " << x << endl; typedef pair<int, int> pii; const int inf = 2e9; const int maxn = 1e6 + 10; int d[4][2] = {1, 0, -1, 0, 0, 1, 0, -1}; // int lowbit(int x){return x&-x;} // void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);} // int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;} inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); } while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar(); return s * w; } inline void write(ll x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } int main() { int m, d; m = read(); d = read(); int ans = 0; for (int i = 1; i <= m; i++) for (int j = 1; j <= d; j++) { if ((j / 10) >= 2 && (j % 10) >= 2 && (j / 10) + (j % 10) == i) ans++; } write(ans); puts(""); return 0; }
#include <bits/stdc++.h> using namespace std; #define ls rt << 1 #define rs (rt << 1) + 1 #define PI acos(-1) #define eps 1e-8 #define ll long long #define fuck(x) cout << #x << " " << x << endl; typedef pair<int, int> pii; const int inf = 2e9; const int maxn = 1e6 + 10; int d[4][2] = {1, 0, -1, 0, 0, 1, 0, -1}; // int lowbit(int x){return x&-x;} // void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);} // int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;} inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); } while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar(); return s * w; } inline void write(ll x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } int main() { int m, d; m = read(); d = read(); int ans = 0; for (int i = 1; i <= m; i++) for (int j = 1; j <= d; j++) { if ((j / 10) >= 2 && (j % 10) >= 2 && (j / 10) * (j % 10) == i) ans++; } write(ans); puts(""); return 0; }
[ "expression.operator.arithmetic.change", "control_flow.branch.if.condition.change" ]
730,665
730,666
u492330079
cpp
p02927
#include <bits/stdc++.h> using namespace std; #define ls rt << 1 #define rs (rt << 1) + 1 #define PI acos(-1) #define eps 1e-8 #define ll long long #define fuck(x) cout << #x << " " << x << endl; typedef pair<int, int> pii; const int inf = 2e9; const int maxn = 1e6 + 10; int d[4][2] = {1, 0, -1, 0, 0, 1, 0, -1}; // int lowbit(int x){return x&-x;} // void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);} // int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;} inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); } while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar(); return s * w; } inline void write(ll x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } int main() { int m, d; m = read(); d = read(); int ans = 0; for (int i = 1; i <= m; i++) for (int j = 1; j <= d; j++) { if ((j / 10) >= 2 && (j % 10) >= 2 && (j / 10) + (j % 10) == m) ans++; } write(ans); puts(""); return 0; }
#include <bits/stdc++.h> using namespace std; #define ls rt << 1 #define rs (rt << 1) + 1 #define PI acos(-1) #define eps 1e-8 #define ll long long #define fuck(x) cout << #x << " " << x << endl; typedef pair<int, int> pii; const int inf = 2e9; const int maxn = 1e6 + 10; int d[4][2] = {1, 0, -1, 0, 0, 1, 0, -1}; // int lowbit(int x){return x&-x;} // void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);} // int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;} inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); } while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar(); return s * w; } inline void write(ll x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } int main() { int m, d; m = read(); d = read(); int ans = 0; for (int i = 1; i <= m; i++) for (int j = 1; j <= d; j++) { if ((j / 10) >= 2 && (j % 10) >= 2 && (j / 10) * (j % 10) == i) ans++; } write(ans); puts(""); return 0; }
[ "expression.operator.arithmetic.change", "control_flow.branch.if.condition.change", "identifier.change" ]
730,667
730,666
u492330079
cpp
p02927
#include <bits/stdc++.h> using namespace std; int main() { int M, D; cin >> M >> D; int ans = 0; for (int m = 1; m <= M; m++) { for (int d10 = 2; d10 <= 9; d10++) { for (int d1 = 2; d1 <= 9; d1++) { if (10 * d10 + d1 >= D) goto OUT; if (m == d1 * d10) ans++; } } OUT:; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int M, D; cin >> M >> D; int ans = 0; for (int m = 1; m <= M; m++) { for (int d10 = 2; d10 <= 9; d10++) { for (int d1 = 2; d1 <= 9; d1++) { if (10 * d10 + d1 > D) goto OUT; if (m == d1 * d10) ans++; } } OUT:; } cout << ans << endl; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
730,668
730,669
u320241053
cpp
p02927
#include <bits/stdc++.h> using namespace std; int main() { int M, D; cin >> M >> D; int ans = 0; for (int i = 1; i <= M; i++) { for (int j = 12; j <= D; j++) { if (j / 10 == 1) { continue; } else if (j % 10 == 1) { continue; } if (M == (j / 10) * (j % 10)) { ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int M, D; cin >> M >> D; int ans = 0; for (int i = 1; i <= M; i++) { for (int j = 12; j <= D; j++) { if (j / 10 == 1) { continue; } else if (j % 10 == 1) { continue; } if (i == (j / 10) * (j % 10)) { ans++; } } } cout << ans << endl; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
730,672
730,673
u454081619
cpp
p02927
#pragma GCC optimize("O3") #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pi; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); ++i) #define pb push_back #define sz(x) (int)x.size() #define f first #define s second int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); int m, d; cin >> m >> d; int cnt = 0; FOR(i, 1, d) { int res = (i / 10) * (i % 10); if (res <= m && res > 0 && (i / 10) >= 2 && (i % 10) >= 2 && (i / 100) == 0) { // cout << (i/10) << " " << (i%10) << endl; cnt++; } } cout << cnt; return 0; }
#pragma GCC optimize("O3") #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pi; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); ++i) #define pb push_back #define sz(x) (int)x.size() #define f first #define s second int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); int m, d; cin >> m >> d; int cnt = 0; FOR(i, 1, d + 1) { int res = (i / 10) * (i % 10); if (res <= m && res > 0 && (i / 10) >= 2 && (i % 10) >= 2 && (i / 100) == 0) { // cout << (i/10) << " " << (i%10) << endl; cnt++; } } cout << cnt; return 0; }
[ "expression.operation.binary.add" ]
730,676
730,677
u855138664
cpp
p02927
#include <bits/stdc++.h> using namespace std; int n, d; int main() { cin >> n >> d; int ile = 0; for (int m = 4; m <= n; ++m) for (int i = 2; i <= 9; ++i) { if (m % i) continue; if (10 * i + (m / i) <= d && m / i > 1) ++ile; } cout << ile; }
#include <bits/stdc++.h> using namespace std; int n, d; int main() { cin >> n >> d; int ile = 0; for (int m = 4; m <= n; ++m) for (int i = 2; i <= 9; ++i) { if (m % i || m / i > 9) continue; if (10 * i + (m / i) <= d && m / i > 1) ++ile; } cout << ile; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
730,678
730,679
u038050360
cpp
p02927
/* * shubhamg931 - Shubham Gupta (B.Tech - IT, 2016-2020 batch) */ #include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define MAXN 500005 #define PI 3.14159265 #define pb push_back #define eb emplace_back #define FAST \ ios_base::sync_with_stdio(false); \ cin.tie(nullptr); \ cout.tie(nullptr); #define FILE_READ freopen("input.txt", "r", stdin); #define FILE_WRITE freopen("output.txt", "w", stdout); #define mp(a, b) make_pair(a, b) #define mset(arr, val) memset(arr, val, sizeof arr) #if 0 typedef long long let; #else typedef int let; // Dont judge me. I am a Javascript Dev! :P #endif typedef unsigned long long ull; typedef long ld; typedef long double ldo; typedef pair<let, let> pll; int main() { FAST let d, m, i, j; cin >> m >> d; let ans = 0; for (i = 22; i < d; ++i) { let x = i / 10, y = i % 10; if (x * y <= m and x * y > 0 and x > 1 and y > 1) { // cout<<x<<y; ans++; } } cout << ans; return 0; }
/* * shubhamg931 - Shubham Gupta (B.Tech - IT, 2016-2020 batch) */ #include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define MAXN 500005 #define PI 3.14159265 #define pb push_back #define eb emplace_back #define FAST \ ios_base::sync_with_stdio(false); \ cin.tie(nullptr); \ cout.tie(nullptr); #define FILE_READ freopen("input.txt", "r", stdin); #define FILE_WRITE freopen("output.txt", "w", stdout); #define mp(a, b) make_pair(a, b) #define mset(arr, val) memset(arr, val, sizeof arr) #if 0 typedef long long let; #else typedef int let; // Dont judge me. I am a Javascript Dev! :P #endif typedef unsigned long long ull; typedef long ld; typedef long double ldo; typedef pair<let, let> pll; int main() { FAST let d, m, i, j; cin >> m >> d; let ans = 0; for (i = 22; i <= d; ++i) { let x = i / 10, y = i % 10; if (x * y <= m and x * y > 0 and x > 1 and y > 1) { // cout<<x<<y; ans++; } } cout << ans; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,680
730,681
u863053903
cpp
p02927
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define MOD 1000000007 #define MAX 1000000007 #define pb push_back #define mp make_pair #define ff first #define ss second #define ub upper_bound #define lb lower_bound #define zoom \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); using namespace std; int main() { zoom; ll M, D, i, j; cin >> M >> D; ll ans = 0; for (i = 1; i <= M; i += 1) { for (j = 2; j <= D; j += 1) { if (i % j != 0) continue; ll temp = i / j; if (j * 10 + temp > D || temp < 2) continue; ans += 1; } } cout << ans; return 0; }
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define MOD 1000000007 #define MAX 1000000007 #define pb push_back #define mp make_pair #define ff first #define ss second #define ub upper_bound #define lb lower_bound #define zoom \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); using namespace std; int main() { zoom; ll M, D, i, j; cin >> M >> D; ll ans = 0; for (i = 1; i <= M; i += 1) { for (j = 2; j <= D; j += 1) { if (i % j != 0) continue; ll temp = i / j; if (j * 10 + temp > D || temp < 2 || temp >= 10) continue; ans += 1; } } cout << ans; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
730,686
730,687
u172458874
cpp
p02927
#include <bits/stdc++.h> using namespace std; int main(void) { int M, D, count = 0; cin >> M >> D; for (int i = 2; i < D / 10; i++) { for (int j = 2; j < 9; j++) { for (int k = 4; k <= M; k++) { if (k == i * j) count++; } } } if (D > 20) { for (int j = 2; j <= D % 10; j++) { for (int k = 4; k <= M; k++) { if (k == (D / 10) * j) count++; } } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int M, D, count = 0; cin >> M >> D; for (int i = 2; i < D / 10; i++) { for (int j = 2; j < 10; j++) { for (int k = 4; k <= M; k++) { if (k == i * j) count++; } } } if (D > 20) { for (int j = 2; j <= D % 10; j++) { for (int k = 4; k <= M; k++) { if (k == (D / 10) * j) count++; } } } cout << count << endl; return 0; }
[ "literal.number.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,696
730,697
u164448353
cpp
p02927
#include <bits/stdc++.h> int32_t main() { int m, d; scanf("%d%d", &m, &d); int ans = 0; for (int i = 10; i < d; i++) { int d1 = i / 10; int d10 = i % 10; if (d1 * d10 <= m && d1 >= 2 && d10 >= 2) { ans++; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> int32_t main() { int m, d; scanf("%d%d", &m, &d); int ans = 0; for (int i = 22; i <= d; i++) { int d1 = i / 10; int d10 = i % 10; if (d1 * d10 <= m && d1 >= 2 && d10 >= 2) { ans++; } } printf("%d\n", ans); return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,702
730,703
u030489681
cpp
p02927
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int main() { int m, d, ans; cin >> m >> d; ans = 0; for (int i = 22; i < d; i++) { string i_s = to_string(i); if (((i_s[0] - '0') < 2) || ((i_s[1] - '0') < 2)) continue; int p = (i_s[0] - '0') * (i_s[1] - '0'); if ((p <= m) && (p > 0)) ans++; } 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 ll; int main() { int m, d, ans; cin >> m >> d; ans = 0; for (int i = 22; i <= d; i++) { string i_s = to_string(i); if (((i_s[0] - '0') < 2) || ((i_s[1] - '0') < 2)) continue; int p = (i_s[0] - '0') * (i_s[1] - '0'); if ((p <= m) && (p > 0)) ans++; } cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,704
730,705
u238786149
cpp
p02927
#include <bits/stdc++.h> #define ll long long #define rep(X, N) for (int X = 0; X < (N); X++) #define pback push_back #define mpair make_pair #define MODN 1000000007 #define ceilint(A, B) ((A) + (B - 1)) / (B) #define ALL(v) (v).begin(), (v).end() using namespace std; int main() { int m, d; cin >> m >> d; int ans = 0; for (int i = 1; i <= m; i++) { for (int j = 1; j <= d; j++) { int d1 = j / 10; int d2 = j % 10; if (d1 >= 2 && d2 >= 2 && m == d1 * d2) ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define ll long long #define rep(X, N) for (int X = 0; X < (N); X++) #define pback push_back #define mpair make_pair #define MODN 1000000007 #define ceilint(A, B) ((A) + (B - 1)) / (B) #define ALL(v) (v).begin(), (v).end() using namespace std; int main() { int m, d; cin >> m >> d; int ans = 0; for (int i = 1; i <= m; i++) { for (int j = 1; j <= d; j++) { int d1 = j / 10; int d2 = j % 10; if (d1 >= 2 && d2 >= 2 && i == d1 * d2) { ans++; } } } cout << ans << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
730,706
730,707
u145078501
cpp
p02927
#include <bits/stdc++.h> typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; using Graph = vector<vector<int>>; int main() { int M, D; cin >> M >> D; int ans = 0; for (int i = 1; i <= M; i++) { for (int j = 22; j < D; j++) { if (j % 10 >= 2 && (j / 10) * (j % 10) == i) ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; using Graph = vector<vector<int>>; int main() { int M, D; cin >> M >> D; int ans = 0; for (int i = 1; i <= M; i++) { for (int j = 22; j <= D; j++) { if (j % 10 >= 2 && (j / 10) * (j % 10) == i) ans++; } } cout << ans << endl; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,712
730,713
u808593466
cpp
p02927
#include <iostream> using namespace std; int main() { int m, d; cin >> m >> d; int ans = 0; for (int i = 1; m >= i; i++) { for (int j = 1; d >= j; j++) { int d1 = d % 10; int d10 = d / 10; if (d1 > 2 && d10 >= 2 && d1 * d10 == m) ans++; } } cout << ans << endl; }
#include <iostream> using namespace std; int main() { int m, d; cin >> m >> d; int ans = 0; for (int i = 1; m >= i; i++) { for (int j = 1; d >= j; j++) { int d1 = j % 10; int d10 = j / 10; if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) ans++; } } cout << ans << endl; }
[ "identifier.change", "expression.operation.binary.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
730,714
730,715
u466161487
cpp
p02927
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define rep(i, s, N) for (ll i{s}; i < (N); i++) #define rem(i, N, s) for (ll i{N}; i > (s); i--) #define debug(x) cerr << #x << ": " << x << '\n' #define debugp(i) cerr << "(" << i.first << ", " << i.second << ")\n" #define debugv(v) \ cerr << #v << ": "; \ for (auto &&i : v) \ cerr << i << " "; \ cerr << '\n' #define debugvp(v) \ cerr << #v << ": "; \ for (auto &&i : v) \ cerr << "(" << i.first << ", " << i.second << ") "; \ cerr << '\n' const int MOD = (int)1e9 + 7; const long double pi = 3.141592653589793238462643383279L; using namespace std; using ll = long long; using ld = long double; using str = string; using wstr = wstring; const string rt = "\n", sp = " "; const wstring wrt = L"\n", wsp = L" "; /* GCD */ template <typename M, typename N> constexpr common_type_t<M, N> gcd(M a, N b) { return b != 0 ? gcd(b, a % b) : a; } /* LCM */ template <typename M, typename N> constexpr common_type_t<M, N> lcm(M a, N b) { return a * b / gcd(a, b); } /* UNIONFIND */ template <typename T> struct UnionFind { vector<T> par; UnionFind(T n) : par(n, -1) {} void init(T n) { par.assign(n, -1); } T root(T x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(T x, T y) { return root(x) == root(y); } bool merge(T x, T y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; /* COMB */ auto comb(ll N) { vector<vector<ll>> v(N + 1, vector<ll>(N + 1)); for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } return v; } auto comb(ll N, ll n) { vector<vector<ll>> v(max(N + 1, n + 1), vector<ll>(max(N + 1, n + 1))); for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } return v[N][n]; } /* COMB % MOD */ template <typename T> ll combpm(T N_, T C_) { const int NUM_ = 400001; static ll fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1]; if (fact[0] == 0) { inv[1] = fact[0] = factr[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i % MOD, factr[i] = factr[i - 1] * inv[i] % MOD; } if (C_ < 0 || C_ > N_) return 0; return factr[C_] * fact[N_] % MOD * factr[N_ - C_] % MOD; } /* MAKE VECTOR */ template <class T> constexpr vector<T> make_vector(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...)); } /* MAKE DEQUE */ template <class T> constexpr deque<T> make_deque(size_t a) { return deque<T>(a); } template <class T, class... Ts> auto make_deque(size_t a, Ts... ts) { return deque<decltype(make_deque<T>(ts...))>(a, make_deque<T>(ts...)); } /* TEST */ void test(ll n) { cout << "test" << n << endl; } /* PRECISION */ void fixsp(ll n) { cout << fixed << setprecision(n); } void defsp(ll n) { cout << defaultfloat << setprecision(n); } /* WEIGHTENED UNIONFIND */ struct WUnionFind { vector<int> par; vector<int> rank; WUnionFind(int n = 1) { init(n); } void init(int n = 1) { par.resize(n); rank.resize(n); for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); return par[x] = r; } } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y); if (rank[x] == rank[y]) ++rank[x]; par[y] = x; return true; } }; /* DIVISOR */ deque<ll> divisor(ll n) { deque<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } /* MODE */ template <typename T> auto mode(T data) { if (data.size() == 1) return *begin(data); sort(begin(data), end(data)); typename decltype(data)::value_type mode{}; size_t n{}, count{1}; for (auto iter = adjacent_find(begin(data), end(data)), last = end(data), next = end(data); iter != last;) { next = upper_bound(iter, last, *iter); count = distance(iter, next); if (n < count) n = count, mode = *iter; iter = adjacent_find(next, last); } return mode; } /* MEDIAN */ template <typename T> auto median(T data) { sort(begin(data), end(data)); size_t median_index = data.size() / 2; return ( data.size() % 2 == 0 ? static_cast<double>(data[median_index] + data[median_index - 1]) / 2 : data[median_index]); } /* INT POW */ template <typename T> T multi(T a, ll b) { T ans{1}; for (int i{}; i < b; i++) ans *= a; return ans; } /* INF */ template <typename T> constexpr T inf() { return numeric_limits<T>::max(); } /* FASTER IO */ void fastio(ll a) { ios::sync_with_stdio(false); cin.tie(NULL); if (a) fixsp(a); } /* MIN COST FLOW */ template <typename flow_t, typename cost_t> struct PrimalDual { const cost_t INF; struct edge { int to; flow_t cap; cost_t cost; int rev; bool isrev; }; vector<vector<edge>> graph; vector<cost_t> potential, min_cost; vector<int> prevv, preve; PrimalDual(int V) : graph(V), INF(numeric_limits<cost_t>::max()) {} void add_edge(int from, int to, flow_t cap, cost_t cost) { graph[from].emplace_back( (edge){to, cap, cost, (int)graph[to].size(), false}); graph[to].emplace_back( (edge){from, 0, -cost, (int)graph[from].size() - 1, true}); } cost_t min_cost_flow(int s, int t, flow_t f) { int V = (int)graph.size(); cost_t ret = 0; using Pi = pair<cost_t, int>; priority_queue<Pi, vector<Pi>, greater<Pi>> que; potential.assign(V, 0); preve.assign(V, -1); prevv.assign(V, -1); while (f > 0) { min_cost.assign(V, INF); que.emplace(0, s); min_cost[s] = 0; while (!que.empty()) { Pi p = que.top(); que.pop(); if (min_cost[p.second] < p.first) continue; for (int i = 0; i < graph[p.second].size(); i++) { edge &e = graph[p.second][i]; cost_t nextCost = min_cost[p.second] + e.cost + potential[p.second] - potential[e.to]; if (e.cap > 0 && min_cost[e.to] > nextCost) { min_cost[e.to] = nextCost; prevv[e.to] = p.second, preve[e.to] = i; que.emplace(min_cost[e.to], e.to); } } } if (min_cost[t] == INF) return -1; for (int v = 0; v < V; v++) potential[v] += min_cost[v]; flow_t addflow = f; for (int v = t; v != s; v = prevv[v]) { addflow = min(addflow, graph[prevv[v]][preve[v]].cap); } f -= addflow; ret += addflow * potential[t]; for (int v = t; v != s; v = prevv[v]) { edge &e = graph[prevv[v]][preve[v]]; e.cap -= addflow; graph[v][e.rev].cap += addflow; } } return ret; } void output() { for (int i = 0; i < graph.size(); i++) { for (auto &e : graph[i]) { if (e.isrev) continue; auto &rev_e = graph[e.to][e.rev]; cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << rev_e.cap + e.cap << ")" << endl; } } } }; /* BELLMANFORD */ vector<long long> BellmanFord(int s, int V, vector<tuple<long long, long long, long long>> &G) { vector<long long> d(V, inf<long long>()); vector<bool> neg(V); d[s] = 0; for (int i = 0; i < V - 1; ++i) { for (auto &&e : G) { if (d[get<0>(e)] == inf<long long>()) continue; d[get<1>(e)] = min(d[get<1>(e)], d[get<0>(e)] + get<2>(e)); } } for (int i = 0; i < V; ++i) { for (auto &&e : G) { if (d[get<0>(e)] == inf<long long>()) continue; if (d[get<1>(e)] > d[get<0>(e)] + get<2>(e)) { d[get<1>(e)] = d[get<0>(e)] + get<2>(e); neg[get<1>(e)] = 1; } if (neg[get<0>(e)]) neg[get<1>(e)] = 1; } } for (int i = 0; i < V; i++) { if (neg[i]) d[i] = -inf<long long>(); } return d; } /* DIJKSTRA */ vector<long long> Dijkstra(int s, int V, vector<tuple<long long, long long, long long>> &G) { vector<vector<pair<long long, long long>>> uv(V); for (auto &&i : G) uv[get<0>(i)].emplace_back(get<1>(i), get<2>(i)); vector<long long> d(V, inf<long long>() / 2); vector<long long> prev(V, -1); d[s] = 0; priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> Q; rep(i, 0, V) Q.emplace(d[i], i); while (!Q.empty()) { long long u = Q.top().second; Q.pop(); for (auto &&v : uv[u]) { long long alt = d[u] + v.second; if (d[v.first] > alt) { d[v.first] = alt; if (d[v.first] > inf<long long>() / 4) d[v.first] = inf<long long>() / 2; else if (d[v.first] < -inf<long long>() / 4) d[v.first] = -inf<long long>() / 2; prev[v.first] = u; Q.emplace(alt, v.first); } } } for (auto &&i : d) { if (abs(i) > inf<long long>() / 4) (i *= 2)++; } return d; } /* BFS */ vector<long long> BFS(long long s, long long V, vector<pair<long long, long long>> &G) { queue<long long> Q; vector<vector<long long>> uv(V); for (auto &&i : G) uv[i.first].emplace_back(i.second); vector<long long> d(V, inf<long long>()); d[s] = 0; Q.emplace(s); while (!Q.empty()) { long long v = Q.front(); Q.pop(); for (auto &&i : uv[v]) { if (d[i] == inf<long long>()) { d[i] = d[v] + 1; Q.emplace(i); } } } return d; } /* WARSHALLFLOYD */ vector<vector<long long>> WarshallFloyd(int V, vector<tuple<long long, long long, long long>> &G) { vector<vector<long long>> d(V, vector<long long>(V, inf<long long>())); for (auto &&i : G) { d[get<0>(i)][get<1>(i)] = get<2>(i); } rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) { if (d[i][k] != inf<ll>() && d[k][j] != inf<ll>()) d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } rep(i, 0, V) { d[i][i] = 0; } return d; } /* NUITA.INC & KYOTO UNIVERSITY */ /* LAST EDITED ON 8.23.2019 */ /* CODE STARTS FROM HERE */ int main() { ll M, D; cin >> M >> D; ll ans{}; rep(i, 1, M + 1) { rep(j, 2, D) { ll d10 = j / 10; ll d1 = j % 10; if (d10 > 1 && d1 > 1) { if (i == d10 * d1) { ans++; } } } } cout << ans; }
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define rep(i, s, N) for (ll i{s}; i < (N); i++) #define rem(i, N, s) for (ll i{N}; i > (s); i--) #define debug(x) cerr << #x << ": " << x << '\n' #define debugp(i) cerr << "(" << i.first << ", " << i.second << ")\n" #define debugv(v) \ cerr << #v << ": "; \ for (auto &&i : v) \ cerr << i << " "; \ cerr << '\n' #define debugvp(v) \ cerr << #v << ": "; \ for (auto &&i : v) \ cerr << "(" << i.first << ", " << i.second << ") "; \ cerr << '\n' const int MOD = (int)1e9 + 7; const long double pi = 3.141592653589793238462643383279L; using namespace std; using ll = long long; using ld = long double; using str = string; using wstr = wstring; const string rt = "\n", sp = " "; const wstring wrt = L"\n", wsp = L" "; /* GCD */ template <typename M, typename N> constexpr common_type_t<M, N> gcd(M a, N b) { return b != 0 ? gcd(b, a % b) : a; } /* LCM */ template <typename M, typename N> constexpr common_type_t<M, N> lcm(M a, N b) { return a * b / gcd(a, b); } /* UNIONFIND */ template <typename T> struct UnionFind { vector<T> par; UnionFind(T n) : par(n, -1) {} void init(T n) { par.assign(n, -1); } T root(T x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(T x, T y) { return root(x) == root(y); } bool merge(T x, T y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; /* COMB */ auto comb(ll N) { vector<vector<ll>> v(N + 1, vector<ll>(N + 1)); for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } return v; } auto comb(ll N, ll n) { vector<vector<ll>> v(max(N + 1, n + 1), vector<ll>(max(N + 1, n + 1))); for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } return v[N][n]; } /* COMB % MOD */ template <typename T> ll combpm(T N_, T C_) { const int NUM_ = 400001; static ll fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1]; if (fact[0] == 0) { inv[1] = fact[0] = factr[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i % MOD, factr[i] = factr[i - 1] * inv[i] % MOD; } if (C_ < 0 || C_ > N_) return 0; return factr[C_] * fact[N_] % MOD * factr[N_ - C_] % MOD; } /* MAKE VECTOR */ template <class T> constexpr vector<T> make_vector(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...)); } /* MAKE DEQUE */ template <class T> constexpr deque<T> make_deque(size_t a) { return deque<T>(a); } template <class T, class... Ts> auto make_deque(size_t a, Ts... ts) { return deque<decltype(make_deque<T>(ts...))>(a, make_deque<T>(ts...)); } /* TEST */ void test(ll n) { cout << "test" << n << endl; } /* PRECISION */ void fixsp(ll n) { cout << fixed << setprecision(n); } void defsp(ll n) { cout << defaultfloat << setprecision(n); } /* WEIGHTENED UNIONFIND */ struct WUnionFind { vector<int> par; vector<int> rank; WUnionFind(int n = 1) { init(n); } void init(int n = 1) { par.resize(n); rank.resize(n); for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); return par[x] = r; } } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y); if (rank[x] == rank[y]) ++rank[x]; par[y] = x; return true; } }; /* DIVISOR */ deque<ll> divisor(ll n) { deque<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } /* MODE */ template <typename T> auto mode(T data) { if (data.size() == 1) return *begin(data); sort(begin(data), end(data)); typename decltype(data)::value_type mode{}; size_t n{}, count{1}; for (auto iter = adjacent_find(begin(data), end(data)), last = end(data), next = end(data); iter != last;) { next = upper_bound(iter, last, *iter); count = distance(iter, next); if (n < count) n = count, mode = *iter; iter = adjacent_find(next, last); } return mode; } /* MEDIAN */ template <typename T> auto median(T data) { sort(begin(data), end(data)); size_t median_index = data.size() / 2; return ( data.size() % 2 == 0 ? static_cast<double>(data[median_index] + data[median_index - 1]) / 2 : data[median_index]); } /* INT POW */ template <typename T> T multi(T a, ll b) { T ans{1}; for (int i{}; i < b; i++) ans *= a; return ans; } /* INF */ template <typename T> constexpr T inf() { return numeric_limits<T>::max(); } /* FASTER IO */ void fastio(ll a) { ios::sync_with_stdio(false); cin.tie(NULL); if (a) fixsp(a); } /* MIN COST FLOW */ template <typename flow_t, typename cost_t> struct PrimalDual { const cost_t INF; struct edge { int to; flow_t cap; cost_t cost; int rev; bool isrev; }; vector<vector<edge>> graph; vector<cost_t> potential, min_cost; vector<int> prevv, preve; PrimalDual(int V) : graph(V), INF(numeric_limits<cost_t>::max()) {} void add_edge(int from, int to, flow_t cap, cost_t cost) { graph[from].emplace_back( (edge){to, cap, cost, (int)graph[to].size(), false}); graph[to].emplace_back( (edge){from, 0, -cost, (int)graph[from].size() - 1, true}); } cost_t min_cost_flow(int s, int t, flow_t f) { int V = (int)graph.size(); cost_t ret = 0; using Pi = pair<cost_t, int>; priority_queue<Pi, vector<Pi>, greater<Pi>> que; potential.assign(V, 0); preve.assign(V, -1); prevv.assign(V, -1); while (f > 0) { min_cost.assign(V, INF); que.emplace(0, s); min_cost[s] = 0; while (!que.empty()) { Pi p = que.top(); que.pop(); if (min_cost[p.second] < p.first) continue; for (int i = 0; i < graph[p.second].size(); i++) { edge &e = graph[p.second][i]; cost_t nextCost = min_cost[p.second] + e.cost + potential[p.second] - potential[e.to]; if (e.cap > 0 && min_cost[e.to] > nextCost) { min_cost[e.to] = nextCost; prevv[e.to] = p.second, preve[e.to] = i; que.emplace(min_cost[e.to], e.to); } } } if (min_cost[t] == INF) return -1; for (int v = 0; v < V; v++) potential[v] += min_cost[v]; flow_t addflow = f; for (int v = t; v != s; v = prevv[v]) { addflow = min(addflow, graph[prevv[v]][preve[v]].cap); } f -= addflow; ret += addflow * potential[t]; for (int v = t; v != s; v = prevv[v]) { edge &e = graph[prevv[v]][preve[v]]; e.cap -= addflow; graph[v][e.rev].cap += addflow; } } return ret; } void output() { for (int i = 0; i < graph.size(); i++) { for (auto &e : graph[i]) { if (e.isrev) continue; auto &rev_e = graph[e.to][e.rev]; cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << rev_e.cap + e.cap << ")" << endl; } } } }; /* BELLMANFORD */ vector<long long> BellmanFord(int s, int V, vector<tuple<long long, long long, long long>> &G) { vector<long long> d(V, inf<long long>()); vector<bool> neg(V); d[s] = 0; for (int i = 0; i < V - 1; ++i) { for (auto &&e : G) { if (d[get<0>(e)] == inf<long long>()) continue; d[get<1>(e)] = min(d[get<1>(e)], d[get<0>(e)] + get<2>(e)); } } for (int i = 0; i < V; ++i) { for (auto &&e : G) { if (d[get<0>(e)] == inf<long long>()) continue; if (d[get<1>(e)] > d[get<0>(e)] + get<2>(e)) { d[get<1>(e)] = d[get<0>(e)] + get<2>(e); neg[get<1>(e)] = 1; } if (neg[get<0>(e)]) neg[get<1>(e)] = 1; } } for (int i = 0; i < V; i++) { if (neg[i]) d[i] = -inf<long long>(); } return d; } /* DIJKSTRA */ vector<long long> Dijkstra(int s, int V, vector<tuple<long long, long long, long long>> &G) { vector<vector<pair<long long, long long>>> uv(V); for (auto &&i : G) uv[get<0>(i)].emplace_back(get<1>(i), get<2>(i)); vector<long long> d(V, inf<long long>() / 2); vector<long long> prev(V, -1); d[s] = 0; priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> Q; rep(i, 0, V) Q.emplace(d[i], i); while (!Q.empty()) { long long u = Q.top().second; Q.pop(); for (auto &&v : uv[u]) { long long alt = d[u] + v.second; if (d[v.first] > alt) { d[v.first] = alt; if (d[v.first] > inf<long long>() / 4) d[v.first] = inf<long long>() / 2; else if (d[v.first] < -inf<long long>() / 4) d[v.first] = -inf<long long>() / 2; prev[v.first] = u; Q.emplace(alt, v.first); } } } for (auto &&i : d) { if (abs(i) > inf<long long>() / 4) (i *= 2)++; } return d; } /* BFS */ vector<long long> BFS(long long s, long long V, vector<pair<long long, long long>> &G) { queue<long long> Q; vector<vector<long long>> uv(V); for (auto &&i : G) uv[i.first].emplace_back(i.second); vector<long long> d(V, inf<long long>()); d[s] = 0; Q.emplace(s); while (!Q.empty()) { long long v = Q.front(); Q.pop(); for (auto &&i : uv[v]) { if (d[i] == inf<long long>()) { d[i] = d[v] + 1; Q.emplace(i); } } } return d; } /* WARSHALLFLOYD */ vector<vector<long long>> WarshallFloyd(int V, vector<tuple<long long, long long, long long>> &G) { vector<vector<long long>> d(V, vector<long long>(V, inf<long long>())); for (auto &&i : G) { d[get<0>(i)][get<1>(i)] = get<2>(i); } rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) { if (d[i][k] != inf<ll>() && d[k][j] != inf<ll>()) d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } rep(i, 0, V) { d[i][i] = 0; } return d; } /* NUITA.INC & KYOTO UNIVERSITY */ /* LAST EDITED ON 8.23.2019 */ /* CODE STARTS FROM HERE */ int main() { ll M, D; cin >> M >> D; ll ans{}; rep(i, 1, M + 1) { rep(j, 2, D + 1) { ll d10 = j / 10; ll d1 = j % 10; if (d10 > 1 && d1 > 1) { if (i == d10 * d1) { ans++; } } } } cout << ans; }
[ "expression.operation.binary.add" ]
730,716
730,717
u936790121
cpp
p02927
#include <chrono> #include <iostream> #include <random> #include <vector> std::mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int m, d; std::cin >> m >> d; int ans = 0; for (int i = 2; i * 11 <= d && i < 10; i++) { for (int j = 2; i * 10 + j <= d && j < 10; j++) { if (i * j <= m) { ans++; } } } std::cout << ans << std::endl; }
#include <chrono> #include <iostream> #include <random> #include <vector> std::mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int m, d; std::cin >> m >> d; int ans = 0; for (int i = 2; i * 10 <= d && i < 10; i++) { for (int j = 2; i * 10 + j <= d && j < 10; j++) { if (i * j <= m) { ans++; } } } std::cout << ans << std::endl; }
[ "literal.number.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,718
730,719
u296475749
cpp
p02927
#include <bits/stdc++.h> #define loop(n) \ for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); \ ngtkana_is_genius++) #define rep(i, begin, end) for (int i = int(begin); i < int(end); i++) #define lint long long auto cmn = [](auto &a, auto b) { if (a > b) { a = b; return true; } return false; }; auto cmx = [](auto &a, auto b) { if (a < b) { a = b; return true; } return false; }; void debug_impl() { std::cerr << std::endl; } template <typename Head, typename... Tail> void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); } #define debug(...) \ std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:"; \ debug_impl(__VA_ARGS__); \ std::cerr << std::noboolalpha; int main() { std::cin.tie(0); std::cin.sync_with_stdio(false); int M, D; std::cin >> M >> D; auto ret = 0; rep(d, 1, D) { auto a = d % 10; auto b = d / 10; if (a < 2 || b < 2) continue; // debug(a, b, d); if (a * b <= M) ret++; } std::cout << ret << std::endl; return 0; }
#include <bits/stdc++.h> #define loop(n) \ for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); \ ngtkana_is_genius++) #define rep(i, begin, end) for (int i = int(begin); i < int(end); i++) #define lint long long auto cmn = [](auto &a, auto b) { if (a > b) { a = b; return true; } return false; }; auto cmx = [](auto &a, auto b) { if (a < b) { a = b; return true; } return false; }; void debug_impl() { std::cerr << std::endl; } template <typename Head, typename... Tail> void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); } #define debug(...) \ std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:"; \ debug_impl(__VA_ARGS__); \ std::cerr << std::noboolalpha; int main() { std::cin.tie(0); std::cin.sync_with_stdio(false); int M, D; std::cin >> M >> D; auto ret = 0; rep(d, 1, D + 1) { auto a = d % 10; auto b = d / 10; if (a < 2 || b < 2) continue; // debug(a, b, d); if (a * b <= M) ret++; } std::cout << ret << std::endl; return 0; }
[ "expression.operation.binary.add" ]
730,720
730,721
u846041485
cpp
p02927
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <ciso646> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define inf 0x3f3f3f3f3f3f3f3f #define ALL(a) (a).begin(), (a).end() #define DEBUG(x) // cerr<<#x<<": "<<x<<endl #define ll long long #define ull unsigned long long using pii = pair<ll, ll>; #define eps 1e-14 #define SETUP \ cin.tie(0), ios::sync_with_stdio(false), \ cout << setprecision(15) << std::fixed; #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) template <class T> using vec2 = std::vector<vector<T>>; //// bit //// #ifdef _MSC_VER #ifdef _WIN32 inline unsigned int __builtin_ctz(unsigned int x) { unsigned long r; _BitScanForward(&r, x); return r; } inline unsigned int __builtin_clz(unsigned int x) { unsigned long r; _BitScanReverse(&r, x); return 31 - r; } inline unsigned int __builtin_ffs(unsigned int x) { unsigned long r; return _BitScanForward(&r, x) ? r + 1 : 0; } // inline unsigned int __builtin_popcount(unsigned int x){ return __popcnt(x); } #ifdef _WIN64 inline unsigned long long __builtin_ctzll(unsigned long long x) { unsigned long r; _BitScanForward64(&r, x); return r; } inline unsigned long long __builtin_clzll(unsigned long long x) { unsigned long r; _BitScanReverse64(&r, x); return 63 - r; } inline unsigned long long __builtin_ffsll(unsigned long long x) { unsigned long r; return _BitScanForward64(&r, x) ? r + 1 : 0; } inline unsigned long long __builtin_popcountll(unsigned long long x) { return __popcnt64(x); } #else inline unsigned int hidword(unsigned long long x) { return static_cast<unsigned int>(x >> 32); } inline unsigned int lodword(unsigned long long x) { return static_cast<unsigned int>(x & 0xFFFFFFFF); } inline unsigned long long __builtin_ctzll(unsigned long long x) { return lodword(x) ? __builtin_ctz(lodword(x)) : __builtin_ctz(hidword(x)) + 32; } inline unsigned long long __builtin_clzll(unsigned long long x) { return hidword(x) ? __builtin_clz(hidword(x)) : __builtin_clz(lodword(x)) + 32; } inline unsigned long long __builtin_ffsll(unsigned long long x) { return lodword(x) ? __builtin_ffs(lodword(x)) : hidword(x) ? __builtin_ffs(hidword(x)) + 32 : 0; } // inline unsigned long long __builtin_popcountll(unsigned long long x) { return // __builtin_popcount(lodword(x)) + __builtin_popcount(hidword(x)); } #endif // _WIN64 #endif // _WIN32 #endif // _MSC_VER namespace { struct input_returnner { ll N; input_returnner(ll N_ = 0) : N(N_) {} template <typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); } template <typename T> operator T() const { T res; cin >> res; return res; } template <typename T> T operator-(T right) { return T(input_returnner()) - right; } template <typename T> T operator+(T right) { return T(input_returnner()) + right; } template <typename T> T operator*(T right) { return T(input_returnner()) * right; } template <typename T> T operator/(T right) { return T(input_returnner()) / right; } template <typename T> T operator<<(T right) { return T(input_returnner()) << right; } template <typename T> T operator>>(T right) { return T(input_returnner()) >> right; } }; template <typename T> input_returnner in() { return in<T>(); } input_returnner in() { return input_returnner(); } input_returnner in(ll N) { return std::move(input_returnner(N)); } } // namespace template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } template <typename T> struct is_vector : std::false_type {}; template <typename T> struct is_vector<std::vector<T>> : std::true_type {}; template <typename T> constexpr bool is_vector_v = is_vector<T>::value; template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { if (!v.empty()) { for (int i = 0; i < v.size(); ++i) { out << v[i] << (i == v.size() - 1 ? "\n" : (is_vector_v<T> ? "" : ", ")); } } return out; } namespace std { // ref: // https://stackoverflow.com/questions/7110301/generic-hash-for-tuples-in-unordered-map-unordered-set template <class T> inline void hash_combine(std::size_t &seed, T const &v) { seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl { static void apply(size_t &seed, Tuple const &tuple) { HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0> { static void apply(size_t &seed, Tuple const &tuple) { hash_combine(seed, std::get<0>(tuple)); } }; template <typename... TT> struct hash<std::tuple<TT...>> { size_t operator()(std::tuple<TT...> const &tt) const { size_t seed = 0; HashValueImpl<std::tuple<TT...>>::apply(seed, tt); return seed; } }; template <class T, class U> class hash<std::pair<T, U>> { public: size_t operator()(const std::pair<T, U> &x) const { return hash<std::tuple<T, U>>()(std::tie(x.first, x.second)); } }; } // namespace std // ref: https://stackoverflow.com/questions/6245735/pretty-print-stdtuple namespace aux { template <std::size_t...> struct seq {}; template <std::size_t N, std::size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <std::size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, std::size_t... Is> void print_tuple(std::basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using swallow = int[]; (void)swallow{0, (void(os << (Is == 0 ? "" : ", ") << std::get<Is>(t)), 0)...}; } } // namespace aux template <class Ch, class Tr, class... Args> auto operator<<(std::basic_ostream<Ch, Tr> &os, std::tuple<Args...> const &t) -> std::basic_ostream<Ch, Tr> & { os << "("; aux::print_tuple(os, t, aux::gen_seq<sizeof...(Args)>()); return os << ")"; } template <class S, class T> std::ostream &operator<<(std::ostream &os, const std::pair<S, T> &p) { return os << "(" << p.first << ", " << p.second << ")"; } // ref: // https://stackoverflow.com/questions/8542591/c11-reverse-range-based-for-loo�Fp template <typename T> struct reversion_wrapper { T &iterable; }; template <typename T> auto begin(reversion_wrapper<T> w) { return std::rbegin(w.iterable); } template <typename T> auto end(reversion_wrapper<T> w) { return std::rend(w.iterable); } template <typename T> reversion_wrapper<T> REV(T &&iterable) { return {iterable}; } template <class T> bool inside(T left, T val, T right) { return left <= val and val < right; } template <class T> T bitCount(T num) { T res = 0; while (num > 0) { if (num & 1) ++res; num >>= 1; } return res; } ll MOD = 1e9 + 7; // ll MOD = 998244353; void solve(); signed main() { SETUP; #ifdef _DEBUG while (true) { #endif solve(); #ifdef _DEBUG cout << "-------" << endl; } #endif #ifdef _DEBUG system("pause"); #endif return 0; } #define int ll struct mint { int64_t value; mint() : value(0) {} mint(int64_t value_) : value(value_ % MOD) {} inline mint &operator+=(const mint &rhs) { value += rhs.value; if (value >= MOD) { value -= MOD; } return *this; } inline mint &operator-=(const mint &rhs) { value -= rhs.value; if (value < 0) { value += MOD; } return *this; } inline mint &operator*=(const mint &rhs) { value *= rhs.value; value %= MOD; return *this; } inline mint &operator%=(const mint &rhs) { return *this; } }; inline mint operator+(const mint &lhs, const mint &rhs) { mint res = lhs; res += rhs; return res; } inline mint operator-(const mint &lhs, const mint &rhs) { mint res = lhs; res -= rhs; return res; } inline mint operator*(const mint &lhs, const mint &rhs) { mint res = lhs; res *= rhs; return res; } inline mint operator%(const mint &lhs, const uint64_t &rhs) { return lhs; } ostream &operator<<(ostream &out, mint n) { return out << n.value; } void solve() { int M, D; cin >> M >> D; int res = 0; FOR(m, 1, M + 1) { FOR(d, 1, D) { int d1 = d % 10; int d2 = d / 10; if (d1 >= 2 and d2 >= 2 and d1 * d2 == m) { ++res; } } } cout << res << endl; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <ciso646> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define inf 0x3f3f3f3f3f3f3f3f #define ALL(a) (a).begin(), (a).end() #define DEBUG(x) // cerr<<#x<<": "<<x<<endl #define ll long long #define ull unsigned long long using pii = pair<ll, ll>; #define eps 1e-14 #define SETUP \ cin.tie(0), ios::sync_with_stdio(false), \ cout << setprecision(15) << std::fixed; #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) template <class T> using vec2 = std::vector<vector<T>>; //// bit //// #ifdef _MSC_VER #ifdef _WIN32 inline unsigned int __builtin_ctz(unsigned int x) { unsigned long r; _BitScanForward(&r, x); return r; } inline unsigned int __builtin_clz(unsigned int x) { unsigned long r; _BitScanReverse(&r, x); return 31 - r; } inline unsigned int __builtin_ffs(unsigned int x) { unsigned long r; return _BitScanForward(&r, x) ? r + 1 : 0; } // inline unsigned int __builtin_popcount(unsigned int x){ return __popcnt(x); } #ifdef _WIN64 inline unsigned long long __builtin_ctzll(unsigned long long x) { unsigned long r; _BitScanForward64(&r, x); return r; } inline unsigned long long __builtin_clzll(unsigned long long x) { unsigned long r; _BitScanReverse64(&r, x); return 63 - r; } inline unsigned long long __builtin_ffsll(unsigned long long x) { unsigned long r; return _BitScanForward64(&r, x) ? r + 1 : 0; } inline unsigned long long __builtin_popcountll(unsigned long long x) { return __popcnt64(x); } #else inline unsigned int hidword(unsigned long long x) { return static_cast<unsigned int>(x >> 32); } inline unsigned int lodword(unsigned long long x) { return static_cast<unsigned int>(x & 0xFFFFFFFF); } inline unsigned long long __builtin_ctzll(unsigned long long x) { return lodword(x) ? __builtin_ctz(lodword(x)) : __builtin_ctz(hidword(x)) + 32; } inline unsigned long long __builtin_clzll(unsigned long long x) { return hidword(x) ? __builtin_clz(hidword(x)) : __builtin_clz(lodword(x)) + 32; } inline unsigned long long __builtin_ffsll(unsigned long long x) { return lodword(x) ? __builtin_ffs(lodword(x)) : hidword(x) ? __builtin_ffs(hidword(x)) + 32 : 0; } // inline unsigned long long __builtin_popcountll(unsigned long long x) { return // __builtin_popcount(lodword(x)) + __builtin_popcount(hidword(x)); } #endif // _WIN64 #endif // _WIN32 #endif // _MSC_VER namespace { struct input_returnner { ll N; input_returnner(ll N_ = 0) : N(N_) {} template <typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); } template <typename T> operator T() const { T res; cin >> res; return res; } template <typename T> T operator-(T right) { return T(input_returnner()) - right; } template <typename T> T operator+(T right) { return T(input_returnner()) + right; } template <typename T> T operator*(T right) { return T(input_returnner()) * right; } template <typename T> T operator/(T right) { return T(input_returnner()) / right; } template <typename T> T operator<<(T right) { return T(input_returnner()) << right; } template <typename T> T operator>>(T right) { return T(input_returnner()) >> right; } }; template <typename T> input_returnner in() { return in<T>(); } input_returnner in() { return input_returnner(); } input_returnner in(ll N) { return std::move(input_returnner(N)); } } // namespace template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } template <typename T> struct is_vector : std::false_type {}; template <typename T> struct is_vector<std::vector<T>> : std::true_type {}; template <typename T> constexpr bool is_vector_v = is_vector<T>::value; template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { if (!v.empty()) { for (int i = 0; i < v.size(); ++i) { out << v[i] << (i == v.size() - 1 ? "\n" : (is_vector_v<T> ? "" : ", ")); } } return out; } namespace std { // ref: // https://stackoverflow.com/questions/7110301/generic-hash-for-tuples-in-unordered-map-unordered-set template <class T> inline void hash_combine(std::size_t &seed, T const &v) { seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl { static void apply(size_t &seed, Tuple const &tuple) { HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0> { static void apply(size_t &seed, Tuple const &tuple) { hash_combine(seed, std::get<0>(tuple)); } }; template <typename... TT> struct hash<std::tuple<TT...>> { size_t operator()(std::tuple<TT...> const &tt) const { size_t seed = 0; HashValueImpl<std::tuple<TT...>>::apply(seed, tt); return seed; } }; template <class T, class U> class hash<std::pair<T, U>> { public: size_t operator()(const std::pair<T, U> &x) const { return hash<std::tuple<T, U>>()(std::tie(x.first, x.second)); } }; } // namespace std // ref: https://stackoverflow.com/questions/6245735/pretty-print-stdtuple namespace aux { template <std::size_t...> struct seq {}; template <std::size_t N, std::size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <std::size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, std::size_t... Is> void print_tuple(std::basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using swallow = int[]; (void)swallow{0, (void(os << (Is == 0 ? "" : ", ") << std::get<Is>(t)), 0)...}; } } // namespace aux template <class Ch, class Tr, class... Args> auto operator<<(std::basic_ostream<Ch, Tr> &os, std::tuple<Args...> const &t) -> std::basic_ostream<Ch, Tr> & { os << "("; aux::print_tuple(os, t, aux::gen_seq<sizeof...(Args)>()); return os << ")"; } template <class S, class T> std::ostream &operator<<(std::ostream &os, const std::pair<S, T> &p) { return os << "(" << p.first << ", " << p.second << ")"; } // ref: // https://stackoverflow.com/questions/8542591/c11-reverse-range-based-for-loo�Fp template <typename T> struct reversion_wrapper { T &iterable; }; template <typename T> auto begin(reversion_wrapper<T> w) { return std::rbegin(w.iterable); } template <typename T> auto end(reversion_wrapper<T> w) { return std::rend(w.iterable); } template <typename T> reversion_wrapper<T> REV(T &&iterable) { return {iterable}; } template <class T> bool inside(T left, T val, T right) { return left <= val and val < right; } template <class T> T bitCount(T num) { T res = 0; while (num > 0) { if (num & 1) ++res; num >>= 1; } return res; } ll MOD = 1e9 + 7; // ll MOD = 998244353; void solve(); signed main() { SETUP; #ifdef _DEBUG while (true) { #endif solve(); #ifdef _DEBUG cout << "-------" << endl; } #endif #ifdef _DEBUG system("pause"); #endif return 0; } #define int ll struct mint { int64_t value; mint() : value(0) {} mint(int64_t value_) : value(value_ % MOD) {} inline mint &operator+=(const mint &rhs) { value += rhs.value; if (value >= MOD) { value -= MOD; } return *this; } inline mint &operator-=(const mint &rhs) { value -= rhs.value; if (value < 0) { value += MOD; } return *this; } inline mint &operator*=(const mint &rhs) { value *= rhs.value; value %= MOD; return *this; } inline mint &operator%=(const mint &rhs) { return *this; } }; inline mint operator+(const mint &lhs, const mint &rhs) { mint res = lhs; res += rhs; return res; } inline mint operator-(const mint &lhs, const mint &rhs) { mint res = lhs; res -= rhs; return res; } inline mint operator*(const mint &lhs, const mint &rhs) { mint res = lhs; res *= rhs; return res; } inline mint operator%(const mint &lhs, const uint64_t &rhs) { return lhs; } ostream &operator<<(ostream &out, mint n) { return out << n.value; } void solve() { int M, D; cin >> M >> D; int res = 0; FOR(m, 1, M + 1) { FOR(d, 1, D + 1) { int d1 = d % 10; int d2 = d / 10; if (d1 >= 2 and d2 >= 2 and d1 * d2 == m) { ++res; } } } cout << res << endl; }
[ "expression.operation.binary.add" ]
730,722
730,723
u579875569
cpp
p02927
#include <bits/stdc++.h> using namespace std; int main() { int m, d; cin >> m >> d; int ans = 0; for (int i = 2; i <= 9; i++) { for (int j = 2; j <= 9; j++) { int cur = i * 10 + j; if (cur > d) continue; int curm = i * j; if (curm <= m) ans++; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int m, d; cin >> m >> d; int ans = 0; for (int i = 2; i <= 9; i++) { for (int j = 2; j <= 9; j++) { int cur = i * 10 + j; if (cur > d) continue; int curm = i * j; if (curm <= m) ans++; } } cout << ans; return 0; }
[]
730,726
730,727
u901862155
cpp
p02927
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define For(i, a, b) for (int i = a; i <= b; i++) #define F first #define S second #define all(x) x.begin(), x.end() #define sz(x) ((int)x.size()) #define MOD (ll)(998244353) #define INF 1e17 #define int ll #define EPS (1e-6) using namespace std; using ll = long long; using pii = pair<int, int>; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } int fpow(int b, int p) { if (p == 0) return 1; int h = fpow(b, p / 2); if (p % 2) return h * b % MOD * h % MOD; return h * h % MOD; } bool cmp(pii a, pii b) { return a.S < b.S; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); int a, b; cin >> a >> b; int ans = 0; For(i, 1, a) { For(j, 20, b) { if (b % 10 >= 2 && (b % 10) * (b / 10) == a) ans++; } } cout << ans << "\n"; return 0; }
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define For(i, a, b) for (int i = a; i <= b; i++) #define F first #define S second #define all(x) x.begin(), x.end() #define sz(x) ((int)x.size()) #define MOD (ll)(998244353) #define INF 1e17 #define int ll #define EPS (1e-6) using namespace std; using ll = long long; using pii = pair<int, int>; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } int fpow(int b, int p) { if (p == 0) return 1; int h = fpow(b, p / 2); if (p % 2) return h * b % MOD * h % MOD; return h * h % MOD; } bool cmp(pii a, pii b) { return a.S < b.S; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); int a, b; cin >> a >> b; int ans = 0; For(i, 1, a) { For(j, 20, b) { if (j % 10 >= 2 && (j % 10) * (j / 10) == i) ans++; } } cout << ans << "\n"; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
730,728
730,729
u055148700
cpp
p02928
#include <algorithm> #include <iostream> #include <map> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; long long MOD = 1000000007; int main() { long long N, K; cin >> N >> K; long long A[N]; rep(i, N) cin >> A[i]; // 入力終了 long long ans = 0; // 自分自身の中にある転倒数の数 long long inner = 0; rep(i, N - 1) { for (int j = i + 1; j < N; j++) { if (A[i] > A[j]) inner = (inner + 1) % MOD; } } // inner分をansに反映 ans = (inner * K) % MOD; // A[i]より小さい数がA[]の中にいくつあるか long long cnt[2001] = {0}; rep(i, N) { rep(j, N) { if (A[j] < A[i]) cnt[A[i]]++; } } // 繰り返しでは,題意をみたすcnt[A[i]]回が(K-1)回繰り返される // i回目の繰り返しで,(i+1)回目以降の繰り返しにも関係する // (説明適当) rep(i, N) { long long tmp = (K - 1) * K / 2 % MOD; ans = (ans + (cnt[A[i]] * tmp % MOD)) % MOD; } // 解答 cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; long long MOD = 1000000007; int main() { long long N, K; cin >> N >> K; long long A[N]; rep(i, N) cin >> A[i]; // 入力終了 long long ans = 0; // 自分自身の中にある転倒数の数 long long inner = 0; rep(i, N - 1) { for (int j = i + 1; j < N; j++) { if (A[i] > A[j]) inner = (inner + 1) % MOD; } } // inner分をansに反映 ans = (inner * K) % MOD; // A[i]より小さい数がA[]の中にいくつあるか long long cnt[2001] = {0}; rep(i, N) { rep(j, N) { if (A[j] < A[i]) cnt[A[i]]++; } } // 繰り返しでは,題意をみたすcnt[A[i]]回が(K-1)回繰り返される // i回目の繰り返しで,(i+1)回目以降の繰り返しにも関係する // (説明適当) rep(i, 2001) { long long tmp = (K - 1) * K / 2 % MOD; ans = (ans + (cnt[i] * tmp % MOD)) % MOD; } // 解答 cout << ans << endl; return 0; }
[]
730,730
730,731
u537852947
cpp
p02928
#include <bits/stdc++.h> using ll = long long; #define REP(i, n) for (ll i = 0; i < ll(n); i++) #define FOR(i, a, b) for (ll i = a; i <= ll(b); i++) #define ALL(x) x.begin(), x.end() #define INF (ll)1e9 // 10^9:∞ #define LLINF (ll)1e12 #define MOD (ll)(1e9 + 7) // 10^9+7:合同式の法 #define PI 3.141592653589 #define PB push_back #define F first #define S second #define __MAGIC__ \ ios::sync_with_stdio(false); \ cin.tie(nullptr); #define YESNO(T) \ if (T) { \ cout << "YES" << endl; \ } else { \ cout << "NO" << endl; \ } #define yesno(T) \ if (T) { \ cout << "yes" << endl; \ } else { \ cout << "no" << endl; \ } #define YesNo(T) \ if (T) { \ cout << "Yes" << endl; \ } else { \ cout << "No" << endl; \ } #define Graph vector<vector<int>> #define PII pair<int, int> #define VI vector<int> #define VVI vector<vector<int>> #define VPII vector<pair<int, int>> #define DDD fixed << setprecision(10) #define endl "\n" using namespace std; /*..................DEFINE GLOBAL VARIABLES...................*/ /*.....................DEFINE FUNCTIONS ......................*/ /*.........................kemkemG0...........................*/ signed main() { __MAGIC__ ll N, K; cin >> N >> K; VI A(N); REP(i, N) cin >> A[i]; ll ans = 0; REP(i, N) REP(j, N) { if (i < j && A[i] > A[j]) { ans = (ans % MOD + K) % MOD; } if (A[i] > A[j]) { ans = (ans % MOD + (K * (K - 1)) % MOD / 2) % MOD; } ans %= MOD; } cout << ans % MOD << endl; return 0; }
#include <bits/stdc++.h> using ll = long long; #define REP(i, n) for (ll i = 0; i < ll(n); i++) #define FOR(i, a, b) for (ll i = a; i <= ll(b); i++) #define ALL(x) x.begin(), x.end() #define INF (ll)1e9 // 10^9:∞ #define LLINF (ll)1e12 #define MOD (ll)(1e9 + 7) // 10^9+7:合同式の法 #define PI 3.141592653589 #define PB push_back #define F first #define S second #define __MAGIC__ \ ios::sync_with_stdio(false); \ cin.tie(nullptr); #define YESNO(T) \ if (T) { \ cout << "YES" << endl; \ } else { \ cout << "NO" << endl; \ } #define yesno(T) \ if (T) { \ cout << "yes" << endl; \ } else { \ cout << "no" << endl; \ } #define YesNo(T) \ if (T) { \ cout << "Yes" << endl; \ } else { \ cout << "No" << endl; \ } #define Graph vector<vector<int>> #define PII pair<int, int> #define VI vector<int> #define VVI vector<vector<int>> #define VPII vector<pair<int, int>> #define DDD fixed << setprecision(10) #define endl "\n" using namespace std; /*..................DEFINE GLOBAL VARIABLES...................*/ /*.....................DEFINE FUNCTIONS ......................*/ /*.........................kemkemG0...........................*/ signed main() { __MAGIC__ ll N, K; cin >> N >> K; VI A(N); REP(i, N) cin >> A[i]; ll ans = 0; REP(i, N) REP(j, N) { if (i < j && A[i] > A[j]) { ans = (ans % MOD + K) % MOD; } if (A[i] > A[j]) { ans = (ans % MOD + ((K * (K - 1)) / 2) % MOD) % MOD; } ans %= MOD; } cout << ans % MOD << endl; return 0; }
[ "expression.operation.binary.remove", "assignment.change" ]
730,732
730,733
u345693891
cpp
p02928
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1000000007; int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ll ans = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] == a[j]) continue; else if (a[i] < a[j]) ans += k * (k - 1) / 2; else ans += k * (k + 1) / 2; ans %= MOD; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1000000007; int main() { ll n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ll ans = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] == a[j]) continue; else if (a[i] < a[j]) ans += k * (k - 1) / 2; else ans += k * (k + 1) / 2; ans %= MOD; } } cout << ans << endl; }
[ "variable_declaration.type.change" ]
730,760
730,761
u813174766
cpp
p02928
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<int, int> const int MOD = 1e9 + 7; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) { cin >> a[i]; } ll ans = 0; for (int i = 0; i < n; i++) { ll big = 0, small = 0; for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) small++; if (a[i] < a[j]) big++; } ans += big * k * (k - 1) / 2 % MOD + small * k * (k + 1) / 2 % MOD; ans %= MOD; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<int, int> const ll MOD = 1e9 + 7; int main() { ll n, k; cin >> n >> k; vector<int> a(n); rep(i, n) { cin >> a[i]; } ll ans = 0; for (int i = 0; i < n; i++) { ll big = 0, small = 0; for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) small++; if (a[i] < a[j]) big++; } ans += big * (k * (k - 1) / 2 % MOD) + small * (k * (k + 1) / 2 % MOD); ans %= MOD; } cout << ans << endl; }
[ "variable_declaration.type.change" ]
730,762
730,763
u692550512
cpp
p02928
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define ArraySizeOf(array) (sizeof(array) / sizeof(array[0])) #define res(i, n) for (int i = n;; i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i < n; i++) #define rev(i, n) for (int i = n - 1; i >= 0; i--) #define REV(i, n) for (int i = n - 1; i > 0; i--) #define req(i, n, m) for (int i = n; i < m; i++) #define REQ(i, n, m, l) for (int i = n; i < m; i += l) #define _GLIBCXX_DEBUG int INF = 1e9 + 7; long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117; unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1) { unsigned day; if (dow < dow1) dow += 7; day = dow - dow1; day += 7 * n - 6; return day; } signed gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } signed lcm(long long x, long long y) { return x / gcd(x, y) * y; } unsigned DayToWeekNumber(unsigned day) { return (day - 1) / 7 + 1; } unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0) { return (dow0 + 35 + day - day0) % 7; } using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N); rep(i, N) cin >> A[i]; long long count = 0; rep(i, N) for (int j = i + 1; j < N; j++) if (A[j] < A[i]) count++; count %= INF; count *= K; count %= INF; sort(A.begin(), A.end()); vector<int> B(N); long long ans = 0; REP(i, N) { if (A[i - 1] != A[i]) B[i] = i; else B[i] = B[i - 1]; ans += B[i]; ans %= INF; } long long a = (K * (K - 1) / 2) % INF; ans *= a; ans += count; ans %= INF; cout << ans << endl; }
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define ArraySizeOf(array) (sizeof(array) / sizeof(array[0])) #define res(i, n) for (int i = n;; i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i < n; i++) #define rev(i, n) for (int i = n - 1; i >= 0; i--) #define REV(i, n) for (int i = n - 1; i > 0; i--) #define req(i, n, m) for (int i = n; i < m; i++) #define REQ(i, n, m, l) for (int i = n; i < m; i += l) #define _GLIBCXX_DEBUG int INF = 1e9 + 7; long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117; unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1) { unsigned day; if (dow < dow1) dow += 7; day = dow - dow1; day += 7 * n - 6; return day; } signed gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } signed lcm(long long x, long long y) { return x / gcd(x, y) * y; } unsigned DayToWeekNumber(unsigned day) { return (day - 1) / 7 + 1; } unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0) { return (dow0 + 35 + day - day0) % 7; } using namespace std; int main() { long long N, K; cin >> N >> K; vector<int> A(N); rep(i, N) cin >> A[i]; long long count = 0; rep(i, N) for (int j = i + 1; j < N; j++) if (A[j] < A[i]) count++; count %= INF; count *= K; count %= INF; sort(A.begin(), A.end()); vector<int> B(N); long long ans = 0; REP(i, N) { if (A[i - 1] != A[i]) B[i] = i; else B[i] = B[i - 1]; ans += B[i]; ans %= INF; } long long a = (K * (K - 1) / 2) % INF; ans *= a; ans += count; ans %= INF; cout << ans << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
730,764
730,765
u991713078
cpp
p02928
#include <bits/stdc++.h> using namespace std; int main() { long long O = 1000000007; long long N, K; cin >> N >> K; vector<int> A(N); vector<int> B(N * 2); for (int X = 0; X < N; X++) { cin >> A[X]; B[X] = A[X]; B[N + X] = A[X]; } long long M = 0; for (int X = 0; X < N - 1; X++) { for (int Y = X + 1; Y < N; Y++) { if (A[X] > A[Y]) { M++; M %= 1000000007; } } } long long H = 0; for (int X = 0; X < N; X++) { for (int Y = N + 1; Y < N * 2; Y++) { if (B[X] > B[Y]) { H++; H %= 1000000007; } } } cout << ((M * K) % O + (H * (K * (K - 1) / 2 % O)) % O) % O << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long O = 1000000007; long long N, K; cin >> N >> K; vector<int> A(N); vector<int> B(N * 2); for (int X = 0; X < N; X++) { cin >> A[X]; B[X] = A[X]; B[N + X] = A[X]; } long long M = 0; for (int X = 0; X < N - 1; X++) { for (int Y = X + 1; Y < N; Y++) { if (A[X] > A[Y]) { M++; M %= 1000000007; } } } long long H = 0; for (int X = 0; X < N; X++) { for (int Y = N; Y < N * 2; Y++) { if (B[X] > B[Y]) { H++; H %= 1000000007; } } } cout << ((M * K) % O + (H * (K * (K - 1) / 2 % O)) % O) % O << endl; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove" ]
730,766
730,767
u740002394
cpp
p02928
#include <algorithm> #include <climits> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; using ll = long long; template <typename T> void print(T t) { cout << t << endl; } ll MOD = 1000000007; int main() { int N, K; cin >> N >> K; vector<ll> A(N), Ten(N, 0), Rank(N, 0); for (auto &a : A) cin >> a; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (A[j] > A[i]) { if (j < i) Ten[i]++; Rank[i]++; } } } ll ans = 0; for (int i = 0; i < N; i++) { ans += Ten[i] * K; ans %= MOD; ans += Rank[i] * (K * (K - 1ll) / 2) % MOD; ans %= MOD; } print(ans); }
#include <algorithm> #include <climits> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; using ll = long long; template <typename T> void print(T t) { cout << t << endl; } ll MOD = 1000000007; int main() { int N, K; cin >> N >> K; vector<ll> A(N), Ten(N, 0), Rank(N, 0); for (auto &a : A) cin >> a; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (A[j] > A[i]) { if (j < i) Ten[i]++; Rank[i]++; } } } ll ans = 0; for (int i = 0; i < N; i++) { ans += Ten[i] * K; ans %= MOD; ans += Rank[i] * ((K * (K - 1ll) / 2) % MOD); ans %= MOD; } print(ans); }
[]
730,770
730,771
u991692050
cpp
p02928
#include <algorithm> #include <climits> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; using ll = long long; template <typename T> void print(T t) { cout << t << endl; } ll MOD = 1000000007; int main() { int N, K; cin >> N >> K; vector<ll> A(N), Ten(N, 0), Rank(N, 0); for (auto &a : A) cin >> a; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (A[j] > A[i]) { if (j < i) Ten[i]++; Rank[i]++; } } } ll ans = 0; for (int i = 0; i < N; i++) { ans += Ten[i] * K; ans %= MOD; ans += Rank[i] * K * (K - 1ll) / 2; ans %= MOD; } print(ans); }
#include <algorithm> #include <climits> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; using ll = long long; template <typename T> void print(T t) { cout << t << endl; } ll MOD = 1000000007; int main() { int N, K; cin >> N >> K; vector<ll> A(N), Ten(N, 0), Rank(N, 0); for (auto &a : A) cin >> a; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (A[j] > A[i]) { if (j < i) Ten[i]++; Rank[i]++; } } } ll ans = 0; for (int i = 0; i < N; i++) { ans += Ten[i] * K; ans %= MOD; ans += Rank[i] * ((K * (K - 1ll) / 2) % MOD); ans %= MOD; } print(ans); }
[]
730,772
730,771
u991692050
cpp
p02928
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #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 dbg(x) cerr << #x << " = " << x << '\n' #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; int fun(int n) { return ((n * (n - 1)) / 2) % 1000000007; } inline void solve() { map<int, int> oc; int n, k, ans = 0; cin >> n >> k; vi a(n), b(n), help(n, 0); for (int &i : a) cin >> i; for (int i = 0; i < n; i++) { int b = 0, f = 0; for (int j = i + 1; j < n; j++) if (a[i] > a[j]) b++; for (int j = 0; j < i; j++) if (a[i] > a[j]) f++; ans = (ans + ((f + b) * fun(k)) + (b * k)) % 1000000007; } cout << ans << endl; return; } 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 <iostream> #include <map> #include <queue> #include <set> #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 dbg(x) cerr << #x << " = " << x << '\n' #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; int fun(int n) { return ((n * (n - 1)) / 2) % 1000000007; } inline void solve() { map<int, int> oc; int n, k, ans = 0; cin >> n >> k; vi a(n), b(n), help(n, 0); for (int &i : a) cin >> i; for (int i = 0; i < n; i++) { int b = 0, f = 0; for (int j = i + 1; j < n; j++) if (a[i] > a[j]) b++; for (int j = 0; j < i; j++) if (a[i] > a[j]) f++; ans = (ans + ((f + b) * fun(k)) + (b * k)) % 1000000007; } cout << ans << endl; return; } signed main() { int n = 1; // cin>>n; while (n--) solve(); return 0; }
[]
730,777
730,778
u931901821
cpp
p02928
// #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> #ifdef BOI #include "debug.h" #else #define debug(args...) #endif #define endl '\n' using ll = long long; using namespace std; const ll mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); ll n, k; cin >> n >> k; vector<ll> a(n); ll ans = 0; // map<ll, ll> inc; for (ll &it : a) cin >> it; for (ll i = 0; i < n; ++i) { ll temp = 0; for (ll j = i + 1; j < n; ++j) { temp += a[i] > a[j]; } // temp = (temp*k)%mod; // temp = (temp*(k + 1))%mod; // temp = (temp/2)%mod; ll ntemp = ((k * (k + 1)) / 2) % mod; temp = (ntemp * temp) % mod; debug(temp); ans = (ans + temp) % mod; temp = 0; for (ll j = 0; j < i; ++j) { temp += a[i] > a[j]; } // temp = (temp*k)%mod; // temp = (temp*(k - 1))%mod; // temp = (temp/2)%mod; ll xtemp = ((k * (k - 1)) / 2) % mod; temp = (xtemp * temp) % mod; debug(temp); ans = (ans + temp) % mod; } // debug(inc); // for(auto it : inc) { // ll temp = k; // temp = (temp*(k - 1))%mod; // temp = (temp/2)%mod; // ans = (ans + temp)%mod; // } cout << ans; return 0; }
// #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> #ifdef BOI #include "debug.h" #else #define debug(args...) #endif #define endl '\n' using ll = long long; using namespace std; const ll mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); #ifdef BOI freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif ll n, k; cin >> n >> k; vector<ll> a(n); ll ans = 0; // map<ll, ll> inc; for (ll &it : a) cin >> it; for (ll i = 0; i < n; ++i) { ll temp = 0; for (ll j = i + 1; j < n; ++j) { temp += a[i] > a[j]; } // temp = (temp*k)%mod; // temp = (temp*(k + 1))%mod; // temp = (temp/2)%mod; ll ntemp = ((k * (k + 1)) / 2) % mod; temp = (ntemp * temp) % mod; debug(temp); ans = (ans + temp) % mod; temp = 0; for (ll j = 0; j < i; ++j) { temp += a[i] > a[j]; } // temp = (temp*k)%mod; // temp = (temp*(k - 1))%mod; // temp = (temp/2)%mod; ll xtemp = ((k * (k - 1)) / 2) % mod; temp = (xtemp * temp) % mod; debug(temp); ans = (ans + temp) % mod; } // debug(inc); // for(auto it : inc) { // ll temp = k; // temp = (temp*(k - 1))%mod; // temp = (temp/2)%mod; // ans = (ans + temp)%mod; // } cout << ans; return 0; }
[]
730,779
730,780
u514461570
cpp
p02928
#include <bits/stdc++.h> using namespace std; #include <iomanip> #include <math.h> template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = 1001001001; vector<pair<int64_t, int64_t>> prime_factorize(int64_t x) { vector<pair<int64_t, int64_t>> p; for (int64_t i = 2; i * i <= x; i++) { int cnt = 0; if (x % i == 0) { while (x % i == 0) { cnt++; x /= i; } p.push_back(make_pair(i, cnt)); } } if (x != 1) { p.push_back(make_pair(x, 1)); } return p; } int main() { int64_t N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } int64_t p = 1000000007; int64_t sum = 0; int64_t cnt = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (A[i] > A[j]) { cnt++; } } } sum += (cnt * K % p); cnt = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (A[i] > A[j]) { cnt++; } } } sum += (cnt % p * K * (K - 1) / 2); cout << sum % p << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #include <iomanip> #include <math.h> template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = 1001001001; vector<pair<int64_t, int64_t>> prime_factorize(int64_t x) { vector<pair<int64_t, int64_t>> p; for (int64_t i = 2; i * i <= x; i++) { int cnt = 0; if (x % i == 0) { while (x % i == 0) { cnt++; x /= i; } p.push_back(make_pair(i, cnt)); } } if (x != 1) { p.push_back(make_pair(x, 1)); } return p; } int main() { int64_t N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } int64_t p = 1000000007; int64_t sum = 0; int64_t cnt = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (A[i] > A[j]) { cnt++; } } } sum += (cnt * K % p); cnt = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (A[i] > A[j]) { cnt++; } } } sum += cnt % p * (K * (K - 1) / 2 % p); //割り算のMODは途中でMODしてはいけない cout << sum % p << endl; return 0; }
[ "assignment.change" ]
730,783
730,784
u209457657
cpp
p02928
#include "bits/stdc++.h" #include <random> using namespace std; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) \ for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); } const lint MOD = 1e9 + 7, INF = 1e16; lint N, K; lint arr[2000]; int main() { cin >> N >> K; REP(i, N) { cin >> arr[i]; } lint ans = 0; REP(i, N) { lint cnt1 = 0, cnt2 = 0; REP(j, N) { if (arr[i] > arr[j]) { cnt2++; if (i < j) { cnt1++; } } } (ans += cnt1 * K + cnt2 * ((K * (K - 1)) % MOD) / 2) %= MOD; } cout << ans << endl; }
#include "bits/stdc++.h" #include <random> using namespace std; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) \ for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); } const lint MOD = 1e9 + 7, INF = 1e16; lint N, K; lint arr[2000]; int main() { cin >> N >> K; REP(i, N) { cin >> arr[i]; } lint ans = 0; REP(i, N) { lint cnt1 = 0, cnt2 = 0; REP(j, N) { if (arr[i] > arr[j]) { cnt2++; if (i < j) { cnt1++; } } } (ans += cnt1 * K + cnt2 * ((K * (K - 1) / 2) % MOD)) %= MOD; } cout << ans << endl; }
[ "assignment.change", "expression.operation.binary.remove" ]
730,800
730,801
u554988565
cpp
p02928
#include "bits/stdc++.h" #include <random> using namespace std; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) \ for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); } const lint MOD = 1e9 + 7, INF = 1e16; lint N, K; lint arr[2000]; int main() { cin >> N >> K; REP(i, N) { cin >> arr[i]; } lint ans = 0; REP(i, N) { lint cnt1 = 0, cnt2 = 0; REP(j, N) { if (arr[i] > arr[j]) { cnt2++; if (i < j) { cnt1++; } } } (ans += cnt1 * K + cnt2 * K * (K - 1) / 2) %= MOD; } cout << ans << endl; }
#include "bits/stdc++.h" #include <random> using namespace std; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) \ for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); } const lint MOD = 1e9 + 7, INF = 1e16; lint N, K; lint arr[2000]; int main() { cin >> N >> K; REP(i, N) { cin >> arr[i]; } lint ans = 0; REP(i, N) { lint cnt1 = 0, cnt2 = 0; REP(j, N) { if (arr[i] > arr[j]) { cnt2++; if (i < j) { cnt1++; } } } (ans += cnt1 * K + cnt2 * ((K * (K - 1) / 2) % MOD)) %= MOD; } cout << ans << endl; }
[]
730,802
730,801
u554988565
cpp
p02928
#include <bits/stdc++.h> using namespace std; #define froop1(a, n) for (int i = a; i < n; i++) #define froop2(a, n) for (int i = a; i > n; i--) #define ll long long #define pq(name, type) priority_queue<type> name #define vec(name, type, length, value) vector<type> name(length, value) #define vec2(name, type, length, width, value) \ vector<vector<type>> name(length, vector<type>(width, value)); int main() { ll N, K, sum = 0; cin >> N >> K; vector<ll> a(N, 0); map<ll, ll> b; froop1(0, N) { cin >> a.at(i); if (b.count(a.at(i))) { b[a.at(i)]++; } else { b[a.at(i)] = 1; } } ll c = 0, kk = K * (K - 1) / 2; kk %= 1000000007LL; for (pair<ll, ll> p : b) { sum += c * kk; sum %= 1000000007LL; c += p.second; } froop1(0, N) { for (int j = i; j < N; j++) { if (a.at(i) > a.at(j)) sum += K; sum %= 1000000007LL; } } cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; #define froop1(a, n) for (int i = a; i < n; i++) #define froop2(a, n) for (int i = a; i > n; i--) #define ll long long #define pq(name, type) priority_queue<type> name #define vec(name, type, length, value) vector<type> name(length, value) #define vec2(name, type, length, width, value) \ vector<vector<type>> name(length, vector<type>(width, value)); int main() { ll N, K, sum = 0; cin >> N >> K; vector<ll> a(N, 0); map<ll, ll> b; froop1(0, N) { cin >> a.at(i); if (b.count(a.at(i))) { b[a.at(i)]++; } else { b[a.at(i)] = 1; } } ll c = 0, kk = K * (K - 1) / 2; kk %= 1000000007LL; for (pair<ll, ll> p : b) { sum += c * kk * p.second; sum %= 1000000007LL; c += p.second; } froop1(0, N) { for (int j = i; j < N; j++) { if (a.at(i) > a.at(j)) sum += K; sum %= 1000000007LL; } } cout << sum << endl; }
[ "assignment.change" ]
730,807
730,808
u475471747
cpp
p02928
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define rep1(i, n) for (int i = 1; i <= (int)n; i++) #define sp(n) cout << fixed << setprecision(n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; using namespace std; const ll mod = 1e9 + 7; int main(void) { ll n, k; cin >> n >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; vector<ll> b(n, 0), c(n, 0); rep(i, n) { for (int j = 0; j < i; j++) { if (a[i] > a[j]) b[i]++; } for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) c[i]++; } } ll res = 0; rep(i, n) { ll buf = (c[i] * k) % mod + ((b[i] + c[i]) * ((k - 1) * k / 2) % mod) % mod; res = (res + buf) % mod; // cout<<res<<endl; } cout << res << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define rep1(i, n) for (int i = 1; i <= (int)n; i++) #define sp(n) cout << fixed << setprecision(n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; using namespace std; const ll mod = 1e9 + 7; int main(void) { ll n, k; cin >> n >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; vector<ll> b(n, 0), c(n, 0); rep(i, n) { for (int j = 0; j < i; j++) { if (a[i] > a[j]) b[i]++; } for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) c[i]++; } } ll res = 0; rep(i, n) { ll buf = (c[i] * k % mod + (b[i] + c[i]) * ((k - 1) * k / 2 % mod)) % mod; res = (res + buf) % mod; // cout<<res<<endl; } cout << res << endl; }
[]
730,820
730,821
u222866518
cpp
p02928
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define rep1(i, n) for (int i = 1; i <= (int)n; i++) #define sp(n) cout << fixed << setprecision(n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; using namespace std; const ll mod = 1e9 + 7; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main(void) { int n; ll k; cin >> n >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; vector<ll> b(2010, 0), c(2010, 0); rep(i, n) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) b[i]++; //見る数内での転倒数 } for (int j = 0; j < i; j++) { if (a[i] > a[j]) c[i]++; } } mint res = 0; rep(i, n) { mint buf = (b[i] * k + (b[i] + c[i]) * k * (k - 1) / 2); res += buf; } cout << res.x << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define rep1(i, n) for (int i = 1; i <= (int)n; i++) #define sp(n) cout << fixed << setprecision(n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; using namespace std; const ll mod = 1e9 + 7; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main(void) { int n; ll k; cin >> n >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; vector<mint> b(2010, 0), c(2010, 0); rep(i, n) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) b[i] += 1; //見る数内での転倒数 } for (int j = 0; j < i; j++) { if (a[i] > a[j]) c[i] += 1; } } mint res = 0; rep(i, n) { mint buf = (b[i] * k + (b[i] + c[i]) * k * (k - 1) / 2); res += buf; } cout << res.x << endl; }
[]
730,822
730,823
u222866518
cpp
p02928
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define rep1(i, n) for (int i = 1; i <= (int)n; i++) #define sp(n) cout << fixed << setprecision(n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; using namespace std; const ll mod = 1e9 + 7; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main(void) { int n; ll k; cin >> n >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; vector<ll> b(2010, 0), c(2010, 0); rep(i, n) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) b[i]++; //見る数内での転倒数 } for (int j = 0; j < i; j++) { if (a[i] > a[j]) c[i]++; } } mint res = 0; rep(i, n) { mint buf = (b[i] * k + (b[i] + c[i]) * k * (k - 1) / 2); res += buf; } cout << res.x << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define rep1(i, n) for (int i = 1; i <= (int)n; i++) #define sp(n) cout << fixed << setprecision(n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; using namespace std; const ll mod = 1e9 + 7; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main(void) { int n; ll k; cin >> n >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; vector<mint> b(2010, 0), c(2010, 0); rep(i, n) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) b[i] += 1; //見る数内での転倒数 } for (int j = 0; j < i; j++) { if (a[i] > a[j]) c[i] += 1; } } mint res = 0; rep(i, n) { mint buf = (b[i] * k + (b[i] + c[i]) * k * (k - 1) / 2); res += buf; } cout << res.x << endl; }
[]
730,822
730,824
u222866518
cpp
p02928
// う し た ぷ に き あ く ん 笑 #include <algorithm> #include <array> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define int long long constexpr int MOD = 1000000000 + 7; // copied from https://github.com/atcoder-live/library/blob/master/mint.cpp struct mint { using ll = long long; const int mod = 1e9 + 7; 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; } signed main() { cin.tie(0); ios::sync_with_stdio(0); int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int inner_inversion = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) inner_inversion++; } } int outer_inversion = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] > a[j]) outer_inversion++; } } mint ans = 0; ans += inner_inversion * k; ans += outer_inversion * k % MOD * (k - 1) / 2 % MOD; cout << ans << endl; }
// う し た ぷ に き あ く ん 笑 #include <algorithm> #include <array> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define int long long constexpr int MOD = 1000000000 + 7; // copied from https://github.com/atcoder-live/library/blob/master/mint.cpp struct mint { using ll = long long; const int mod = 1e9 + 7; 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; } signed main() { cin.tie(0); ios::sync_with_stdio(0); int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int inner_inversion = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) inner_inversion++; } } int outer_inversion = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] > a[j]) outer_inversion++; } } mint ans = 0; ans += inner_inversion * k; ans += outer_inversion * ((k * (k - 1) / 2) % MOD); cout << ans << endl; }
[ "expression.operation.binary.remove" ]
730,825
730,826
u076506345
cpp
p02928
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m" #define pp1(...) \ "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m" #define dg(x) debug() << pp1(x) #define dg1(x) debug() << pp(x) #define dg2(x, y) debug() << pp(x) pp(y) #define dg3(x, y, z) debug() << pp(x) pp(y) pp(z) #define dg4(w, x, y, z) debug() << pp(w) pp(x) pp(y) pp(z) #define int long long #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof x); #define sz(x) (int)x.size() template <typename T> void db(T x) { debug() << ">>> " << x; } template <typename T> void db(T x, T y) { debug() << ">>> " << x << " , " << y; } template <typename T> void db(T x, T y, T z) { debug() << ">>> " << x << " , " << y << " , " << z; } template <typename T> void db(T x, T y, T z, T a) { debug() << ">>> " << x << " , " << y << " , " << z << " , " << a; } const int xx = 2e5; const int Mod = 1e9 + 7; const int inf = 1e18; const int Maxn = 20010; auto in = [](auto &&...args) { (cin >> ... >> args); }; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> inversion(n), Cnt(n); for (int i = 0; i < n; i++) { int c = 0; for (int j = i + 1; j < n; j++) { if (a[j] < a[i]) c++; } inversion[i] = c; c = 0; for (int j = 0; j < n; j++) { if (i == j) continue; if (a[j] < a[i]) c++; } Cnt[i] = c; } dg(inversion); dg(Cnt); int ans = 0; int K = (k * (k - 1) / 2); for (int i = 0; i < n; i++) { int x = (inversion[i] * k) % Mod; int y = (K * Cnt[i]) % Mod; ans += (x + y) % Mod; ans = ans % Mod; } cout << ans << '\n'; }
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m" #define pp1(...) \ "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m" #define dg(x) debug() << pp1(x) #define dg1(x) debug() << pp(x) #define dg2(x, y) debug() << pp(x) pp(y) #define dg3(x, y, z) debug() << pp(x) pp(y) pp(z) #define dg4(w, x, y, z) debug() << pp(w) pp(x) pp(y) pp(z) #define int long long #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof x); #define sz(x) (int)x.size() template <typename T> void db(T x) { debug() << ">>> " << x; } template <typename T> void db(T x, T y) { debug() << ">>> " << x << " , " << y; } template <typename T> void db(T x, T y, T z) { debug() << ">>> " << x << " , " << y << " , " << z; } template <typename T> void db(T x, T y, T z, T a) { debug() << ">>> " << x << " , " << y << " , " << z << " , " << a; } const int xx = 2e5; const int Mod = 1e9 + 7; const int inf = 1e18; const int Maxn = 20010; auto in = [](auto &&...args) { (cin >> ... >> args); }; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> inversion(n), Cnt(n); for (int i = 0; i < n; i++) { int c = 0; for (int j = i + 1; j < n; j++) { if (a[j] < a[i]) c++; } inversion[i] = c; c = 0; for (int j = 0; j < n; j++) { if (i == j) continue; if (a[j] < a[i]) c++; } Cnt[i] = c; } dg(inversion); dg(Cnt); int ans = 0; int K = (k * (k - 1) / 2); K = K % Mod; for (int i = 0; i < n; i++) { int x = (inversion[i] * k) % Mod; int y = (K * Cnt[i]) % Mod; ans += (x + y) % Mod; ans = ans % Mod; } cout << ans << '\n'; }
[ "assignment.add" ]
730,830
730,831
u428805520
cpp
p02928
#include <bits/stdc++.h> #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define per(i, b) gnr(i, 0, b) using namespace std; using ll = long long; using P = pair<int, int>; static ll MOD = 1'000'000'007; int main() { ll n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a.at(i); ll res = 0; for (int i = 0; i < n; i++) { // 転倒数 a内 // 転倒数 全体 ll ina = 0; ll inTotal = 0; for (int j = i + 1; j < n; j++) { if (a.at(i) > a.at(j)) { ina++; } } for (int j = 0; j < n; j++) { if (a.at(i) > a.at(j)) { inTotal++; } } res += (ina * k) % MOD; res %= MOD; res += (inTotal * ((k * (k - 1)) / 2) % MOD) % MOD; res %= MOD; } cout << res << endl; return 0; }
#include <bits/stdc++.h> #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define per(i, b) gnr(i, 0, b) using namespace std; using ll = long long; using P = pair<int, int>; static ll MOD = 1'000'000'007; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a.at(i); ll res = 0; for (int i = 0; i < n; i++) { // 転倒数 a内 // 転倒数 全体 ll ina = 0; ll inTotal = 0; for (int j = i + 1; j < n; j++) { if (a.at(i) > a.at(j)) { ina++; } } for (int j = 0; j < n; j++) { if (a.at(i) > a.at(j)) { inTotal++; } } res += (ina * k) % MOD; res %= MOD; res += (inTotal * (((ll)k * (k - 1)) / 2 % MOD)) % MOD; res %= MOD; } cout << res << endl; return 0; }
[ "variable_declaration.type.change" ]
730,832
730,833
u011438316
cpp
p02928
#include <bits/stdc++.h> #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define per(i, b) gnr(i, 0, b) using namespace std; using ll = long long; using P = pair<int, int>; static ll MOD = 1'000'000'007; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a.at(i); ll res = 0; for (int i = 0; i < n; i++) { // 転倒数 a内 // 転倒数 全体 ll ina = 0; ll inTotal = 0; for (int j = i + 1; j < n; j++) { if (a.at(i) > a.at(j)) { ina++; } } for (int j = 0; j < n; j++) { if (a.at(i) > a.at(j)) { inTotal++; } } res += (ina * k) % MOD; res %= MOD; res += (inTotal * (((ll)k * (k - 1)) / 2) % MOD) % MOD; res %= MOD; } cout << res << endl; return 0; }
#include <bits/stdc++.h> #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define per(i, b) gnr(i, 0, b) using namespace std; using ll = long long; using P = pair<int, int>; static ll MOD = 1'000'000'007; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a.at(i); ll res = 0; for (int i = 0; i < n; i++) { // 転倒数 a内 // 転倒数 全体 ll ina = 0; ll inTotal = 0; for (int j = i + 1; j < n; j++) { if (a.at(i) > a.at(j)) { ina++; } } for (int j = 0; j < n; j++) { if (a.at(i) > a.at(j)) { inTotal++; } } res += (ina * k) % MOD; res %= MOD; res += (inTotal * (((ll)k * (k - 1)) / 2 % MOD)) % MOD; res %= MOD; } cout << res << endl; return 0; }
[]
730,834
730,833
u011438316
cpp
p02928
#include <bits/stdc++.h> #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define per(i, b) gnr(i, 0, b) using namespace std; using ll = long long; using P = pair<int, int>; static int MOD = 1'000'000'007; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a.at(i); ll res = 0; for (int i = 0; i < n; i++) { // 転倒数 a内 // 転倒数 全体 ll ina = 0; ll inTotal = 0; for (int j = i + 1; j < n; j++) { if (a.at(i) > a.at(j)) { ina++; } } for (int j = 0; j < n; j++) { if (a.at(i) > a.at(j)) { inTotal++; } } res += (ina * k) % MOD; res %= MOD; res += (inTotal * (((ll)k * (k - 1)) / 2) % MOD) % MOD; res %= MOD; } cout << res << endl; return 0; }
#include <bits/stdc++.h> #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define per(i, b) gnr(i, 0, b) using namespace std; using ll = long long; using P = pair<int, int>; static ll MOD = 1'000'000'007; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a.at(i); ll res = 0; for (int i = 0; i < n; i++) { // 転倒数 a内 // 転倒数 全体 ll ina = 0; ll inTotal = 0; for (int j = i + 1; j < n; j++) { if (a.at(i) > a.at(j)) { ina++; } } for (int j = 0; j < n; j++) { if (a.at(i) > a.at(j)) { inTotal++; } } res += (ina * k) % MOD; res %= MOD; res += (inTotal * (((ll)k * (k - 1)) / 2 % MOD)) % MOD; res %= MOD; } cout << res << endl; return 0; }
[ "variable_declaration.type.change" ]
730,835
730,833
u011438316
cpp
p02928
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { int n; long long k; cin >> n >> k; vector<int> A(n); for (int i = 0; i < n; i++) { cin >> A.at(i); } long long kk; if (k % 2 == 0) { kk = (k / 2) * (k - 1) % (7 + (long long)1e9); } else { kk = k * ((k - 1) / 2) % (7 + (long long)1e9); } long long ans1 = 0; long long ans2 = 0; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (A[i] > A[j]) { ans1 = (ans1 + k) % (7 + (long long)1e9); } } for (int j = 0; j < n; j++) { if (A[i] > A[j]) { ans2 = (ans2 + kk) % (7 + (long long)1e9); } } } cout << (ans1 + ans2) % (7 + (long long)1e9) << endl; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { int n; long long k; cin >> n >> k; vector<int> A(n); for (int i = 0; i < n; i++) { cin >> A.at(i); } long long kk; if (k % 2 == 0) { kk = ((k / 2) * (k - 1)) % (7 + (long long)1e9); } else { kk = (k * ((k - 1) / 2)) % (7 + (long long)1e9); } long long ans1 = 0; long long ans2 = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (A[i] > A[j]) { ans1 = (ans1 + k) % (7 + (long long)1e9); } } for (int j = 0; j < n; j++) { if (A[i] > A[j]) { ans2 = (ans2 + kk) % (7 + (long long)1e9); } } } cout << (ans1 + ans2) % (7 + (long long)1e9) << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
730,836
730,837
u981206782
cpp
p02928
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define a first #define b second #define sz(x) (ll)((x).size()) #define pb push_back #define mp make_pair #define bg begin() #define ed end() #define all(x) (x).bg, (x).ed #define rep(i, n) for (ll i = 0; i < (n); i++) #define rep1(i, n) for (ll i = 1; i <= (n); i++) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define rrep1(i, n) for (ll i = (n); i >= 1; i--) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) const ll MOD = 1000000007; const ll INF = 1000000000000000; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll maxx(ll x, ll y, ll z) { return max(max(x, y), z); } ll minn(ll x, ll y, ll z) { return min(min(x, y), z); } ll gcd(ll x, ll y) { if (x % y == 0) return y; else return gcd(y, x % y); } ll lcm(ll x, ll y) { return x * (y / gcd(x, y)); } vector<ll> pw2(51, 1); vector<ll> pw10(19, 1); int main() { { rep1(i, 50) pw2[i] = 2 * pw2[i - 1]; } { rep1(i, 18) pw10[i] = 10 * pw10[i - 1]; } ll N, K; cin >> N >> K; ll ans = 0; vector<ll> A(N, 0); rep(i, N) cin >> A[i]; ll tmp = 0; rep(i, N - 1) FOR(j, i + 1, N) { if (A[i] > A[j]) tmp++; } ans += tmp * K; ans %= MOD; map<ll, ll> m; //*K(K-1)/2 rep(i, N) { if (m.find(A[i]) == m.ed) m[A[i]] = 1; else m[A[i]]++; } tmp = 0; ll tmtmp = 0; for (auto it = m.bg; it != m.ed; it++) { tmtmp += (tmp * (it->a)) % MOD; tmtmp %= MOD; tmp += (it->b); tmp %= MOD; } ll tmpK = (K * (K - 1)) / 2; tmpK %= MOD; ans += (tmtmp * tmpK) % MOD; ans %= MOD; cout << ans << endl; }
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define a first #define b second #define sz(x) (ll)((x).size()) #define pb push_back #define mp make_pair #define bg begin() #define ed end() #define all(x) (x).bg, (x).ed #define rep(i, n) for (ll i = 0; i < (n); i++) #define rep1(i, n) for (ll i = 1; i <= (n); i++) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define rrep1(i, n) for (ll i = (n); i >= 1; i--) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) const ll MOD = 1000000007; const ll INF = 1000000000000000; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll maxx(ll x, ll y, ll z) { return max(max(x, y), z); } ll minn(ll x, ll y, ll z) { return min(min(x, y), z); } ll gcd(ll x, ll y) { if (x % y == 0) return y; else return gcd(y, x % y); } ll lcm(ll x, ll y) { return x * (y / gcd(x, y)); } vector<ll> pw2(51, 1); vector<ll> pw10(19, 1); int main() { { rep1(i, 50) pw2[i] = 2 * pw2[i - 1]; } { rep1(i, 18) pw10[i] = 10 * pw10[i - 1]; } ll N, K; cin >> N >> K; ll ans = 0; vector<ll> A(N, 0); rep(i, N) cin >> A[i]; ll tmp = 0; rep(i, N - 1) FOR(j, i + 1, N) { if (A[i] > A[j]) tmp++; } ans += tmp * K; ans %= MOD; map<ll, ll> m; //*K(K-1)/2 rep(i, N) { if (m.find(A[i]) == m.ed) m[A[i]] = 1; else m[A[i]]++; } tmp = 0; ll tmtmp = 0; for (auto it = m.bg; it != m.ed; it++) { tmtmp += (tmp * (it->b)) % MOD; tmtmp %= MOD; tmp += (it->b); tmp %= MOD; } ll tmpK = (K * (K - 1)) / 2; tmpK %= MOD; ans += (tmtmp * tmpK) % MOD; ans %= MOD; cout << ans << endl; }
[ "assignment.value.change", "expression.operation.binary.change" ]
730,838
730,839
u527058497
cpp
p02928
#include <bits/stdc++.h> using namespace std; #define CPP_STR(x) CPP_STR_I(x) #define CPP_CAT(x, y) CPP_CAT_I(x, y) #define CPP_STR_I(args...) #args #define CPP_CAT_I(x, y) x##y using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using f32 = float; using f64 = double; #define FOR(i, start, end) \ for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); \ i < CPP_CAT(i, xxxx_end); ++i) #define REP(i, n) FOR(i, 0, n) #define REPS(i, n) for (i64 i = 1; i <= n; ++i) #define RREP(i, n) for (i64 i = n - 1; i >= 0; --i) #define RREPS(i, n) for (i64 i = n; i >= 1; --i) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); #define pb push_back #define mp make_pair template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename C> i64 SIZE(const C &c) { return static_cast<i64>(c.size()); } template <typename T, size_t N> i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); } struct ProconInit { static constexpr int IOS_PREC = 15; static constexpr bool AUTOFLUSH = false; ProconInit() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(IOS_PREC); if (AUTOFLUSH) cout << unitbuf; } } PROCON_INIT; template <int MOD> struct Fp { i64 val; constexpr Fp(i64 v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { i64 a = r.val, b = MOD, u = 1, v = 0; while (b) { i64 t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } constexpr bool operator>(const Fp &r) const noexcept { return this->val > r.val; } constexpr bool operator>=(const Fp &r) const noexcept { return this->val >= r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, i64 n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; #define MOD 1'000'000'007 using mint = Fp<MOD>; int main() { i64 N, K; cin >> N >> K; vector<i64> A(N); REP(i, N) cin >> A[i]; mint cnt = 0; while (1) { bool sorted = true; REP(i, N - 1) { if (A[i] > A[i + 1]) { swap(A[i], A[i + 1]); cnt += 1; sorted = false; } } if (sorted) break; } cnt *= K; map<i64, i64> dist; REP(i, N) dist[A[i]]++; i64 nlower = 0; i64 prev = 0; for (auto [x, n] : dist) { nlower += prev; prev += n; } mint out = nlower; out *= K * (K - 1); out /= 2; cnt += out; cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define CPP_STR(x) CPP_STR_I(x) #define CPP_CAT(x, y) CPP_CAT_I(x, y) #define CPP_STR_I(args...) #args #define CPP_CAT_I(x, y) x##y using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using f32 = float; using f64 = double; #define FOR(i, start, end) \ for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); \ i < CPP_CAT(i, xxxx_end); ++i) #define REP(i, n) FOR(i, 0, n) #define REPS(i, n) for (i64 i = 1; i <= n; ++i) #define RREP(i, n) for (i64 i = n - 1; i >= 0; --i) #define RREPS(i, n) for (i64 i = n; i >= 1; --i) #define ALL(f, c, ...) \ (([&](decltype((c)) cccc) { \ return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \ })(c)) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); #define pb push_back #define mp make_pair template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename C> i64 SIZE(const C &c) { return static_cast<i64>(c.size()); } template <typename T, size_t N> i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); } struct ProconInit { static constexpr int IOS_PREC = 15; static constexpr bool AUTOFLUSH = false; ProconInit() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(IOS_PREC); if (AUTOFLUSH) cout << unitbuf; } } PROCON_INIT; template <int MOD> struct Fp { i64 val; constexpr Fp(i64 v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { i64 a = r.val, b = MOD, u = 1, v = 0; while (b) { i64 t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } constexpr bool operator>(const Fp &r) const noexcept { return this->val > r.val; } constexpr bool operator>=(const Fp &r) const noexcept { return this->val >= r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, i64 n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; #define MOD 1'000'000'007 using mint = Fp<MOD>; int main() { i64 N, K; cin >> N >> K; vector<i64> A(N); REP(i, N) cin >> A[i]; mint cnt = 0; while (1) { bool sorted = true; REP(i, N - 1) { if (A[i] > A[i + 1]) { swap(A[i], A[i + 1]); cnt += 1; sorted = false; } } if (sorted) break; } cnt *= K; map<i64, i64> dist; REP(i, N) dist[A[i]]++; i64 nlower = 0; i64 prev = 0; for (auto [x, n] : dist) { nlower += prev * n; prev += n; } mint out = nlower; out *= K * (K - 1); out /= 2; cnt += out; cout << cnt << endl; return 0; }
[ "assignment.change" ]
730,840
730,841
u461336793
cpp
p02928
#include <bits/stdc++.h> #include <cmath> // using namespace boost::multiprecision; using namespace std; typedef long long ll; // typedef unsigned long long ll; const double EPS = 1e-9; #define rep(i, n) for (int i = 0; i < (n); ++i) //#define rep(i, n) for (ll i = 0; i < (n); ++i) //#define sz(x) ll(x.size()) // typedef pair<int, int> P; // typedef pair<ll, int> P; // typedef pair<ll, ll> P; // const double INF = 1e10; // const ll INF = LONG_LONG_MAX / 100; // const ll INF = (1ll << 31) - 1; // const ll INF = 1e15; // const ll MINF = LONG_LONG_MIN; // const int INF = INT_MAX / 10; #define cmin(x, y) x = min(x, y) #define cmax(x, y) x = max(x, y) // typedef pair<int, int> P; // typedef pair<double, double> P; #define ret() return 0; bool contain(set<char> &s, char a) { return s.find(a) != s.end(); } // ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt"); // ofstream outfile("log.txt"); // outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') // << rank << endl; // std::cout << std::bitset<8>(9); const int mod = 1000000007; // const ll mod = 1e10; typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } friend std::istream &operator>>(std::istream &in, mint &o) { ll a; in >> a; o = a; return in; } friend std::ostream &operator<<(std::ostream &out, const mint &o) { out << o.x; return out; } }; struct BIT { private: vector<int> bit; int N; public: BIT(int size) { N = size; bit.resize(N + 1); } // 一点更新です void add(int a, int w) { for (int x = a; x <= N; x += x & -x) bit[x] += w; } // 1~Nまでの和を求める。 int sum(int a) { int ret = 0; for (int x = a; x > 0; x -= x & -x) ret += bit[x]; return ret; } }; int main() { int n; ll k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } mint tento = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if (v[i] < v[j]) tento = tento + 1; } } tento *= k; vector<int> min_count(n, 0); rep(i, n) { rep(j, n) { if (v[i] > v[j]) min_count[i]++; } } mint c = 0; for (ll i : min_count) { c += i * k * (k - 1) / 2; } mint ans = tento + c; cout << ans << endl; }
#include <bits/stdc++.h> #include <cmath> // using namespace boost::multiprecision; using namespace std; typedef long long ll; // typedef unsigned long long ll; const double EPS = 1e-9; #define rep(i, n) for (int i = 0; i < (n); ++i) //#define rep(i, n) for (ll i = 0; i < (n); ++i) //#define sz(x) ll(x.size()) // typedef pair<int, int> P; // typedef pair<ll, int> P; // typedef pair<ll, ll> P; // const double INF = 1e10; // const ll INF = LONG_LONG_MAX / 100; // const ll INF = (1ll << 31) - 1; // const ll INF = 1e15; // const ll MINF = LONG_LONG_MIN; // const int INF = INT_MAX / 10; #define cmin(x, y) x = min(x, y) #define cmax(x, y) x = max(x, y) // typedef pair<int, int> P; // typedef pair<double, double> P; #define ret() return 0; bool contain(set<char> &s, char a) { return s.find(a) != s.end(); } // ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt"); // ofstream outfile("log.txt"); // outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') // << rank << endl; // std::cout << std::bitset<8>(9); const int mod = 1000000007; // const ll mod = 1e10; typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } friend std::istream &operator>>(std::istream &in, mint &o) { ll a; in >> a; o = a; return in; } friend std::ostream &operator<<(std::ostream &out, const mint &o) { out << o.x; return out; } }; struct BIT { private: vector<int> bit; int N; public: BIT(int size) { N = size; bit.resize(N + 1); } // 一点更新です void add(int a, int w) { for (int x = a; x <= N; x += x & -x) bit[x] += w; } // 1~Nまでの和を求める。 int sum(int a) { int ret = 0; for (int x = a; x > 0; x -= x & -x) ret += bit[x]; return ret; } }; int main() { int n; ll k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } mint tento = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if (v[i] < v[j]) tento = tento + 1; } } tento *= k; vector<int> min_count(n, 0); rep(i, n) { rep(j, n) { if (v[i] > v[j]) min_count[i]++; } } mint c = 0; for (ll i : min_count) { c += mint(i) * k * (k - 1) / 2; } mint ans = tento + c; cout << ans << endl; }
[ "call.add", "call.arguments.change" ]
730,842
730,843
u564182781
cpp
p02928
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using namespace std; using ll = int64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<int>; using vvi = vector<vi>; template <class T> using PQ = priority_queue<T>; template <class T> using PQG = priority_queue<T, vector<T>, greater<T>>; const int INF = 100010001; const ll LINF = (ll)INF * INF * 10; template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second; } const int mod = 1000000007; // const int mod = 998244353; struct mint { int64_t x; mint(int64_t 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(int64_t 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) { 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; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int k; cin >> k; vi a(n); rep(i, n) { int al; cin >> al; a[i] = al; } vi b = a; sort(all(b)); mint ans, jj = mint(k - 1) * k / 2; rep(i, n) { int j = i; while (j != n - 1 and b[j] == b[j + 1]) j++; ans += mint(n - 1 - j) * (j - i + 1); } ans *= jj; multiset<int> mst; rep(i, n) { mst.insert(a[i]); auto itr = mst.upper_bound(a[i]); ans += (mint)distance(itr, mst.end()) * k; } cout << ans << endl; }
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using namespace std; using ll = int64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<int>; using vvi = vector<vi>; template <class T> using PQ = priority_queue<T>; template <class T> using PQG = priority_queue<T, vector<T>, greater<T>>; const int INF = 100010001; const ll LINF = (ll)INF * INF * 10; template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second; } const int mod = 1000000007; // const int mod = 998244353; struct mint { int64_t x; mint(int64_t 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(int64_t 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) { 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; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int k; cin >> k; vi a(n); rep(i, n) { int al; cin >> al; a[i] = al; } vi b = a; sort(all(b)); mint ans, jj = mint(k - 1) * k / 2; rep(i, n) { int j = i; while (j != n - 1 and b[j] == b[j + 1]) j++; ans += mint(n - 1 - j) * (j - i + 1); i = j; } ans *= jj; multiset<int> mst; rep(i, n) { mst.insert(a[i]); auto itr = mst.upper_bound(a[i]); ans += (mint)distance(itr, mst.end()) * k; } cout << ans << endl; }
[ "assignment.add" ]
730,844
730,845
u802434195
cpp
p02928
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using namespace std; using ll = int64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<int>; using vvi = vector<vi>; template <class T> using PQ = priority_queue<T>; template <class T> using PQG = priority_queue<T, vector<T>, greater<T>>; const int INF = 100010001; const ll LINF = (ll)INF * INF * 10; template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second; } const int mod = 1000000007; // const int mod = 998244353; struct mint { int64_t x; mint(int64_t 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(int64_t 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) { 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; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int k; cin >> k; vi a(n); rep(i, n) { int al; cin >> al; a[i] = al; } vi b = a; sort(all(b)); mint ans, jj = mint(k - 1) * k / 2; rep(i, n) { int j = i; while (j != n - 1 and b[j] == b[j + 1]) j++; ans += (n - 1 - j) * (j - i + 1); } ans *= jj; multiset<int> mst; rep(i, n) { mst.insert(a[i]); auto itr = mst.upper_bound(a[i]); ans += (mint)distance(itr, mst.end()) * k; } cout << ans << endl; }
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using namespace std; using ll = int64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<int>; using vvi = vector<vi>; template <class T> using PQ = priority_queue<T>; template <class T> using PQG = priority_queue<T, vector<T>, greater<T>>; const int INF = 100010001; const ll LINF = (ll)INF * INF * 10; template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second; } const int mod = 1000000007; // const int mod = 998244353; struct mint { int64_t x; mint(int64_t 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(int64_t 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) { 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; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int k; cin >> k; vi a(n); rep(i, n) { int al; cin >> al; a[i] = al; } vi b = a; sort(all(b)); mint ans, jj = mint(k - 1) * k / 2; rep(i, n) { int j = i; while (j != n - 1 and b[j] == b[j + 1]) j++; ans += mint(n - 1 - j) * (j - i + 1); i = j; } ans *= jj; multiset<int> mst; rep(i, n) { mst.insert(a[i]); auto itr = mst.upper_bound(a[i]); ans += (mint)distance(itr, mst.end()) * k; } cout << ans << endl; }
[ "call.add", "assignment.add" ]
730,846
730,845
u802434195
cpp
p02928
#include <bits/stdc++.h> using namespace std; #define rep(i, cc, n) for (int i = cc; i < n; ++i) #define lrep(i, cc, n) for (long long i = cc; i < n; ++i) #define rrep(i, cc, n) for (long i = cc; i > n; --i) #define pii pair<int, int> #define pll pair<long long, long long> using ll = long long; const ll inf = 1001001001; const ll mod = 1000000007; int main() { int n; ll k; cin >> n >> k; vector<int> a(n); vector<int> b(n); ll b2 = 0, c2 = 0; vector<int> c(n); rep(i, 0, n) cin >> a[i]; rep(i, 0, n) { rep(j, i + 1, n) { if (a[i] > a[j]) b2++; } rep(j, 0, i) { if (a[j] < a[i]) c2++; } } ll d = ((k + 1) * k) % mod / 2; ll e = ((k - 1) * k) % mod / 2; ll ans = ((b2 * (d % mod)) % mod + (c2 * (e % mod)) % mod) % mod; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, cc, n) for (int i = cc; i < n; ++i) #define lrep(i, cc, n) for (long long i = cc; i < n; ++i) #define rrep(i, cc, n) for (long i = cc; i > n; --i) #define pii pair<int, int> #define pll pair<long long, long long> using ll = long long; const ll inf = 1001001001; const ll mod = 1000000007; int main() { int n; ll k; cin >> n >> k; vector<int> a(n); vector<int> b(n); ll b2 = 0, c2 = 0; vector<int> c(n); rep(i, 0, n) cin >> a[i]; rep(i, 0, n) { rep(j, i, n) { if (a[i] > a[j]) b2++; } rep(j, 0, i) { if (a[j] < a[i]) c2++; } } ll d = ((k + 1) * k) / 2; ll e = ((k - 1) * k) / 2; ll ans = ((b2 * (d % mod)) % mod + (c2 * (e % mod)) % mod) % mod; cout << ans << endl; }
[ "expression.operation.binary.remove" ]
730,847
730,848
u330518333
cpp
p02928
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; const int m = 1000000007; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a[i]; ll inv1 = 0, inv2 = 0; rep(i, n) { rep(j, n) { if (i == j) continue; if (a[i] > a[j]) { if (i < j) inv1++; inv2++; } } } ll ans = 0; ans += (k * inv1) % m; ans += ((k * (k - 1)) / 2) % m * inv2; ans %= m; cout << ans; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; const int m = 1000000007; int main() { ll n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a[i]; ll inv1 = 0, inv2 = 0; rep(i, n) { rep(j, n) { if (i == j) continue; if (a[i] > a[j]) { if (i < j) inv1++; inv2++; } } } ll ans = 0; ans += (k * inv1) % m; ans += ((k * (k - 1)) / 2) % m * inv2; ans %= m; cout << ans; return 0; }
[ "variable_declaration.type.change" ]
730,857
730,858
u281829807
cpp
p02928
#include <algorithm> #include <bitset> #include <chrono> #include <cstring> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define pi 3.141592653589793238 #define MOD 1000000007 #define INF 999999999999999999 #define pb push_back #define ff first #define ss second #define mt make_tuple #define ll long long #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define f0 get<0> #define f1 get<1> #define f2 get<2> typedef vector<ll> vi; typedef vector<vi> vvi; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); fast; ll T = 1, i, j; // cin >> T; while (T--) { ll n, k; cin >> n >> k; vector<ll> v(n); for (i = 0; i < n; i++) { cin >> v[i]; } vector<ll> bef(n), aft(n); for (i = 0; i < n; i++) { for (j = 0; j < i; j++) { if (v[j] < v[i]) { bef[i]++; } } for (j = i + 1; j < n; j++) { if (v[j] < v[i]) { aft[i]++; } } } ll ans = 0; for (i = 0; i < n; i++) { ll b, a; b = bef[i], a = aft[i]; ans += k * a + (a + b) * (k * k - (k * (k + 1) / 2)); ans %= MOD; } cout << ans; } return 0; }
#include <algorithm> #include <bitset> #include <chrono> #include <cstring> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define pi 3.141592653589793238 #define MOD 1000000007 #define INF 999999999999999999 #define pb push_back #define ff first #define ss second #define mt make_tuple #define ll long long #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define f0 get<0> #define f1 get<1> #define f2 get<2> typedef vector<ll> vi; typedef vector<vi> vvi; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); fast; ll T = 1, i, j; // cin >> T; while (T--) { ll n, k; cin >> n >> k; vector<ll> v(n); for (i = 0; i < n; i++) { cin >> v[i]; } vector<ll> bef(n), aft(n); for (i = 0; i < n; i++) { for (j = 0; j < i; j++) { if (v[j] < v[i]) { bef[i]++; } } for (j = i + 1; j < n; j++) { if (v[j] < v[i]) { aft[i]++; } } } ll ans = 0; for (i = 0; i < n; i++) { ll b, a; b = bef[i], a = aft[i]; ans += k * a + (a + b) * ((k * k - (k * (k + 1) / 2)) % MOD); ans %= MOD; } cout << ans; } return 0; }
[]
730,861
730,862
u734397606
cpp
p02928
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a.at(i); vector<ll> inans(n); for (int i = 0; i < n; i++) { if (i == n - 1) { inans.at(i) = 0; break; } else { ll x = a.at(i); ll ct = 0; for (int j = i + 1; j < n; j++) { if (x > a.at(j)) ct++; } inans.at(i) = ct; } } vector<ll> loopans(n); for (int i = 0; i < n; i++) { ll ct = 0; for (int j = 0; j < n; j++) { if (i == j) continue; if (a.at(i) > a.at(j)) ct++; } loopans.at(i) = ct; } ll ans = 0; for (int i = 0; i < n - 1; i++) { ans += (ll)k * inans.at(i); ans %= 1000000007; ans += (ll)((k * (k - 1) / 2) % 1000000007) * (loopans.at(i)); ans %= 1000000007; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a.at(i); vector<ll> inans(n); for (int i = 0; i < n; i++) { if (i == n - 1) { inans.at(i) = 0; break; } else { ll x = a.at(i); ll ct = 0; for (int j = i + 1; j < n; j++) { if (x > a.at(j)) ct++; } inans.at(i) = ct; } } vector<ll> loopans(n); for (int i = 0; i < n; i++) { ll ct = 0; for (int j = 0; j < n; j++) { if (i == j) continue; if (a.at(i) > a.at(j)) ct++; } loopans.at(i) = ct; } ll ans = 0; for (int i = 0; i <= n - 1; i++) { ans += (ll)k * inans.at(i); ans %= 1000000007; ans += (ll)((k * (k - 1) / 2) % 1000000007) * (loopans.at(i)); ans %= 1000000007; } cout << ans << endl; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
730,868
730,869
u582684800
cpp
p02928
#include <bits/stdc++.h> #define fi first #define se second const int N = 100100; const long long mod = 1e9 + 7; using namespace std; int n; int a[N]; long long k; int main() { ios_base::sync_with_stdio(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } long long res = 0, A = 0; for (int i = 1; i <= n; i++) { long long B = 0; for (int j = i + 1; j <= n; j++) { A += (a[i] > a[j]); } for (int j = 1; j <= n; j++) { B += (a[i] > a[j]); } res = (res + B * k * (k - 1) / 2) % mod; } cout << (res + A * k) % mod << "\n"; }
#include <bits/stdc++.h> #define fi first #define se second const int N = 100100; const long long mod = 1e9 + 7; using namespace std; int n; int a[N]; long long k; int main() { ios_base::sync_with_stdio(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } long long res = 0, A = 0; for (int i = 1; i <= n; i++) { long long B = 0; for (int j = i + 1; j <= n; j++) { A += (a[i] > a[j]); } for (int j = 1; j <= n; j++) { B += (a[i] > a[j]); } res = (res + B * (k * (k - 1) / 2 % mod)) % mod; } cout << (res + A * k) % mod << "\n"; }
[]
730,872
730,873
u941977569
cpp
p02928
#include <bits/stdc++.h> using namespace std; const long long int M = 1e9 + 7; int main() { long long int n, k, i, j; cin >> n >> k; long long int a[n + 1]; for (i = 0; i < n; i++) { cin >> a[i]; } long long int ans = 0; for (i = 0; i < n; i++) { long long int c = 0, d = 0; for (j = 0; j < i; j++) { if (a[j] > a[i]) { c++; } } for (j = 0; j < n; j++) { if (a[j] > a[i]) { d++; } } ans += c * k + k * (k - 1) / 2 * d; ans = ans % M; } cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; const long long int M = 1e9 + 7; int main() { long long int n, k, i, j; cin >> n >> k; long long int a[n + 1]; for (i = 0; i < n; i++) { cin >> a[i]; } long long int ans = 0; for (i = 0; i < n; i++) { long long int c = 0, d = 0; for (j = 0; j < i; j++) { if (a[j] > a[i]) { c++; } } for (j = 0; j < n; j++) { if (a[j] > a[i]) { d++; } } ans += c * k + (k * (k - 1) / 2) % M * d % M; ans = ans % M; } cout << ans << "\n"; }
[ "assignment.change" ]
730,885
730,886
u532483802
cpp
p02928
#include <algorithm> #include <climits> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < (int)n; i++) #define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++) #define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++) #define REPe(e, mp) for (auto &e : mp) #define all(x) x.begin(), x.end() #define MOD 1000000007 // 1e9+7 using namespace std; using ll = long long int; using vecint = vector<int>; using vecll = vector<ll>; using vec2int = vector<vector<int>>; using P = pair<int, int>; //////////////////////////////////////////////// //////////////////////////////////////////////// int main() { //////////////////////////////////////////////// cin.tie(nullptr); ios_base::sync_with_stdio(false); //////////////////////////////////////////////// int n; ll k; cin >> n >> k; vecint a(n); REPe(e, a) cin >> e; vecll x(n, 0); vecll y(n, 0); REP(i, n) { FOR(j, i + 1, n) { if (a[i] > a[j]) { x[i]++; } } FOR(j, 0, i) { if (a[i] > a[j]) { y[i]++; } } } // REP(i, n) cout << x[i] << " " << y[i] << endl; ll ans = 0; REP(i, n) { ans += ((x[i] + y[i]) * ((k * k - k) / 2) % MOD + k * x[i]) % MOD; ans %= MOD; } cout << ans << endl; } //////////////////////////////////////////////
#include <algorithm> #include <climits> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < (int)n; i++) #define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++) #define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++) #define REPe(e, mp) for (auto &e : mp) #define all(x) x.begin(), x.end() #define MOD 1000000007 // 1e9+7 using namespace std; using ll = long long int; using vecint = vector<int>; using vecll = vector<ll>; using vec2int = vector<vector<int>>; using P = pair<int, int>; //////////////////////////////////////////////// //////////////////////////////////////////////// int main() { //////////////////////////////////////////////// cin.tie(nullptr); ios_base::sync_with_stdio(false); //////////////////////////////////////////////// int n; ll k; cin >> n >> k; vecint a(n); REPe(e, a) cin >> e; vecll x(n, 0); vecll y(n, 0); REP(i, n) { FOR(j, i + 1, n) { if (a[i] > a[j]) { x[i]++; } } FOR(j, 0, i) { if (a[i] > a[j]) { y[i]++; } } } // REP(i, n) cout << x[i] << " " << y[i] << endl; ll ans = 0; REP(i, n) { ans += ((x[i] + y[i]) * (((k * k - k) / 2) % MOD) + k * x[i]) % MOD; ans %= MOD; } cout << ans << endl; } //////////////////////////////////////////////
[]
730,891
730,892
u138062788
cpp
p02928
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; const int mod = 1e9 + 7; int main() { ll n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a[i]; int cnt = 0, cnt2 = 0; rep(i, n) { for (int j = i + 1; j < n; ++j) { if (a[i] > a[j]) cnt++; } } rep(i, n) { rep(j, n) { if (a[i] > a[j]) cnt2++; } } ll ans = cnt * k; ans %= mod; ans += cnt2 * k % mod * (k - 1) / 2 % mod; ans %= mod; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; const int mod = 1e9 + 7; int main() { ll n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a[i]; int cnt = 0, cnt2 = 0; rep(i, n) { for (int j = i + 1; j < n; ++j) { if (a[i] > a[j]) cnt++; } } rep(i, n) { rep(j, n) { if (a[i] > a[j]) cnt2++; } } ll ans = cnt * k; ans %= mod; ans += cnt2 * ((k * (k - 1) / 2) % mod); ans %= mod; cout << ans << endl; return 0; }
[ "expression.operation.binary.remove" ]
730,902
730,903
u754114382
cpp
p02928
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> #define rep(i, n) for (long long i = 0; i < (n); ++i) #define rep2(i, n, m) for (long long i = n; i <= m; i++) #define ALL(a) (a).begin(), (a).end() using namespace std; using ll = long long; using P = pair<int, int>; const ll INF = 1e18; inline void chmax(ll &a, ll b) { a = max(a, b); } inline void chmin(ll &a, ll b) { a = min(a, b); } ll mod = 1000000007; int main() { ll n, k; cin >> n >> k; vector<ll> A(n); rep(i, n) cin >> A[i]; // sortしてない vector<ll> migi(n); rep(i, n - 1) { rep2(j, i + 1, n - 1) { if (A[i] > A[j]) migi[i]++; } } ll migisum = 0; rep(i, n) migisum += migi[i]; vector<ll> mog(n); rep(i, n) { rep(j, n) if (A[i] > A[j]) mog[i]++; } ll mogsum = 0; rep(i, n) mogsum += mog[i]; ll gm = (mogsum * k * (k - 1) / 2) % mod; cout << (migisum * k + gm) % mod << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> #define rep(i, n) for (long long i = 0; i < (n); ++i) #define rep2(i, n, m) for (long long i = n; i <= m; i++) #define ALL(a) (a).begin(), (a).end() using namespace std; using ll = long long; using P = pair<int, int>; const ll INF = 1e18; inline void chmax(ll &a, ll b) { a = max(a, b); } inline void chmin(ll &a, ll b) { a = min(a, b); } ll mod = 1000000007; int main() { ll n, k; cin >> n >> k; vector<ll> A(n); rep(i, n) cin >> A[i]; // sortしてない vector<ll> migi(n); rep(i, n - 1) { rep2(j, i + 1, n - 1) { if (A[i] > A[j]) migi[i]++; } } ll migisum = 0; rep(i, n) migisum += migi[i]; vector<ll> mog(n); rep(i, n) { rep(j, n) if (A[i] > A[j]) mog[i]++; } ll mogsum = 0; rep(i, n) mogsum += mog[i]; ll gm = mogsum * ((k * (k - 1) / 2) % mod); cout << (migisum * k + gm) % mod << endl; return 0; }
[]
730,904
730,905
u449123607
cpp
p02928
#include "bits/stdc++.h" using namespace std; #define ll long long int #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n; i >= 0; i--) #define REP(i, s, t) for (int i = s; i <= t; i++) #define RREP(i, s, t) for (int i = s; i >= t; i--) #define dump(x) cerr << #x << " = " << (x) << endl; #define INF 2000000000 #define mod 1000000007 #define INF2 1000000000000000000 #define int long long signed main(void) { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; int A[2010]; rep(i, N) cin >> A[i]; int ans = 0; rep(i, N) { int cntL = 0, cntR = 0; rep(j, N) { if (i < j && A[i] > A[j]) cntR++; else if (j < i && A[i] > A[j]) cntL++; } int tmpL = (cntL * ((K) * (K - 1) / 2) % mod) % mod; int tmpR = (cntR * (K * (K + 1)) / 2 % mod) % mod; ans = (ans + tmpL + tmpR) % mod; // cout << i << " " << cntL << " " << cntR << " " << ans << endl; } cout << ans << endl; return 0; } // 2 1 2 1 2 1
#include "bits/stdc++.h" using namespace std; #define ll long long int #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n; i >= 0; i--) #define REP(i, s, t) for (int i = s; i <= t; i++) #define RREP(i, s, t) for (int i = s; i >= t; i--) #define dump(x) cerr << #x << " = " << (x) << endl; #define INF 2000000000 #define mod 1000000007 #define INF2 1000000000000000000 #define int long long signed main(void) { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; int A[2010]; rep(i, N) cin >> A[i]; int ans = 0; rep(i, N) { int cntL = 0, cntR = 0; rep(j, N) { if (i < j && A[i] > A[j]) cntR++; else if (j < i && A[i] > A[j]) cntL++; } int tmpL = (cntL * (((K) * (K - 1) / 2) % mod)) % mod; int tmpR = (cntR * (((K * (K + 1)) / 2) % mod)) % mod; ans = (ans + tmpL + tmpR) % mod; // cout << i << " " << cntL << " " << cntR << " " << ans << endl; } cout << ans << endl; return 0; } // 2 1 2 1 2 1
[]
730,906
730,907
u965730380
cpp
p02928
#pragma GCC optimize("Ofast") #include <algorithm> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> using namespace std; int main() { long long int n, k; cin >> n >> k; vector<long long int> a(2 * n); for (long long int i = 0; i < n; i++) cin >> a[i]; for (long long int i = n; i < 2 * n; i++) a[i] = a[i - n]; long long int res = 0; // aの中にある転倒数 for (long long int i = 0; i < n - 1; i++) { for (long long int j = i + 1; j < n; j++) { if (a[i] > a[j]) { res++; } } } // aを跨いで存在する転倒数 long long int res1 = 0; for (long long int i = 0; i < n; i++) { for (long long int j = n; j < 2 * n; j++) { if (a[i] > a[j]) { res1++; } } } long long int ans = k * res % 1000000007; ans += res1 * (((k - 1) * k) / 2 % 1000000007) % 1000000007; cout << ans << endl; }
#pragma GCC optimize("Ofast") #include <algorithm> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> using namespace std; int main() { long long int n, k; cin >> n >> k; vector<long long int> a(2 * n); for (long long int i = 0; i < n; i++) cin >> a[i]; for (long long int i = n; i < 2 * n; i++) a[i] = a[i - n]; long long int res = 0; // aの中にある転倒数 for (long long int i = 0; i < n - 1; i++) { for (long long int j = i + 1; j < n; j++) { if (a[i] > a[j]) { res++; } } } // aを跨いで存在する転倒数 long long int res1 = 0; for (long long int i = 0; i < n; i++) { for (long long int j = n; j < 2 * n; j++) { if (a[i] > a[j]) { res1++; } } } long long int ans = k * res % 1000000007; ans += res1 * (((k - 1) * k) / 2 % 1000000007) % 1000000007; ans %= 1000000007; cout << ans << endl; }
[ "assignment.add" ]
730,908
730,909
u583888880
cpp
p02928
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define PI 3.14159265358979323846 #define int long long constexpr int INF = numeric_limits<int>::max() / 2; constexpr long long INFL = numeric_limits<long long>::max() / 2; constexpr int MOD = 1000000007; using Graph = vector<vector<int>>; signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, K; cin >> N >> K; int A[N]; rep(i, N) { cin >> A[i]; } int cm = 0, cn = 0; rep(i, N) { rep(j, N) { if (A[i] > A[j]) cm++; } } rep(i, N) { for (int j = i + 1; j < N; j++) { if (A[i] > A[j]) cn++; } } int ans = ((cn * K) % MOD + ((((K * (K - 1)) % MOD) / 2) * cm) % MOD) % MOD; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define PI 3.14159265358979323846 #define int long long constexpr int INF = numeric_limits<int>::max() / 2; constexpr long long INFL = numeric_limits<long long>::max() / 2; constexpr int MOD = 1000000007; using Graph = vector<vector<int>>; signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, K; cin >> N >> K; int A[N]; rep(i, N) { cin >> A[i]; } int cm = 0, cn = 0; rep(i, N) { rep(j, N) { if (A[i] > A[j]) cm++; } } rep(i, N) { for (int j = i + 1; j < N; j++) { if (A[i] > A[j]) cn++; } } int ans = ((cn * K) % MOD + ((((K * (K - 1)) / 2) % MOD) * cm) % MOD) % MOD; cout << ans << endl; }
[ "assignment.change" ]
730,912
730,913
u093973314
cpp
p02928
#include <algorithm> #include <bitset> #include <cassert> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits.h> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long int lint; #define rep(i, n) for (lint i = 0; i < n; i++) #define sort(v) sort((v).begin(), (v).end()) #define reverse(v) reverse((v).begin(), (v).end()) #define upper(v, hoge) upper_bound(v.begin(), v.end(), hoge) #define lower(v, hoge) lower_bound(v.begin(), v.end(), hoge) #define llower(v, hoge) *lower_bound(v.begin(), v.end(), hoge) #define lupper(v, hoge) *upper_bound(v.begin(), v.end(), hoge) #define mp make_pair #define IP pair<int, int> #define enld endl lint power(lint x, lint n, lint m) { //(x^n)%mを返す lint res = 1; x %= m; while (n > 0) { if (n % 2 == 1) { res = res * x % m; } x = x * x % m; n /= 2; } return res; } lint invmod(lint n, lint m) { // nの逆元を返す lint ret = 0; ret = power(n, m - 2, m); return ret; } int main() { lint N, K; cin >> N >> K; lint MOD = pow(10, 9) + 7; vector<lint> A(N); rep(i, N) { cin >> A[i]; } lint S1 = 0; lint S2 = 0; rep(i, N) { rep(j, N) { if (A[i] > A[j]) { S1++; S1 %= MOD; } } } rep(i, N) { rep(j, N) { if (i < j) { if (A[i] > A[j]) { S2++; S2 %= MOD; } } } } lint ans = (K % MOD * S1 % MOD) % MOD + (K % MOD * (K - 1) % MOD * invmod(2, MOD) % MOD * S2 % MOD) % MOD; ans %= MOD; cout << ans << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits.h> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long int lint; #define rep(i, n) for (lint i = 0; i < n; i++) #define sort(v) sort((v).begin(), (v).end()) #define reverse(v) reverse((v).begin(), (v).end()) #define upper(v, hoge) upper_bound(v.begin(), v.end(), hoge) #define lower(v, hoge) lower_bound(v.begin(), v.end(), hoge) #define llower(v, hoge) *lower_bound(v.begin(), v.end(), hoge) #define lupper(v, hoge) *upper_bound(v.begin(), v.end(), hoge) #define mp make_pair #define IP pair<int, int> #define enld endl lint power(lint x, lint n, lint m) { //(x^n)%mを返す lint res = 1; x %= m; while (n > 0) { if (n % 2 == 1) { res = res * x % m; } x = x * x % m; n /= 2; } return res; } lint invmod(lint n, lint m) { // nの逆元を返す lint ret = 0; ret = power(n, m - 2, m); return ret; } int main() { lint N, K; cin >> N >> K; lint MOD = pow(10, 9) + 7; vector<lint> A(N); rep(i, N) { cin >> A[i]; } lint S1 = 0; lint S2 = 0; rep(i, N) { rep(j, N) { if (A[i] > A[j]) { S1++; S1 %= MOD; } } } rep(i, N) { rep(j, N) { if (i < j) { if (A[i] > A[j]) { S2++; S2 %= MOD; } } } } lint ans = (K % MOD * S2 % MOD) % MOD + K % MOD * (K - 1) % MOD * invmod(2, MOD) % MOD * S1 % MOD; ans %= MOD; cout << ans << endl; }
[ "identifier.change", "expression.operation.binary.change" ]
730,914
730,915
u247679666
cpp
p02928
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; ll k; cin >> k; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } ll cou = 0; ll q = 10e8 + 7; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) { cou++; } } } ll ans = 0; ans = cou * k; ans %= q; ll t = k * (k - 1); t /= 2; for (int i = 0; i < n; i++) { cou = 0; for (int j = 0; j < n; j++) { if (i != j) { if (a[i] > a[j]) { cou++; } } } ans += cou * t; ans %= q; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; ll k; cin >> k; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } ll cou = 0; ll q = 10e8 + 7; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) { cou++; } } } ll ans = 0; ans = cou * k; ans %= q; ll t = k * (k - 1); t /= 2; t %= q; for (int i = 0; i < n; i++) { cou = 0; for (int j = 0; j < n; j++) { if (i != j) { if (a[i] > a[j]) { cou++; } } } ans += cou * t; ans %= q; } cout << ans << endl; }
[ "assignment.add" ]
730,916
730,917
u457483230
cpp
p02928
#include <bits/stdc++.h> #include <functional> #include <numeric> using namespace std; namespace mod { template <class T, int M> class MInt; template <class T, int M> MInt<T, M> Pow(const MInt<T, M> &base, T exp); template <class T, int M> MInt<T, M> Inv(const MInt<T, M> &n); template <class T, int M> class MInt { T n_; public: MInt() : n_(0) {} MInt(T n) : n_((n % M + M) % M) {} MInt &operator+=(const MInt &rhs) { n_ += rhs.n_; if (n_ >= M) { n_ -= M; } return *this; } MInt &operator-=(const MInt &rhs) { n_ += M - rhs.n_; if (n_ >= M) { n_ -= M; } return *this; } MInt &operator*=(const MInt &rhs) { n_ = n_ * rhs.n_ % M; return *this; } MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); } T Get() { return n_; } }; template <class T, int M> MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) { MInt<T, M> res(lhs); return res -= rhs; } template <class T, int M> MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) { MInt<T, M> res(lhs); return res += rhs; } template <class T, int M> MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) { MInt<T, M> res(lhs); return res *= rhs; } template <class T, int M> MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) { MInt<T, M> res(lhs); return res /= rhs; } template <class T, int M> MInt<T, M> Pow(const MInt<T, M> &base, T exp) { if (exp == 0) { return 1; } auto a = Pow(base, exp / 2); a *= a; if (exp % 2 == 1) { a *= base; } return a; } template <class T, int M> MInt<T, M> Inv(const MInt<T, M> &n) { return Pow(n, static_cast<T>(M - 2)); } } // namespace mod const int md = 1e9 + 7; using MInt = mod::MInt<long long, md>; int main(int argc, const char *argv[]) { int n, k; cin >> n >> k; vector<int> va(n); for (int i = 0; i < n; i++) { cin >> va[i]; } vector<MInt> cnts(n, 0), cnts_all(n, 0); for (int i = 0; i < va.size() - 1; i++) { for (int j = 0; j < va.size(); j++) { if (va[i] > va[j]) { cnts_all[i] += 1; if (j >= i) { cnts[i] += 1; } } } } MInt mk(k); MInt sum_cnts = accumulate(cnts.begin(), cnts.end(), MInt(0), plus<MInt>()), sum_cnts_all = accumulate(cnts.begin(), cnts.end(), MInt(0), plus<MInt>()); MInt ans = (mk * sum_cnts) + (sum_cnts_all * (mk * (mk - MInt(1))) / MInt(2)); cout << ans.Get() << '\n'; return 0; }
#include <bits/stdc++.h> #include <functional> #include <numeric> using namespace std; namespace mod { template <class T, int M> class MInt; template <class T, int M> MInt<T, M> Pow(const MInt<T, M> &base, T exp); template <class T, int M> MInt<T, M> Inv(const MInt<T, M> &n); template <class T, int M> class MInt { T n_; public: MInt() : n_(0) {} MInt(T n) : n_((n % M + M) % M) {} MInt &operator+=(const MInt &rhs) { n_ += rhs.n_; if (n_ >= M) { n_ -= M; } return *this; } MInt &operator-=(const MInt &rhs) { n_ += M - rhs.n_; if (n_ >= M) { n_ -= M; } return *this; } MInt &operator*=(const MInt &rhs) { n_ = n_ * rhs.n_ % M; return *this; } MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); } T Get() { return n_; } }; template <class T, int M> MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) { MInt<T, M> res(lhs); return res -= rhs; } template <class T, int M> MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) { MInt<T, M> res(lhs); return res += rhs; } template <class T, int M> MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) { MInt<T, M> res(lhs); return res *= rhs; } template <class T, int M> MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) { MInt<T, M> res(lhs); return res /= rhs; } template <class T, int M> MInt<T, M> Pow(const MInt<T, M> &base, T exp) { if (exp == 0) { return 1; } auto a = Pow(base, exp / 2); a *= a; if (exp % 2 == 1) { a *= base; } return a; } template <class T, int M> MInt<T, M> Inv(const MInt<T, M> &n) { return Pow(n, static_cast<T>(M - 2)); } } // namespace mod const int md = 1e9 + 7; using MInt = mod::MInt<long long, md>; int main(int argc, const char *argv[]) { int n, k; cin >> n >> k; vector<int> va(n); for (int i = 0; i < n; i++) { cin >> va[i]; } vector<MInt> cnts(n, 0), cnts_all(n, 0); for (int i = 0; i < va.size(); i++) { for (int j = 0; j < va.size(); j++) { if (va[i] > va[j]) { cnts_all[i] += 1; if (j >= i) { cnts[i] += 1; } } } } MInt mk(k); MInt sum_cnts = accumulate(cnts.begin(), cnts.end(), MInt(0), plus<MInt>()), sum_cnts_all = accumulate(cnts_all.begin(), cnts_all.end(), MInt(0), plus<MInt>()); MInt ans = (mk * sum_cnts) + (sum_cnts_all * (mk * (mk - MInt(1))) / MInt(2)); cout << ans.Get() << '\n'; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "identifier.change", "call.arguments.change" ]
730,930
730,931
u289545075
cpp
p02928
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = (ll)(1e9 + 7); int main() { ll n; ll k; cin >> n >> k; vector<ll> a(n); ll sum = 0, sum2 = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 1; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] > a[j]) sum++; } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) sum2++; } } ll cnt = 0; ll cntkmin1 = (k * (k - 1) / 2) % MOD; ll cntkmin2 = k % MOD; cnt = (sum2 * k % MOD + sum * cntkmin1 % MOD); cout << cnt % MOD << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = (ll)(1e9 + 7); int main() { ll n; ll k; cin >> n >> k; vector<ll> a(n); ll sum = 0, sum2 = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] > a[j]) sum++; } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) sum2++; } } ll cnt = 0; ll cntkmin1 = (k * (k - 1) / 2) % MOD; ll cntkmin2 = k % MOD; cnt = (sum2 * k % MOD + sum * cntkmin1 % MOD); cout << cnt % MOD << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
730,932
730,933
u962609087
cpp
p02928
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = (ll)(1e9 + 7); int main() { int n; ll k; cin >> n >> k; vector<ll> a(n); ll sum = 0, sum2 = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 1; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] > a[j]) sum++; } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) sum2++; } } ll cnt = 0; ll cntkmin1 = (k * (k - 1) / 2) % MOD; ll cntkmin2 = k % MOD; cnt = (sum2 * k % MOD + sum * cntkmin1 % MOD); cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = (ll)(1e9 + 7); int main() { ll n; ll k; cin >> n >> k; vector<ll> a(n); ll sum = 0, sum2 = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] > a[j]) sum++; } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) sum2++; } } ll cnt = 0; ll cntkmin1 = (k * (k - 1) / 2) % MOD; ll cntkmin2 = k % MOD; cnt = (sum2 * k % MOD + sum * cntkmin1 % MOD); cout << cnt % MOD << endl; }
[ "variable_declaration.type.change", "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
730,934
730,933
u962609087
cpp
p02928
#include "bits/stdc++.h" #define REP(i, num) for (int i = 0; i < (num); ++i) #define LOOP(i) while (i--) #define ALL(c) c.begin(), c.end() #define PRINTALL(c) \ for (auto pitr = c.begin(); pitr != c.end(); ++pitr) { \ cout << *pitr; \ if (next(pitr, 1) != c.end()) \ cout << ' '; \ } \ cout << endl; #define PAIRCOMP(c, comp) \ [](const pair<ll, ll> &lhs, const pair<ll, ll> &rhs) { \ return lhs.c comp rhs.c; \ } using namespace std; using ll = long long; constexpr ll atcoder_mod = 1e9 + 7; template <typename T = int> T in() { T x; cin >> x; return (x); } template <typename T = int, typename C = vector<T>> C vecin(int N) { C x(N); REP(i, N) { x[i] = in<T>(); } return move(x); } void vout() { cout << endl; } template <typename Head, typename... Tail> void vout(Head &&h, Tail &&...t) { cout << ' ' << h; vout(forward<Tail>(t)...); } void out() { cout << endl; } template <typename Head, typename... Tail> void out(Head &&h, Tail &&...t) { cout << h; vout(forward<Tail>(t)...); } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); ll N = in(), K = in(); auto A = vecin(N); vector<ll> PS(N, 0), NS(N, 0); REP(i, N) { REP(j, N) { if (A[i] > A[j]) { if (i > j) { PS[i]++; } else NS[i]++; } } } ll S = 0; ll PST = K, NST = K; if (K % 2) { NST *= (K + 1LL) / 2LL; NST %= atcoder_mod; PST *= (K - 1LL) / 2LL; PST %= atcoder_mod; } else { NST /= 2LL; NST *= K + 1LL; NST %= atcoder_mod; PST /= 2LL; PST *= K = 1LL; PST %= atcoder_mod; } REP(i, N) { S += (NS[i] * NST) % atcoder_mod; S %= atcoder_mod; S += (PS[i] * PST) % atcoder_mod; S %= atcoder_mod; } out(S); return 0; }
#include "bits/stdc++.h" #define REP(i, num) for (int i = 0; i < (num); ++i) #define LOOP(i) while (i--) #define ALL(c) c.begin(), c.end() #define PRINTALL(c) \ for (auto pitr = c.begin(); pitr != c.end(); ++pitr) { \ cout << *pitr; \ if (next(pitr, 1) != c.end()) \ cout << ' '; \ } \ cout << endl; #define PAIRCOMP(c, comp) \ [](const pair<ll, ll> &lhs, const pair<ll, ll> &rhs) { \ return lhs.c comp rhs.c; \ } using namespace std; using ll = long long; constexpr ll atcoder_mod = 1e9 + 7; template <typename T = int> T in() { T x; cin >> x; return (x); } template <typename T = int, typename C = vector<T>> C vecin(int N) { C x(N); REP(i, N) { x[i] = in<T>(); } return move(x); } void vout() { cout << endl; } template <typename Head, typename... Tail> void vout(Head &&h, Tail &&...t) { cout << ' ' << h; vout(forward<Tail>(t)...); } void out() { cout << endl; } template <typename Head, typename... Tail> void out(Head &&h, Tail &&...t) { cout << h; vout(forward<Tail>(t)...); } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); ll N = in(), K = in(); auto A = vecin(N); vector<ll> PS(N, 0), NS(N, 0); REP(i, N) { REP(j, N) { if (A[i] > A[j]) { if (i > j) { PS[i]++; } else NS[i]++; } } } ll S = 0; ll PST = K, NST = K; if (K % 2) { NST *= (K + 1LL) / 2LL; NST %= atcoder_mod; PST *= (K - 1LL) / 2LL; PST %= atcoder_mod; } else { NST /= 2LL; NST *= K + 1LL; NST %= atcoder_mod; PST /= 2LL; PST *= K - 1LL; PST %= atcoder_mod; } REP(i, N) { S += (NS[i] * NST) % atcoder_mod; S %= atcoder_mod; S += (PS[i] * PST) % atcoder_mod; S %= atcoder_mod; } out(S); return 0; }
[ "assignment.value.change" ]
730,938
730,939
u135248164
cpp
p02928
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define ll long long void file() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } const int P = 1e9 + 7; ll modInv(ll a, ll b) { return 1 < a ? b - modInv(b % a, a) * b / a : 1; } ll modDivide(ll a, ll b) { a %= P; ll inv = modInv(b, P); return (inv * a) % P; } int main(int argc, char const *argv[]) { file(); ll n, k; cin >> n >> k; ll A[2002]; for (int i = 0; i < n; ++i) { cin >> A[i]; } ll self_inv = 0; for (int i = 0; i < n - 1; ++i) { for (int j = i + 1; j < n; ++j) { self_inv += A[i] > A[j]; } } ll type1_inv = (self_inv % P * k % P) % P; // self inverse * number of copies ll cp_inv = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cp_inv += A[i] > A[j]; } } ll pairs_cnt = modDivide( k % P * (k - 1) % P, 2); // number of ways to choose pair (k * (k - 1)) / 2 but with modInverse ll type2_inv = (pairs_cnt % P * cp_inv % P) % P; // inverse_between_pair * number_of_pairs cout << (type1_inv % P + type2_inv % P) % P; }
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define ll long long void file() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } const int P = 1e9 + 7; ll modInv(ll a, ll b) { return 1 < a ? b - modInv(b % a, a) * b / a : 1; } ll modDivide(ll a, ll b) { a %= P; ll inv = modInv(b, P); return (inv * a) % P; } int main(int argc, char const *argv[]) { // file(); ll n, k; cin >> n >> k; ll A[2002]; for (int i = 0; i < n; ++i) { cin >> A[i]; } ll self_inv = 0; for (int i = 0; i < n - 1; ++i) { for (int j = i + 1; j < n; ++j) { self_inv += A[i] > A[j]; } } ll type1_inv = (self_inv % P * k % P) % P; // self inverse * number of copies ll cp_inv = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cp_inv += A[i] > A[j]; } } // https://www.geeksforgeeks.org/modular-division/ ll pairs_cnt = modDivide( k % P * (k - 1) % P, 2); // number of ways to choose pair (k * (k - 1)) / 2 but with modInverse ll type2_inv = (pairs_cnt % P * cp_inv % P) % P; // inverse_between_pair * number_of_pairs cout << (type1_inv % P + type2_inv % P) % P; }
[ "call.remove" ]
730,948
730,949
u555865264
cpp
p02928
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define ll long long void file() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } const int P = 1e9 + 7; ll modInv(ll a, ll b) { return 1 < a ? b - modInv(b % a, a) * b / a : 1; } ll modDivide(ll a, ll b) { a %= P; ll inv = modInv(b, P); return (inv * a) % P; } int main(int argc, char const *argv[]) { file(); ll n, k; cin >> n >> k; ll A[2002]; for (int i = 0; i < n; ++i) { cin >> A[i]; } ll self_inv = 0; for (int i = 0; i < n - 1; ++i) { for (int j = i + 1; j < n; ++j) { self_inv += A[i] > A[j]; } } ll type1_inv = (self_inv % P * k % P) % P; // self inverse * number of copies ll cp_inv = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cp_inv += A[i] > A[j]; } } ll pairs_cnt = modDivide( k % P * (k - 1) % P, 2); // number of ways to choose pair (k * (k - 1)) / 2 but with modInverse ll type2_inv = (pairs_cnt % P * cp_inv % P) % P; // inverse_between_pair * number_of_pairs cout << (type1_inv % P + type2_inv % P) % P; }
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define ll long long void file() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } const int P = 1e9 + 7; ll modInv(ll a, ll b) { return 1 < a ? b - modInv(b % a, a) * b / a : 1; } ll modDivide(ll a, ll b) { a %= P; ll inv = modInv(b, P); return (inv * a) % P; } int main(int argc, char const *argv[]) { // file(); ll n, k; cin >> n >> k; ll A[2002]; for (int i = 0; i < n; ++i) { cin >> A[i]; } ll self_inv = 0; for (int i = 0; i < n - 1; ++i) { for (int j = i + 1; j < n; ++j) { self_inv += A[i] > A[j]; } } ll type1_inv = (self_inv % P * k % P) % P; // self inverse * number of copies ll cp_inv = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cp_inv += A[i] > A[j]; } } ll pairs_cnt = modDivide( k % P * (k - 1) % P, 2); // number of ways to choose pair (k * (k - 1)) / 2 but with modInverse ll type2_inv = (pairs_cnt % P * cp_inv % P) % P; // inverse_between_pair * number_of_pairs cout << (type1_inv % P + type2_inv % P) % P; }
[ "call.remove" ]
730,948
730,950
u555865264
cpp
p02928
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) using namespace std; using Graph = vector<vector<int>>; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1 << 30) - 1) #define LINF (1LL << 60) #define EPS (1e-10) typedef long long ll; typedef pair<ll, ll> P; 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; } int main() { ll n, k; cin >> n >> k; ll a[n]; rep(i, n) cin >> a[i]; ll in = 0, out = 0; rep(i, n) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) { in++; } } rep(k, n) if (a[i] > a[k]) { out++; } } cout << ((in * k) % MOD + (out * ((k * (k - 1)) % MOD) * modinv(2, MOD)) % MOD) % MOD << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) using namespace std; using Graph = vector<vector<int>>; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1 << 30) - 1) #define LINF (1LL << 60) #define EPS (1e-10) typedef long long ll; typedef pair<ll, ll> P; 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; } int main() { ll n, k; cin >> n >> k; ll a[n]; rep(i, n) cin >> a[i]; ll in = 0, out = 0; rep(i, n) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) { in++; } } rep(k, n) if (a[i] > a[k]) { out++; } } cout << ((in * k) % MOD + ((out * ((k * (k - 1)) % MOD)) % MOD * modinv(2, MOD)) % MOD) % MOD << endl; return 0; }
[ "expression.operation.binary.add" ]
730,951
730,952
u501163846
cpp
p02928
#include <bits/stdc++.h> using namespace std; typedef signed long long lint; mt19937 mt(time(nullptr)); // uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive int main(void) { cin.tie(0); ios::sync_with_stdio(false); cout << fixed; lint n, k; cin >> n >> k; vector<lint> a(n); for (lint i = 0; i < n; ++i) cin >> a[i]; lint ans = 0, mod = 1e9 + 7; for (lint i = 0; i < n; ++i) { lint h = 0; for (lint j = 0; j < n; ++j) { if (a[i] > a[j]) h++; } lint s = 0; for (lint j = i + 1; j < n; ++j) { if (a[i] > a[j]) s++; } ans += k * (k - 1) % mod / 2 * h % mod; ans %= mod; ans += k * s % mod; ans %= mod; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef signed long long lint; mt19937 mt(time(nullptr)); // uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive int main(void) { cin.tie(0); ios::sync_with_stdio(false); cout << fixed; lint n, k; cin >> n >> k; vector<lint> a(n); for (lint i = 0; i < n; ++i) cin >> a[i]; lint ans = 0, mod = 1e9 + 7; for (lint i = 0; i < n; ++i) { lint h = 0; for (lint j = 0; j < n; ++j) { if (a[i] > a[j]) h++; } lint s = 0; for (lint j = i + 1; j < n; ++j) { if (a[i] > a[j]) s++; } ans += k * (k - 1) / 2 % mod * h % mod; ans %= mod; ans += k * s % mod; ans %= mod; } cout << ans << endl; return 0; }
[ "expression.operation.binary.remove", "assignment.change" ]
730,953
730,954
u691764803
cpp
p02928
#include <bits/stdc++.h> using namespace std; typedef signed long long lint; mt19937 mt(time(nullptr)); // uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive int main(void) { cin.tie(0); ios::sync_with_stdio(false); cout << fixed; lint n, k; cin >> n >> k; vector<lint> a(n); for (lint i = 0; i < n; ++i) cin >> a[i]; lint ans = 0, mod = 1e9 + 7; for (lint i = 0; i < n; ++i) { lint h = 0; for (lint j = 0; j < n; ++j) { if (a[i] < a[j]) h++; } lint s = 0; for (lint j = i + 1; j < n; ++j) { if (a[i] > a[j]) s++; } ans += k * (k - 1) / 2 * h % mod; ans %= mod; ans += k * s % mod; ans %= mod; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef signed long long lint; mt19937 mt(time(nullptr)); // uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive int main(void) { cin.tie(0); ios::sync_with_stdio(false); cout << fixed; lint n, k; cin >> n >> k; vector<lint> a(n); for (lint i = 0; i < n; ++i) cin >> a[i]; lint ans = 0, mod = 1e9 + 7; for (lint i = 0; i < n; ++i) { lint h = 0; for (lint j = 0; j < n; ++j) { if (a[i] > a[j]) h++; } lint s = 0; for (lint j = i + 1; j < n; ++j) { if (a[i] > a[j]) s++; } ans += k * (k - 1) / 2 % mod * h % mod; ans %= mod; ans += k * s % mod; ans %= mod; } cout << ans << endl; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.change" ]
730,955
730,954
u691764803
cpp
p02928
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> // output #define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' '); #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl // utility #define ALL(i) (i).begin(), (i).end() #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i) #define IN(a, x, b) (a <= x && x < b) #define OUT(a, x, b) (x < a || b <= x) template <class T> inline T chmax(T &a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T chmin(T &a, const T b) { return a = (a > b) ? b : a; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; const int MOD = 1000000007; /* const int MOD = 998244353; */ const int INF = 1e18; const double PI = acos(-1); using namespace std; struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } INIT; signed main() { int N, K; cin >> N >> K; vector<int> A(N); REP(i, N) cin >> A[i]; int ans = 0; REP(i, N) { int cnt1 = 0, cnt2 = 0; REP(j, N) { if (A[i] > A[j]) { if (i < j) cnt1++; else cnt2++; } } (ans += cnt1 * (K * (K + 1) / 2) % MOD) %= MOD; (ans += cnt2 * (K * (K - 1) / 2) % MOD) %= MOD; } cout << ans % MOD << "\n"; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> // output #define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' '); #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl // utility #define ALL(i) (i).begin(), (i).end() #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i) #define IN(a, x, b) (a <= x && x < b) #define OUT(a, x, b) (x < a || b <= x) template <class T> inline T chmax(T &a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T chmin(T &a, const T b) { return a = (a > b) ? b : a; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; const int MOD = 1000000007; /* const int MOD = 998244353; */ const int INF = 1e18; const double PI = acos(-1); using namespace std; struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } INIT; signed main() { int N, K; cin >> N >> K; vector<int> A(N); REP(i, N) cin >> A[i]; int ans = 0; REP(i, N) { int cnt1 = 0, cnt2 = 0; REP(j, N) { if (A[i] > A[j]) { if (i < j) cnt1++; else cnt2++; } } (ans += cnt1 * ((K * (K + 1) / 2) % MOD)) %= MOD; (ans += cnt2 * ((K * (K - 1) / 2) % MOD)) %= MOD; } cout << ans % MOD << "\n"; return 0; }
[]
730,965
730,966
u812973725
cpp
p02928
#include <bits/stdc++.h> #define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++) #define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++) #define RREP(i, n) for (int(i) = ((int)(n)-1); (i) >= 0; i--) #define RFOR(i, a, b) for (int(i) = ((int)(b)-1); (i) >= (int)a; i--) #define ALL(v) (v).begin(), (v).end() #define MOD 1000000007 #define FI first #define SE second #define MP make_pair #define PB push_back #define SZ(x) (int)x.size() #define SP(x) setprecision((int)x) using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<vint> vvint; typedef vector<string> vstr; typedef pair<int, int> pii; const int INF = 1e9; const ll LINF = 1e18; const double EPS = 1e-9; 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() { ll n, k; cin >> n >> k; ll cnt1 = 0; ll cnt2 = 0; ll mod = 1000000007; ll ans; vector<int> vec(n); REP(i, n) { cin >> vec.at(i); } REP(i, n - 1) { FOR(j, i + 1, n) { if (vec.at(i) > vec.at(j)) { cnt1++; } } } for (int i = n - 1; i >= 1; i--) { for (int j = i - 1; j >= 0; j--) { if (vec.at(i) > vec.at(j)) { cnt2++; } } } ans = (k * (k + 1) % mod / 2 % mod * cnt1 % mod + k * (k - 1) % mod / 2 % mod * cnt2 % mod) % mod; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++) #define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++) #define RREP(i, n) for (int(i) = ((int)(n)-1); (i) >= 0; i--) #define RFOR(i, a, b) for (int(i) = ((int)(b)-1); (i) >= (int)a; i--) #define ALL(v) (v).begin(), (v).end() #define MOD 1000000007 #define FI first #define SE second #define MP make_pair #define PB push_back #define SZ(x) (int)x.size() #define SP(x) setprecision((int)x) using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<vint> vvint; typedef vector<string> vstr; typedef pair<int, int> pii; const int INF = 1e9; const ll LINF = 1e18; const double EPS = 1e-9; 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() { ll n, k; cin >> n >> k; ll cnt1 = 0; ll cnt2 = 0; ll mod = 1000000007; ll ans; vector<int> vec(n); REP(i, n) { cin >> vec.at(i); } REP(i, n - 1) { FOR(j, i + 1, n) { if (vec.at(i) > vec.at(j)) { cnt1++; } } } for (int i = n - 1; i >= 1; i--) { for (int j = i - 1; j >= 0; j--) { if (vec.at(i) > vec.at(j)) { cnt2++; } } } ans = (k * (k + 1) / 2 % mod * cnt1 % mod + k * (k - 1) / 2 % mod * cnt2 % mod) % mod; cout << ans << endl; return 0; }
[ "expression.operation.binary.remove" ]
730,967
730,968
u852449189
cpp
p02928
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) using namespace std; typedef long long ll; const static ll MOD = (1e+9) + 7; ll modcross(ll a, ll k) { if (k == 0) return 0; if (k % 2 == 1) return (a + modcross(a, k - 1)) % MOD; ll t = modcross(a, k / 2) % MOD; return (t * 2) % MOD; } int main() { int n, k; cin >> n >> k; vector<int> A(n, 0); rep(i, n) cin >> A[i]; ll ans = 0; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (A[i] > A[j]) ans += (k * (k + 1)) / 2 % MOD; if (A[i] < A[j]) ans += (k * (k - 1)) / 2 % MOD; ans %= MOD; } } cout << ans % MOD << endl; return 0; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (ll i = 0; i < (n); i++) #define rep1(i, n) for (ll i = 1; i <= (n); i++) using namespace std; typedef long long ll; const static ll MOD = (1e+9) + 7; ll modcross(ll a, ll k) { if (k == 0) return 0; if (k % 2 == 1) return (a + modcross(a, k - 1)) % MOD; ll t = modcross(a, k / 2) % MOD; return (t * 2) % MOD; } int main() { ll n, k; cin >> n >> k; vector<ll> A(n, 0); rep(i, n) cin >> A[i]; ll ans = 0; for (ll i = 0; i < n - 1; i++) { for (ll j = i + 1; j < n; j++) { if (A[i] > A[j]) ans += (k * (k + 1)) / 2 % MOD; if (A[i] < A[j]) ans += (k * (k - 1)) / 2 % MOD; ans %= MOD; } } cout << ans % MOD << endl; return 0; }
[ "preprocessor.define.value.change", "variable_declaration.type.change", "control_flow.loop.for.initializer.change" ]
730,969
730,970
u480887263
cpp
p02928
#include <bits/stdc++.h> using namespace std; #define lli long long #define all(i) i.begin(), i.end() #define rall(i) i.rbegin(), i.rend() #define rep0(i, j) for (int i = 0; i < j; i++) #define rep1(i, j) for (int i = 1; i <= j; i++) #define rep0d(i, j) for (int i = j - 1; i >= 0; i--) #define MOD 1000000007 #define INF (int)1e7 class Graph { typedef pair<int, int> p; int V; list<p> *adj; public: Graph(int V) { this->V = V; adj = new list<p>[V]; } void addEdge(int u, int v, int w) { adj[u].push_back(make_pair(v, w)); } bool route(lli from, lli to) { // vec[i]==j: j->iっていうもとに戻れる道がある vector<lli> vec(V, -1); dfs(1, from, vec); return vec[to] >= 0; } void dfs(lli ed, lli num, vector<lli> &vec) { for (auto e : adj[num]) { if (vec[e.first] != -1) continue; vec[e.first] = num; dfs(ed + 1, e.first, vec); } } vector<int> bfs(int n) { queue<int> q; vector<int> vec(V, -1); q.push(n); vec[n] = 0; while (!q.empty()) { int p = q.front(); q.pop(); for (auto e : adj[p]) { if (vec[e.first] == -1) { q.push(e.first); vec[e.first] = e.second + vec[p]; } } } return vec; } vector<int> shortestPath(int src) { priority_queue<p, vector<p>, greater<p>> pq; vector<int> dist(V, INF); pq.push(make_pair(0, src)); dist[src] = 0; while (!pq.empty()) { int u = pq.top().second; pq.pop(); list<pair<int, int>>::iterator i; for (i = adj[u].begin(); i != adj[u].end(); ++i) { int v = (*i).first; int weight = (*i).second; if (dist[v] > dist[u] + weight) { dist[v] = dist[u] + weight; pq.push(make_pair(dist[v], v)); } } } for (int i = 0; i < V; i++) if (dist[i] == INF) dist[i] = -1; return dist; } }; bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) { return left.first < right.first; } bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) { return left.second < right.second; } void dfs(lli ed, lli num, vector<map<lli, lli>> &vec) { lli n = 1; for (auto e : vec[num]) { if (n == ed) n++; if (e.second != -1) continue; vec[num][e.first] = n; vec[e.first][num] = n; dfs(n, e.first, vec); n++; } } lli gcd(lli a, lli b) { if (a < b) return gcd(b, a); lli temp; while ((temp = a % b)) { a = b; b = temp; } return b; } struct nCr { vector<lli> f, rf; lli count = 0; nCr(lli num) : f(num), rf(num) { count = num; f[0] = 1; rep1(i, num) f[i] = (f[i - 1] * i) % MOD; rep0(i, num + 1) rf[i] = inv(f[i]); } lli inv(lli x) { lli res = 1; lli k = MOD - 2; lli y = x; while (k) { if (k & 1) res = (res * y) % MOD; y = (y * y) % MOD; k /= 2; } return res; } lli C(lli n, lli k) { lli a = f[n]; lli b = rf[n - k]; lli c = rf[k]; lli bc = (b * c) % MOD; return (a * bc) % MOD; } }; struct UF { vector<int> par, size; UF(int N) : par(N), size(N, 1) { rep0(i, N) par[i] = i; } int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; par[rx] = ry; size[rx] += size[ry]; } bool same(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } int getSize(int x) { return size[x]; } }; int main() { lli n, k; cin >> n >> k; vector<lli> vec(n), arr(3 * n); rep0(i, n) cin >> vec[i]; map<lli, lli> mp; rep0(i, n) { lli e = vec[i], num = 0; auto fin = mp.lower_bound(e); for (auto itr = mp.begin(); itr != fin; ++itr) num += itr->second; if (fin != mp.end() && fin->first <= e) num += fin->second; arr[i] = num; mp[e]++; } rep0(i, n) { lli e = vec[i], num = 0; auto fin = mp.lower_bound(e); for (auto itr = mp.begin(); itr != fin; ++itr) num += itr->second; if (fin != mp.end() && fin->first <= e) num += fin->second; arr[n + i] = num; mp[e]++; } // rep0(i,n){ // lli e=vec[i], num=0; // auto fin=mp.lower_bound(e); // for(auto itr=mp.begin(); itr!=fin; ++itr) num+=itr->second; // if(fin != mp.end() && fin->first <= e)num+=fin->second; // arr[2*n+i]=num; // mp[e]++; // } // rep0(i,n*3)cout << i-arr[i] << ' '; // cout << endl; lli ans = 0; // for(auto e:mp)cout << e.first << ' ' << e.second << endl; rep0(i, n) { ans += (i - arr[i]) * k % MOD + ((n + i - arr[n + i] - (i - arr[i])) * k * (k - 1) / 2) % MOD; // ans= (ans + i-arr[i])%MOD; // lli temp=0; // for(auto e=mp.begin(); e->first < vec[i]; e++){ // temp+=e->second; //} // ans=(ans + temp*k*(k-1)/2 )%MOD; // cout <<(i-arr[i])*k % MOD << ' ' << ((n+i-arr[n+i] - // (i-arr[i]))*k*(k-1)/2) %MOD << endl; } cout << ans % MOD; }
#include <bits/stdc++.h> using namespace std; #define lli long long #define all(i) i.begin(), i.end() #define rall(i) i.rbegin(), i.rend() #define rep0(i, j) for (int i = 0; i < j; i++) #define rep1(i, j) for (int i = 1; i <= j; i++) #define rep0d(i, j) for (int i = j - 1; i >= 0; i--) #define MOD 1000000007 #define INF (int)1e7 class Graph { typedef pair<int, int> p; int V; list<p> *adj; public: Graph(int V) { this->V = V; adj = new list<p>[V]; } void addEdge(int u, int v, int w) { adj[u].push_back(make_pair(v, w)); } bool route(lli from, lli to) { // vec[i]==j: j->iっていうもとに戻れる道がある vector<lli> vec(V, -1); dfs(1, from, vec); return vec[to] >= 0; } void dfs(lli ed, lli num, vector<lli> &vec) { for (auto e : adj[num]) { if (vec[e.first] != -1) continue; vec[e.first] = num; dfs(ed + 1, e.first, vec); } } vector<int> bfs(int n) { queue<int> q; vector<int> vec(V, -1); q.push(n); vec[n] = 0; while (!q.empty()) { int p = q.front(); q.pop(); for (auto e : adj[p]) { if (vec[e.first] == -1) { q.push(e.first); vec[e.first] = e.second + vec[p]; } } } return vec; } vector<int> shortestPath(int src) { priority_queue<p, vector<p>, greater<p>> pq; vector<int> dist(V, INF); pq.push(make_pair(0, src)); dist[src] = 0; while (!pq.empty()) { int u = pq.top().second; pq.pop(); list<pair<int, int>>::iterator i; for (i = adj[u].begin(); i != adj[u].end(); ++i) { int v = (*i).first; int weight = (*i).second; if (dist[v] > dist[u] + weight) { dist[v] = dist[u] + weight; pq.push(make_pair(dist[v], v)); } } } for (int i = 0; i < V; i++) if (dist[i] == INF) dist[i] = -1; return dist; } }; bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) { return left.first < right.first; } bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) { return left.second < right.second; } void dfs(lli ed, lli num, vector<map<lli, lli>> &vec) { lli n = 1; for (auto e : vec[num]) { if (n == ed) n++; if (e.second != -1) continue; vec[num][e.first] = n; vec[e.first][num] = n; dfs(n, e.first, vec); n++; } } lli gcd(lli a, lli b) { if (a < b) return gcd(b, a); lli temp; while ((temp = a % b)) { a = b; b = temp; } return b; } struct nCr { vector<lli> f, rf; lli count = 0; nCr(lli num) : f(num), rf(num) { count = num; f[0] = 1; rep1(i, num) f[i] = (f[i - 1] * i) % MOD; rep0(i, num + 1) rf[i] = inv(f[i]); } lli inv(lli x) { lli res = 1; lli k = MOD - 2; lli y = x; while (k) { if (k & 1) res = (res * y) % MOD; y = (y * y) % MOD; k /= 2; } return res; } lli C(lli n, lli k) { lli a = f[n]; lli b = rf[n - k]; lli c = rf[k]; lli bc = (b * c) % MOD; return (a * bc) % MOD; } }; struct UF { vector<int> par, size; UF(int N) : par(N), size(N, 1) { rep0(i, N) par[i] = i; } int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; par[rx] = ry; size[rx] += size[ry]; } bool same(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } int getSize(int x) { return size[x]; } }; int main() { lli n, k; cin >> n >> k; vector<lli> vec(n), arr(3 * n); rep0(i, n) cin >> vec[i]; map<lli, lli> mp; rep0(i, n) { lli e = vec[i], num = 0; auto fin = mp.lower_bound(e); for (auto itr = mp.begin(); itr != fin; ++itr) num += itr->second; if (fin != mp.end() && fin->first <= e) num += fin->second; arr[i] = num; mp[e]++; } rep0(i, n) { lli e = vec[i], num = 0; auto fin = mp.lower_bound(e); for (auto itr = mp.begin(); itr != fin; ++itr) num += itr->second; if (fin != mp.end() && fin->first <= e) num += fin->second; arr[n + i] = num; mp[e]++; } // rep0(i,n){ // lli e=vec[i], num=0; // auto fin=mp.lower_bound(e); // for(auto itr=mp.begin(); itr!=fin; ++itr) num+=itr->second; // if(fin != mp.end() && fin->first <= e)num+=fin->second; // arr[2*n+i]=num; // mp[e]++; // } // rep0(i,n*3)cout << i-arr[i] << ' '; // cout << endl; lli ans = 0; // for(auto e:mp)cout << e.first << ' ' << e.second << endl; rep0(i, n) { ans += (i - arr[i]) * k % MOD + ((n + i - arr[n + i] - (i - arr[i])) * (k * (k - 1) / 2 % MOD)) % MOD; // cout <<(i-arr[i])*k % MOD << ' ' << ((n+i-arr[n+i] - // (i-arr[i]))*k*(k-1)/2) %MOD << endl; } cout << ans % MOD; }
[]
730,975
730,976
u950603962
cpp
p02928
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define oset \ tree<long long, null_type, less<long long>, rb_tree_tag, \ tree_order_statistics_node_update> using ll = long long; ll mod = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int t; t = 1; while (t--) { ll n, k, i; cin >> n >> k; oset s, s2; ll a[n + 2]; for (i = 0; i < n; i++) { cin >> a[i]; s2.insert(a[i]); } ll bigonR[n + 2], bigger[n + 2]; for (i = 0; i < n; i++) { bigger[i] = s2.order_of_key(a[i]); } for (i = n - 1; i >= 0; i--) { bigonR[i] = s.order_of_key(a[i]); s.insert(a[i]); } ll sum = 0; for (i = 0; i < n; i++) { ll kk = (k * (k - 1)) / 2; kk %= mod; sum += ((bigger[i] * kk) % mod); sum %= mod; sum += ((bigonR[i] * k) % mod); sum %= mod; } cout << sum % mod; cout << "\n"; } }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define oset \ tree<long long, null_type, less_equal<long long>, rb_tree_tag, \ tree_order_statistics_node_update> using ll = long long; ll mod = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int t; t = 1; while (t--) { ll n, k, i; cin >> n >> k; oset s, s2; ll a[n + 2]; for (i = 0; i < n; i++) { cin >> a[i]; s2.insert(a[i]); } ll bigonR[n + 2], bigger[n + 2]; for (i = 0; i < n; i++) { bigger[i] = s2.order_of_key(a[i]); } for (i = n - 1; i >= 0; i--) { bigonR[i] = s.order_of_key(a[i]); s.insert(a[i]); } ll sum = 0; for (i = 0; i < n; i++) { // cout << bigger[i] << ' ' << bigonR[i] << "\n"; ll kk = (k * (k - 1)) / 2; kk %= mod; sum += ((bigger[i] * kk) % mod); sum %= mod; sum += ((bigonR[i] * k) % mod); sum %= mod; } cout << sum; cout << "\n"; } }
[ "preprocessor.define.value.change", "expression.operation.binary.remove" ]
730,977
730,978
u900937596
cpp
p02928
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int main() { int N, K; int A[2000]; scanf("%d %d", &N, &K); for (int i = 0; i < N; i++) scanf("%d", A + i); long long ans = 0; int tmp = 0; for (int i = 0; i < N - 1; i++) { for (int j = 0; j < N - i - 1; j++) { if (A[j] > A[j + 1]) { swap(A[j], A[j + 1]); tmp++; } } } ans = (long long)tmp * K % MOD; int cnt = 0; long long coef = ((long long)K * (K - 1) / 2) % MOD; for (int i = 1; i < N; i++) { if (A[i] != A[i - 1]) cnt++; ans = (ans + coef * cnt) % MOD; } printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int main() { int N, K; int A[2000]; scanf("%d %d", &N, &K); for (int i = 0; i < N; i++) scanf("%d", A + i); long long ans = 0; int tmp = 0; for (int i = 0; i < N - 1; i++) { for (int j = 0; j < N - i - 1; j++) { if (A[j] > A[j + 1]) { swap(A[j], A[j + 1]); tmp++; } } } ans = (long long)tmp * K % MOD; int cnt = 0; long long coef = ((long long)K * (K - 1) / 2) % MOD; for (int i = 1; i < N; i++) { if (A[i] != A[i - 1]) cnt = i; ans = (ans + coef * cnt) % MOD; } printf("%lld\n", ans); return 0; }
[]
730,979
730,980
u821180083
cpp
p02928
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; const int mod = 1000000007; int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } ll res = 0; if (k == 1) { for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (a[i] > a[j]) ++res; } } cout << res << endl; return 0; } ll res1 = 0, res2 = 0; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (a[i] > a[j]) { ++res1; } } } ll mul = 1; if (k % 2 == 0) { mul = (ll)(k / 2 * (k + 1)) % mod; } else { mul = (ll)((k + 1) / 2 * k) % mod; } res1 = (res1 * mul) % mod; for (int i = 0; i < n; ++i) { for (int j = 0; j < i; ++j) { if (a[i] > a[j]) ++res2; } } if (k % 2 == 0) { mul = (ll)(k / 2 * (k - 1)) % mod; } else { mul = (ll)((k - 1) / 2 * k) % mod; } res2 = (res2 * mul) % mod; res = (res1 + res2) % mod; cout << res << endl; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; const int mod = 1000000007; int main() { int n; ll k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } ll res = 0; if (k == 1) { for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (a[i] > a[j]) ++res; } } cout << res << endl; return 0; } ll res1 = 0, res2 = 0; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (a[i] > a[j]) { ++res1; } } } ll mul = 1; if (k % 2 == 0) { mul = (ll)(k / 2 * (k + 1)) % mod; } else { mul = (ll)((k + 1) / 2 * k) % mod; } res1 = (res1 * mul) % mod; for (int i = 0; i < n; ++i) { for (int j = 0; j < i; ++j) { if (a[i] > a[j]) ++res2; } } if (k % 2 == 0) { mul = (ll)(k / 2 * (k - 1)) % mod; } else { mul = (ll)((k - 1) / 2 * k) % mod; } res2 = (res2 * mul) % mod; res = (res1 + res2) % mod; cout << res << endl; }
[]
730,988
730,989
u190018920
cpp
p02928
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ll long long #define lld long double #define ALL(x) x.begin(), x.end() using namespace std; const ll MOD = 1000000000 + 7; ll mpow(ll base, ll n) { if (n == 0) return 1; ll prev = mpow(base, n / 2); if (n % 2 == 1) { return (prev * prev * base) % MOD; } else { return (prev * prev) % MOD; } } int main() { ll n, k; cin >> n >> k; vector<ll> v(n); rep(i, n) cin >> v[i]; vector<ll> num(n, 0); vector<ll> invnum(n, 0); vector<ll> smaller(n, 0); rep(i, n) rep(j, i + 1, n) { if (v[i] > v[j]) { num[i]++; invnum[j]++; } } rep(i, n) { rep(j, n) { if (v[i] > v[j]) { smaller[i]++; } } } ll ans = 0; rep(i, n) { // cerr << i << " " << num[i] << " " << smaller[i] << endl; ans += num[i] * k; ans %= MOD; ll tmp = smaller[i]; tmp *= ((k - 1) * k / 2) % MOD; tmp %= MOD; assert(tmp > 0); ans += tmp; ans %= MOD; assert(ans > 0); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ll long long #define lld long double #define ALL(x) x.begin(), x.end() using namespace std; const ll MOD = 1000000000 + 7; ll mpow(ll base, ll n) { if (n == 0) return 1; ll prev = mpow(base, n / 2); if (n % 2 == 1) { return (prev * prev * base) % MOD; } else { return (prev * prev) % MOD; } } int main() { ll n, k; cin >> n >> k; vector<ll> v(n); rep(i, n) cin >> v[i]; vector<ll> num(n, 0); vector<ll> invnum(n, 0); vector<ll> smaller(n, 0); rep(i, n) rep(j, i + 1, n) { if (v[i] > v[j]) { num[i]++; invnum[j]++; } } rep(i, n) { rep(j, n) { if (v[i] > v[j]) { smaller[i]++; } } } ll ans = 0; rep(i, n) { // cerr << i << " " << num[i] << " " << smaller[i] << endl; ans += num[i] * k; ans %= MOD; ll tmp = smaller[i]; tmp *= ((k - 1) * k / 2) % MOD; tmp %= MOD; assert(tmp >= 0); ans += tmp; ans %= MOD; assert(ans >= 0); } cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "call.arguments.change", "expression.operation.binary.change" ]
730,990
730,991
u174404613
cpp
p02928
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ll long long #define lld long double #define ALL(x) x.begin(), x.end() using namespace std; const ll MOD = 1000000000 + 7; ll mpow(ll base, ll n) { if (n == 0) return 1; ll prev = mpow(base, n / 2); if (n % 2 == 1) { return (prev * prev * base) % MOD; } else { return (prev * prev) % MOD; } } int main() { ll n, k; cin >> n >> k; vector<int> v(n); rep(i, n) cin >> v[i]; vector<int> num(n, 0); vector<int> invnum(n, 0); vector<int> smaller(n, 0); rep(i, n) rep(j, i + 1, n) { if (v[i] > v[j]) { num[i]++; invnum[j]++; } } rep(i, n) { rep(j, n) { if (v[i] > v[j]) { smaller[i]++; } } } ll ans = 0; rep(i, n) { // cerr << i << " " << num[i] << " " << smaller[i] << endl; ans += num[i] * k; ans %= MOD; ll tmp = smaller[i]; tmp *= ((k - 1) * k / 2) % MOD; tmp %= MOD; assert(tmp > 0); ans += tmp; ans %= MOD; assert(ans > 0); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ll long long #define lld long double #define ALL(x) x.begin(), x.end() using namespace std; const ll MOD = 1000000000 + 7; ll mpow(ll base, ll n) { if (n == 0) return 1; ll prev = mpow(base, n / 2); if (n % 2 == 1) { return (prev * prev * base) % MOD; } else { return (prev * prev) % MOD; } } int main() { ll n, k; cin >> n >> k; vector<ll> v(n); rep(i, n) cin >> v[i]; vector<ll> num(n, 0); vector<ll> invnum(n, 0); vector<ll> smaller(n, 0); rep(i, n) rep(j, i + 1, n) { if (v[i] > v[j]) { num[i]++; invnum[j]++; } } rep(i, n) { rep(j, n) { if (v[i] > v[j]) { smaller[i]++; } } } ll ans = 0; rep(i, n) { // cerr << i << " " << num[i] << " " << smaller[i] << endl; ans += num[i] * k; ans %= MOD; ll tmp = smaller[i]; tmp *= ((k - 1) * k / 2) % MOD; tmp %= MOD; assert(tmp >= 0); ans += tmp; ans %= MOD; assert(ans >= 0); } cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "call.arguments.change", "expression.operation.binary.change" ]
730,992
730,991
u174404613
cpp
p02928
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fst first #define snd second typedef pair<int, int> pii; const ll mod = 1e9 + 7; const ll N = 2001; ll a[N]; pii na[N]; ll k; ll n; ll res1 = 0, res2 = 0; int bs(int low, int high, int idx) { int ans = n; int target = na[idx].fst; while (low <= high) { int mid = (low + high) / 2; pii temp = na[mid]; if (temp.fst > target) { ans = mid; high = mid - 1; } else if (temp.fst <= target) { low = mid + 1; } } return ans; } int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; na[i] = {a[i], i}; } set<ll> s; for (int i = 0; i < n; i++) { s.insert(a[i]); auto it = upper_bound(s.begin(), s.end(), a[i]); if (it != s.end()) { ll val = distance(s.begin(), it); res1 += s.size() - val; } } sort(na, na + n); for (int i = 0; i < n; i++) { res2 += n - bs(0, n, i); } ll fans = ((((k * (k - 1)) / (ll)2) % mod * res2) % mod + (k * res1) % mod) % mod; cout << fans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fst first #define snd second typedef pair<int, int> pii; const ll mod = 1e9 + 7; const ll N = 2001; ll a[N]; pii na[N]; ll k; ll n; ll res1 = 0, res2 = 0; int bs(int low, int high, int idx) { int ans = n; int target = na[idx].fst; while (low <= high) { int mid = (low + high) / 2; pii temp = na[mid]; if (temp.fst > target) { ans = mid; high = mid - 1; } else if (temp.fst <= target) { low = mid + 1; } } return ans; } int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; na[i] = {a[i], i}; } multiset<ll> s; for (int i = 0; i < n; i++) { s.insert(a[i]); auto it = upper_bound(s.begin(), s.end(), a[i]); if (it != s.end()) { ll val = distance(s.begin(), it); res1 += s.size() - val; } } sort(na, na + n); for (int i = 0; i < n; i++) { res2 += n - bs(0, n, i); } ll fans = ((((k * (k - 1)) / (ll)2) % mod * res2) % mod + (k * res1) % mod) % mod; cout << fans << endl; return 0; }
[ "variable_declaration.type.change" ]
730,995
730,996
u738166971
cpp
p02928
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fst first #define snd second typedef pair<int, int> pii; const int mod = 1e9 + 7; const int N = 2001; ll a[N]; pii na[N]; ll k; ll n; ll res1 = 0, res2 = 0; int bs(int low, int high, int idx) { int ans = n; int target = na[idx].fst; while (low <= high) { int mid = (low + high) / 2; pii temp = na[mid]; if (temp.fst > target) { ans = mid; high = mid - 1; } else if (temp.fst <= target) { low = mid + 1; } } return ans; } int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; na[i] = {a[i], i}; } set<ll> s; for (int i = 0; i < n; i++) { s.insert(a[i]); auto it = upper_bound(s.begin(), s.end(), a[i]); if (it != s.end()) { ll val = distance(s.begin(), it); res1 += s.size() - val; } } sort(na, na + n); for (int i = 0; i < n; i++) { res2 += n - bs(0, n, i); } ll fans = ((((k * (k - 1)) / 2) % mod * res2) % mod + (k * res1) % mod) % mod; cout << fans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fst first #define snd second typedef pair<int, int> pii; const ll mod = 1e9 + 7; const ll N = 2001; ll a[N]; pii na[N]; ll k; ll n; ll res1 = 0, res2 = 0; int bs(int low, int high, int idx) { int ans = n; int target = na[idx].fst; while (low <= high) { int mid = (low + high) / 2; pii temp = na[mid]; if (temp.fst > target) { ans = mid; high = mid - 1; } else if (temp.fst <= target) { low = mid + 1; } } return ans; } int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; na[i] = {a[i], i}; } multiset<ll> s; for (int i = 0; i < n; i++) { s.insert(a[i]); auto it = upper_bound(s.begin(), s.end(), a[i]); if (it != s.end()) { ll val = distance(s.begin(), it); res1 += s.size() - val; } } sort(na, na + n); for (int i = 0; i < n; i++) { res2 += n - bs(0, n, i); } ll fans = ((((k * (k - 1)) / (ll)2) % mod * res2) % mod + (k * res1) % mod) % mod; cout << fans << endl; return 0; }
[ "variable_declaration.type.change" ]
730,997
730,996
u738166971
cpp
p02928
#include <bits/stdc++.h> using namespace std; int main() { int n; long long ans = 0, k, modk, mod = 1000000007; cin >> n >> k; vector<int> a(n), invs_my(n, 0), invs_other(n, 0); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) invs_my[i]++; } } for (int i = 0; i < n; i++) { for (int j = 1; j < n; j++) { if (a[i] > a[j]) invs_other[i]++; } } for (int i = 0; i < n; i++) { modk = ((k - 1) * k / 2) % mod; ans = (ans + modk * invs_other[i]) % mod; ans = (ans + k * invs_my[i]) % mod; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; long long ans = 0, k, modk, mod = 1000000007; cin >> n >> k; vector<int> a(n), invs_my(n, 0), invs_other(n, 0); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) invs_my[i]++; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] > a[j]) invs_other[i]++; } } for (int i = 0; i < n; i++) { modk = ((k - 1) * k / 2) % mod; ans = (ans + modk * invs_other[i]) % mod; ans = (ans + k * invs_my[i]) % mod; } cout << ans << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
731,007
731,008
u623759422
cpp
p02928
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, a, b) for (int i = a; i < (b); ++i) #define all(x) (x).begin(), (x).end() #define YY cout << "Yes" << endl; #define NN cout << "No" << endl; const int INF = 1000000007; typedef long long ll; using namespace std; using Graph = vector<vector<int>>; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } int solve() { int n, k; cin >> n >> k; vector<int> v(n); ll ans = 0; rep(i, n) cin >> v[i]; rep(i, n) REP(j, i + 1, n) { if (v[i] > v[j]) { ans += k * (k + 1) / 2; ans %= INF; } else if (v[i] < v[j]) { ans += k * (k - 1) / 2; ans %= INF; } } cout << ans << endl; return 0; } int main() { // ios::sync_with_stdio(false);cin.tie(nullptr); // cout << fixed;cout << setprecision(16) << endl; solve(); return 0; }
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, a, b) for (int i = a; i < (b); ++i) #define all(x) (x).begin(), (x).end() #define YY cout << "Yes" << endl; #define NN cout << "No" << endl; const int INF = 1000000007; typedef long long ll; using namespace std; using Graph = vector<vector<int>>; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } int solve() { ll n, k; cin >> n >> k; vector<int> v(n); ll ans = 0; rep(i, n) cin >> v[i]; rep(i, n) REP(j, i + 1, n) { if (v[i] > v[j]) { ans += k * (k + 1) / 2; ans %= INF; } else if (v[i] < v[j]) { ans += (k) * (k - 1) / 2; ans %= INF; } } cout << ans << endl; return 0; } int main() { // ios::sync_with_stdio(false);cin.tie(nullptr); // cout << fixed;cout << setprecision(16) << endl; solve(); return 0; }
[ "variable_declaration.type.change" ]
731,009
731,010
u820341516
cpp
p02928
#include <bits/stdc++.h> using namespace std; int main() { long long int N, K, X = 0, M = 1000000007; cin >> N >> K; int A[N]; for (int i = 0; i < N; i++) cin >> A[i]; for (int i = 0; i < N; i++) { long long int S = 0, T = 0; for (int j = 0; j < i; j++) if (A[i] > A[j]) S++; for (int j = i; j < N; j++) if (A[i] > A[j]) T++; X += K * (K + 1) / 2 * T % M + K * (K - 1) / 2 * S % M; X %= M; } cout << X << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int N, K, X = 0, M = 1000000007; cin >> N >> K; int A[N]; for (int i = 0; i < N; i++) cin >> A[i]; for (int i = 0; i < N; i++) { long long int S = 0, T = 0; for (int j = 0; j < i; j++) if (A[i] > A[j]) S++; for (int j = i; j < N; j++) if (A[i] > A[j]) T++; X += K * (K + 1) / 2 % M * T % M + K * (K - 1) / 2 % M * S % M; X %= M; } cout << X << endl; }
[ "assignment.change" ]
731,011
731,012
u820224016
cpp
p02928
#include <bits/stdc++.h> using namespace std; int main() { long long int N, K, X = 0, M = 1000000007; cin >> N >> K; int A[N]; for (int i = 0; i < N; i++) cin >> A[i]; for (int i = 0; i < N; i++) { long long int S = 0, T = 0; for (int j = 0; j < i; j++) if (A[i] < A[j]) S++; for (int j = i; j < N; j++) if (A[i] < A[j]) T++; X += K * (K + 1) / 2 * T % M + K * (K - 1) / 2 * S % M; X %= M; } cout << X << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int N, K, X = 0, M = 1000000007; cin >> N >> K; int A[N]; for (int i = 0; i < N; i++) cin >> A[i]; for (int i = 0; i < N; i++) { long long int S = 0, T = 0; for (int j = 0; j < i; j++) if (A[i] > A[j]) S++; for (int j = i; j < N; j++) if (A[i] > A[j]) T++; X += K * (K + 1) / 2 % M * T % M + K * (K - 1) / 2 % M * S % M; X %= M; } cout << X << endl; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.change" ]
731,013
731,012
u820224016
cpp
p02928
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); #define FOR(i, s, n) for (int i = s; i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(n) (n).begin(), (n).end() #define RALL(n) (n).rbegin(), (n).rend() #define ATYN(n) cout << ((n) ? "Yes" : "No") << '\n'; #define CFYN(n) cout << ((n) ? "YES" : "NO") << '\n'; #define OUT(n) cout << (n) << '\n'; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; constexpr int MOD = 1000000007; int mod(const ll &x) { return x > 0 ? x % MOD : (x + MOD) % MOD; } int modm(const ll &x, const ll &m) { return (x % MOD) * (m % MOD) % MOD; } int modpow(ll x, ll p) { int ret = 1; while (p > 0) { if (p & 1) ret = modm(ret, x); x = modm(x, x); p >>= 1; } return ret; } // x * modinv(d) int modd(ll x, ll d) { return modm(x, modpow(d, MOD - 2)); } int main(void) { IOS auto nc2 = [](ll x) { return mod(x * (x - 1) / 2); }; int n, k; cin >> n >> k; vector<int> v(n); REP(i, n) cin >> v[i]; vector<int> t1(n), t2(n); REP(i, n) { REP(j, n) { if (v[i] < v[j]) { t1[i]++; if (i > j) t2[i]++; } } } ll ans = 0; REP(i, n) { ans = mod(ans + t1[i] * nc2(k) + t2[i] * k); } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); #define FOR(i, s, n) for (int i = s; i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(n) (n).begin(), (n).end() #define RALL(n) (n).rbegin(), (n).rend() #define ATYN(n) cout << ((n) ? "Yes" : "No") << '\n'; #define CFYN(n) cout << ((n) ? "YES" : "NO") << '\n'; #define OUT(n) cout << (n) << '\n'; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; constexpr int MOD = 1000000007; int mod(const ll &x) { return x > 0 ? x % MOD : (x + MOD) % MOD; } int modm(const ll &x, const ll &m) { return (x % MOD) * (m % MOD) % MOD; } int modpow(ll x, ll p) { int ret = 1; while (p > 0) { if (p & 1) ret = modm(ret, x); x = modm(x, x); p >>= 1; } return ret; } // x * modinv(d) int modd(ll x, ll d) { return modm(x, modpow(d, MOD - 2)); } int main(void) { IOS auto nc2 = [](ll x) { return mod(x * (x - 1) / 2); }; int n, k; cin >> n >> k; vector<int> v(n); REP(i, n) cin >> v[i]; vector<ll> t1(n), t2(n); REP(i, n) { REP(j, n) { if (v[i] < v[j]) { t1[i]++; if (i > j) t2[i]++; } } // cerr<< t1[i] << " " << t2[i] << endl; } ll ans = 0; REP(i, n) { ans = mod(ans + t1[i] * nc2(k) + t2[i] * k); } cout << ans << '\n'; return 0; }
[]
731,016
731,017
u330661451
cpp
p02928
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, s, f) for (int i = s; i < f; i++) #define INF 1000000000000000000 #define MOD 1000000007 typedef pair<int, int> P; bool prime(int n) { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return n != 1; } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } int mod_pow(int n, int p, int m) { if (p == 0) return 1; if (p % 2 == 0) { int t = mod_pow(n, p / 2, m); return (t * t) % m; } return n * mod_pow(n, p - 1, m) % m; } int extGCD(int a, int b, int &x, int &y) { if (b == 0) { x = 1; y = 0; return a; } long long d = extGCD(b, a % b, y, x); y -= a / b * x; return d; } int modinv(int a, int m) { int 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; } int digit(int x) { int cnt = 0; while (x > 0) { cnt += x % 10; x /= 10; } return cnt; } int read() { int tmp; cin >> tmp; return tmp; } int xor128() { static int x = 123456789, y = 362436069, z = 521288629, w = 88675123; int t = (x xor (x << 11)); x = y; y = z; z = w; return (w = (w xor (w >> 19)) xor (t xor (t >> 8))); } map<int, int> factaring(int x) { map<int, int> ans; int now = 2; while (now * now <= x) { if (x % now == 0) { x /= now; ans[now]++; } else now++; } if (x != 1) ans[x]++; return ans; } int MY_COM(int n, int k) { int x = 1, y = 1; rep(i, k) { y *= i + 1; y %= MOD; } for (int i = n - k + 1; i <= n; i++) { x *= i; x %= MOD; } return x * modinv(y, MOD) % MOD; } const int MAX = 510000; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } class UnionFind { private: vector<int> par; public: //宣言 UnionFind(int n) { for (int i = 0; i < n; i++) par.push_back(-1); } //根を求める int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } //同じグループか bool same(int x, int y) { return root(x) == root(y); } //併合 void unite(int x, int y) { x = root(x), y = root(y); if (x == y) return; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return; } //連結成分のサイズ int size(int x) { return -par[root(x)]; } }; class BIT { private: vector<int> bit; int n; public: BIT(int _n) { bit.resize(_n + 1); rep(i, _n + 1) bit[i] = 0; n = _n; } BIT() { n = 0; } void set(int _n) { bit.resize(_n + 1); rep(i, _n + 1) bit[i] = 0; n = _n; } int get() { return bit.size(); } int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= (i & -i); } return s; } int sum(int i, int j) { int be = sum(i - 1); int af = sum(j); return af - be; } void add(int i, int x) { while (i <= n) { bit[i] += x; i += (i & -i); } } }; signed main() { int n, k; cin >> n >> k; int a[2005]; rep(i, n) cin >> a[i]; int ans = 0; rep(i, n) { int cnt = 0; rep(j, n) { if (a[i] > a[j]) cnt++; } int cnt2 = 0; for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) cnt2++; } ans += (k - 1) * k / 2 * cnt % MOD; ans %= MOD; ans += cnt2 * k % MOD; ans %= MOD; } cout << ans << endl; return 0; }
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, s, f) for (int i = s; i < f; i++) #define INF 1000000000000000000 #define MOD 1000000007 typedef pair<int, int> P; bool prime(int n) { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return n != 1; } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } int mod_pow(int n, int p, int m) { if (p == 0) return 1; if (p % 2 == 0) { int t = mod_pow(n, p / 2, m); return (t * t) % m; } return n * mod_pow(n, p - 1, m) % m; } int extGCD(int a, int b, int &x, int &y) { if (b == 0) { x = 1; y = 0; return a; } long long d = extGCD(b, a % b, y, x); y -= a / b * x; return d; } int modinv(int a, int m) { int 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; } int digit(int x) { int cnt = 0; while (x > 0) { cnt += x % 10; x /= 10; } return cnt; } int read() { int tmp; cin >> tmp; return tmp; } int xor128() { static int x = 123456789, y = 362436069, z = 521288629, w = 88675123; int t = (x xor (x << 11)); x = y; y = z; z = w; return (w = (w xor (w >> 19)) xor (t xor (t >> 8))); } map<int, int> factaring(int x) { map<int, int> ans; int now = 2; while (now * now <= x) { if (x % now == 0) { x /= now; ans[now]++; } else now++; } if (x != 1) ans[x]++; return ans; } int MY_COM(int n, int k) { int x = 1, y = 1; rep(i, k) { y *= i + 1; y %= MOD; } for (int i = n - k + 1; i <= n; i++) { x *= i; x %= MOD; } return x * modinv(y, MOD) % MOD; } const int MAX = 510000; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } class UnionFind { private: vector<int> par; public: //宣言 UnionFind(int n) { for (int i = 0; i < n; i++) par.push_back(-1); } //根を求める int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } //同じグループか bool same(int x, int y) { return root(x) == root(y); } //併合 void unite(int x, int y) { x = root(x), y = root(y); if (x == y) return; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return; } //連結成分のサイズ int size(int x) { return -par[root(x)]; } }; class BIT { private: vector<int> bit; int n; public: BIT(int _n) { bit.resize(_n + 1); rep(i, _n + 1) bit[i] = 0; n = _n; } BIT() { n = 0; } void set(int _n) { bit.resize(_n + 1); rep(i, _n + 1) bit[i] = 0; n = _n; } int get() { return bit.size(); } int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= (i & -i); } return s; } int sum(int i, int j) { int be = sum(i - 1); int af = sum(j); return af - be; } void add(int i, int x) { while (i <= n) { bit[i] += x; i += (i & -i); } } }; signed main() { int n, k; cin >> n >> k; int a[2005]; rep(i, n) cin >> a[i]; int ans = 0; rep(i, n) { int cnt = 0; rep(j, n) { if (a[i] > a[j]) cnt++; } int cnt2 = 0; for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) cnt2++; } ans += (k - 1) * k / 2 % MOD * cnt % MOD; ans %= MOD; ans += cnt2 * k % MOD; ans %= MOD; } cout << ans << endl; return 0; }
[ "assignment.change" ]
731,022
731,023
u452009494
cpp
p02928
#include "bits/stdc++.h" using namespace std; typedef long long int ll; typedef pair<ll, ll> pi; typedef pair<pair<ll, ll>, ll> pii; vector<ll> vec; vector<vector<ll>> vec2; ll MOD = 1000000007; ll INF = 1145141919454519; int main() { ll N, K; cin >> N >> K; for (ll i = 0; i < N; i++) { ll t; cin >> t; vec.push_back(t); } //点灯数を求める //自分の右側にいくつ有るか vector<ll> r_T(N, 0); for (ll i = 0; i < N; i++) { for (ll j = i + 1; j < N; j++) { if (vec[i] > vec[j]) r_T[i]++; } } //自分の左側にいくつ有るか vector<ll> l_T(N, 0); for (ll i = N - 1; i >= 0; i--) { for (ll j = i - 1; j >= 0; j--) { if (vec[i] > vec[j]) l_T[i]++; } } ll sum = 0; for (ll i = 0; i < N; i++) { sum += r_T[i] * K % MOD; sum %= MOD; // cout << r_T[i] + l_T[i] << endl; sum += (r_T[i] + l_T[i]) * (((K - 1) * K) / 2) % MOD; // sum += l_T[i] * (K-1) % MOD; sum %= MOD; } cout << sum << endl; }
#include "bits/stdc++.h" using namespace std; typedef long long int ll; typedef pair<ll, ll> pi; typedef pair<pair<ll, ll>, ll> pii; vector<ll> vec; vector<vector<ll>> vec2; ll MOD = 1000000007; ll INF = 1145141919454519; int main() { ll N, K; cin >> N >> K; for (ll i = 0; i < N; i++) { ll t; cin >> t; vec.push_back(t); } //点灯数を求める //自分の右側にいくつ有るか vector<ll> r_T(N, 0); for (ll i = 0; i < N; i++) { for (ll j = i + 1; j < N; j++) { if (vec[i] > vec[j]) r_T[i]++; } } //自分の左側にいくつ有るか vector<ll> l_T(N, 0); for (ll i = N - 1; i >= 0; i--) { for (ll j = i - 1; j >= 0; j--) { if (vec[i] > vec[j]) l_T[i]++; } } ll sum = 0; for (ll i = 0; i < N; i++) { sum += r_T[i] * K % MOD; sum %= MOD; // cout << r_T[i] + l_T[i] << endl; sum += (r_T[i] + l_T[i]) * (((K - 1) * K) / 2 % MOD) % MOD; // sum += l_T[i] * (K-1) % MOD; sum %= MOD; } cout << sum << endl; }
[ "assignment.change" ]
731,028
731,029
u048791623
cpp