problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k ⌀ | fixed_code stringlengths 12 526k ⌀ | labels listlengths 0 15 ⌀ | buggy_submission_id int64 1 1.54M ⌀ | fixed_submission_id int64 2 1.54M ⌀ | user_id stringlengths 10 10 ⌀ | language stringclasses 9 values |
|---|---|---|---|---|---|---|---|
p03027 | #include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < (n); ++i)
#define foor(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, n) for (int i = (n); i--;)
#define roof(i, b, a) for (int i = (b); i >= (a); --i)
#define elsif else if
#define all(x) x.begin(), x.end()
#define Sort(x) sort(all(x))
#define Reverse(x) reverse(all(x))
#define PQ priority_queue
#define NP(x) next_permutation(all(x))
#define M_PI 3.14159265358979323846
#define popcount __builtin_popcount
using namespace std;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef unsigned long long ull;
typedef vector<ull> vu;
typedef vector<vu> vvu;
typedef double dbl;
typedef vector<dbl> vd;
typedef vector<vd> vvd;
typedef string str;
typedef vector<str> vs;
typedef vector<vs> vvs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<int, int> mii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> mll;
typedef pair<dbl, dbl> pdd;
typedef vector<pdd> vpdd;
typedef map<dbl, dbl> mdd;
typedef pair<str, str> pss;
typedef vector<pss> vpss;
typedef map<str, str> mss;
typedef pair<int, ll> pil;
typedef vector<pil> vpil;
typedef map<int, ll> mil;
typedef pair<ll, int> pli;
typedef vector<pli> vpli;
typedef map<ll, int> mli;
typedef pair<dbl, int> pdi;
typedef vector<pdi> vpdi;
typedef map<dbl, int> mdi;
template <typename T> vector<T> &operator<<(vector<T> &v, const T t) {
v.push_back(t);
return v;
}
template <typename T> multiset<T> &operator<<(multiset<T> &m, const T t) {
m.insert(t);
return m;
}
template <typename T> set<T> &operator<<(set<T> &s, const T t) {
s.insert(t);
return s;
}
template <typename T> stack<T> &operator<<(stack<T> &s, const T t) {
s.push(t);
return s;
}
template <typename T> stack<T> &operator>>(stack<T> &s, T &t) {
t = s.top();
s.pop();
return s;
}
template <typename T> queue<T> &operator<<(queue<T> &q, const T t) {
q.push(t);
return q;
}
template <typename T> queue<T> &operator>>(queue<T> &q, T &t) {
t = q.front();
q.pop();
return q;
}
template <typename T, typename U>
PQ<T, vector<T>, U> &operator<<(PQ<T, vector<T>, U> &q, const T t) {
q.push(t);
return q;
}
template <typename T, typename U>
PQ<T, vector<T>, U> &operator>>(PQ<T, vector<T>, U> &q, T &t) {
t = q.top();
q.pop();
return q;
}
template <typename T, typename U>
istream &operator>>(istream &s, pair<T, U> &p) {
return s >> p.first >> p.second;
}
template <typename T> istream &operator>>(istream &s, vector<T> &v) {
fr(i, v.size()) { s >> v[i]; }
return s;
}
template <typename T, typename U>
ostream &operator<<(ostream &s, const pair<T, U> p) {
return s << p.first << " " << p.second;
}
// template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto
// a:v){s<<a<<endl;}return s;}
template <typename T> ostream &operator<<(ostream &s, const vector<T> v) {
fr(i, v.size()) { i ? s << " " << v[i] : s << v[i]; }
return s;
}
template <typename T> ostream &operator<<(ostream &s, const deque<T> d) {
fr(i, d.size()) { i ? s << " " << d[i] : s << d[i]; }
return s;
}
template <typename T> _Bit_reference operator&=(_Bit_reference b, T t) {
return b = b & t;
}
template <typename T> _Bit_reference operator^=(_Bit_reference b, T t) {
return b = b ^ t;
}
template <typename T> _Bit_reference operator|=(_Bit_reference b, T t) {
return b = b | t;
}
template <typename T, typename U>
pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {
return {a.first + b.first, a.second + b.second};
}
template <typename T, typename U>
pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {
return {a.first - b.first, a.second - b.second};
}
void print(void) { cout << endl; }
template <typename T> void print(T t) { cout << t << endl; }
template <typename T, typename... U> void print(T &&t, U &&...u) {
cout << t << " ";
print(forward<U>(u)...);
}
bool YN(bool b) {
print(b ? "YES" : "NO");
return b;
}
bool PI(bool b) {
print(b ? "POSSIBLE" : "IMPOSSIBLE");
return b;
}
bool Yn(bool b) {
print(b ? "Yes" : "No");
return b;
}
bool Pi(bool b) {
print(b ? "Possible" : "Impossible");
return b;
}
bool yn(bool b) {
print(b ? "yes" : "no");
return b;
}
bool pi(bool b) {
print(b ? "possible" : "impossible");
return b;
}
const int e5 = 1e5;
const int e9 = 1e9;
const int MD = 1e9 + 7;
const ll e18 = 1e18;
template <typename T> str to_string(const T &n) {
ostringstream s;
s << n;
return s.str();
}
template <typename T> T &chmax(T &a, T b) { return a = max(a, b); }
template <typename T> T &chmin(T &a, T b) { return a = min(a, b); }
template <typename T, typename U>
vector<pair<T, U>> dijkstra(const vector<vector<pair<T, U>>> &E, const U s,
const T inf) {
using P = pair<T, U>;
vector<P> d;
fr(i, E.size()) { d << P{inf, i}; }
PQ<P, vector<P>, greater<P>> pq;
pq << (d[s] = P{0, s});
while (pq.size()) {
P a = pq.top();
pq.pop();
U v = a.second;
if (d[v].first >= a.first) {
for (P e : E[v]) {
if (d[v].first + e.first < d[e.second].first) {
d[e.second] = P{d[v].first + e.first, v};
pq << P{d[v].first + e.first, e.second};
}
}
}
}
return d;
}
template <typename T, typename U>
map<U, pair<T, U>> dijkstra(map<U, vector<pair<T, U>>> E, const U s,
const T inf) {
using P = pair<T, U>;
map<U, P> d;
for (pair<U, vector<P>> e : E) {
d[e.first] = P{inf, e.first};
}
PQ<P, vector<P>, greater<P>> pq;
pq << (d[s] = P{0, s});
while (pq.size()) {
P a = pq.top();
pq.pop();
U v = a.second;
if (d[v].first >= a.first) {
for (P e : E[v]) {
if (d[v].first + e.first < d[e.second].first) {
d[e.second] = P{d[v].first + e.first, v};
pq << P{d[v].first + e.first, e.second};
}
}
}
}
return d;
}
ll maxflow(vector<mil> &E, int s, int t) {
ll z = 0;
vi b(E.size(), -1);
for (int i = 0;; ++i) {
static auto dfs = [&](int v, ll f, auto &dfs) -> ll {
if (v == t)
return f;
b[v] = i;
for (auto &p : E[v]) {
if (b[p.first] < i && p.second) {
if (ll r = dfs(p.first, min(f, p.second), dfs)) {
p.second -= r;
E[p.first][v] += r;
return r;
}
}
}
return 0;
};
ll x = dfs(s, ll(1e18), dfs);
z += x;
if (x == 0)
return z;
}
}
template <typename T> T distsq(pair<T, T> a, pair<T, T> b) {
return (a.first - b.first) * (a.first - b.first) +
(a.second - b.second) * (a.second - b.second);
}
template <typename T> T max(const vector<T> a) {
T m = a[0];
for (T e : a) {
m = max(m, e);
}
return m;
}
template <typename T> T min(const vector<T> a) {
T m = a[0];
for (T e : a) {
m = min(m, e);
}
return m;
}
template <typename T> T gcd(const T a, const T b) {
return a ? gcd(b % a, a) : b;
}
template <typename T> T gcd(const vector<T> a) {
T g = a[0];
for (T e : a) {
g = gcd(g, e);
}
return g;
}
template <typename T> vector<T> LIS(const vector<T> A) {
vector<T> B;
for (T a : A) {
auto it = lower_bound(all(B), a);
if (it == B.end()) {
B << a;
} else {
*it = a;
}
}
return B;
}
template <typename T> vector<T> LCS(vector<T> A, vector<T> B) {
int N = A.size(), M = B.size();
vector<vector<pair<int, pii>>> d(N + 1, vector<pair<int, pii>>(M + 1));
fr(i, N) {
fr(j, M) {
if (A[i] == B[j]) {
d[i + 1][j + 1] = {d[i][j].first + 1, {i, j}};
} else {
d[i + 1][j + 1] = max(d[i][j + 1], d[i + 1][j]);
}
}
}
vector<T> r;
for (pii p = {N, M}; d[p.first][p.second].first;
p = d[p.first][p.second].second) {
r << A[d[p.first][p.second].second.first];
}
Reverse(r);
return r;
}
str LCS(str S, str T) {
vector<char> s =
LCS(vector<char>(S.begin(), S.end()), vector<char>(T.begin(), T.end()));
return str(s.begin(), s.end());
}
template <typename T> vector<pair<T, T>> ConvexHull(vector<pair<T, T>> V) {
if (V.size() <= 3) {
return V;
}
Sort(V);
rf(i, V.size() - 1) V << V[i];
vector<pair<T, T>> r;
for (pair<T, T> p : V) {
int s = r.size();
while (s >= 2 &&
(p.second - r[s - 1].second) * (p.first - r[s - 2].first) <
(p.second - r[s - 2].second) * (p.first - r[s - 1].first)) {
r.pop_back();
--s;
}
r << p;
}
r.pop_back();
return r;
}
class UnionFind {
vi p, s;
void extend(int N) {
foor(i, p.size(), N) {
p << i;
s << 1;
}
}
public:
UnionFind(void) {}
UnionFind(int N) { extend(N - 1); }
int find(int i) {
extend(i);
return p[i] = p[i] == i ? i : find(p[i]);
}
void unite(int a, int b) {
extend(a);
extend(b);
if ((a = find(a)) != (b = find(b))) {
if (s[a] > s[b]) {
swap(a, b);
}
s[b] += s[a];
p[a] = b;
}
}
void unite(pii p) { return unite(p.first, p.second); }
bool same(int a, int b) {
extend(a);
extend(b);
return find(a) == find(b);
}
bool same(pii p) { return same(p.first, p.second); }
int size(int x) {
extend(x);
return s[find(x)];
}
};
ll MST(vector<pair<ll, pii>> &E) {
Sort(E);
UnionFind uf;
ll z = 0;
for (auto &e : E) {
if (!uf.same(e.second)) {
z += e.first;
uf.unite(e.second);
}
}
return z;
}
ll strmod(const str &s, const int m) {
ll x = 0;
fr(i, s.size()) { x = (x * 10 + s[i] - 48) % m; }
return x;
}
vvl mul(const vvl &A, const vvl &B, const int m) {
vvl C;
fr(y, A.size()) { C << vl(B[y].size()); }
fr(y, C.size()) {
fr(x, C[y].size()) {
fr(i, A[0].size()) { (C[y][x] += A[y][i] * B[i][x]) %= m; }
}
}
return C;
}
vvl pow(const vvl &A, const ll n, const int m) {
vvl B;
fr(y, A.size()) { B << vl(A.size()); }
if (n == 0) {
fr(i, B.size()) { B[i][i] = 1; }
}
elsif(n % 2) { B = mul(A, pow(A, n - 1, m), m); }
else {
vvl C = pow(A, n / 2, m);
B = mul(C, C, m);
}
return B;
}
ll pow(const ll a, const ll n, const int m) {
ll t;
return n ? (n & 1 ? a >= 0 ? a % m : (m - (-a % m)) % m : 1) *
(t = pow(a, n >> 1, m), t * t % m) % m
: !!a;
}
ll inv(const ll x, const int p) { return pow(x, p - 2, p); }
ll inv(const ll x) { return inv(x, MD); }
vpll fact(const int n, const int p) {
vpll v(n + 1);
v[0].first = 1;
foor(i, 1, n) { v[i].first = v[i - 1].first * i % p; }
v[n].second = inv(v[n].first, p);
roof(i, n, 1) { v[i - 1].second = v[i].second * i % p; }
return v;
}
class Combination {
const vpll f;
const int M;
public:
Combination(int n, int m) : f(fact(n, m)), M(m) {}
Combination(int n) : Combination(n, MD) {}
ll P(int n, int k) {
return n < 0 || k < 0 || n < k ? 0ll : f[n].first * f[n - k].second % M;
}
ll C(int n, int k) { return k < 0 ? 0 : P(n, k) * f[k].second % M; }
ll H(int n, int k) { return n == 0 && k == 0 ? 1ll : C(n + k - 1, k); }
ll F(int n) { return n < 0 ? 0 : f[n].first; }
};
ll C2(const int n) { return (ll)n * ~-n / 2; }
ll sum(const vi a) {
ll s = 0;
for (int e : a) {
s += e;
}
return s;
}
ll sum(const vl a) {
ll s = 0;
for (ll e : a) {
s += e;
}
return s;
}
template <typename T> int MSB(T N) {
int r = -1;
for (; N > 0; N /= 2) {
++r;
}
return r;
}
template <typename T> class SegmentTree {
vector<T> S;
T (*const op)(T a, T b);
const T zero;
const int B;
public:
SegmentTree(int N, T (*f)(T a, T b), const T zero)
: S(1 << MSB(N - 1) + 2, zero), op(f), zero(zero),
B(1 << MSB(N - 1) + 1) {}
SegmentTree(vector<T> v, T (*f)(T a, T b), const T zero)
: SegmentTree(v.size(), f, zero) {
fr(i, v.size()) { S[S.size() / 2 + i] = v[i]; }
roof(i, S.size() / 2 - 1, 1) { S[i] = op(S[i * 2], S[i * 2 + 1]); }
}
T calc(int l, int r) {
l += B;
r += B;
if (l > r) {
return zero;
}
if (l == r) {
return S[l];
}
T L = S[l], R = S[r];
for (; l / 2 < r / 2; l /= 2, r /= 2) {
if (l % 2 == 0) {
L = op(L, S[l + 1]);
}
if (r % 2 == 1) {
R = op(S[r - 1], R);
}
}
return op(L, R);
}
void replace(int i, T x) {
for (S[i += B] = x; i != 1; i /= 2) {
if (i % 2) {
S[i / 2] = op(S[i - 1], S[i]);
} else {
S[i / 2] = op(S[i], S[i + 1]);
}
}
}
void add(int i, T x) { replace(i, op(S[B + i], x)); }
T top() { return S[1]; }
};
ll BITsum(vl &B, int i) {
ll z = 0;
while (i > 0) {
z += B[i];
i -= i & -i;
}
return z;
}
void BITadd(vl &B, int i, ll x) {
while (i < B.size()) {
B[i] += x;
i += i & -i;
}
}
ll fib(const ll n, const int m) {
ll a, b, c, d, A, B, C, D;
a = 1;
b = 0;
c = 0;
d = 1;
rf(i, 63) {
A = a * a + b * c;
B = a * b + b * d;
C = c * a + d * c;
D = c * b + d * d;
if (n >> i & 1) {
a = A;
b = B;
c = C;
d = D;
A = a + b;
B = a;
C = c + d;
D = c;
}
a = A % m;
b = B % m;
c = C % m;
d = D % m;
}
return b;
}
vi primes(int n) {
vb b(n + 1);
vi p;
foor(i, 2, n) {
if (!b[i]) {
p << i;
for (int j = 2 * i; j <= n; j += i) {
b[j] = true;
}
}
}
return p;
}
vb isprime(const int n) {
vb v(n + 1, true);
v[0] = v[1] = false;
foor(i, 2, n) {
if (v[i]) {
for (int j = 2 * i; j <= n; j += i) {
v[j] = false;
}
}
}
return v;
}
const int M = 1e6 + 3;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int Q;
cin >> Q;
vpll f = fact(M - 1, M);
fr(q, Q) {
ll x, d, n;
cin >> x >> d >> n;
if (d == 0) {
print(x * n % M);
} else {
ll t = x * inv(d, M) % M;
if (t == 0 || t + n - 1 >= M) {
print(0);
} else {
print(f[t + n - 1].first * f[t - 1].second % M * pow(d, n, M) % M);
}
}
}
}
| #include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < (n); ++i)
#define foor(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, n) for (int i = (n); i--;)
#define roof(i, b, a) for (int i = (b); i >= (a); --i)
#define elsif else if
#define all(x) x.begin(), x.end()
#define Sort(x) sort(all(x))
#define Reverse(x) reverse(all(x))
#define PQ priority_queue
#define NP(x) next_permutation(all(x))
#define M_PI 3.14159265358979323846
#define popcount __builtin_popcount
using namespace std;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef unsigned long long ull;
typedef vector<ull> vu;
typedef vector<vu> vvu;
typedef double dbl;
typedef vector<dbl> vd;
typedef vector<vd> vvd;
typedef string str;
typedef vector<str> vs;
typedef vector<vs> vvs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<int, int> mii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> mll;
typedef pair<dbl, dbl> pdd;
typedef vector<pdd> vpdd;
typedef map<dbl, dbl> mdd;
typedef pair<str, str> pss;
typedef vector<pss> vpss;
typedef map<str, str> mss;
typedef pair<int, ll> pil;
typedef vector<pil> vpil;
typedef map<int, ll> mil;
typedef pair<ll, int> pli;
typedef vector<pli> vpli;
typedef map<ll, int> mli;
typedef pair<dbl, int> pdi;
typedef vector<pdi> vpdi;
typedef map<dbl, int> mdi;
template <typename T> vector<T> &operator<<(vector<T> &v, const T t) {
v.push_back(t);
return v;
}
template <typename T> multiset<T> &operator<<(multiset<T> &m, const T t) {
m.insert(t);
return m;
}
template <typename T> set<T> &operator<<(set<T> &s, const T t) {
s.insert(t);
return s;
}
template <typename T> stack<T> &operator<<(stack<T> &s, const T t) {
s.push(t);
return s;
}
template <typename T> stack<T> &operator>>(stack<T> &s, T &t) {
t = s.top();
s.pop();
return s;
}
template <typename T> queue<T> &operator<<(queue<T> &q, const T t) {
q.push(t);
return q;
}
template <typename T> queue<T> &operator>>(queue<T> &q, T &t) {
t = q.front();
q.pop();
return q;
}
template <typename T, typename U>
PQ<T, vector<T>, U> &operator<<(PQ<T, vector<T>, U> &q, const T t) {
q.push(t);
return q;
}
template <typename T, typename U>
PQ<T, vector<T>, U> &operator>>(PQ<T, vector<T>, U> &q, T &t) {
t = q.top();
q.pop();
return q;
}
template <typename T, typename U>
istream &operator>>(istream &s, pair<T, U> &p) {
return s >> p.first >> p.second;
}
template <typename T> istream &operator>>(istream &s, vector<T> &v) {
fr(i, v.size()) { s >> v[i]; }
return s;
}
template <typename T, typename U>
ostream &operator<<(ostream &s, const pair<T, U> p) {
return s << p.first << " " << p.second;
}
// template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto
// a:v){s<<a<<endl;}return s;}
template <typename T> ostream &operator<<(ostream &s, const vector<T> v) {
fr(i, v.size()) { i ? s << " " << v[i] : s << v[i]; }
return s;
}
template <typename T> ostream &operator<<(ostream &s, const deque<T> d) {
fr(i, d.size()) { i ? s << " " << d[i] : s << d[i]; }
return s;
}
template <typename T> _Bit_reference operator&=(_Bit_reference b, T t) {
return b = b & t;
}
template <typename T> _Bit_reference operator^=(_Bit_reference b, T t) {
return b = b ^ t;
}
template <typename T> _Bit_reference operator|=(_Bit_reference b, T t) {
return b = b | t;
}
template <typename T, typename U>
pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {
return {a.first + b.first, a.second + b.second};
}
template <typename T, typename U>
pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {
return {a.first - b.first, a.second - b.second};
}
void print(void) { cout << endl; }
template <typename T> void print(T t) { cout << t << endl; }
template <typename T, typename... U> void print(T &&t, U &&...u) {
cout << t << " ";
print(forward<U>(u)...);
}
bool YN(bool b) {
print(b ? "YES" : "NO");
return b;
}
bool PI(bool b) {
print(b ? "POSSIBLE" : "IMPOSSIBLE");
return b;
}
bool Yn(bool b) {
print(b ? "Yes" : "No");
return b;
}
bool Pi(bool b) {
print(b ? "Possible" : "Impossible");
return b;
}
bool yn(bool b) {
print(b ? "yes" : "no");
return b;
}
bool pi(bool b) {
print(b ? "possible" : "impossible");
return b;
}
const int e5 = 1e5;
const int e9 = 1e9;
const int MD = 1e9 + 7;
const ll e18 = 1e18;
template <typename T> str to_string(const T &n) {
ostringstream s;
s << n;
return s.str();
}
template <typename T> T &chmax(T &a, T b) { return a = max(a, b); }
template <typename T> T &chmin(T &a, T b) { return a = min(a, b); }
template <typename T, typename U>
vector<pair<T, U>> dijkstra(const vector<vector<pair<T, U>>> &E, const U s,
const T inf) {
using P = pair<T, U>;
vector<P> d;
fr(i, E.size()) { d << P{inf, i}; }
PQ<P, vector<P>, greater<P>> pq;
pq << (d[s] = P{0, s});
while (pq.size()) {
P a = pq.top();
pq.pop();
U v = a.second;
if (d[v].first >= a.first) {
for (P e : E[v]) {
if (d[v].first + e.first < d[e.second].first) {
d[e.second] = P{d[v].first + e.first, v};
pq << P{d[v].first + e.first, e.second};
}
}
}
}
return d;
}
template <typename T, typename U>
map<U, pair<T, U>> dijkstra(map<U, vector<pair<T, U>>> E, const U s,
const T inf) {
using P = pair<T, U>;
map<U, P> d;
for (pair<U, vector<P>> e : E) {
d[e.first] = P{inf, e.first};
}
PQ<P, vector<P>, greater<P>> pq;
pq << (d[s] = P{0, s});
while (pq.size()) {
P a = pq.top();
pq.pop();
U v = a.second;
if (d[v].first >= a.first) {
for (P e : E[v]) {
if (d[v].first + e.first < d[e.second].first) {
d[e.second] = P{d[v].first + e.first, v};
pq << P{d[v].first + e.first, e.second};
}
}
}
}
return d;
}
ll maxflow(vector<mil> &E, int s, int t) {
ll z = 0;
vi b(E.size(), -1);
for (int i = 0;; ++i) {
static auto dfs = [&](int v, ll f, auto &dfs) -> ll {
if (v == t)
return f;
b[v] = i;
for (auto &p : E[v]) {
if (b[p.first] < i && p.second) {
if (ll r = dfs(p.first, min(f, p.second), dfs)) {
p.second -= r;
E[p.first][v] += r;
return r;
}
}
}
return 0;
};
ll x = dfs(s, ll(1e18), dfs);
z += x;
if (x == 0)
return z;
}
}
template <typename T> T distsq(pair<T, T> a, pair<T, T> b) {
return (a.first - b.first) * (a.first - b.first) +
(a.second - b.second) * (a.second - b.second);
}
template <typename T> T max(const vector<T> a) {
T m = a[0];
for (T e : a) {
m = max(m, e);
}
return m;
}
template <typename T> T min(const vector<T> a) {
T m = a[0];
for (T e : a) {
m = min(m, e);
}
return m;
}
template <typename T> T gcd(const T a, const T b) {
return a ? gcd(b % a, a) : b;
}
template <typename T> T gcd(const vector<T> a) {
T g = a[0];
for (T e : a) {
g = gcd(g, e);
}
return g;
}
template <typename T> vector<T> LIS(const vector<T> A) {
vector<T> B;
for (T a : A) {
auto it = lower_bound(all(B), a);
if (it == B.end()) {
B << a;
} else {
*it = a;
}
}
return B;
}
template <typename T> vector<T> LCS(vector<T> A, vector<T> B) {
int N = A.size(), M = B.size();
vector<vector<pair<int, pii>>> d(N + 1, vector<pair<int, pii>>(M + 1));
fr(i, N) {
fr(j, M) {
if (A[i] == B[j]) {
d[i + 1][j + 1] = {d[i][j].first + 1, {i, j}};
} else {
d[i + 1][j + 1] = max(d[i][j + 1], d[i + 1][j]);
}
}
}
vector<T> r;
for (pii p = {N, M}; d[p.first][p.second].first;
p = d[p.first][p.second].second) {
r << A[d[p.first][p.second].second.first];
}
Reverse(r);
return r;
}
str LCS(str S, str T) {
vector<char> s =
LCS(vector<char>(S.begin(), S.end()), vector<char>(T.begin(), T.end()));
return str(s.begin(), s.end());
}
template <typename T> vector<pair<T, T>> ConvexHull(vector<pair<T, T>> V) {
if (V.size() <= 3) {
return V;
}
Sort(V);
rf(i, V.size() - 1) V << V[i];
vector<pair<T, T>> r;
for (pair<T, T> p : V) {
int s = r.size();
while (s >= 2 &&
(p.second - r[s - 1].second) * (p.first - r[s - 2].first) <
(p.second - r[s - 2].second) * (p.first - r[s - 1].first)) {
r.pop_back();
--s;
}
r << p;
}
r.pop_back();
return r;
}
class UnionFind {
vi p, s;
void extend(int N) {
foor(i, p.size(), N) {
p << i;
s << 1;
}
}
public:
UnionFind(void) {}
UnionFind(int N) { extend(N - 1); }
int find(int i) {
extend(i);
return p[i] = p[i] == i ? i : find(p[i]);
}
void unite(int a, int b) {
extend(a);
extend(b);
if ((a = find(a)) != (b = find(b))) {
if (s[a] > s[b]) {
swap(a, b);
}
s[b] += s[a];
p[a] = b;
}
}
void unite(pii p) { return unite(p.first, p.second); }
bool same(int a, int b) {
extend(a);
extend(b);
return find(a) == find(b);
}
bool same(pii p) { return same(p.first, p.second); }
int size(int x) {
extend(x);
return s[find(x)];
}
};
ll MST(vector<pair<ll, pii>> &E) {
Sort(E);
UnionFind uf;
ll z = 0;
for (auto &e : E) {
if (!uf.same(e.second)) {
z += e.first;
uf.unite(e.second);
}
}
return z;
}
ll strmod(const str &s, const int m) {
ll x = 0;
fr(i, s.size()) { x = (x * 10 + s[i] - 48) % m; }
return x;
}
vvl mul(const vvl &A, const vvl &B, const int m) {
vvl C;
fr(y, A.size()) { C << vl(B[y].size()); }
fr(y, C.size()) {
fr(x, C[y].size()) {
fr(i, A[0].size()) { (C[y][x] += A[y][i] * B[i][x]) %= m; }
}
}
return C;
}
vvl pow(const vvl &A, const ll n, const int m) {
vvl B;
fr(y, A.size()) { B << vl(A.size()); }
if (n == 0) {
fr(i, B.size()) { B[i][i] = 1; }
}
elsif(n % 2) { B = mul(A, pow(A, n - 1, m), m); }
else {
vvl C = pow(A, n / 2, m);
B = mul(C, C, m);
}
return B;
}
ll pow(const ll a, const ll n, const int m) {
ll t;
return n ? (n & 1 ? a >= 0 ? a % m : (m - (-a % m)) % m : 1) *
(t = pow(a, n >> 1, m), t * t % m) % m
: !!a;
}
ll inv(const ll x, const int p) { return pow(x, p - 2, p); }
ll inv(const ll x) { return inv(x, MD); }
vpll fact(const int n, const int p) {
vpll v(n + 1);
v[0].first = 1;
foor(i, 1, n) { v[i].first = v[i - 1].first * i % p; }
v[n].second = inv(v[n].first, p);
roof(i, n, 1) { v[i - 1].second = v[i].second * i % p; }
return v;
}
class Combination {
const vpll f;
const int M;
public:
Combination(int n, int m) : f(fact(n, m)), M(m) {}
Combination(int n) : Combination(n, MD) {}
ll P(int n, int k) {
return n < 0 || k < 0 || n < k ? 0ll : f[n].first * f[n - k].second % M;
}
ll C(int n, int k) { return k < 0 ? 0 : P(n, k) * f[k].second % M; }
ll H(int n, int k) { return n == 0 && k == 0 ? 1ll : C(n + k - 1, k); }
ll F(int n) { return n < 0 ? 0 : f[n].first; }
};
ll C2(const int n) { return (ll)n * ~-n / 2; }
ll sum(const vi a) {
ll s = 0;
for (int e : a) {
s += e;
}
return s;
}
ll sum(const vl a) {
ll s = 0;
for (ll e : a) {
s += e;
}
return s;
}
template <typename T> int MSB(T N) {
int r = -1;
for (; N > 0; N /= 2) {
++r;
}
return r;
}
template <typename T> class SegmentTree {
vector<T> S;
T (*const op)(T a, T b);
const T zero;
const int B;
public:
SegmentTree(int N, T (*f)(T a, T b), const T zero)
: S(1 << MSB(N - 1) + 2, zero), op(f), zero(zero),
B(1 << MSB(N - 1) + 1) {}
SegmentTree(vector<T> v, T (*f)(T a, T b), const T zero)
: SegmentTree(v.size(), f, zero) {
fr(i, v.size()) { S[S.size() / 2 + i] = v[i]; }
roof(i, S.size() / 2 - 1, 1) { S[i] = op(S[i * 2], S[i * 2 + 1]); }
}
T calc(int l, int r) {
l += B;
r += B;
if (l > r) {
return zero;
}
if (l == r) {
return S[l];
}
T L = S[l], R = S[r];
for (; l / 2 < r / 2; l /= 2, r /= 2) {
if (l % 2 == 0) {
L = op(L, S[l + 1]);
}
if (r % 2 == 1) {
R = op(S[r - 1], R);
}
}
return op(L, R);
}
void replace(int i, T x) {
for (S[i += B] = x; i != 1; i /= 2) {
if (i % 2) {
S[i / 2] = op(S[i - 1], S[i]);
} else {
S[i / 2] = op(S[i], S[i + 1]);
}
}
}
void add(int i, T x) { replace(i, op(S[B + i], x)); }
T top() { return S[1]; }
};
ll BITsum(vl &B, int i) {
ll z = 0;
while (i > 0) {
z += B[i];
i -= i & -i;
}
return z;
}
void BITadd(vl &B, int i, ll x) {
while (i < B.size()) {
B[i] += x;
i += i & -i;
}
}
ll fib(const ll n, const int m) {
ll a, b, c, d, A, B, C, D;
a = 1;
b = 0;
c = 0;
d = 1;
rf(i, 63) {
A = a * a + b * c;
B = a * b + b * d;
C = c * a + d * c;
D = c * b + d * d;
if (n >> i & 1) {
a = A;
b = B;
c = C;
d = D;
A = a + b;
B = a;
C = c + d;
D = c;
}
a = A % m;
b = B % m;
c = C % m;
d = D % m;
}
return b;
}
vi primes(int n) {
vb b(n + 1);
vi p;
foor(i, 2, n) {
if (!b[i]) {
p << i;
for (int j = 2 * i; j <= n; j += i) {
b[j] = true;
}
}
}
return p;
}
vb isprime(const int n) {
vb v(n + 1, true);
v[0] = v[1] = false;
foor(i, 2, n) {
if (v[i]) {
for (int j = 2 * i; j <= n; j += i) {
v[j] = false;
}
}
}
return v;
}
const int M = 1e6 + 3;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int Q;
cin >> Q;
vpll f = fact(M - 1, M);
fr(q, Q) {
ll x, d, n;
cin >> x >> d >> n;
if (d == 0) {
print(pow(x, n, M));
} else {
ll t = x * inv(d, M) % M;
if (t == 0 || t + n - 1 >= M) {
print(0);
} else {
print(f[t + n - 1].first * f[t - 1].second % M * pow(d, n, M) % M);
}
}
}
}
| [
"call.add",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 837,343 | 837,344 | u283869437 | cpp |
p03027 | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MOD = 1000003;
int pot[MOD + 5], z, x, d, n, licz, mian, r;
// rozwiązuje równanie ax=1(%MOD), gdy MOD pierwsze
int inverse(int a, int n = MOD - 2) {
int r = 1;
while (n) {
if (n % 2)
r = (r * 1LL * a) % MOD;
a = (a * 1LL * a) % MOD;
n >>= 1;
}
return r;
}
// (a^b)%c
int poteguj(int a, int b, int c = MOD) {
int r = 1, m = a;
while (b) {
if (b % 2)
r = (r * 1LL * m) % c;
m = (m * 1LL * m) % c;
b /= 2;
}
return r;
}
int main() {
pot[0] = 1;
for (int i = 1; i < MOD; i++)
pot[i] = (pot[i - 1] * 1LL * i) % MOD;
scanf("%d", &z);
while (z--) {
scanf("%d %d %d", &x, &d, &n);
if (x == 0 || d == 0) {
printf("%d\n", poteguj(x, n));
continue;
} else if (d == 1) {
if (x + n - 1 >= MOD)
printf("0\n");
else {
r = (pot[x + n - 1] * 1LL * inverse(pot[x - 1])) % MOD;
printf("%d\n", r);
}
continue;
} else {
licz = (x * inverse(d)) % MOD + n - 1;
mian = (x * inverse(d)) % MOD - 1;
if (licz >= MOD)
printf("0\n");
else {
r = (pot[licz] * 1LL * inverse(pot[mian])) % MOD;
r = (r * 1LL * poteguj(d, n)) % MOD;
printf("%d\n", r);
}
}
}
}
| #include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MOD = 1000003;
int pot[MOD + 5], z, x, d, n, licz, mian, r;
// rozwiązuje równanie ax=1(%MOD), gdy MOD pierwsze
int inverse(int a, int n = MOD - 2) {
int r = 1;
while (n) {
if (n % 2)
r = (r * 1LL * a) % MOD;
a = (a * 1LL * a) % MOD;
n >>= 1;
}
return r;
}
// (a^b)%c
int poteguj(int a, int b, int c = MOD) {
int r = 1, m = a;
while (b) {
if (b % 2)
r = (r * 1LL * m) % c;
m = (m * 1LL * m) % c;
b /= 2;
}
return r;
}
int main() {
pot[0] = 1;
for (int i = 1; i < MOD; i++)
pot[i] = (pot[i - 1] * 1LL * i) % MOD;
scanf("%d", &z);
while (z--) {
scanf("%d %d %d", &x, &d, &n);
if (x == 0 || d == 0) {
printf("%d\n", poteguj(x, n));
continue;
} else if (d == 1) {
if (x + n - 1 >= MOD)
printf("0\n");
else {
r = (pot[x + n - 1] * 1LL * inverse(pot[x - 1])) % MOD;
printf("%d\n", r);
}
continue;
} else {
licz = (x * 1LL * inverse(d)) % MOD + n - 1;
mian = (x * 1LL * inverse(d)) % MOD - 1;
if (licz >= MOD)
printf("0\n");
else {
r = (pot[licz] * 1LL * inverse(pot[mian])) % MOD;
r = (r * 1LL * poteguj(d, n)) % MOD;
printf("%d\n", r);
}
}
}
}
| [
"assignment.change"
] | 837,352 | 837,353 | u643180062 | cpp |
p03027 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1000003;
ll fact[1111111];
ll po(ll a, ll b) {
if (b == 0)
return 1;
ll z = po(a, b / 2);
z = z * z % mod;
if (b % 2 == 1)
z = z * a % mod;
return z;
}
ll inv(ll a) { return po(a, mod - 2); }
int main() {
ll Q;
cin >> Q;
fact[0] = 1;
for (int i = 0; i < mod + 10; i++)
fact[i + 1] = fact[i] * (i + 1) % mod;
ll x[Q], d[Q], n[Q];
for (int i = 0; i < Q; ++i) {
cin >> x[i] >> d[i] >> n[i];
}
for (int i = 0; i < Q; ++i) {
if (d[i] == 0)
cout << po(x[i], n[i]);
else {
ll first = x[i] * inv(d[i]) % mod;
ll end = first + n[i] - 1;
if (first <= mod && mod <= end)
cout << 0 << endl;
else {
ll a = fact[end] * inv(fact[first - 1]) % mod;
cout << a * po(d[i], n[i]) % mod << endl;
}
}
}
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1000003;
ll fact[1111111];
ll po(ll a, ll b) {
if (b == 0)
return 1;
ll z = po(a, b / 2);
z = z * z % mod;
if (b % 2 == 1)
z = z * a % mod;
return z;
}
ll inv(ll a) { return po(a, mod - 2); }
int main() {
ll Q;
cin >> Q;
fact[0] = 1;
for (int i = 0; i < mod + 10; i++)
fact[i + 1] = fact[i] * (i + 1) % mod;
ll x[Q], d[Q], n[Q];
for (int i = 0; i < Q; ++i) {
cin >> x[i] >> d[i] >> n[i];
}
for (int i = 0; i < Q; ++i) {
if (d[i] == 0)
cout << po(x[i], n[i]) << endl;
else {
ll first = x[i] * inv(d[i]) % mod;
ll end = first + n[i] - 1;
if (first <= mod && mod <= end)
cout << 0 << endl;
else {
ll a = fact[end] * inv(fact[first - 1]) % mod;
cout << a * po(d[i], n[i]) % mod << endl;
}
}
}
}
| [
"io.output.newline.add"
] | 837,359 | 837,360 | u084968244 | cpp |
p03027 |
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e6 + 3)
#define P pair<int, int>
#define PLL pair<ll, ll>
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define RFOR(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define all(a) a.begin(), a.end()
#define IN(a, n) \
rep(i, n) { cin >> a[i]; }
const int vx[4] = {0, 1, 0, -1};
const int vy[4] = {1, 0, -1, 0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
ll power(ll x, ll k) {
ll ret = 1;
while (k > 0) {
if (k & 1)
(ret *= x) %= M;
(x *= x) %= M;
k >>= 1;
}
return ret;
}
int fact[M + 10];
int ifact[M + 10];
main() {
fact[0] = 1;
FOR(i, 1, M + 1) {
fact[i] = (1LL * fact[i - 1] * i) % M;
ifact[i] = power(fact[i], M - 2);
}
int q;
cin >> q;
while (q--) {
int x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << power(x, n) << endl;
} else {
int t = (1LL * x * power(d, M - 2)) % M;
if (x <= M && M <= x + n - 1) {
cout << 0 << endl;
} else {
cout << (((1LL * fact[t + n - 1] * ifact[t - 1]) % M) * power(d, n) % M)
<< endl;
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e6 + 3)
#define P pair<int, int>
#define PLL pair<ll, ll>
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define RFOR(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define all(a) a.begin(), a.end()
#define IN(a, n) \
rep(i, n) { cin >> a[i]; }
const int vx[4] = {0, 1, 0, -1};
const int vy[4] = {1, 0, -1, 0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
ll power(ll x, ll k) {
ll ret = 1;
while (k > 0) {
if (k & 1)
(ret *= x) %= M;
(x *= x) %= M;
k >>= 1;
}
return ret;
}
int fact[M + 10];
int ifact[M + 10];
main() {
fact[0] = 1;
FOR(i, 1, M + 1) {
fact[i] = (1LL * fact[i - 1] * i) % M;
ifact[i] = power(fact[i], M - 2);
}
int q;
cin >> q;
while (q--) {
int x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << power(x, n) << endl;
} else {
int t = (1LL * x * power(d, M - 2)) % M;
if (t <= M && M <= t + n - 1) {
cout << 0 << endl;
} else {
cout << (((1LL * fact[t + n - 1] * ifact[t - 1]) % M) * power(d, n) % M)
<< endl;
}
}
}
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 837,365 | 837,366 | u229842440 | cpp |
p03027 |
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e6 + 3)
#define P pair<int, int>
#define PLL pair<ll, ll>
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define RFOR(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define all(a) a.begin(), a.end()
#define IN(a, n) \
rep(i, n) { cin >> a[i]; }
const int vx[4] = {0, 1, 0, -1};
const int vy[4] = {1, 0, -1, 0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
ll power(ll x, ll k) {
ll ret = 1;
while (k > 0) {
if (k & 1)
(ret *= x) %= M;
(x *= x) %= M;
k >>= 1;
}
return ret;
}
int fact[M + 10];
int ifact[M + 10];
main() {
fact[0] = 1;
FOR(i, 1, M + 1) {
fact[i] = (1LL * fact[i - 1] * i) % M;
ifact[i] = power(fact[i], M - 2);
}
int q;
cin >> q;
while (q--) {
int x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << power(x, n) << endl;
} else {
int t = (1LL * x * power(d, M - 2)) % M;
if (x <= M && M <= x + n - 1) {
cout << 0 << endl;
} else {
cout << (((1LL * fact[t + n - 1] * ifact[t - 1]) % M) * power(d, n) % M)
<< endl;
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e6 + 3)
#define P pair<int, int>
#define PLL pair<ll, ll>
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define RFOR(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define all(a) a.begin(), a.end()
#define IN(a, n) \
rep(i, n) { cin >> a[i]; }
const int vx[4] = {0, 1, 0, -1};
const int vy[4] = {1, 0, -1, 0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init() {
cin.tie(0);
ios::sync_with_stdio(false);
}
ll power(ll x, ll k) {
ll ret = 1;
while (k > 0) {
if (k & 1)
(ret *= x) %= M;
(x *= x) %= M;
k >>= 1;
}
return ret;
}
int fact[M + 10];
int ifact[M + 10];
main() {
fact[0] = 1;
FOR(i, 1, M + 1) {
fact[i] = (1LL * fact[i - 1] * i) % M;
ifact[i] = power(fact[i], M - 2);
}
int q;
cin >> q;
while (q--) {
int x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << power(x, n) << endl;
} else {
int t = (1LL * x * power(d, M - 2)) % M;
if (t <= M && M <= t + n - 1) {
cout << 0 << endl;
} else {
cout << (((1LL * fact[t + n - 1] * ifact[t - 1]) % M) * power(d, n) % M)
<< endl;
}
}
}
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 837,365 | 837,367 | u229842440 | cpp |
p03027 | #include <bits/stdc++.h>
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) _range(i, 0, n)
#define _range(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)
#define _rrep(i, n) _rrange(i, n, 0)
#define _rrange(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rrep(...) _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__)
#define _all(arg) begin(arg), end(arg)
#define uniq(arg) sort(_all(arg)), (arg).erase(unique(_all(arg)), end(arg))
#define getidx(ary, key) lower_bound(_all(ary), key) - begin(ary)
#define clr(a, b) memset((a), (b), sizeof(a))
#define bit(n) (1LL << (n))
// #define DEBUG
#ifdef DEBUG
#define dump(...) fprintf(stderr, __VA_ARGS__)
#else
#define dump(...)
#endif
template <class T> bool chmax(T &a, const T &b) {
return (a < b) ? (a = b, 1) : 0;
}
template <class T> bool chmin(T &a, const T &b) {
return (b < a) ? (a = b, 1) : 0;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf = 1LL << 62;
const ll mod = 1000003LL;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll extgcd(ll a, ll b, ll &x, ll &y) {
x = 1, y = 0;
ll g = a;
if (b != 0)
g = extgcd(b, a % b, y, x), y -= a / b * x;
return g;
}
ll ADD(const ll &a, const ll &b, const ll &mod) { return (a + b) % mod; }
ll SUB(const ll &a, const ll &b, const ll &mod) { return (a - b + mod) % mod; }
ll MUL(const ll &a, const ll &b, const ll &mod) { return (1LL * a * b) % mod; }
ll DIV(const ll &a, const ll &b, const ll &mod) {
ll x, y;
extgcd(b, mod, x, y);
return MUL(a, (x + mod) % mod, mod);
}
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1, 6);
uniform_real_distribution<double> score(0.0, 10.0);
///////////////////////
const int N = 1e6 + 123;
ll fact[N + 1];
void set_fact() {
fact[0] = 1;
rep(i, N) fact[i + 1] = ((((ll)i + 1) % mod) * fact[i]) % mod;
}
ll mod_inv(ll a, ll m) {
ll x, y;
extgcd(a, m, x, y);
return (m + x % m) % m;
}
// n! mod p
ll mod_fact(ll n, ll p, ll &e) {
e = 0;
if (!n)
return 1;
ll res = mod_fact(n / p, p, e);
e += n / p;
if ((n / p) % 2)
return res * (p - fact[n % p]) % p;
else
return res * fact[n % p] % p;
}
// nCk mod p ; O(log_p n)
ll mod_comb(ll n, ll k, ll p) {
if (n < 0 || k < 0 || n < k)
return 0;
ll e1, e2, e3;
ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2),
a3 = mod_fact(n - k, p, e3);
if (e1 > e2 + e3)
return 0;
return a1 * mod_inv(a2 * a3 % p, p) % p;
}
// nHk mod p ;
ll mod_h_comb(ll n, ll k, ll p) { return mod_comb(n + k - 1, k, p); }
///////////////////////
//
ll modpow(ll x, ll n) {
ll ret = 1LL;
ll cur = x;
while (n > 0) {
if (n & 1LL) {
ret = MUL(ret, cur, mod);
}
cur = MUL(cur, cur, mod);
n /= 2;
}
return ret;
}
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
set_fact();
int Q;
cin >> Q;
rep(loop, Q) {
ll x, d, n;
cin >> x >> d >> n;
if (d == 0LL) {
cout << modpow(x, n) << endl;
return 0;
}
x = DIV(x, d, mod);
if (x + (n - 1) >= mod or x == 0LL) {
cout << 0 << endl;
return 0;
}
ll res = DIV(fact[x + (n - 1)], fact[x - 1], mod);
res = MUL(res, modpow(d, n), mod);
cout << res << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) _range(i, 0, n)
#define _range(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)
#define _rrep(i, n) _rrange(i, n, 0)
#define _rrange(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rrep(...) _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__)
#define _all(arg) begin(arg), end(arg)
#define uniq(arg) sort(_all(arg)), (arg).erase(unique(_all(arg)), end(arg))
#define getidx(ary, key) lower_bound(_all(ary), key) - begin(ary)
#define clr(a, b) memset((a), (b), sizeof(a))
#define bit(n) (1LL << (n))
// #define DEBUG
#ifdef DEBUG
#define dump(...) fprintf(stderr, __VA_ARGS__)
#else
#define dump(...)
#endif
template <class T> bool chmax(T &a, const T &b) {
return (a < b) ? (a = b, 1) : 0;
}
template <class T> bool chmin(T &a, const T &b) {
return (b < a) ? (a = b, 1) : 0;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf = 1LL << 62;
const ll mod = 1000003LL;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll extgcd(ll a, ll b, ll &x, ll &y) {
x = 1, y = 0;
ll g = a;
if (b != 0)
g = extgcd(b, a % b, y, x), y -= a / b * x;
return g;
}
ll ADD(const ll &a, const ll &b, const ll &mod) { return (a + b) % mod; }
ll SUB(const ll &a, const ll &b, const ll &mod) { return (a - b + mod) % mod; }
ll MUL(const ll &a, const ll &b, const ll &mod) { return (1LL * a * b) % mod; }
ll DIV(const ll &a, const ll &b, const ll &mod) {
ll x, y;
extgcd(b, mod, x, y);
return MUL(a, (x + mod) % mod, mod);
}
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1, 6);
uniform_real_distribution<double> score(0.0, 10.0);
///////////////////////
const int N = 1e6 + 123;
ll fact[N + 1];
void set_fact() {
fact[0] = 1;
rep(i, N) fact[i + 1] = ((((ll)i + 1) % mod) * fact[i]) % mod;
}
ll mod_inv(ll a, ll m) {
ll x, y;
extgcd(a, m, x, y);
return (m + x % m) % m;
}
// n! mod p
ll mod_fact(ll n, ll p, ll &e) {
e = 0;
if (!n)
return 1;
ll res = mod_fact(n / p, p, e);
e += n / p;
if ((n / p) % 2)
return res * (p - fact[n % p]) % p;
else
return res * fact[n % p] % p;
}
// nCk mod p ; O(log_p n)
ll mod_comb(ll n, ll k, ll p) {
if (n < 0 || k < 0 || n < k)
return 0;
ll e1, e2, e3;
ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2),
a3 = mod_fact(n - k, p, e3);
if (e1 > e2 + e3)
return 0;
return a1 * mod_inv(a2 * a3 % p, p) % p;
}
// nHk mod p ;
ll mod_h_comb(ll n, ll k, ll p) { return mod_comb(n + k - 1, k, p); }
///////////////////////
//
ll modpow(ll x, ll n) {
ll ret = 1LL;
ll cur = x;
while (n > 0) {
if (n & 1LL) {
ret = MUL(ret, cur, mod);
}
cur = MUL(cur, cur, mod);
n /= 2;
}
return ret;
}
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
set_fact();
int Q;
cin >> Q;
rep(loop, Q) {
ll x, d, n;
cin >> x >> d >> n;
if (d == 0LL) {
cout << modpow(x, n) << endl;
continue;
}
x = DIV(x, d, mod);
if (x + (n - 1) >= mod or x == 0LL) {
cout << 0 << endl;
continue;
}
ll res = DIV(fact[x + (n - 1)], fact[x - 1], mod);
res = MUL(res, modpow(d, n), mod);
cout << res << endl;
}
return 0;
}
| [
"control_flow.return.remove",
"control_flow.continue.add"
] | 837,370 | 837,371 | u704625420 | cpp |
p03027 | #include <iostream>
using namespace std;
typedef long long ll;
const ll MOD = 1000003;
ll fact[1000003], fact_inv[1000003];
ll inv[1000003]; //普通の数のinv
ll modpow(ll a, ll b) {
ll ret = 1, kakeru = a;
while (b > 0) {
if (b & 1)
ret *= kakeru, ret %= MOD;
kakeru *= kakeru, kakeru %= MOD;
b >>= 1;
}
return ret;
}
void set_fact() {
fact[0] = 0, fact[1] = 1;
for (int i = 2; i < MOD; i++) {
fact[i] = fact[i - 1] * i;
fact[i] %= MOD;
}
fact_inv[MOD - 1] = modpow(fact[MOD - 1], MOD - 2);
for (int i = MOD - 2; i >= 0; i--) {
fact_inv[i] = fact_inv[i + 1] * (i + 1);
fact_inv[i] %= MOD;
}
}
void set_inv() {
for (int i = 0; i < MOD; i++) {
inv[i] = modpow(i, MOD - 2);
}
}
int main() {
set_inv();
set_fact();
int Q;
cin >> Q;
for (int q = 0; q < Q; q++) {
ll x, d, n;
cin >> x >> d >> n;
//全体の式を/(d^n)すると、等差1の数列の積になる。それって階乗じゃん。
// x/dは割り切れなくても、modの世界なので整数になるので、結局問題なし。
//階乗とそれぞれの数字に逆元を事前に計算しておけばO(1)で取得できるので解ける
ll tmp = (x * inv[d]) % MOD;
if (d == 0) {
cout << modpow(d, n) << endl;
continue;
}
if (n - 1 >= (MOD - tmp)) {
cout << 0 << endl;
} else {
cout << (((fact[(tmp + n - 1) % MOD] * fact_inv[(tmp - 1 + MOD) % MOD]) %
MOD) *
modpow(d, n)) %
MOD
<< endl;
}
}
return 0;
} | #include <iostream>
using namespace std;
typedef long long ll;
const ll MOD = 1000003;
ll fact[1000003], fact_inv[1000003];
ll inv[1000003]; //普通の数のinv
ll modpow(ll a, ll b) {
ll ret = 1, kakeru = a;
while (b > 0) {
if (b & 1)
ret *= kakeru, ret %= MOD;
kakeru *= kakeru, kakeru %= MOD;
b >>= 1;
}
return ret;
}
void set_fact() {
fact[0] = 0, fact[1] = 1;
for (int i = 2; i < MOD; i++) {
fact[i] = fact[i - 1] * i;
fact[i] %= MOD;
}
fact_inv[MOD - 1] = modpow(fact[MOD - 1], MOD - 2);
for (int i = MOD - 2; i >= 0; i--) {
fact_inv[i] = fact_inv[i + 1] * (i + 1);
fact_inv[i] %= MOD;
}
}
void set_inv() {
for (int i = 0; i < MOD; i++) {
inv[i] = modpow(i, MOD - 2);
}
}
int main() {
set_inv();
set_fact();
int Q;
cin >> Q;
for (int q = 0; q < Q; q++) {
ll x, d, n;
cin >> x >> d >> n;
//全体の式を/(d^n)すると、等差1の数列の積になる。それって階乗じゃん。
// x/dは割り切れなくても、modの世界なので整数になるので、結局問題なし。
//階乗とそれぞれの数字に逆元を事前に計算しておけばO(1)で取得できるので解ける
ll tmp = (x * inv[d]) % MOD;
if (d == 0) {
cout << modpow(x, n) << endl;
continue;
}
if (n - 1 >= (MOD - tmp)) {
cout << 0 << endl;
} else {
cout << (((fact[(tmp + n - 1) % MOD] * fact_inv[(tmp - 1 + MOD) % MOD]) %
MOD) *
modpow(d, n)) %
MOD
<< endl;
}
}
return 0;
} | [
"identifier.change",
"io.output.change"
] | 837,378 | 837,379 | u107077805 | cpp |
p03027 | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1e6 + 3;
long long int rev_mod(long long int num) {
long long int pow_num = MOD - 2;
long long int mod_num = MOD;
long long int pow_cur = num;
long long int ret = 1;
while (pow_num > 0) {
if (pow_num % 2 == 1) {
ret *= pow_cur;
ret %= mod_num;
}
pow_cur *= pow_cur;
pow_cur %= mod_num;
pow_num /= 2;
}
return ret;
}
long long int pow_mul(long long int num, long long int p) {
long long int pow_num = p;
long long int mod_num = MOD;
long long int pow_cur = num;
long long int ret = 1;
while (pow_num > 0) {
if (pow_num % 2 == 1) {
ret *= pow_cur;
ret %= mod_num;
}
pow_cur *= pow_cur;
pow_cur %= mod_num;
pow_num /= 2;
}
return ret;
}
long long int fact[1000005];
int main() {
fact[0] = 1;
for (int i = 1; i < 1000005; i++) {
fact[i] = fact[i - 1] * i % MOD;
}
int Q;
cin >> Q;
for (int loop = 0; loop < Q; loop++) {
long long int x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << pow_mul(x, n) << endl;
}
long long int L = x * rev_mod(d) % MOD;
long long int R = L + n - 1;
if (L == 0 || R / MOD >= 1) {
cout << 0 << endl;
continue;
}
cout << fact[R] * rev_mod(fact[L - 1]) % MOD * pow_mul(d, n) % MOD << endl;
}
return 0;
} | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1e6 + 3;
long long int rev_mod(long long int num) {
long long int pow_num = MOD - 2;
long long int mod_num = MOD;
long long int pow_cur = num;
long long int ret = 1;
while (pow_num > 0) {
if (pow_num % 2 == 1) {
ret *= pow_cur;
ret %= mod_num;
}
pow_cur *= pow_cur;
pow_cur %= mod_num;
pow_num /= 2;
}
return ret;
}
long long int pow_mul(long long int num, long long int p) {
long long int pow_num = p;
long long int mod_num = MOD;
long long int pow_cur = num;
long long int ret = 1;
while (pow_num > 0) {
if (pow_num % 2 == 1) {
ret *= pow_cur;
ret %= mod_num;
}
pow_cur *= pow_cur;
pow_cur %= mod_num;
pow_num /= 2;
}
return ret;
}
long long int fact[1000005];
int main() {
fact[0] = 1;
for (int i = 1; i < 1000005; i++) {
fact[i] = fact[i - 1] * i % MOD;
}
int Q;
cin >> Q;
for (int loop = 0; loop < Q; loop++) {
long long int x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << pow_mul(x, n) << endl;
continue;
}
long long int L = x * rev_mod(d) % MOD;
long long int R = L + n - 1;
if (L == 0 || R / MOD >= 1) {
cout << 0 << endl;
continue;
}
cout << fact[R] * rev_mod(fact[L - 1]) % MOD * pow_mul(d, n) % MOD << endl;
}
return 0;
} | [] | 837,391 | 837,392 | u997521090 | cpp |
p03027 | #include <iostream>
using namespace std;
const int MOD = 1000003;
const int N_MAX = 1000003;
typedef long long ll;
ll inv[N_MAX], fac[N_MAX], finv[N_MAX];
void init() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < N_MAX; i++) {
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
fac[i] = fac[i - 1] * (ll)i % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
int main() {
init();
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
ll x, d, n;
cin >> x >> d >> n;
ll m = (x * inv[d]) % MOD;
if (d == 0) {
ll powx = 1;
ll tmp = x;
for (int j = 0; j <= 40; j++) {
if (n & (1 << j)) {
powx *= tmp;
powx %= MOD;
}
tmp = (tmp * tmp);
tmp %= MOD;
}
cout << powx << endl;
} else if (m == 0 || m + n - 1 >= MOD || x == 0) {
cout << 0 << endl;
} else {
ll ans = (fac[m + n - 1] * finv[m - 1]) % MOD;
ll tmp = d;
ll powd = 1;
for (int j = 0; j <= 20; j++) {
if (n & (1 << j)) {
powd *= tmp;
powd %= MOD;
}
tmp = (tmp * tmp);
tmp %= MOD;
}
ans *= powd;
ans %= MOD;
cout << ans << endl;
}
}
} | #include <iostream>
using namespace std;
const int MOD = 1000003;
const int N_MAX = 1000003;
typedef long long ll;
ll inv[N_MAX], fac[N_MAX], finv[N_MAX];
void init() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < N_MAX; i++) {
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
fac[i] = fac[i - 1] * (ll)i % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
int main() {
init();
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
ll x, d, n;
cin >> x >> d >> n;
ll m = (x * inv[d]) % MOD;
if (d == 0) {
ll powx = 1;
ll tmp = x;
for (int j = 0; j <= 30; j++) {
if (n & (1 << j)) {
powx *= tmp;
powx %= MOD;
}
tmp = (tmp * tmp);
tmp %= MOD;
}
cout << powx << endl;
} else if (m == 0 || m + n - 1 >= MOD || x == 0) {
cout << 0 << endl;
} else {
ll ans = (fac[m + n - 1] * finv[m - 1]) % MOD;
ll tmp = d;
ll powd = 1;
for (int j = 0; j <= 20; j++) {
if (n & (1 << j)) {
powd *= tmp;
powd %= MOD;
}
tmp = (tmp * tmp);
tmp %= MOD;
}
ans *= powd;
ans %= MOD;
cout << ans << endl;
}
}
} | [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 837,397 | 837,398 | u693133807 | cpp |
p03027 | #include <iostream>
using namespace std;
const int MOD = 1000003;
const int N_MAX = 1000003;
typedef long long ll;
ll inv[N_MAX], fac[N_MAX], finv[N_MAX];
void init() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < N_MAX; i++) {
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
fac[i] = fac[i - 1] * (ll)i % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
int main() {
init();
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
ll x, d, n;
cin >> x >> d >> n;
ll m = (x * inv[d]) % MOD;
if (d == 0) {
ll powx = 1;
ll tmp = x;
for (int j = 0; j <= 40; j++) {
if (n & (1 << j)) {
powx *= tmp;
powx %= MOD;
}
tmp = (tmp * tmp);
tmp %= MOD;
}
cout << powx << endl;
} else if (m + n - 1 >= MOD || x == 0) {
cout << 0 << endl;
} else {
ll ans = (fac[m + n - 1] * finv[m - 1]) % MOD;
ll tmp = d;
ll powd = 1;
for (int j = 0; j <= 20; j++) {
if (n & (1 << j)) {
powd *= tmp;
powd %= MOD;
}
tmp = (tmp * tmp);
tmp %= MOD;
}
ans *= powd;
ans %= MOD;
cout << ans << endl;
}
}
} | #include <iostream>
using namespace std;
const int MOD = 1000003;
const int N_MAX = 1000003;
typedef long long ll;
ll inv[N_MAX], fac[N_MAX], finv[N_MAX];
void init() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < N_MAX; i++) {
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
fac[i] = fac[i - 1] * (ll)i % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
int main() {
init();
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
ll x, d, n;
cin >> x >> d >> n;
ll m = (x * inv[d]) % MOD;
if (d == 0) {
ll powx = 1;
ll tmp = x;
for (int j = 0; j <= 30; j++) {
if (n & (1 << j)) {
powx *= tmp;
powx %= MOD;
}
tmp = (tmp * tmp);
tmp %= MOD;
}
cout << powx << endl;
} else if (m == 0 || m + n - 1 >= MOD || x == 0) {
cout << 0 << endl;
} else {
ll ans = (fac[m + n - 1] * finv[m - 1]) % MOD;
ll tmp = d;
ll powd = 1;
for (int j = 0; j <= 20; j++) {
if (n & (1 << j)) {
powd *= tmp;
powd %= MOD;
}
tmp = (tmp * tmp);
tmp %= MOD;
}
ans *= powd;
ans %= MOD;
cout << ans << endl;
}
}
} | [
"literal.number.change",
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 837,399 | 837,398 | u693133807 | cpp |
p03027 | #include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 10005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template <class T> void read(T &res) {
res = 0;
T f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
res = res * 10 + c - '0';
c = getchar();
}
res *= f;
}
template <class T> void out(T x) {
if (x < 0) {
x = -x;
putchar('-');
}
if (x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
const int MOD = 1000003;
int pre[MOD + 5];
int mul(int a, int b) { return 1LL * a * b % MOD; }
int inc(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
int fpow(int x, int c) {
int res = 1, t = x;
while (c) {
if (c & 1)
res = mul(res, t);
t = mul(t, t);
c >>= 1;
}
return res;
}
void Solve() {
pre[0] = 1;
for (int i = 1; i < MOD; ++i)
pre[i] = mul(pre[i - 1], i);
int Q, x, d, n;
read(Q);
for (int i = 1; i <= Q; ++i) {
read(x);
read(d);
read(n);
if (d == 0) {
out(fpow(x, n));
continue;
}
x = mul(x, fpow(d, MOD - 2));
if (x + n - 1 >= MOD || x == 0) {
puts("0");
continue;
}
int res = mul(pre[x + n - 1], fpow(pre[x - 1], MOD - 2));
res = mul(res, fpow(d, n));
out(res);
enter;
}
}
int main() {
#ifdef ivorysi
freopen("f1.in", "r", stdin);
#endif
Solve();
return 0;
}
| #include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 10005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template <class T> void read(T &res) {
res = 0;
T f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
res = res * 10 + c - '0';
c = getchar();
}
res *= f;
}
template <class T> void out(T x) {
if (x < 0) {
x = -x;
putchar('-');
}
if (x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
const int MOD = 1000003;
int pre[MOD + 5];
int mul(int a, int b) { return 1LL * a * b % MOD; }
int inc(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
int fpow(int x, int c) {
int res = 1, t = x;
while (c) {
if (c & 1)
res = mul(res, t);
t = mul(t, t);
c >>= 1;
}
return res;
}
void Solve() {
pre[0] = 1;
for (int i = 1; i < MOD; ++i)
pre[i] = mul(pre[i - 1], i);
int Q, x, d, n;
read(Q);
for (int i = 1; i <= Q; ++i) {
read(x);
read(d);
read(n);
if (d == 0) {
out(fpow(x, n));
enter;
continue;
}
x = mul(x, fpow(d, MOD - 2));
if (x + n - 1 >= MOD || x == 0) {
puts("0");
continue;
}
int res = mul(pre[x + n - 1], fpow(pre[x - 1], MOD - 2));
res = mul(res, fpow(d, n));
out(res);
enter;
}
}
int main() {
#ifdef ivorysi
freopen("f1.in", "r", stdin);
#endif
Solve();
return 0;
}
| [] | 837,403 | 837,404 | u845980916 | cpp |
p03027 | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
template <int MOD> class Modular {
private:
long long value;
public:
constexpr Modular() : value(){};
constexpr Modular(const Modular &other) : value(other.value) {}
template <typename U> constexpr Modular(const U &x) { value = normalize(x); }
template <typename U> static long long normalize(const U &x) {
long long v;
if (-MOD <= x && x < MOD)
v = static_cast<long long>(x);
else
v = static_cast<long long>(x % MOD);
if (v < 0)
v += MOD;
return v;
}
constexpr long long inverse(long long x) {
x = (x % MOD + MOD) % MOD;
long long y = MOD, u = 1, v = 0;
while (y) {
long long t = x / y;
x -= t * y;
swap(x, y);
u -= t * v;
swap(u, v);
}
return (u % MOD + MOD) % MOD;
}
explicit operator long long() const noexcept { return value; }
constexpr Modular &operator=(const Modular &other) &noexcept {
value = other.value;
return *this;
}
template <typename U> constexpr Modular &operator=(const U &other) &noexcept {
return *this = Modular(other);
}
constexpr Modular &operator+=(const Modular &other) noexcept {
if ((value += other.value) >= MOD)
value -= MOD;
return *this;
}
template <typename U> constexpr Modular &operator+=(const U &other) noexcept {
return *this += Modular(other);
}
constexpr Modular &operator-=(const Modular &other) noexcept {
if ((value -= other.value) < 0)
value += MOD;
return *this;
}
template <typename U> constexpr Modular &operator-=(const U &other) noexcept {
return *this -= Modular(other);
}
constexpr Modular &operator*=(const Modular &other) noexcept {
value = value * other.value % MOD;
return *this;
}
template <typename U> constexpr Modular &operator*=(const U &other) noexcept {
return *this *= Modular(other);
}
constexpr Modular &operator/=(const Modular &other) noexcept {
return *this *= Modular(inverse(other.value));
}
template <typename U> constexpr Modular &operator/=(const U &other) noexcept {
return *this *= Modular(inverse(normalize(other)));
}
constexpr Modular &operator++() noexcept { return *this += 1; }
constexpr Modular operator++(int) noexcept {
Modular ret(*this);
*this += 1;
return ret;
}
constexpr Modular &operator--() noexcept { return *this -= 1; }
constexpr Modular operator--(int) noexcept {
Modular ret(*this);
*this += 1;
return ret;
}
constexpr Modular operator-() const { return Modular(-value); }
friend constexpr bool operator==(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return lhs.value == rhs.value;
}
template <typename U>
friend constexpr bool operator==(const Modular<MOD> &lhs, U rhs) noexcept {
return lhs == Modular<MOD>(rhs);
}
template <typename U>
friend constexpr bool operator==(U lhs, const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) == rhs;
}
friend constexpr bool operator!=(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return !(lhs == rhs);
}
template <typename U>
friend constexpr bool operator!=(const Modular<MOD> &lhs, U rhs) noexcept {
return !(lhs == rhs);
}
template <typename U>
friend constexpr bool operator!=(U lhs, const Modular<MOD> rhs) noexcept {
return !(lhs == rhs);
}
friend constexpr bool operator<(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return lhs.value < rhs.value;
}
template <typename U>
friend constexpr bool operator<(const Modular<MOD> &lhs, U rhs) noexcept {
return lhs.value < rhs;
}
template <typename U>
friend constexpr bool operator<(U lhs, const Modular<MOD> &rhs) noexcept {
return lhs < rhs.value;
}
friend constexpr bool operator>(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return rhs.value < lhs.value;
}
template <typename U>
friend constexpr bool operator>(const Modular<MOD> &lhs, U rhs) noexcept {
return rhs.value < lhs;
}
template <typename U>
friend constexpr bool operator>(U lhs, const Modular<MOD> &rhs) noexcept {
return rhs < lhs.value;
}
friend constexpr bool operator<=(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return !(lhs.value > rhs.value);
}
template <typename U>
friend constexpr bool operator<=(const Modular<MOD> &lhs, U rhs) noexcept {
return !(lhs.value > rhs);
}
template <typename U>
friend constexpr bool operator<=(U lhs, const Modular<MOD> &rhs) noexcept {
return !(lhs < rhs.value);
}
friend constexpr bool operator>=(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return !(lhs.value < rhs.value);
}
template <typename U>
friend constexpr bool operator>=(const Modular<MOD> &lhs, U rhs) noexcept {
return !(lhs.value < rhs);
}
template <typename U>
friend constexpr bool operator>=(U lhs, const Modular<MOD> &rhs) noexcept {
return !(lhs < rhs.value);
}
friend constexpr Modular<MOD> operator+(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) += rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator+(const Modular<MOD> &lhs,
U rhs) noexcept {
return Modular<MOD>(lhs) += rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator+(U lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) += rhs;
}
friend constexpr Modular<MOD> operator-(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) -= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator-(const Modular<MOD> &lhs,
U rhs) noexcept {
return Modular<MOD>(lhs) -= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator-(U lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) -= rhs;
}
friend constexpr Modular<MOD> operator*(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) *= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator*(const Modular<MOD> &lhs,
U rhs) noexcept {
return Modular<MOD>(lhs) *= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator*(U lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) *= rhs;
}
friend constexpr Modular<MOD> operator/(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) /= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator/(const Modular<MOD> &lhs,
U rhs) noexcept {
return Modular<MOD>(lhs) /= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator/(U lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) /= rhs;
}
friend std::ostream &operator<<(std::ostream &stream,
const Modular<MOD> &number) noexcept {
return stream << number.value;
}
friend std::istream &operator>>(std::istream &stream, Modular<MOD> &number) {
long long in;
stream >> in;
number.value = Modular<MOD>::normalize(in);
return stream;
}
constexpr int getmod() const { return MOD; }
};
template <int MOD, typename U>
Modular<MOD> power(const Modular<MOD> &x, const U &y) {
assert(y >= 0);
Modular<MOD> k = x, result = 1;
U p = y;
while (p > 0) {
if (p & 1)
result *= k;
k *= k;
p >>= 1;
}
return result;
}
template <int MOD> class BinaryCoefficients {
private:
vector<Modular<MOD>> fact_, inv_, finv_;
public:
constexpr BinaryCoefficients(int n = 2020200)
: fact_(n, 1), inv_(n, 1), finv_(n, 1) {
for (int i = 2; i < n; i++) {
fact_[i] = fact_[i - 1] * i;
inv_[i] = -inv_[MOD % i] * (MOD / i);
finv_[i] = finv_[i - 1] * inv_[i];
}
}
constexpr Modular<MOD> comb(int n, int k) const noexcept {
if (n < k || n < 0 || k < 0)
return 0;
return fact_[n] * finv_[k] * finv_[n - k];
}
constexpr Modular<MOD> fact(int n) const noexcept {
if (n < 0)
return 0;
return fact_[n];
}
constexpr Modular<MOD> inv(int n) const noexcept {
if (n < 0)
return 0;
return inv_[n];
}
constexpr Modular<MOD> finv(int n) const noexcept {
if (n < 0)
return 0;
return finv_[n];
}
};
constexpr int mod = 1000003;
using mint = Modular<mod>;
using bicoef = BinaryCoefficients<mod>;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
bicoef bc;
int q;
cin >> q;
while (q--) {
mint x, d;
long long n;
cin >> x >> d >> n;
if (d == 0) {
cout << power(d, n) << '\n';
continue;
}
mint k = x / d;
if (k == 0 || (long long)k + n - 1 >= mod) {
cout << 0 << '\n';
continue;
}
cout << bc.fact((long long)k + n - 1) * bc.finv((long long)k - 1) *
power(d, n)
<< '\n';
}
return 0;
} | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
template <int MOD> class Modular {
private:
long long value;
public:
constexpr Modular() : value(){};
constexpr Modular(const Modular &other) : value(other.value) {}
template <typename U> constexpr Modular(const U &x) { value = normalize(x); }
template <typename U> static long long normalize(const U &x) {
long long v;
if (-MOD <= x && x < MOD)
v = static_cast<long long>(x);
else
v = static_cast<long long>(x % MOD);
if (v < 0)
v += MOD;
return v;
}
constexpr long long inverse(long long x) {
x = (x % MOD + MOD) % MOD;
long long y = MOD, u = 1, v = 0;
while (y) {
long long t = x / y;
x -= t * y;
swap(x, y);
u -= t * v;
swap(u, v);
}
return (u % MOD + MOD) % MOD;
}
explicit operator long long() const noexcept { return value; }
constexpr Modular &operator=(const Modular &other) &noexcept {
value = other.value;
return *this;
}
template <typename U> constexpr Modular &operator=(const U &other) &noexcept {
return *this = Modular(other);
}
constexpr Modular &operator+=(const Modular &other) noexcept {
if ((value += other.value) >= MOD)
value -= MOD;
return *this;
}
template <typename U> constexpr Modular &operator+=(const U &other) noexcept {
return *this += Modular(other);
}
constexpr Modular &operator-=(const Modular &other) noexcept {
if ((value -= other.value) < 0)
value += MOD;
return *this;
}
template <typename U> constexpr Modular &operator-=(const U &other) noexcept {
return *this -= Modular(other);
}
constexpr Modular &operator*=(const Modular &other) noexcept {
value = value * other.value % MOD;
return *this;
}
template <typename U> constexpr Modular &operator*=(const U &other) noexcept {
return *this *= Modular(other);
}
constexpr Modular &operator/=(const Modular &other) noexcept {
return *this *= Modular(inverse(other.value));
}
template <typename U> constexpr Modular &operator/=(const U &other) noexcept {
return *this *= Modular(inverse(normalize(other)));
}
constexpr Modular &operator++() noexcept { return *this += 1; }
constexpr Modular operator++(int) noexcept {
Modular ret(*this);
*this += 1;
return ret;
}
constexpr Modular &operator--() noexcept { return *this -= 1; }
constexpr Modular operator--(int) noexcept {
Modular ret(*this);
*this += 1;
return ret;
}
constexpr Modular operator-() const { return Modular(-value); }
friend constexpr bool operator==(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return lhs.value == rhs.value;
}
template <typename U>
friend constexpr bool operator==(const Modular<MOD> &lhs, U rhs) noexcept {
return lhs == Modular<MOD>(rhs);
}
template <typename U>
friend constexpr bool operator==(U lhs, const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) == rhs;
}
friend constexpr bool operator!=(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return !(lhs == rhs);
}
template <typename U>
friend constexpr bool operator!=(const Modular<MOD> &lhs, U rhs) noexcept {
return !(lhs == rhs);
}
template <typename U>
friend constexpr bool operator!=(U lhs, const Modular<MOD> rhs) noexcept {
return !(lhs == rhs);
}
friend constexpr bool operator<(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return lhs.value < rhs.value;
}
template <typename U>
friend constexpr bool operator<(const Modular<MOD> &lhs, U rhs) noexcept {
return lhs.value < rhs;
}
template <typename U>
friend constexpr bool operator<(U lhs, const Modular<MOD> &rhs) noexcept {
return lhs < rhs.value;
}
friend constexpr bool operator>(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return rhs.value < lhs.value;
}
template <typename U>
friend constexpr bool operator>(const Modular<MOD> &lhs, U rhs) noexcept {
return rhs.value < lhs;
}
template <typename U>
friend constexpr bool operator>(U lhs, const Modular<MOD> &rhs) noexcept {
return rhs < lhs.value;
}
friend constexpr bool operator<=(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return !(lhs.value > rhs.value);
}
template <typename U>
friend constexpr bool operator<=(const Modular<MOD> &lhs, U rhs) noexcept {
return !(lhs.value > rhs);
}
template <typename U>
friend constexpr bool operator<=(U lhs, const Modular<MOD> &rhs) noexcept {
return !(lhs < rhs.value);
}
friend constexpr bool operator>=(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return !(lhs.value < rhs.value);
}
template <typename U>
friend constexpr bool operator>=(const Modular<MOD> &lhs, U rhs) noexcept {
return !(lhs.value < rhs);
}
template <typename U>
friend constexpr bool operator>=(U lhs, const Modular<MOD> &rhs) noexcept {
return !(lhs < rhs.value);
}
friend constexpr Modular<MOD> operator+(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) += rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator+(const Modular<MOD> &lhs,
U rhs) noexcept {
return Modular<MOD>(lhs) += rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator+(U lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) += rhs;
}
friend constexpr Modular<MOD> operator-(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) -= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator-(const Modular<MOD> &lhs,
U rhs) noexcept {
return Modular<MOD>(lhs) -= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator-(U lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) -= rhs;
}
friend constexpr Modular<MOD> operator*(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) *= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator*(const Modular<MOD> &lhs,
U rhs) noexcept {
return Modular<MOD>(lhs) *= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator*(U lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) *= rhs;
}
friend constexpr Modular<MOD> operator/(const Modular<MOD> &lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) /= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator/(const Modular<MOD> &lhs,
U rhs) noexcept {
return Modular<MOD>(lhs) /= rhs;
}
template <typename U>
friend constexpr Modular<MOD> operator/(U lhs,
const Modular<MOD> &rhs) noexcept {
return Modular<MOD>(lhs) /= rhs;
}
friend std::ostream &operator<<(std::ostream &stream,
const Modular<MOD> &number) noexcept {
return stream << number.value;
}
friend std::istream &operator>>(std::istream &stream, Modular<MOD> &number) {
long long in;
stream >> in;
number.value = Modular<MOD>::normalize(in);
return stream;
}
constexpr int getmod() const { return MOD; }
};
template <int MOD, typename U>
Modular<MOD> power(const Modular<MOD> &x, const U &y) {
assert(y >= 0);
Modular<MOD> k = x, result = 1;
U p = y;
while (p > 0) {
if (p & 1)
result *= k;
k *= k;
p >>= 1;
}
return result;
}
template <int MOD> class BinaryCoefficients {
private:
vector<Modular<MOD>> fact_, inv_, finv_;
public:
constexpr BinaryCoefficients(int n = 2020200)
: fact_(n, 1), inv_(n, 1), finv_(n, 1) {
for (int i = 2; i < n; i++) {
fact_[i] = fact_[i - 1] * i;
inv_[i] = -inv_[MOD % i] * (MOD / i);
finv_[i] = finv_[i - 1] * inv_[i];
}
}
constexpr Modular<MOD> comb(int n, int k) const noexcept {
if (n < k || n < 0 || k < 0)
return 0;
return fact_[n] * finv_[k] * finv_[n - k];
}
constexpr Modular<MOD> fact(int n) const noexcept {
if (n < 0)
return 0;
return fact_[n];
}
constexpr Modular<MOD> inv(int n) const noexcept {
if (n < 0)
return 0;
return inv_[n];
}
constexpr Modular<MOD> finv(int n) const noexcept {
if (n < 0)
return 0;
return finv_[n];
}
};
constexpr int mod = 1000003;
using mint = Modular<mod>;
using bicoef = BinaryCoefficients<mod>;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
bicoef bc;
int q;
cin >> q;
while (q--) {
mint x, d;
long long n;
cin >> x >> d >> n;
if (d == 0) {
cout << power(x, n) << '\n';
continue;
}
mint k = x / d;
if ((long long)k == 0 || (long long)k + n - 1 >= mod) {
cout << 0 << '\n';
continue;
}
cout << bc.fact((long long)k + n - 1) * bc.finv((long long)k - 1) *
power(d, n)
<< '\n';
}
return 0;
} | [
"identifier.change",
"io.output.change",
"control_flow.branch.if.condition.change"
] | 837,405 | 837,406 | u817760251 | cpp |
p03027 | #pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define INIT \
std::cin.tie(0); \
std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t &x, t &y) { return x < y; }
#define DESC(t) [](t &x, t &y) { return x > y; }
#define PSORT(s, p, e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v, t) \
for_each((v).begin(), (v).end(), [](t &a) { cout << a << " "; }); \
cout << endl;
#define IN(a, x, b) (a <= x && x <= b)
template <class T> inline T CHMAX(T &x, const T y) {
return x = (x < y) ? y : x;
}
template <class T> inline T CHMIN(T &x, const T y) {
return x = (x > y) ? y : x;
}
#define OUT(dist) std::cout << (dist);
#define WS std::cout << " ";
#define NL std::cout << "\n"
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using V2 = vector<vector<T>>;
template <class T, int W = 255> using A = array<T, W>;
template <class T, int W = 255, int H = 255> using A2 = array<array<T, W>, W>;
// ---
template <class T = int, T P = 1000003> struct ModuloP {
T x;
ModuloP() : x(0) {}
ModuloP(T y) {
x = y % P;
if (x < 0)
x += P;
}
ModuloP<T> operator+(const ModuloP<T> y) { return (ModuloP<T>(x) += y); }
ModuloP<T> operator*(const ModuloP<T> y) { return (ModuloP<T>(x) *= y); }
ModuloP<T> operator-(const ModuloP<T> y) { return (ModuloP<T>(x) -= y); }
ModuloP<T> operator/(const ModuloP<T> y) { return (ModuloP<T>(x) /= y); }
ModuloP<T> operator-() {
return (x == 0) ? ModuloP<T>(P - x) : ModuloP<T>(x);
}
ModuloP<T> &operator+=(ModuloP<T> y) {
x += y.x;
if (x >= P)
x -= P;
return *this;
}
ModuloP<T> &operator*=(ModuloP<T> y) {
x = (1LL * x * y.x) % P;
return *this;
}
ModuloP<T> &operator-=(ModuloP<T> y) {
x += P - y.x;
if (x >= P)
x -= P;
return *this;
}
ModuloP<T> &operator/=(ModuloP<T> y) { return ((*this) *= y.fermetinv()); }
bool operator==(const ModuloP<T> y) { return x == y.x; }
bool operator!=(const ModuloP<T> y) { return x != y.x; }
bool operator<(const ModuloP<T> y) { return x < y.x; }
bool operator<=(const ModuloP<T> y) { return x <= y.x; }
bool operator>(const ModuloP<T> y) { return x > y.x; }
bool operator>=(const ModuloP<T> y) { return x >= y.x; }
ModuloP<T> pow(T n) { // O(log n)
ModuloP<T> ans(1), t(x);
while (n) {
if (n & 1)
ans *= t;
t *= t;
n >>= 1;
}
return ans;
}
ModuloP<T> fermetinv() { return pow(P - 2); }
};
using MP = ModuloP<int>;
// ---
V<MP> fact;
int main() {
INIT;
int Q;
cin >> Q;
fact.resize(1000003);
fact[1] = MP(1);
for (int i = 2; i < 1000003; i++) {
fact[i] = fact[i - 1] * MP(i);
}
REP(i, Q) {
int x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << MP(x).pow(n).x << "\n";
continue;
}
MP m = MP(x) / MP(d);
if (1000003 <= m.x + n - 1) {
cout << "Hello" << 0 << "\n";
continue;
}
MP ans = fact[m.x + n - 1] * fact[m.x - 1].fermetinv();
MP dn(d);
ans *= dn.pow(n);
cout << ans.x << "\n";
}
}
| #pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define INIT \
std::cin.tie(0); \
std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t &x, t &y) { return x < y; }
#define DESC(t) [](t &x, t &y) { return x > y; }
#define PSORT(s, p, e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v, t) \
for_each((v).begin(), (v).end(), [](t &a) { cout << a << " "; }); \
cout << endl;
#define IN(a, x, b) (a <= x && x <= b)
template <class T> inline T CHMAX(T &x, const T y) {
return x = (x < y) ? y : x;
}
template <class T> inline T CHMIN(T &x, const T y) {
return x = (x > y) ? y : x;
}
#define OUT(dist) std::cout << (dist);
#define WS std::cout << " ";
#define NL std::cout << "\n"
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using V2 = vector<vector<T>>;
template <class T, int W = 255> using A = array<T, W>;
template <class T, int W = 255, int H = 255> using A2 = array<array<T, W>, W>;
// ---
template <class T = int, T P = 1000003> struct ModuloP {
T x;
ModuloP() : x(0) {}
ModuloP(T y) {
x = y % P;
if (x < 0)
x += P;
}
ModuloP<T> operator+(const ModuloP<T> y) { return (ModuloP<T>(x) += y); }
ModuloP<T> operator*(const ModuloP<T> y) { return (ModuloP<T>(x) *= y); }
ModuloP<T> operator-(const ModuloP<T> y) { return (ModuloP<T>(x) -= y); }
ModuloP<T> operator/(const ModuloP<T> y) { return (ModuloP<T>(x) /= y); }
ModuloP<T> operator-() {
return (x == 0) ? ModuloP<T>(P - x) : ModuloP<T>(x);
}
ModuloP<T> &operator+=(ModuloP<T> y) {
x += y.x;
if (x >= P)
x -= P;
return *this;
}
ModuloP<T> &operator*=(ModuloP<T> y) {
x = (1LL * x * y.x) % P;
return *this;
}
ModuloP<T> &operator-=(ModuloP<T> y) {
x += P - y.x;
if (x >= P)
x -= P;
return *this;
}
ModuloP<T> &operator/=(ModuloP<T> y) { return ((*this) *= y.fermetinv()); }
bool operator==(const ModuloP<T> y) { return x == y.x; }
bool operator!=(const ModuloP<T> y) { return x != y.x; }
bool operator<(const ModuloP<T> y) { return x < y.x; }
bool operator<=(const ModuloP<T> y) { return x <= y.x; }
bool operator>(const ModuloP<T> y) { return x > y.x; }
bool operator>=(const ModuloP<T> y) { return x >= y.x; }
ModuloP<T> pow(T n) { // O(log n)
ModuloP<T> ans(1), t(x);
while (n) {
if (n & 1)
ans *= t;
t *= t;
n >>= 1;
}
return ans;
}
ModuloP<T> fermetinv() { return pow(P - 2); }
};
using MP = ModuloP<int>;
// ---
V<MP> fact;
int main() {
INIT;
int Q;
cin >> Q;
fact.resize(1000003);
fact[1] = MP(1);
for (int i = 2; i < 1000003; i++) {
fact[i] = fact[i - 1] * MP(i);
}
REP(i, Q) {
int x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << MP(x).pow(n).x << "\n";
continue;
}
MP m = MP(x) / MP(d);
if (1000003 <= m.x + n - 1) {
cout << 0 << "\n";
continue;
}
MP ans = fact[m.x + n - 1] * fact[m.x - 1].fermetinv();
MP dn(d);
ans *= dn.pow(n);
cout << ans.x << "\n";
}
}
| [
"expression.operation.binary.remove"
] | 837,407 | 837,408 | u685774550 | cpp |
p03027 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, N) for (i = 0; i < N; i++)
#define MAX_I INT_MAX // 1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX // 1e9
#define MAX_LL LLONG_MAX // 1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX // 1e19
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<char, char> PCC;
typedef pair<ll, ll> PLL;
typedef pair<char, int> PCI;
typedef pair<int, char> PIC;
typedef pair<ll, int> PLI;
typedef pair<int, ll> PIL;
typedef pair<ll, char> PLC;
typedef pair<char, ll> PCL;
const int MAX = 1e6 + 3;
const ll MOD = 1e6 + 3;
ll 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] = (ll)fac[i - 1] * i % MOD;
inv[i] = (ll)MOD - inv[MOD % i] * 1ll * (MOD / i) % MOD;
finv[i] = (ll)finv[i - 1] * inv[i] % MOD;
}
}
ll mod_pow(ll x, ll p) {
ll res = 1;
while (p) {
if (p & 1)
res = res * x % MOD;
res = res * res % MOD;
p >>= 1;
}
return res;
}
int main(void) {
int Q;
cin >> Q;
COMinit();
while (Q--) {
ll x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << mod_pow(x, n) << endl;
continue;
}
x = x * inv[d] % MOD;
ll ans = mod_pow(d, n);
if (x + n - 1 >= MOD)
cout << 0LL << endl;
else {
ans = ans * fac[x + n - 1] % MOD;
ans = ans * finv[x - 1] % MOD;
cout << ans << endl;
}
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define REP(i, N) for (i = 0; i < N; i++)
#define MAX_I INT_MAX // 1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX // 1e9
#define MAX_LL LLONG_MAX // 1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX // 1e19
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<char, char> PCC;
typedef pair<ll, ll> PLL;
typedef pair<char, int> PCI;
typedef pair<int, char> PIC;
typedef pair<ll, int> PLI;
typedef pair<int, ll> PIL;
typedef pair<ll, char> PLC;
typedef pair<char, ll> PCL;
const int MAX = 1e6 + 3;
const ll MOD = 1e6 + 3;
ll 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] = (ll)fac[i - 1] * i % MOD;
inv[i] = (ll)MOD - inv[MOD % i] * 1ll * (MOD / i) % MOD;
finv[i] = (ll)finv[i - 1] * inv[i] % MOD;
}
}
ll mod_pow(ll x, ll p) {
ll res = 1;
while (p) {
if (p & 1)
res = res * x % MOD;
x = x * x % MOD;
p >>= 1;
}
return res;
}
int main(void) {
int Q;
cin >> Q;
COMinit();
while (Q--) {
ll x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << mod_pow(x, n) << endl;
continue;
}
x = x * inv[d] % MOD;
ll ans = mod_pow(d, n);
if (x + n - 1 >= MOD)
cout << 0LL << endl;
else {
ans = ans * fac[x + n - 1] % MOD;
ans = ans * finv[x - 1] % MOD;
cout << ans << endl;
}
}
return 0;
}
| [
"assignment.variable.change",
"identifier.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 837,409 | 837,410 | u069450081 | cpp |
p03027 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define DEBUG(x) cout << #x << ": " << (x) << '\n'
#define DEBUG_VEC(v) \
cout << #v << ":"; \
REP(i, v.size()) cout << ' ' << v[i]; \
cout << '\n'
#define ALL(a) (a).begin(), (a).end()
template <typename T> inline void CHMAX(T &a, const T b) {
if (a < b)
a = b;
}
template <typename T> inline void CHMIN(T &a, const T b) {
if (a > b)
a = b;
}
constexpr ll MOD = 1000003ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a) % MOD + MOD) % MOD
const double EPS = 1e-11;
#define EQ0(x) (abs((x)) < EPS)
#define EQ(a, b) (abs((a) - (b)) < EPS)
template <typename T> struct Modint {
using Type = typename decay<decltype(T::value)>::type;
Type val;
constexpr Modint() noexcept : val() {}
template <typename U> constexpr Modint(const U &x) noexcept {
val = normalize(x);
}
template <typename U> static Type normalize(const U &x) noexcept {
Type v;
if (-mod() <= x && x < mod())
v = static_cast<Type>(x);
else
v = static_cast<Type>(x % mod());
if (v < 0)
v += mod();
return v;
}
constexpr Type &value() noexcept { return val; }
constexpr const Type &value() const noexcept { return val; }
template <typename U> constexpr explicit operator U() const noexcept {
return static_cast<U>(val);
}
constexpr static Type mod() noexcept { return T::value; }
constexpr Modint &operator+=(const Modint &rhs) noexcept {
if ((val += rhs.val) >= mod())
val -= mod();
return *this;
}
template <typename U> constexpr Modint &operator+=(const U &rhs) noexcept {
return *this += Modint(rhs);
}
constexpr Modint &operator-=(const Modint &rhs) noexcept {
if ((val -= rhs.val) < 0)
val += mod();
return *this;
}
template <typename U> constexpr Modint &operator-=(const U &rhs) noexcept {
return *this -= Modint(rhs);
}
constexpr Modint &operator++() noexcept { return *this += 1; }
constexpr Modint &operator--() noexcept { return *this -= 1; }
constexpr Modint operator++(int) noexcept {
Modint result(*this);
*this += 1;
return result;
}
constexpr Modint operator--(int) noexcept {
Modint result(*this);
*this -= 1;
return result;
}
constexpr Modint operator-() const noexcept { return Modint(-val); }
constexpr Modint &operator*=(const Modint rhs) noexcept {
val = val * rhs.val % mod();
return *this;
}
constexpr Modint &operator/=(const Modint &rhs) noexcept {
Type x = rhs.val, m = mod(), u = 0, v = 1;
while (x != 0) {
Type t = m / x;
m -= t * x;
swap(x, m);
u -= t * v;
swap(u, v);
}
assert(m == 1);
return *this *= Modint(u);
}
};
template <typename T>
constexpr bool operator==(const Modint<T> &lhs, const Modint<T> &rhs) noexcept {
return lhs.val == rhs.val;
}
template <typename T, typename U>
constexpr bool operator==(const Modint<T> &lhs, U rhs) noexcept {
return lhs == Modint<T>(rhs);
}
template <typename T, typename U>
constexpr bool operator==(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) == rhs;
}
template <typename T>
constexpr bool operator!=(const Modint<T> &lhs, const Modint<T> &rhs) noexcept {
return !(lhs == rhs);
}
template <typename T, typename U>
constexpr bool operator!=(const Modint<T> &lhs, U rhs) noexcept {
return !(lhs == rhs);
}
template <typename T, typename U>
constexpr bool operator!=(U lhs, const Modint<T> &rhs) noexcept {
return !(lhs == rhs);
}
template <typename T>
constexpr bool operator<(const Modint<T> &lhs, const Modint<T> &rhs) noexcept {
return lhs.val < rhs.val;
}
template <typename T, typename U>
constexpr bool operator<(const Modint<T> &lhs, U rhs) noexcept {
return lhs < Modint<T>(rhs);
}
template <typename T, typename U>
constexpr bool operator<(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) < rhs;
}
template <typename T>
constexpr bool operator>(const Modint<T> &lhs, const Modint<T> &rhs) noexcept {
return lhs.val > rhs.val;
}
template <typename T, typename U>
constexpr bool operator>(const Modint<T> &lhs, U rhs) noexcept {
return lhs > Modint<T>(rhs);
}
template <typename T, typename U>
constexpr bool operator>(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) > rhs;
}
template <typename T>
constexpr Modint<T> operator+(const Modint<T> &lhs,
const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) += rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator+(const Modint<T> &lhs, U rhs) noexcept {
return Modint<T>(lhs) += rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator+(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) += rhs;
}
template <typename T>
constexpr Modint<T> operator-(const Modint<T> &lhs,
const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) -= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator-(const Modint<T> &lhs, U rhs) noexcept {
return Modint<T>(lhs) -= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator-(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) -= rhs;
}
template <typename T>
constexpr Modint<T> operator*(const Modint<T> &lhs,
const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) *= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator*(const Modint<T> &lhs, U rhs) noexcept {
return Modint<T>(lhs) *= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator*(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) *= rhs;
}
template <typename T>
constexpr Modint<T> operator/(const Modint<T> &lhs,
const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) /= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator/(const Modint<T> &lhs, U rhs) noexcept {
return Modint<T>(lhs) /= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator/(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) /= rhs;
}
template <typename T, typename U>
Modint<T> constexpr power(const Modint<T> &a, const U &b) noexcept {
Modint<T> x = a, res = 1;
U p = b;
while (p > 0) {
if (p & 1)
res *= x;
x *= x;
p >>= 1;
}
return res;
}
template <class T> struct Combination {
using Type = typename decay<decltype(T::value)>::type;
// vector<Modint<T>> fact_, finv_;
// constexpr Combination(int n) noexcept : fact_(n+1, 1), finv_(n+1, 1) {
// Type MOD=fact_[0].mod();
// FOR(i, 2, n+1){
// fact_[i]=fact_[i-1]*i;
// }
// finv_[n]=power(fact_[n], MOD-2);
// FORR(i, 3, n+1){
// finv_[i-1]=finv_[i]*i;
// }
// }
// iの逆元も求める場合
vector<Modint<T>> fact_, inv_, finv_;
constexpr Combination(int n) noexcept
: fact_(n + 1, 1), inv_(n + 1, 1), finv_(n + 1, 1) {
Type MOD = fact_[0].mod();
FOR(i, 2, n + 1) {
fact_[i] = fact_[i - 1] * i;
inv_[i] = -inv_[MOD % i] * (MOD / i);
finv_[i] = finv_[i - 1] * inv_[i];
}
}
constexpr Modint<T> inv(int n) const noexcept {
if (n < 0)
return 0;
return inv_[n];
}
constexpr Modint<T> com(int n, int k) const noexcept {
if (n < k || n < 0 || k < 0)
return Modint<T>(0);
return fact_[n] * finv_[k] * finv_[n - k];
}
constexpr Modint<T> fact(int n) const noexcept {
if (n < 0)
return Modint<T>(0);
return fact_[n];
}
constexpr Modint<T> finv(int n) const noexcept {
if (n < 0)
return Modint<T>(0);
return finv_[n];
}
};
template <typename T>
constexpr ostream &operator<<(ostream &stream,
const Modint<T> &number) noexcept {
return stream << number.val;
}
template <typename T>
constexpr istream &operator>>(istream &stream, Modint<T> &number) noexcept {
return stream >> number.val;
}
using Mint = Modint<integral_constant<decay<decltype(MOD)>::type, MOD>>;
using Comb = Combination<integral_constant<decay<decltype(MOD)>::type, MOD>>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
// cout<<setprecision(10)<<fixed;
int Q, d, n;
Mint x;
Comb comb(MOD - 1);
cin >> Q;
REP(i, Q) {
cin >> x;
cin >> d >> n;
if (x == 0) {
cout << 0 << '\n';
continue;
}
if (d == 0) {
cout << power(x, n) << '\n';
continue;
}
Mint tmp = x * comb.inv(d);
if (tmp + n > MOD - 1) {
cout << 0 << '\n';
continue;
}
if (tmp > 1) {
cout << comb.fact(tmp.val + n - 1) * comb.finv(tmp.val - 1) *
power(Mint(d), n)
<< '\n';
} else {
cout << comb.fact(tmp.val + n - 1) * power(Mint(d), n) << '\n';
}
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define DEBUG(x) cout << #x << ": " << (x) << '\n'
#define DEBUG_VEC(v) \
cout << #v << ":"; \
REP(i, v.size()) cout << ' ' << v[i]; \
cout << '\n'
#define ALL(a) (a).begin(), (a).end()
template <typename T> inline void CHMAX(T &a, const T b) {
if (a < b)
a = b;
}
template <typename T> inline void CHMIN(T &a, const T b) {
if (a > b)
a = b;
}
constexpr ll MOD = 1000003ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a) % MOD + MOD) % MOD
const double EPS = 1e-11;
#define EQ0(x) (abs((x)) < EPS)
#define EQ(a, b) (abs((a) - (b)) < EPS)
template <typename T> struct Modint {
using Type = typename decay<decltype(T::value)>::type;
Type val;
constexpr Modint() noexcept : val() {}
template <typename U> constexpr Modint(const U &x) noexcept {
val = normalize(x);
}
template <typename U> static Type normalize(const U &x) noexcept {
Type v;
if (-mod() <= x && x < mod())
v = static_cast<Type>(x);
else
v = static_cast<Type>(x % mod());
if (v < 0)
v += mod();
return v;
}
constexpr Type &value() noexcept { return val; }
constexpr const Type &value() const noexcept { return val; }
template <typename U> constexpr explicit operator U() const noexcept {
return static_cast<U>(val);
}
constexpr static Type mod() noexcept { return T::value; }
constexpr Modint &operator+=(const Modint &rhs) noexcept {
if ((val += rhs.val) >= mod())
val -= mod();
return *this;
}
template <typename U> constexpr Modint &operator+=(const U &rhs) noexcept {
return *this += Modint(rhs);
}
constexpr Modint &operator-=(const Modint &rhs) noexcept {
if ((val -= rhs.val) < 0)
val += mod();
return *this;
}
template <typename U> constexpr Modint &operator-=(const U &rhs) noexcept {
return *this -= Modint(rhs);
}
constexpr Modint &operator++() noexcept { return *this += 1; }
constexpr Modint &operator--() noexcept { return *this -= 1; }
constexpr Modint operator++(int) noexcept {
Modint result(*this);
*this += 1;
return result;
}
constexpr Modint operator--(int) noexcept {
Modint result(*this);
*this -= 1;
return result;
}
constexpr Modint operator-() const noexcept { return Modint(-val); }
constexpr Modint &operator*=(const Modint rhs) noexcept {
val = val * rhs.val % mod();
return *this;
}
constexpr Modint &operator/=(const Modint &rhs) noexcept {
Type x = rhs.val, m = mod(), u = 0, v = 1;
while (x != 0) {
Type t = m / x;
m -= t * x;
swap(x, m);
u -= t * v;
swap(u, v);
}
assert(m == 1);
return *this *= Modint(u);
}
};
template <typename T>
constexpr bool operator==(const Modint<T> &lhs, const Modint<T> &rhs) noexcept {
return lhs.val == rhs.val;
}
template <typename T, typename U>
constexpr bool operator==(const Modint<T> &lhs, U rhs) noexcept {
return lhs == Modint<T>(rhs);
}
template <typename T, typename U>
constexpr bool operator==(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) == rhs;
}
template <typename T>
constexpr bool operator!=(const Modint<T> &lhs, const Modint<T> &rhs) noexcept {
return !(lhs == rhs);
}
template <typename T, typename U>
constexpr bool operator!=(const Modint<T> &lhs, U rhs) noexcept {
return !(lhs == rhs);
}
template <typename T, typename U>
constexpr bool operator!=(U lhs, const Modint<T> &rhs) noexcept {
return !(lhs == rhs);
}
template <typename T>
constexpr bool operator<(const Modint<T> &lhs, const Modint<T> &rhs) noexcept {
return lhs.val < rhs.val;
}
template <typename T, typename U>
constexpr bool operator<(const Modint<T> &lhs, U rhs) noexcept {
return lhs < Modint<T>(rhs);
}
template <typename T, typename U>
constexpr bool operator<(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) < rhs;
}
template <typename T>
constexpr bool operator>(const Modint<T> &lhs, const Modint<T> &rhs) noexcept {
return lhs.val > rhs.val;
}
template <typename T, typename U>
constexpr bool operator>(const Modint<T> &lhs, U rhs) noexcept {
return lhs > Modint<T>(rhs);
}
template <typename T, typename U>
constexpr bool operator>(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) > rhs;
}
template <typename T>
constexpr Modint<T> operator+(const Modint<T> &lhs,
const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) += rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator+(const Modint<T> &lhs, U rhs) noexcept {
return Modint<T>(lhs) += rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator+(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) += rhs;
}
template <typename T>
constexpr Modint<T> operator-(const Modint<T> &lhs,
const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) -= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator-(const Modint<T> &lhs, U rhs) noexcept {
return Modint<T>(lhs) -= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator-(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) -= rhs;
}
template <typename T>
constexpr Modint<T> operator*(const Modint<T> &lhs,
const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) *= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator*(const Modint<T> &lhs, U rhs) noexcept {
return Modint<T>(lhs) *= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator*(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) *= rhs;
}
template <typename T>
constexpr Modint<T> operator/(const Modint<T> &lhs,
const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) /= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator/(const Modint<T> &lhs, U rhs) noexcept {
return Modint<T>(lhs) /= rhs;
}
template <typename T, typename U>
constexpr Modint<T> operator/(U lhs, const Modint<T> &rhs) noexcept {
return Modint<T>(lhs) /= rhs;
}
template <typename T, typename U>
Modint<T> constexpr power(const Modint<T> &a, const U &b) noexcept {
Modint<T> x = a, res = 1;
U p = b;
while (p > 0) {
if (p & 1)
res *= x;
x *= x;
p >>= 1;
}
return res;
}
template <class T> struct Combination {
using Type = typename decay<decltype(T::value)>::type;
// vector<Modint<T>> fact_, finv_;
// constexpr Combination(int n) noexcept : fact_(n+1, 1), finv_(n+1, 1) {
// Type MOD=fact_[0].mod();
// FOR(i, 2, n+1){
// fact_[i]=fact_[i-1]*i;
// }
// finv_[n]=power(fact_[n], MOD-2);
// FORR(i, 3, n+1){
// finv_[i-1]=finv_[i]*i;
// }
// }
// iの逆元も求める場合
vector<Modint<T>> fact_, inv_, finv_;
constexpr Combination(int n) noexcept
: fact_(n + 1, 1), inv_(n + 1, 1), finv_(n + 1, 1) {
Type MOD = fact_[0].mod();
FOR(i, 2, n + 1) {
fact_[i] = fact_[i - 1] * i;
inv_[i] = -inv_[MOD % i] * (MOD / i);
finv_[i] = finv_[i - 1] * inv_[i];
}
}
constexpr Modint<T> inv(int n) const noexcept {
if (n < 0)
return 0;
return inv_[n];
}
constexpr Modint<T> com(int n, int k) const noexcept {
if (n < k || n < 0 || k < 0)
return Modint<T>(0);
return fact_[n] * finv_[k] * finv_[n - k];
}
constexpr Modint<T> fact(int n) const noexcept {
if (n < 0)
return Modint<T>(0);
return fact_[n];
}
constexpr Modint<T> finv(int n) const noexcept {
if (n < 0)
return Modint<T>(0);
return finv_[n];
}
};
template <typename T>
constexpr ostream &operator<<(ostream &stream,
const Modint<T> &number) noexcept {
return stream << number.val;
}
template <typename T>
constexpr istream &operator>>(istream &stream, Modint<T> &number) noexcept {
return stream >> number.val;
}
using Mint = Modint<integral_constant<decay<decltype(MOD)>::type, MOD>>;
using Comb = Combination<integral_constant<decay<decltype(MOD)>::type, MOD>>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
// cout<<setprecision(10)<<fixed;
int Q, d, n;
Mint x;
Comb comb(MOD - 1);
cin >> Q;
REP(i, Q) {
cin >> x;
cin >> d >> n;
if (x == 0) {
cout << 0 << '\n';
continue;
}
if (d == 0) {
cout << power(x, n) << '\n';
continue;
}
Mint tmp = x * comb.inv(d);
if (tmp.val + n > MOD) {
cout << 0 << '\n';
continue;
}
if (tmp > 1) {
cout << comb.fact(tmp.val + n - 1) * comb.finv(tmp.val - 1) *
power(Mint(d), n)
<< '\n';
} else {
cout << comb.fact(tmp.val + n - 1) * power(Mint(d), n) << '\n';
}
}
return 0;
}
| [
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 837,411 | 837,412 | u833393891 | cpp |
p03027 | #include <bits/stdc++.h>
#define l_ength size
const int inf = (1 << 30);
const int mod = 1000003;
using ll = long long;
using namespace std;
ll modPow(ll a, int n) {
ll res = 1;
int i = 1;
while (i <= n) {
if (n & i) {
res *= a;
res %= mod;
}
i <<= 1;
a = a * a % mod;
}
return res;
}
ll mf[2000200];
ll dvf[2000200];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int q;
cin >> q;
mf[0] = 1;
dvf[0] = 1;
for (int k = 1; k <= 2000100; ++k) {
mf[k] = (k * mf[k - 1]) % mod;
dvf[k] = (modPow(k, mod - 2) * dvf[k - 1]) % mod;
}
while (q--) {
ll x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << modPow(x, n) << endl;
continue;
}
if (n >= mod)
cout << 0 << endl;
if (d != 1) {
x = (x * modPow(d, mod - 2)) % mod;
} else
cout << (modPow(d, n) * (mf[x + n - 1] * dvf[x - 1] % mod)) % mod << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define l_ength size
const int inf = (1 << 30);
const int mod = 1000003;
using ll = long long;
using namespace std;
ll modPow(ll a, int n) {
ll res = 1;
int i = 1;
while (i <= n) {
if (n & i) {
res *= a;
res %= mod;
}
i <<= 1;
a = a * a % mod;
}
return res;
}
ll mf[2000200];
ll dvf[2000200];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int q;
cin >> q;
mf[0] = 1;
dvf[0] = 1;
for (int k = 1; k <= 2000100; ++k) {
mf[k] = (k * mf[k - 1]) % mod;
dvf[k] = (modPow(k, mod - 2) * dvf[k - 1]) % mod;
}
while (q--) {
ll x, d, n;
cin >> x >> d >> n;
if (d == 0) {
cout << modPow(x, n) << endl;
continue;
}
if (n >= mod) {
cout << 0 << endl;
continue;
}
if (d != 1) {
x = (x * modPow(d, mod - 2)) % mod;
}
cout << (modPow(d, n) * (mf[x + n - 1] * dvf[x - 1] % mod)) % mod << endl;
}
return 0;
} | [
"control_flow.branch.else.remove"
] | 837,415 | 837,414 | u268977772 | cpp |
p03027 | #include <bits/stdc++.h>
#define l_ength size
const int inf = (1 << 30);
const int mod = 1000003;
using ll = long long;
using namespace std;
ll modPow(ll a, int n) {
ll res = 1;
int i = 1;
while (i <= n) {
if (n & i) {
res *= a;
res %= mod;
}
i <<= 1;
a = a * a % mod;
}
return res;
}
ll mf[3000100];
ll dvf[3000100];
int main() {
int q;
cin >> q;
mf[0] = 1;
dvf[0] = 1;
for (int k = 1; k <= 3000000; ++k) {
mf[k] = (k * mf[k - 1]) % mod;
dvf[k] = (modPow(k, mod - 2) * dvf[k - 1]) % mod;
}
while (q--) {
ll x, d, n;
cin >> x >> d >> n;
if (d != 1) {
if (d == 0) {
cout << modPow(x, n) << endl;
break;
}
x = (x * modPow(d, mod - 2)) % mod;
}
if (n >= mod)
cout << 0 << endl;
else
cout << (modPow(d, n) * (mf[x + n - 1] * dvf[x - 1] % mod)) % mod << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define l_ength size
const int inf = (1 << 30);
const int mod = 1000003;
using ll = long long;
using namespace std;
ll modPow(ll a, int n) {
ll res = 1;
int i = 1;
while (i <= n) {
if (n & i) {
res *= a;
res %= mod;
}
i <<= 1;
a = a * a % mod;
}
return res;
}
ll mf[3000100];
ll dvf[3000100];
int main() {
int q;
cin >> q;
mf[0] = 1;
dvf[0] = 1;
for (int k = 1; k <= 3000000; ++k) {
mf[k] = (k * mf[k - 1]) % mod;
dvf[k] = (modPow(k, mod - 2) * dvf[k - 1]) % mod;
}
while (q--) {
ll x, d, n;
cin >> x >> d >> n;
if (d != 1) {
if (d == 0) {
cout << modPow(x, n) << endl;
continue;
}
x = (x * modPow(d, mod - 2)) % mod;
}
if (n >= mod)
cout << 0 << endl;
else
cout << (modPow(d, n) * (mf[x + n - 1] * dvf[x - 1] % mod)) % mod << endl;
}
return 0;
} | [
"control_flow.break.remove",
"control_flow.continue.add"
] | 837,416 | 837,417 | u268977772 | cpp |
p03027 | #include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int mod = 1000003;
///////////// modの計算
long long mod_adjust(long long a) { // 余りをとる(0~mod-1に調整する)
if (a > mod) {
return a % mod;
}
if (a < 0) {
a *= -1;
a %= mod;
return mod - a;
}
return a;
}
int mod_adjust(int a) { // 余りをとる(0~mod-1に調整する)
return (int)mod_adjust((long long)a);
}
int mod_add(int a, int b) { // 足し算
a = mod_adjust(a), b = mod_adjust(b);
long long k = a % mod;
k += b % mod;
k %= mod;
return (int)k;
}
int mod_sub(int a, int b) { // 引き算
long long k = mod_adjust((long long)a);
k += mod_adjust((long long)b);
k %= mod;
return (int)k;
}
int mod_multi(int a, int b) { // 掛け算
long long k = mod_adjust((long long)a);
k *= mod_adjust((long long)b);
k %= mod;
return (int)k;
}
int mod_inv(int a) { // 逆元
a = mod_adjust(a);
if (a == 1) {
return 1;
}
long long p = mod, q = a, m = 0, n = 1, r, c;
while (q > 1) {
r = p % q;
c = p / q;
c = mod_adjust(m - n * c);
p = q, m = n, q = r, n = c;
}
return n;
}
int mod_div(int a, int b) { // 割り算
return mod_multi(a, mod_inv(b));
}
int mod_pow(int x, int n) { // 累乗(logNオーダーなので速い)
if (n < 0) {
return mod_pow(mod_div(1, x), -n);
}
if (n == 0) {
return 1;
}
if (n == 1) {
return x;
}
if (n % 2 == 0) {
int k = mod_pow(x, n / 2);
return mod_multi(k, k);
} else {
int k = mod_pow(x, n / 2);
return mod_multi(mod_multi(k, k), x);
}
}
int *factorial = NULL; // 階乗
int *factorial_inv = NULL; // 階乗の逆元
// 階乗を事前に計算しておく関数。
// Nはmod_combination(n, r)で呼び出されうる最大の数。
void calc_factorial(
int N) { ////////////////////////// 初めに必ず呼び出すこと!!!
factorial = new int[N + 1];
factorial_inv = new int[N + 1];
factorial[0] = 1;
factorial_inv[0] = 1;
for (int i = 1; i <= N; i++) {
if (i >= mod) {
factorial[i] = 0;
factorial_inv[i] = 0;
} else {
factorial[i] = mod_multi(factorial[i - 1], i);
factorial_inv[i] = mod_inv(factorial[i]);
}
}
}
int mod_combination(int n, int r) { // nCr を計算する
if (n < 0 || r < 0 || r > n) {
return 0;
}
return mod_multi(factorial[n],
mod_multi(factorial_inv[n - r], factorial_inv[r]));
}
int main() {
calc_factorial(mod);
int Q;
cin >> Q;
for (int q = 0; q < Q; q++) {
int x, d, n;
cin >> x >> d >> n;
x = x % mod, d = d % mod;
if (d == 0) {
cout << mod_pow(x, n) << endl;
continue;
}
x = mod_div(x, d);
int a = x - 1, b = x + n - 1;
if (b >= mod) {
cout << 0 << endl;
}
int prod = mod_div(factorial[b], factorial[a]);
prod = mod_multi(prod, mod_pow(d, n));
cout << prod << endl;
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int mod = 1000003;
///////////// modの計算
long long mod_adjust(long long a) { // 余りをとる(0~mod-1に調整する)
if (a > mod) {
return a % mod;
}
if (a < 0) {
a *= -1;
a %= mod;
return mod - a;
}
return a;
}
int mod_adjust(int a) { // 余りをとる(0~mod-1に調整する)
return (int)mod_adjust((long long)a);
}
int mod_add(int a, int b) { // 足し算
a = mod_adjust(a), b = mod_adjust(b);
long long k = a % mod;
k += b % mod;
k %= mod;
return (int)k;
}
int mod_sub(int a, int b) { // 引き算
long long k = mod_adjust((long long)a);
k += mod_adjust((long long)b);
k %= mod;
return (int)k;
}
int mod_multi(int a, int b) { // 掛け算
long long k = mod_adjust((long long)a);
k *= mod_adjust((long long)b);
k %= mod;
return (int)k;
}
int mod_inv(int a) { // 逆元
a = mod_adjust(a);
if (a == 1) {
return 1;
}
long long p = mod, q = a, m = 0, n = 1, r, c;
while (q > 1) {
r = p % q;
c = p / q;
c = mod_adjust(m - n * c);
p = q, m = n, q = r, n = c;
}
return n;
}
int mod_div(int a, int b) { // 割り算
return mod_multi(a, mod_inv(b));
}
int mod_pow(int x, int n) { // 累乗(logNオーダーなので速い)
if (n < 0) {
return mod_pow(mod_div(1, x), -n);
}
if (n == 0) {
return 1;
}
if (n == 1) {
return x;
}
if (n % 2 == 0) {
int k = mod_pow(x, n / 2);
return mod_multi(k, k);
} else {
int k = mod_pow(x, n / 2);
return mod_multi(mod_multi(k, k), x);
}
}
int *factorial = NULL; // 階乗
int *factorial_inv = NULL; // 階乗の逆元
// 階乗を事前に計算しておく関数。
// Nはmod_combination(n, r)で呼び出されうる最大の数。
void calc_factorial(
int N) { ////////////////////////// 初めに必ず呼び出すこと!!!
factorial = new int[N + 1];
factorial_inv = new int[N + 1];
factorial[0] = 1;
factorial_inv[0] = 1;
for (int i = 1; i <= N; i++) {
if (i >= mod) {
factorial[i] = 0;
factorial_inv[i] = 0;
} else {
factorial[i] = mod_multi(factorial[i - 1], i);
factorial_inv[i] = mod_inv(factorial[i]);
}
}
}
int mod_combination(int n, int r) { // nCr を計算する
if (n < 0 || r < 0 || r > n) {
return 0;
}
return mod_multi(factorial[n],
mod_multi(factorial_inv[n - r], factorial_inv[r]));
}
int main() {
calc_factorial(mod);
int Q;
cin >> Q;
for (int q = 0; q < Q; q++) {
int x, d, n;
cin >> x >> d >> n;
x = x % mod, d = d % mod;
if (d == 0) {
cout << mod_pow(x, n) << endl;
continue;
}
x = mod_div(x, d);
int a = x - 1, b = x + n - 1;
if (b >= mod) {
cout << 0 << endl;
continue;
}
int prod = mod_div(factorial[b], factorial[a]);
prod = mod_multi(prod, mod_pow(d, n));
cout << prod << endl;
}
return 0;
} | [] | 837,420 | 837,421 | u793275002 | cpp |
p03027 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const long long Mod = 1000003LL;
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;
}
long long poww(long long x, long long n, long long mod) {
long long ans = 1;
while (n > 0) {
if (n % 2 == 1) {
ans *= x;
ans %= mod;
}
n /= 2;
x = x * x;
x %= mod;
}
return ans;
}
int main() {
vector<long long> kaiz;
kaiz.push_back(0);
kaiz.push_back(1);
for (long i = 2; i < Mod; i++) {
kaiz.push_back((kaiz[i - 1] * i) % Mod);
}
int q;
cin >> q;
long long x, d, n;
long long k;
long long ans;
rep(i, q) {
cin >> x >> d >> n;
if (d == 0) {
cout << (x * n) % Mod << endl;
} else {
k = (x * modinv(d, Mod)) % Mod;
if (k + n - 1 >= Mod) {
cout << 0 << endl;
} else {
ans = kaiz[k + n - 1] * modinv(kaiz[k - 1], Mod);
ans %= Mod;
cout << (ans * poww(d, n, Mod)) % Mod << endl;
}
}
}
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const long long Mod = 1000003LL;
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;
}
long long poww(long long x, long long n, long long mod) {
long long ans = 1;
while (n > 0) {
if (n % 2 == 1) {
ans *= x;
ans %= mod;
}
n /= 2;
x = x * x;
x %= mod;
}
return ans;
}
int main() {
vector<long long> kaiz;
kaiz.push_back(0);
kaiz.push_back(1);
for (long i = 2; i < Mod; i++) {
kaiz.push_back((kaiz[i - 1] * i) % Mod);
}
int q;
cin >> q;
long long x, d, n;
long long k;
long long ans;
rep(i, q) {
cin >> x >> d >> n;
if (d == 0) {
cout << poww(x, n, Mod) << endl;
} else {
k = (x * modinv(d, Mod)) % Mod;
if (k + n - 1 >= Mod) {
cout << 0 << endl;
} else {
ans = kaiz[k + n - 1] * modinv(kaiz[k - 1], Mod);
ans %= Mod;
cout << (ans * poww(d, n, Mod)) % Mod << endl;
}
}
}
} | [
"call.add",
"io.output.change",
"call.arguments.change"
] | 837,422 | 837,423 | u467826805 | cpp |
p03027 | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll INFLL = (1ll << 60);
const ll MOD = (ll)(1e6 + 3);
#define l_ength size
void mul_mod(ll &a, ll b) {
a *= b;
a %= MOD;
}
void add_mod(ll &a, ll b) {
a = (a < MOD) ? a : (a - MOD);
b = (b < MOD) ? b : (b - MOD);
a += b;
a = (a < MOD) ? a : (a - MOD);
}
ll rwpw(ll a, ll p) {
ll ret = 1ll;
while (p) {
if (p % 2) {
mul_mod(ret, a);
}
mul_mod(a, a);
p /= 2;
}
return ret;
}
ll fc[1001001], nv[1001001];
int main(void) {
ll i, q, x, d, n, p, ans;
fc[0] = 1ll;
nv[0] = 1ll;
for (i = 1; i < MOD; ++i) {
fc[i] = fc[i - 1];
mul_mod(fc[i], i);
nv[i] = rwpw(fc[i], MOD - 2);
}
cin >> q;
for (i = 0; i < q; ++i) {
cin >> x >> d >> n;
if (!d) {
ans = rwpw(x, n);
cout << ans << endl;
}
if (n >= MOD) {
cout << 0 << endl;
continue;
}
p = (x * (rwpw(d, MOD - 2))) % MOD;
if (p + n - 1 >= MOD || (!p)) {
cout << 0 << endl;
continue;
}
ans = fc[p + n - 1];
mul_mod(ans, nv[p - 1]);
mul_mod(ans, rwpw(d, n));
cout << ans << endl;
}
return 0;
}
| #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll INFLL = (1ll << 60);
const ll MOD = (ll)(1e6 + 3);
#define l_ength size
void mul_mod(ll &a, ll b) {
a *= b;
a %= MOD;
}
void add_mod(ll &a, ll b) {
a = (a < MOD) ? a : (a - MOD);
b = (b < MOD) ? b : (b - MOD);
a += b;
a = (a < MOD) ? a : (a - MOD);
}
ll rwpw(ll a, ll p) {
ll ret = 1ll;
while (p) {
if (p % 2) {
mul_mod(ret, a);
}
mul_mod(a, a);
p /= 2;
}
return ret;
}
ll fc[1001001], nv[1001001];
int main(void) {
ll i, q, x, d, n, p, ans;
fc[0] = 1ll;
nv[0] = 1ll;
for (i = 1; i < MOD; ++i) {
fc[i] = fc[i - 1];
mul_mod(fc[i], i);
nv[i] = rwpw(fc[i], MOD - 2);
}
cin >> q;
for (i = 0; i < q; ++i) {
cin >> x >> d >> n;
if (!d) {
ans = rwpw(x, n);
cout << ans << endl;
continue;
}
if (n >= MOD) {
cout << 0 << endl;
continue;
}
p = (x * (rwpw(d, MOD - 2))) % MOD;
if (p + n - 1 >= MOD || (!p)) {
cout << 0 << endl;
continue;
}
ans = fc[p + n - 1];
mul_mod(ans, nv[p - 1]);
mul_mod(ans, rwpw(d, n));
cout << ans << endl;
}
return 0;
}
| [] | 837,428 | 837,429 | u548624367 | cpp |
p03027 | #include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x, n) \
for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll, ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 10;
const ll MOD = 1e6 + 3;
template <ll mod> struct ModCombination {
ll N;
vector<ll> fact, inv, finv;
ModCombination(ll n) : N(n) {
fact.assign(n + 1, 1);
inv.assign(n + 1, 1);
finv.assign(n + 1, 1);
for (int i = 1; i < n; i++) {
fact[i + 1] = fact[i] * (i + 1) % mod;
inv[i + 1] = inv[mod % (i + 1)] * (mod - mod / (i + 1)) % mod;
finv[i + 1] = finv[i] * inv[i + 1] % mod;
}
}
ll Comb(ll n, ll k) {
if (k < 0 || n < k)
return 0;
return (fact[n] * finv[k] % mod) * finv[n - k] % mod;
}
};
ll mod_pow(ll x, ll e) {
return e ? e & 1 ? x * mod_pow(x, e - 1) % MOD : mod_pow(x * x % MOD, e / 2)
: 1;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ModCombination<MOD> c(MOD - 1);
ll Q;
cin >> Q;
for (ll q = 0; q < Q; q++) {
ll x, d, n;
cin >> x >> d >> n;
if (!x) {
cout << 0 << endl;
continue;
}
if (!d) {
cout << mod_pow(x, n) << endl;
}
ll e = x * mod_pow(d, MOD - 2) % MOD;
cout << ((e + n - 1) >= MOD ? 0
: mod_pow(d, n) * c.fact[e + n - 1] % MOD *
c.finv[e - 1] % MOD)
<< endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x, n) \
for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll, ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 10;
const ll MOD = 1e6 + 3;
template <ll mod> struct ModCombination {
ll N;
vector<ll> fact, inv, finv;
ModCombination(ll n) : N(n) {
fact.assign(n + 1, 1);
inv.assign(n + 1, 1);
finv.assign(n + 1, 1);
for (int i = 1; i < n; i++) {
fact[i + 1] = fact[i] * (i + 1) % mod;
inv[i + 1] = inv[mod % (i + 1)] * (mod - mod / (i + 1)) % mod;
finv[i + 1] = finv[i] * inv[i + 1] % mod;
}
}
ll Comb(ll n, ll k) {
if (k < 0 || n < k)
return 0;
return (fact[n] * finv[k] % mod) * finv[n - k] % mod;
}
};
ll mod_pow(ll x, ll e) {
return e ? e & 1 ? x * mod_pow(x, e - 1) % MOD : mod_pow(x * x % MOD, e / 2)
: 1;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ModCombination<MOD> c(MOD - 1);
ll Q;
cin >> Q;
for (ll q = 0; q < Q; q++) {
ll x, d, n;
cin >> x >> d >> n;
if (!x) {
cout << 0 << endl;
continue;
}
if (!d) {
cout << mod_pow(x, n) << endl;
continue;
}
ll e = x * mod_pow(d, MOD - 2) % MOD;
cout << ((e + n - 1) >= MOD ? 0
: mod_pow(d, n) * c.fact[e + n - 1] % MOD *
c.finv[e - 1] % MOD)
<< endl;
}
return 0;
}
| [] | 837,432 | 837,433 | u120143737 | cpp |
p03027 | #include <bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1000003;
const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(10);
}
} iosetup;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
os << p.first << " " << p.second;
return os;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << (i + 1 != v.size() ? " " : "");
}
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (T &in : v)
is >> in;
return is;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
template <typename T = int64> vector<T> make_v(size_t a) {
return vector<T>(a);
}
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
template <int mod> struct ModInt {
int x;
ModInt() : x(0) {}
ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
ModInt &operator+=(const ModInt &p) {
if ((x += p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p) {
if ((x += mod - p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p) {
x = (int)(1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
ModInt operator-() const { return ModInt(-x); }
ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
bool operator==(const ModInt &p) const { return x == p.x; }
bool operator!=(const ModInt &p) const { return x != p.x; }
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
ModInt pow(int64_t n) const {
ModInt ret(1), mul(x);
while (n > 0) {
if (n & 1)
ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
friend istream &operator>>(istream &is, ModInt &a) {
int64_t t;
is >> t;
a = ModInt<mod>(t);
return (is);
}
};
using modint = ModInt<mod>;
template <typename T> struct Combination {
vector<T> _fact, _rfact;
Combination(int sz) : _fact(sz + 1), _rfact(sz + 1) {
_fact[0] = _rfact[sz] = 1;
for (int i = 1; i <= sz; i++)
_fact[i] = _fact[i - 1] * i;
_rfact[sz] /= _fact[sz];
for (int i = sz - 1; i >= 0; i--)
_rfact[i] = _rfact[i + 1] * (i + 1);
}
inline T fact(int k) const { return _fact[k]; }
inline T rfact(int k) const { return _rfact[k]; }
T P(int n, int r) const {
if (r < 0 || n < r)
return 0;
return fact(n) * rfact(n - r);
}
T C(int p, int q) const {
if (q < 0 || p < q)
return 0;
return fact(p) * rfact(q) * rfact(p - q);
}
T H(int n, int r) const {
if (n < 0 || r < 0)
return (0);
return r == 0 ? 1 : C(n + r - 1, r);
}
};
template <typename Monoid> struct SegmentTree {
using F = function<Monoid(Monoid, Monoid)>;
int sz;
vector<Monoid> seg;
const F f;
const Monoid M1;
SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
sz = 1;
while (sz < n)
sz <<= 1;
seg.assign(2 * sz, M1);
}
void set(int k, const Monoid &x) { seg[k + sz] = x; }
void build() {
for (int k = sz - 1; k > 0; k--) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
void update(int k, const Monoid &x) {
k += sz;
seg[k] = x;
while (k >>= 1) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
Monoid query(int a, int b) {
Monoid L = M1, R = M1;
for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
if (a & 1)
L = f(L, seg[a++]);
if (b & 1)
R = f(seg[--b], R);
}
return f(L, R);
}
Monoid operator[](const int &k) const { return seg[k + sz]; }
};
int main() {
int Q;
cin >> Q;
auto f = [&](modint x, modint y) { return x * y; };
SegmentTree<modint> seg(mod, f, modint(1));
for (int i = 0; i < mod; i++) {
seg.set(i, i == 0 ? 1 : i);
}
seg.build();
while (Q--) {
modint X, D;
int N;
cin >> X >> D >> N;
if (D == 0) {
cout << X * N << endl;
continue;
}
modint v = -X / D;
int L = v.x - (N - 1);
int R = v.x;
modint mul;
if (L <= 0) {
mul = 0;
} else {
mul = seg.query(L, R + 1);
}
mul *= (-D).pow(N);
cout << mul << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1000003;
const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(10);
}
} iosetup;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
os << p.first << " " << p.second;
return os;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << (i + 1 != v.size() ? " " : "");
}
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (T &in : v)
is >> in;
return is;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
template <typename T = int64> vector<T> make_v(size_t a) {
return vector<T>(a);
}
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
template <int mod> struct ModInt {
int x;
ModInt() : x(0) {}
ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
ModInt &operator+=(const ModInt &p) {
if ((x += p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p) {
if ((x += mod - p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p) {
x = (int)(1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
ModInt operator-() const { return ModInt(-x); }
ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
bool operator==(const ModInt &p) const { return x == p.x; }
bool operator!=(const ModInt &p) const { return x != p.x; }
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
ModInt pow(int64_t n) const {
ModInt ret(1), mul(x);
while (n > 0) {
if (n & 1)
ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
friend istream &operator>>(istream &is, ModInt &a) {
int64_t t;
is >> t;
a = ModInt<mod>(t);
return (is);
}
};
using modint = ModInt<mod>;
template <typename T> struct Combination {
vector<T> _fact, _rfact;
Combination(int sz) : _fact(sz + 1), _rfact(sz + 1) {
_fact[0] = _rfact[sz] = 1;
for (int i = 1; i <= sz; i++)
_fact[i] = _fact[i - 1] * i;
_rfact[sz] /= _fact[sz];
for (int i = sz - 1; i >= 0; i--)
_rfact[i] = _rfact[i + 1] * (i + 1);
}
inline T fact(int k) const { return _fact[k]; }
inline T rfact(int k) const { return _rfact[k]; }
T P(int n, int r) const {
if (r < 0 || n < r)
return 0;
return fact(n) * rfact(n - r);
}
T C(int p, int q) const {
if (q < 0 || p < q)
return 0;
return fact(p) * rfact(q) * rfact(p - q);
}
T H(int n, int r) const {
if (n < 0 || r < 0)
return (0);
return r == 0 ? 1 : C(n + r - 1, r);
}
};
template <typename Monoid> struct SegmentTree {
using F = function<Monoid(Monoid, Monoid)>;
int sz;
vector<Monoid> seg;
const F f;
const Monoid M1;
SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
sz = 1;
while (sz < n)
sz <<= 1;
seg.assign(2 * sz, M1);
}
void set(int k, const Monoid &x) { seg[k + sz] = x; }
void build() {
for (int k = sz - 1; k > 0; k--) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
void update(int k, const Monoid &x) {
k += sz;
seg[k] = x;
while (k >>= 1) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
Monoid query(int a, int b) {
Monoid L = M1, R = M1;
for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
if (a & 1)
L = f(L, seg[a++]);
if (b & 1)
R = f(seg[--b], R);
}
return f(L, R);
}
Monoid operator[](const int &k) const { return seg[k + sz]; }
};
int main() {
int Q;
cin >> Q;
auto f = [&](modint x, modint y) { return x * y; };
SegmentTree<modint> seg(mod, f, modint(1));
for (int i = 0; i < mod; i++) {
seg.set(i, i == 0 ? 1 : i);
}
seg.build();
while (Q--) {
modint X, D;
int N;
cin >> X >> D >> N;
if (D == 0) {
cout << X.pow(N) << endl;
continue;
}
modint v = -X / D;
int L = v.x - (N - 1);
int R = v.x;
modint mul;
if (L <= 0) {
mul = 0;
} else {
mul = seg.query(L, R + 1);
}
mul *= (-D).pow(N);
cout << mul << endl;
}
}
| [
"io.output.change",
"call.add",
"call.arguments.change"
] | 837,434 | 837,435 | u524343822 | cpp |
p03027 | #include <bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1000003;
const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(10);
}
} iosetup;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
os << p.first << " " << p.second;
return os;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << (i + 1 != v.size() ? " " : "");
}
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (T &in : v)
is >> in;
return is;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
template <typename T = int64> vector<T> make_v(size_t a) {
return vector<T>(a);
}
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
template <int mod> struct ModInt {
int x;
ModInt() : x(0) {}
ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
ModInt &operator+=(const ModInt &p) {
if ((x += p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p) {
if ((x += mod - p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p) {
x = (int)(1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
ModInt operator-() const { return ModInt(-x); }
ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
bool operator==(const ModInt &p) const { return x == p.x; }
bool operator!=(const ModInt &p) const { return x != p.x; }
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
ModInt pow(int64_t n) const {
ModInt ret(1), mul(x);
while (n > 0) {
if (n & 1)
ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
friend istream &operator>>(istream &is, ModInt &a) {
int64_t t;
is >> t;
a = ModInt<mod>(t);
return (is);
}
};
using modint = ModInt<mod>;
template <typename T> struct Combination {
vector<T> _fact, _rfact;
Combination(int sz) : _fact(sz + 1), _rfact(sz + 1) {
_fact[0] = _rfact[sz] = 1;
for (int i = 1; i <= sz; i++)
_fact[i] = _fact[i - 1] * i;
_rfact[sz] /= _fact[sz];
for (int i = sz - 1; i >= 0; i--)
_rfact[i] = _rfact[i + 1] * (i + 1);
}
inline T fact(int k) const { return _fact[k]; }
inline T rfact(int k) const { return _rfact[k]; }
T P(int n, int r) const {
if (r < 0 || n < r)
return 0;
return fact(n) * rfact(n - r);
}
T C(int p, int q) const {
if (q < 0 || p < q)
return 0;
return fact(p) * rfact(q) * rfact(p - q);
}
T H(int n, int r) const {
if (n < 0 || r < 0)
return (0);
return r == 0 ? 1 : C(n + r - 1, r);
}
};
template <typename Monoid> struct SegmentTree {
using F = function<Monoid(Monoid, Monoid)>;
int sz;
vector<Monoid> seg;
const F f;
const Monoid M1;
SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
sz = 1;
while (sz < n)
sz <<= 1;
seg.assign(2 * sz, M1);
}
void set(int k, const Monoid &x) { seg[k + sz] = x; }
void build() {
for (int k = sz - 1; k > 0; k--) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
void update(int k, const Monoid &x) {
k += sz;
seg[k] = x;
while (k >>= 1) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
Monoid query(int a, int b) {
Monoid L = M1, R = M1;
for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
if (a & 1)
L = f(L, seg[a++]);
if (b & 1)
R = f(seg[--b], R);
}
return f(L, R);
}
Monoid operator[](const int &k) const { return seg[k + sz]; }
};
int main() {
int Q;
cin >> Q;
auto f = [&](modint x, modint y) { return x * y; };
SegmentTree<modint> seg(mod, f, modint(1));
for (int i = 0; i < mod; i++) {
seg.set(i, i == 0 ? 1 : i);
}
seg.build();
while (Q--) {
modint X, D;
int N;
cin >> X >> D >> N;
if (D == 0) {
cout << X * N << endl;
continue;
}
modint v = -X / D;
int L = v.x - (N - 1);
int R = v.x;
modint mul;
if (L < 0) {
mul = 0;
} else {
mul = seg.query(L, R + 1);
}
mul *= (-D).pow(N);
cout << mul << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1000003;
const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(10);
}
} iosetup;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
os << p.first << " " << p.second;
return os;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << (i + 1 != v.size() ? " " : "");
}
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (T &in : v)
is >> in;
return is;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
template <typename T = int64> vector<T> make_v(size_t a) {
return vector<T>(a);
}
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
template <int mod> struct ModInt {
int x;
ModInt() : x(0) {}
ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
ModInt &operator+=(const ModInt &p) {
if ((x += p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p) {
if ((x += mod - p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p) {
x = (int)(1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
ModInt operator-() const { return ModInt(-x); }
ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
bool operator==(const ModInt &p) const { return x == p.x; }
bool operator!=(const ModInt &p) const { return x != p.x; }
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
ModInt pow(int64_t n) const {
ModInt ret(1), mul(x);
while (n > 0) {
if (n & 1)
ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
friend istream &operator>>(istream &is, ModInt &a) {
int64_t t;
is >> t;
a = ModInt<mod>(t);
return (is);
}
};
using modint = ModInt<mod>;
template <typename T> struct Combination {
vector<T> _fact, _rfact;
Combination(int sz) : _fact(sz + 1), _rfact(sz + 1) {
_fact[0] = _rfact[sz] = 1;
for (int i = 1; i <= sz; i++)
_fact[i] = _fact[i - 1] * i;
_rfact[sz] /= _fact[sz];
for (int i = sz - 1; i >= 0; i--)
_rfact[i] = _rfact[i + 1] * (i + 1);
}
inline T fact(int k) const { return _fact[k]; }
inline T rfact(int k) const { return _rfact[k]; }
T P(int n, int r) const {
if (r < 0 || n < r)
return 0;
return fact(n) * rfact(n - r);
}
T C(int p, int q) const {
if (q < 0 || p < q)
return 0;
return fact(p) * rfact(q) * rfact(p - q);
}
T H(int n, int r) const {
if (n < 0 || r < 0)
return (0);
return r == 0 ? 1 : C(n + r - 1, r);
}
};
template <typename Monoid> struct SegmentTree {
using F = function<Monoid(Monoid, Monoid)>;
int sz;
vector<Monoid> seg;
const F f;
const Monoid M1;
SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
sz = 1;
while (sz < n)
sz <<= 1;
seg.assign(2 * sz, M1);
}
void set(int k, const Monoid &x) { seg[k + sz] = x; }
void build() {
for (int k = sz - 1; k > 0; k--) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
void update(int k, const Monoid &x) {
k += sz;
seg[k] = x;
while (k >>= 1) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
Monoid query(int a, int b) {
Monoid L = M1, R = M1;
for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
if (a & 1)
L = f(L, seg[a++]);
if (b & 1)
R = f(seg[--b], R);
}
return f(L, R);
}
Monoid operator[](const int &k) const { return seg[k + sz]; }
};
int main() {
int Q;
cin >> Q;
auto f = [&](modint x, modint y) { return x * y; };
SegmentTree<modint> seg(mod, f, modint(1));
for (int i = 0; i < mod; i++) {
seg.set(i, i == 0 ? 1 : i);
}
seg.build();
while (Q--) {
modint X, D;
int N;
cin >> X >> D >> N;
if (D == 0) {
cout << X.pow(N) << endl;
continue;
}
modint v = -X / D;
int L = v.x - (N - 1);
int R = v.x;
modint mul;
if (L <= 0) {
mul = 0;
} else {
mul = seg.query(L, R + 1);
}
mul *= (-D).pow(N);
cout << mul << endl;
}
}
| [
"io.output.change",
"call.add",
"call.arguments.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 837,436 | 837,435 | u524343822 | cpp |
p03027 | #include <cstdio>
#include <iostream>
using namespace std;
typedef long long i64;
const int P = 1e6 + 3;
int inv[2 * P];
int pwr(int x, int a) {
int s = 1;
while (a) {
if (a & 1)
s = (i64)s * x % P;
x = (i64)x * x % P;
a >>= 1;
}
return s;
}
int main() {
int T, i, n, d, x, y;
scanf("%d", &T);
inv[0] = 1;
for (i = 1; i < P; i++)
inv[i] = (i64)inv[i - 1] * i % P;
while (T--) {
scanf("%d%d%d", &x, &d, &n);
if (d == 0) {
printf("%d\n", pwr(d, n));
continue;
}
y = (i64)x * pwr(d, P - 2) % P;
if (y + n > P) {
printf("0\n");
continue;
}
printf("%d\n",
(i64)inv[y + n - 1] * pwr(inv[y - 1], P - 2) % P * pwr(d, n) % P);
}
return 0;
} | #include <cstdio>
#include <iostream>
using namespace std;
typedef long long i64;
const int P = 1e6 + 3;
int inv[2 * P];
int pwr(int x, int a) {
int s = 1;
while (a) {
if (a & 1)
s = (i64)s * x % P;
x = (i64)x * x % P;
a >>= 1;
}
return s;
}
int main() {
int T, i, n, d, x, y;
scanf("%d", &T);
inv[0] = 1;
for (i = 1; i < P; i++)
inv[i] = (i64)inv[i - 1] * i % P;
while (T--) {
scanf("%d%d%d", &x, &d, &n);
if (d == 0) {
printf("%d\n", pwr(x, n));
continue;
}
y = (i64)x * pwr(d, P - 2) % P;
if (y + n > P) {
printf("0\n");
continue;
}
printf("%d\n",
(i64)inv[y + n - 1] * pwr(inv[y - 1], P - 2) % P * pwr(d, n) % P);
}
return 0;
} | [
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 837,437 | 837,438 | u274497234 | cpp |
p03027 | #include <bits/stdc++.h>
#define REP(x, y, z) for (int x = y; x <= z; x++)
#define MSET(x, y) memset(x, y, sizeof(x))
#define M 3000003
#define MOD 1000003
using namespace std;
using LL = long long;
LL pw(LL x, LL y) {
LL res = 1, tmp = x;
while (y) {
if (y & 1)
res = res * tmp % MOD;
tmp = tmp * tmp % MOD;
y /= 2;
}
return res;
}
LL fact[M];
LL comb(LL x, LL y) {
return fact[x] * pw(fact[y], MOD - 2) % MOD * pw(fact[x - y], MOD - 2) % MOD;
}
LL fct(LL x, LL y) {
LL res = fact[x];
if (x - y >= 0)
res *= pw(fact[x - y], MOD - 2);
return res % MOD;
}
int q;
int main() {
fact[0] = 1;
REP(i, 1, M - 1) fact[i] = fact[i - 1] * i % MOD;
int x, d, n;
while (~scanf("%d", &q)) {
while (q--) {
scanf("%d %d %d", &x, &d, &n);
x %= MOD;
d %= MOD;
if (d == 0) {
printf("%lld\n", (LL)x * n % MOD);
continue;
}
LL st = x * pw(d, MOD - 2) % MOD;
LL tmp = (MOD - x) * pw(d, MOD - 2) % MOD;
if (n - 1 >= tmp) {
puts("0");
continue;
}
LL ans = pw(d, n) * fct(st + n - 1, n) % MOD;
printf("%lld\n", ans);
}
}
return 0;
}
| #include <bits/stdc++.h>
#define REP(x, y, z) for (int x = y; x <= z; x++)
#define MSET(x, y) memset(x, y, sizeof(x))
#define M 3000003
#define MOD 1000003
using namespace std;
using LL = long long;
LL pw(LL x, LL y) {
LL res = 1, tmp = x;
while (y) {
if (y & 1)
res = res * tmp % MOD;
tmp = tmp * tmp % MOD;
y /= 2;
}
return res;
}
LL fact[M];
LL comb(LL x, LL y) {
return fact[x] * pw(fact[y], MOD - 2) % MOD * pw(fact[x - y], MOD - 2) % MOD;
}
LL fct(LL x, LL y) {
LL res = fact[x];
if (x - y >= 0)
res *= pw(fact[x - y], MOD - 2);
return res % MOD;
}
int q;
int main() {
fact[0] = 1;
REP(i, 1, M - 1) fact[i] = fact[i - 1] * i % MOD;
int x, d, n;
while (~scanf("%d", &q)) {
while (q--) {
scanf("%d %d %d", &x, &d, &n);
x %= MOD;
d %= MOD;
if (d == 0) {
printf("%lld\n", pw(x, n));
continue;
}
LL st = x * pw(d, MOD - 2) % MOD;
LL tmp = (MOD - x) * pw(d, MOD - 2) % MOD;
if (n - 1 >= tmp) {
puts("0");
continue;
}
LL ans = pw(d, n) * fct(st + n - 1, n) % MOD;
printf("%lld\n", ans);
}
}
return 0;
}
| [
"call.add",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 837,441 | 837,442 | u710687729 | cpp |
p03027 | #include <bits/stdc++.h>
#define REP(x, y, z) for (int x = y; x <= z; x++)
#define MSET(x, y) memset(x, y, sizeof(x))
#define M 3000003
#define MOD 1000003
using namespace std;
using LL = long long;
LL pw(LL x, LL y) {
LL res = 1, tmp = x;
while (y) {
if (y & 1)
res = res * tmp % MOD;
tmp = tmp * tmp % MOD;
y /= 2;
}
return res;
}
LL fact[M];
LL comb(LL x, LL y) {
return fact[x] * pw(fact[y], MOD - 2) % MOD * pw(fact[x - y], MOD - 2) % MOD;
}
LL fct(LL x, LL y) {
LL res = fact[x];
if (x - y >= 0)
res *= pw(fact[x - y], MOD - 2);
return res % MOD;
}
int q;
int main() {
fact[0] = 1;
REP(i, 1, M - 1) fact[i] = fact[i - 1] * i % MOD;
int x, d, n;
while (~scanf("%d", &q)) {
while (q--) {
scanf("%d %d %d", &x, &d, &n);
x %= MOD;
d %= MOD;
if (d == 0) {
printf("%lld\n", x * d % MOD);
continue;
}
LL st = x * pw(d, MOD - 2) % MOD;
LL tmp = (MOD - x) * pw(d, MOD - 2) % MOD;
if (n - 1 >= tmp) {
puts("0");
continue;
}
LL ans = pw(d, n) * fct(st + n - 1, n) % MOD;
printf("%lld\n", ans);
}
}
return 0;
}
| #include <bits/stdc++.h>
#define REP(x, y, z) for (int x = y; x <= z; x++)
#define MSET(x, y) memset(x, y, sizeof(x))
#define M 3000003
#define MOD 1000003
using namespace std;
using LL = long long;
LL pw(LL x, LL y) {
LL res = 1, tmp = x;
while (y) {
if (y & 1)
res = res * tmp % MOD;
tmp = tmp * tmp % MOD;
y /= 2;
}
return res;
}
LL fact[M];
LL comb(LL x, LL y) {
return fact[x] * pw(fact[y], MOD - 2) % MOD * pw(fact[x - y], MOD - 2) % MOD;
}
LL fct(LL x, LL y) {
LL res = fact[x];
if (x - y >= 0)
res *= pw(fact[x - y], MOD - 2);
return res % MOD;
}
int q;
int main() {
fact[0] = 1;
REP(i, 1, M - 1) fact[i] = fact[i - 1] * i % MOD;
int x, d, n;
while (~scanf("%d", &q)) {
while (q--) {
scanf("%d %d %d", &x, &d, &n);
x %= MOD;
d %= MOD;
if (d == 0) {
printf("%lld\n", pw(x, n));
continue;
}
LL st = x * pw(d, MOD - 2) % MOD;
LL tmp = (MOD - x) * pw(d, MOD - 2) % MOD;
if (n - 1 >= tmp) {
puts("0");
continue;
}
LL ans = pw(d, n) * fct(st + n - 1, n) % MOD;
printf("%lld\n", ans);
}
}
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 837,443 | 837,442 | u710687729 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A, P;
cout << (A * 3 + P) / 2 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (A * 3 + P) / 2 << endl;
} | [] | 837,453 | 837,454 | u113287534 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
if ((A * 3 + P) % 2 == 0) {
cout << (A * 3 + P) / 2 << endl;
} else {
cout << (A * 3 + P) / 2 - 1 << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
if ((A * 3 + P) % 2 == 0) {
cout << (A * 3 + P) / 2 << endl;
} else {
cout << (A * 3 + P) / 2 << endl;
}
} | [
"expression.operation.binary.remove"
] | 837,465 | 837,466 | u714624983 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
if (A * 3 + P % 2 == 0) {
cout << (A * 3 + P) / 2 << endl;
} else {
cout << (A * 3 + P) / 2 - 1 << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
if ((A * 3 + P) % 2 == 0) {
cout << (A * 3 + P) / 2 << endl;
} else {
cout << (A * 3 + P) / 2 << endl;
}
} | [
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 837,468 | 837,466 | u714624983 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int m, n;
cin >> m >> n;
cout << 3 * m + n / 2 << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int m, n;
cin >> m >> n;
cout << (3 * m + n) / 2;
return 0;
} | [
"expression.operation.binary.remove"
] | 837,469 | 837,470 | u638166435 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
int sum = 3 * a + p;
cout << sum / 5 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
int sum = 3 * a + p;
cout << sum / 2 << endl;
}
| [
"literal.number.change",
"io.output.change"
] | 837,471 | 837,472 | u605833494 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (a * 3 + p * 2) / 2 << endl;
} | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (a * 3 + p) / 2 << endl;
} | [
"expression.operation.binary.remove"
] | 837,490 | 837,491 | u451954557 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll, lvector, greater<ll>>
#define P pair<ll, ll>
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define print(a) cout << (a) << endl
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll a, p;
cin >> a >> p;
print((a * 3 + p) / 3);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll, lvector, greater<ll>>
#define P pair<ll, ll>
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define print(a) cout << (a) << endl
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll a, p;
cin >> a >> p;
print((a * 3 + p) / 2);
return 0;
} | [
"literal.number.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 837,496 | 837,497 | u894339989 | cpp |
p03029 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int A, P;
cin >> A, P;
int ans;
ans = 3 * A + P;
cout << ans / 2 << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int A, P;
cin >> A >> P;
int ans;
ans = 3 * A + P;
cout << ans / 2 << endl;
return 0;
}
| [] | 837,504 | 837,505 | u282657760 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int ringo, kakera, ans;
cin >> ringo >> kakera;
kakera = kakera + ringo / 3;
ans = kakera / 2;
cout << ans << endl;
} | #include <iostream>
using namespace std;
int main() {
int ringo, kakera, ans;
cin >> ringo >> kakera;
kakera = kakera + ringo * 3;
ans = kakera / 2;
cout << ans << endl;
} | [
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 837,506 | 837,507 | u540695932 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repa(i, a, n) for (int i = (a); i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rrepa(i, a, n) for (int i = n - 1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define MOD 1000000007
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define vc vector
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
int main() {
int a, p;
cin >> a >> p;
cout << 3 * a / 2 << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repa(i, a, n) for (int i = (a); i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rrepa(i, a, n) for (int i = n - 1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define MOD 1000000007
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define vc vector
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
int main() {
int a, p;
cin >> a >> p;
cout << (3 * a + p) / 2 << "\n";
return 0;
}
| [] | 837,510 | 837,511 | u926025622 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
p += 3 * a;
cout << a / 2 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
p += 3 * a;
cout << p / 2 << endl;
} | [
"identifier.change",
"io.output.change"
] | 837,522 | 837,523 | u529089914 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A, P;
cout << (A * 3 + P) / 2 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (A * 3 + P) / 2 << endl;
}
| [] | 837,538 | 837,539 | u234126771 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A, P;
cout << (A * 3 + P) / 2 << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (A * 3 + P) / 2 << endl;
}
| [] | 837,540 | 837,539 | u234126771 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p; // 変数の宣言
cin >> a >> p; // 入力
int sum = a * 3 + p; // リンゴを全て砕き、かけらの合計を求める
int apple_pie; // 作れるアップルパイの数
if (sum % 2 == 0) // かけらの合計が偶数の時
{
apple_pie = (sum - 1) / 2;
} else // かけらの合計が奇数の時
{
apple_pie = sum / 2;
}
cout << apple_pie << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p; // 変数の宣言
cin >> a >> p; // 入力
int sum = a * 3 + p; // リンゴを全て砕き、かけらの合計を求める
int apple_pie; // 作れるアップルパイの数
if (sum % 2 == 1) // かけらの合計が奇数の時
{
apple_pie = (sum - 1) / 2;
} else // かけらの合計が偶数の時
{
apple_pie = sum / 2;
}
cout << apple_pie << endl;
} | [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 837,541 | 837,542 | u267222408 | cpp |
p03029 | #include <algorithm>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
p = p + a / 3;
cout << p / 2;
} | #include <algorithm>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
p = p + a * 3;
cout << p / 2;
} | [
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 837,545 | 837,546 | u490963780 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
int app = A + 3 * P;
int ans = app / 2;
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
int app = 3 * A + P;
int ans = app / 2;
cout << ans << endl;
}
| [
"expression.operation.binary.remove"
] | 837,547 | 837,548 | u105533331 | cpp |
p03029 | long long A, B, C, D, E, F, I, J, K, M, N, O, Q, R, S, T, U, V, X, Y, Z;
// long long A,B,C,D,E,F, H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
double dA, dB, dC, dD, dE, dF, dI, dJ, dK, dM, dN, dO, dP, dQ, dR, dS, dT, dU,
dV, dX, dY, dZ;
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef long long ll;
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
typedef pair<long long, long long> P;
// typedef pair<long long,P> P1;
// typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
//#define INF 100000000000000000//19桁
#define INF 1e18 + 5 // 19桁
#define mod 1000000007
#define fi first
#define se second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define REP(i, n, x) for (long long i = n; i < x; i++)
#define REPN(i, n, x) for (long long i = n + 1; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define rrep(i, x) for (long long i = x - 1; i >= 0; i--)
#define rrepn(i, x) for (long long i = x; i > 1; i--)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
#define ALL(v) (v).begin(), (v).end()
//#define MAX(a,b) if(a>b)
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define popcount __builtin_popcount
const string MINUSINF = "-";
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
void chmax(string &a, string b) {
if (a == MINUSINF)
a = b;
else if (a.size() < b.size())
a = b;
else if (a.size() == b.size()) {
if (a < b)
a = b;
}
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define pr printf
#define re return
#define CASET \
int ___T, case_n = 1; \
scanf("%d ", &___T); \
while (___T-- > 0)
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
stack<long long> sta;
queue<long long> que;
deque<long long> dque;
set<string> s_set;
long long sum, sum1, sum2, sum3, sum4;
long long flg, flg1, flg2, flg3, cnt, cnt1, cnt2, cnt3, cnt4;
long long wk, wk1, wk2, wk3, wk4;
long long ans;
double dsum, dsum1, dsum2, dsum3, dsum4;
double dcnt, dcnt1, dcnt2, dcnt3, dcnt4;
double dwk, dwk1, dwk2, dwk3, dwk4;
double dans;
double dmax, dmax1;
double dmin, dmin1;
// bool f;
long long weight[110],
value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に
// ll a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1],
// a[i][2] にしてしまう
long long n, h[100005];
vector<long long> p, c;
int vis[200001];
vector<string> fi;
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];
long long match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<long long> box;
vector<pair<long long, long long>> prime_factorize(long long n) {
vector<pair<long long, long long>> res;
for (long long p = 2; p * p <= n; ++p) {
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0) {
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 約数列挙
vector<long long> calc_divisor(long long n) {
vector<long long> res;
for (long long i = 1LL; i * i <= n; ++i) {
if (n % i == 0) {
res.push_back(i);
long long j = n / i;
if (j != i)
res.push_back(j);
}
}
sort(res.begin(), res.end());
return res;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
long long max, max1;
long long min, min1;
sum = sum1 = sum2 = sum3 = sum4 = 0;
flg = flg1 = flg2 = flg3 = cnt = cnt1 = cnt2 = cnt3 = cnt4 = 0;
max = max1 = 0;
wk = wk1 = wk2 = wk3 = wk4 = 0;
ans = 0;
min = min1 = INF;
dsum = dsum1 = dsum2 = dsum3 = dsum4 = 0;
dcnt = dcnt1 = dcnt2 = dcnt3 = dcnt4 = 0;
dmax = dmax1 = 0;
dwk = dwk1 = dwk2 = dwk3 = dwk4 = 0;
dans = 0;
dmin = dmin1 = INF;
// std::cin >> N;
// std::cin >> N >> M >> X;
// std::cin >> N >> M >> K;
// std::cin >> dB >> dA;
// std::cin >> A >> B;
// std::cin >> A >> B >> C;
// cin >> K;
//**************************こどふぉ用******************************************
// char c[3]={'R', 'G', 'B'};
// scanf("%lld:%lld",&a,&b);
// for(int i=0,j=1;i<n;i+=j,j++)
/*
cin >> T;
while(T--){
cin >> N >> K;
std::vector<long long> v(N);
// 配列入力1
/*
for(long long i=0; i<N; i++){
std::cin >> v[i];
}
*/
// cout << sum << '\n';
//文字列の出力
// std::cout << s << std::endl;
//}
// re 0;
// std::sort(v.begin(),v.end());//昇順ソート
// std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
// vector<ll> v(N, 0);
// map<std::string, int> freq;
//マップ
/*
map<long long,long long> numsx;
map<long long,long long> numsy;
//M.clear();
for(long long i=0; i<M; i++){
wk=w[i]%K;
numsx[wk]++;
}
*/
//マップ②
/*
map<string, int> mp;
for(int i=0; i<n; i++){
string s; cin>>s; mp[s]++;
}
int mx=-1;
for(auto p:mp) mx=MAX(mx, p.second);
for(auto p:mp){
if(mx==p.second){
cout<<p.first<<endl;
}
}
*/
//セット
/*
set<long long> st;
if(st.find(v[i])==st.end()){
st.insert(v[i]);
}
else{
st.erase(v[i]);
}
*/
// ペア
/*
vector<pair<long long, long long> > p(N);
for(long long i=0; i<N; i++){
long long a, b;
cin >> a >> b;
p[i] = make_pair(a, b);
}
//sort(p.begin(), p.end());
//sort(p.begin(), p.end(),greater<pair<long long,long long> >());
*/
// int ret=1<<20;
// cout << sum << '\n';
//文字列の出力
// std::cout << s << std::endl;
//}
// re 0;
//**************************ここからスタート******************************************
// std::cin >> N;
// std::cin >> N >> M >> X;
// std::cin >> N >> M >> K;
// std::cin >> dB >> dA;
std::cin >> A >> B;
// std::cin >> A >> B >> C;
// cin >> K;
pr("%lld", A * 3 / 2);
re 0;
// std::vector<long long> v(N);
// std::vector<long long> w(N);
// std::vector<long long> x(N);
// std::vector<int> v(100, 0);
// int a[26]={0};
// vector<long long> flagment(N, 0);
// cout << sum << '\n';
// if(1){
// pr("%lld\n",N);
// printf("%lld",(ll)ceil(dB/dA));
// puts("Yes");
// printf("%d",st.size());
//文字列の出力
// std::cout << s << std::endl;
// printf("%.12f\n",ret);
// cout << sum << endl;
// cout << sum << '\n';
// cout << x[i] << " " ;
// cout << '\n';
// pr("%02lld:%02lld",wk/60,wk%60);
//}
// else{
// puts("No");
//}
// v.push_back(i);
// accumulate(vec.begin(), vec.end(), 0)
// 配列入力1
/*
for(long long i=0; i<N; i++){
std::cin >> v[i];
}
*/
// std::sort(v.begin(),v.end());//昇順ソート
// std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
// v.erase(unique(v.begin(), v.end()), v.end());
// reverse(t.begin(),t.end());
//素因数分解
/*
auto pf = prime_factorize(v[i]);
if(pf[0].fi==2){
sum+=pf[0].se;
}
*/
//約数列挙
/*
vector<long long> div = calc_divisor(M);
// M の約数 d であって、d * N <= M となる最大の d を求める
long long res = 1;
for (auto d : div) {
if (d * N <= M) res = max(res, d);
}
*/
//素数判定
/*
for(int i=x; ; i++){
bool dame=0;
for(int j=2; j*j<=i; j++){
if(i%j==0){
dame=1;
break;
}
}
if(!dame){
cout<<i<<endl;
return 0;
}
}
*/
//文字列の出力
// std::cout << s << std::endl;
// cout << sum << '\n';
// cout << sum << '\n';
//ペア
/*
vector<pair<long long, long long> > p(N);
for(long long i=0; i<N; i++){
long long a, b;
cin >> a >> b;
p[i] = make_pair(a, b);
}
//sort(p.begin(), p.end());
//sort(p.begin(), p.end(),greater<pair<long long,long long> >());
*/
//マップ
/*
map<long long,long long> numsx;
map<long long,long long> numsy;
//M.clear();
for(long long i=0; i<M; i++){
wk=w[i]%K;
numsx[wk]++;
}
*/
//マップ②
/*
map<string, int> mp;
for(int i=0; i<n; i++){
string s; cin>>s; mp[s]++;
}
int mx=-1;
for(auto p:mp) mx=MAX(mx, p.second);
for(auto p:mp){
if(mx==p.second){
cout<<p.first<<endl;
}
}
*/
//セット
/*
set<long long> st;
if(st.find(v[i])==st.end()){
st.insert(v[i]);
}
else{
st.erase(v[i]);
}
*/
// if(ceil(sqrt(wk)==floor(sqrt(wk))))
// do{
//}while(next_permutation(v.begin(),v.end()));
// std::cin >> N;
// std::cin >> N >> M >> X;
// std::cin >> N >> M >> K;
// std::cin >> dB >> dA;
// std::cin >> A >> B;
// std::cin >> A >> B >> C;
// cin >> K;
if (1) {
// pr("%lld\n",N);
// printf("%lld",(ll)ceil(dB/dA));
// puts("Yes");
// printf("%d",st.size());
//文字列の出力
// std::cout << s << std::endl;
// printf("%.12f\n",ret);
// cout << sum << endl;
// cout << sum << '\n';
// cout << x[i] << " " ;
// cout << '\n';
// pr("%02lld:%02lld",wk/60,wk%60);
} else {
// puts("No");
}
return 0;
}
| long long A, B, C, D, E, F, I, J, K, M, N, O, Q, R, S, T, U, V, X, Y, Z;
// long long A,B,C,D,E,F, H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
double dA, dB, dC, dD, dE, dF, dI, dJ, dK, dM, dN, dO, dP, dQ, dR, dS, dT, dU,
dV, dX, dY, dZ;
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef long long ll;
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
typedef pair<long long, long long> P;
// typedef pair<long long,P> P1;
// typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
//#define INF 100000000000000000//19桁
#define INF 1e18 + 5 // 19桁
#define mod 1000000007
#define fi first
#define se second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define REP(i, n, x) for (long long i = n; i < x; i++)
#define REPN(i, n, x) for (long long i = n + 1; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define rrep(i, x) for (long long i = x - 1; i >= 0; i--)
#define rrepn(i, x) for (long long i = x; i > 1; i--)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
#define ALL(v) (v).begin(), (v).end()
//#define MAX(a,b) if(a>b)
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define popcount __builtin_popcount
const string MINUSINF = "-";
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
void chmax(string &a, string b) {
if (a == MINUSINF)
a = b;
else if (a.size() < b.size())
a = b;
else if (a.size() == b.size()) {
if (a < b)
a = b;
}
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define pr printf
#define re return
#define CASET \
int ___T, case_n = 1; \
scanf("%d ", &___T); \
while (___T-- > 0)
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
stack<long long> sta;
queue<long long> que;
deque<long long> dque;
set<string> s_set;
long long sum, sum1, sum2, sum3, sum4;
long long flg, flg1, flg2, flg3, cnt, cnt1, cnt2, cnt3, cnt4;
long long wk, wk1, wk2, wk3, wk4;
long long ans;
double dsum, dsum1, dsum2, dsum3, dsum4;
double dcnt, dcnt1, dcnt2, dcnt3, dcnt4;
double dwk, dwk1, dwk2, dwk3, dwk4;
double dans;
double dmax, dmax1;
double dmin, dmin1;
// bool f;
long long weight[110],
value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に
// ll a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1],
// a[i][2] にしてしまう
long long n, h[100005];
vector<long long> p, c;
int vis[200001];
vector<string> fi;
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];
long long match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<long long> box;
vector<pair<long long, long long>> prime_factorize(long long n) {
vector<pair<long long, long long>> res;
for (long long p = 2; p * p <= n; ++p) {
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0) {
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 約数列挙
vector<long long> calc_divisor(long long n) {
vector<long long> res;
for (long long i = 1LL; i * i <= n; ++i) {
if (n % i == 0) {
res.push_back(i);
long long j = n / i;
if (j != i)
res.push_back(j);
}
}
sort(res.begin(), res.end());
return res;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
long long max, max1;
long long min, min1;
sum = sum1 = sum2 = sum3 = sum4 = 0;
flg = flg1 = flg2 = flg3 = cnt = cnt1 = cnt2 = cnt3 = cnt4 = 0;
max = max1 = 0;
wk = wk1 = wk2 = wk3 = wk4 = 0;
ans = 0;
min = min1 = INF;
dsum = dsum1 = dsum2 = dsum3 = dsum4 = 0;
dcnt = dcnt1 = dcnt2 = dcnt3 = dcnt4 = 0;
dmax = dmax1 = 0;
dwk = dwk1 = dwk2 = dwk3 = dwk4 = 0;
dans = 0;
dmin = dmin1 = INF;
// std::cin >> N;
// std::cin >> N >> M >> X;
// std::cin >> N >> M >> K;
// std::cin >> dB >> dA;
// std::cin >> A >> B;
// std::cin >> A >> B >> C;
// cin >> K;
//**************************こどふぉ用******************************************
// char c[3]={'R', 'G', 'B'};
// scanf("%lld:%lld",&a,&b);
// for(int i=0,j=1;i<n;i+=j,j++)
/*
cin >> T;
while(T--){
cin >> N >> K;
std::vector<long long> v(N);
// 配列入力1
/*
for(long long i=0; i<N; i++){
std::cin >> v[i];
}
*/
// cout << sum << '\n';
//文字列の出力
// std::cout << s << std::endl;
//}
// re 0;
// std::sort(v.begin(),v.end());//昇順ソート
// std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
// vector<ll> v(N, 0);
// map<std::string, int> freq;
//マップ
/*
map<long long,long long> numsx;
map<long long,long long> numsy;
//M.clear();
for(long long i=0; i<M; i++){
wk=w[i]%K;
numsx[wk]++;
}
*/
//マップ②
/*
map<string, int> mp;
for(int i=0; i<n; i++){
string s; cin>>s; mp[s]++;
}
int mx=-1;
for(auto p:mp) mx=MAX(mx, p.second);
for(auto p:mp){
if(mx==p.second){
cout<<p.first<<endl;
}
}
*/
//セット
/*
set<long long> st;
if(st.find(v[i])==st.end()){
st.insert(v[i]);
}
else{
st.erase(v[i]);
}
*/
// ペア
/*
vector<pair<long long, long long> > p(N);
for(long long i=0; i<N; i++){
long long a, b;
cin >> a >> b;
p[i] = make_pair(a, b);
}
//sort(p.begin(), p.end());
//sort(p.begin(), p.end(),greater<pair<long long,long long> >());
*/
// int ret=1<<20;
// cout << sum << '\n';
//文字列の出力
// std::cout << s << std::endl;
//}
// re 0;
//**************************ここからスタート******************************************
// std::cin >> N;
// std::cin >> N >> M >> X;
// std::cin >> N >> M >> K;
// std::cin >> dB >> dA;
std::cin >> A >> B;
// std::cin >> A >> B >> C;
// cin >> K;
pr("%lld", (A * 3 + B) / 2);
re 0;
// std::vector<long long> v(N);
// std::vector<long long> w(N);
// std::vector<long long> x(N);
// std::vector<int> v(100, 0);
// int a[26]={0};
// vector<long long> flagment(N, 0);
// cout << sum << '\n';
// if(1){
// pr("%lld\n",N);
// printf("%lld",(ll)ceil(dB/dA));
// puts("Yes");
// printf("%d",st.size());
//文字列の出力
// std::cout << s << std::endl;
// printf("%.12f\n",ret);
// cout << sum << endl;
// cout << sum << '\n';
// cout << x[i] << " " ;
// cout << '\n';
// pr("%02lld:%02lld",wk/60,wk%60);
//}
// else{
// puts("No");
//}
// v.push_back(i);
// accumulate(vec.begin(), vec.end(), 0)
// 配列入力1
/*
for(long long i=0; i<N; i++){
std::cin >> v[i];
}
*/
// std::sort(v.begin(),v.end());//昇順ソート
// std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
// v.erase(unique(v.begin(), v.end()), v.end());
// reverse(t.begin(),t.end());
//素因数分解
/*
auto pf = prime_factorize(v[i]);
if(pf[0].fi==2){
sum+=pf[0].se;
}
*/
//約数列挙
/*
vector<long long> div = calc_divisor(M);
// M の約数 d であって、d * N <= M となる最大の d を求める
long long res = 1;
for (auto d : div) {
if (d * N <= M) res = max(res, d);
}
*/
//素数判定
/*
for(int i=x; ; i++){
bool dame=0;
for(int j=2; j*j<=i; j++){
if(i%j==0){
dame=1;
break;
}
}
if(!dame){
cout<<i<<endl;
return 0;
}
}
*/
//文字列の出力
// std::cout << s << std::endl;
// cout << sum << '\n';
// cout << sum << '\n';
//ペア
/*
vector<pair<long long, long long> > p(N);
for(long long i=0; i<N; i++){
long long a, b;
cin >> a >> b;
p[i] = make_pair(a, b);
}
//sort(p.begin(), p.end());
//sort(p.begin(), p.end(),greater<pair<long long,long long> >());
*/
//マップ
/*
map<long long,long long> numsx;
map<long long,long long> numsy;
//M.clear();
for(long long i=0; i<M; i++){
wk=w[i]%K;
numsx[wk]++;
}
*/
//マップ②
/*
map<string, int> mp;
for(int i=0; i<n; i++){
string s; cin>>s; mp[s]++;
}
int mx=-1;
for(auto p:mp) mx=MAX(mx, p.second);
for(auto p:mp){
if(mx==p.second){
cout<<p.first<<endl;
}
}
*/
//セット
/*
set<long long> st;
if(st.find(v[i])==st.end()){
st.insert(v[i]);
}
else{
st.erase(v[i]);
}
*/
// if(ceil(sqrt(wk)==floor(sqrt(wk))))
// do{
//}while(next_permutation(v.begin(),v.end()));
// std::cin >> N;
// std::cin >> N >> M >> X;
// std::cin >> N >> M >> K;
// std::cin >> dB >> dA;
// std::cin >> A >> B;
// std::cin >> A >> B >> C;
// cin >> K;
if (1) {
// pr("%lld\n",N);
// printf("%lld",(ll)ceil(dB/dA));
// puts("Yes");
// printf("%d",st.size());
//文字列の出力
// std::cout << s << std::endl;
// printf("%.12f\n",ret);
// cout << sum << endl;
// cout << sum << '\n';
// cout << x[i] << " " ;
// cout << '\n';
// pr("%02lld:%02lld",wk/60,wk%60);
} else {
// puts("No");
}
return 0;
}
| [
"call.arguments.change"
] | 837,549 | 837,550 | u069521477 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
int app = 0;
p += a * 3;
cout << p / 3 << endl;
} | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
int app = 0;
p += a * 3;
cout << p / 2 << endl;
} | [
"literal.number.change",
"io.output.change"
] | 837,555 | 837,556 | u657208344 | cpp |
p03029 | #include "bits/stdc++.h"
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) \
sort(all(v)); \
reverse(all(v))
using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
inline void yes() {
cout << "Yes" << '\n';
exit(0);
}
inline void no() {
cout << "No" << '\n';
exit(0);
}
inline i64 gcd(i64 a, i64 b) {
if (min(a, b) == 0)
return max(a, b);
if (a % b == 0)
return b;
return gcd(b, a % b);
}
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve();
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(16);
solve();
return 0;
}
template <typename T>
class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T>
class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) {
if (x < y)
x = y;
}
template <typename T> inline void amin(T &x, T y) {
if (x > y)
x = y;
}
template <typename T> inline T power(T x, i64 n) {
T r = 1;
while (n > 0) {
if (n & 1)
r *= x;
x *= x;
n >>= 1;
}
return r;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (auto &x : v)
is >> x;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
rep(i, v.size()) {
if (i)
os << ' ';
os << v[i];
}
return os;
}
void solve() {
int A, P;
cin >> A >> P;
P += A / 3;
cout << P / 2 << '\n';
}
| #include "bits/stdc++.h"
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) \
sort(all(v)); \
reverse(all(v))
using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
inline void yes() {
cout << "Yes" << '\n';
exit(0);
}
inline void no() {
cout << "No" << '\n';
exit(0);
}
inline i64 gcd(i64 a, i64 b) {
if (min(a, b) == 0)
return max(a, b);
if (a % b == 0)
return b;
return gcd(b, a % b);
}
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve();
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(16);
solve();
return 0;
}
template <typename T>
class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T>
class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) {
if (x < y)
x = y;
}
template <typename T> inline void amin(T &x, T y) {
if (x > y)
x = y;
}
template <typename T> inline T power(T x, i64 n) {
T r = 1;
while (n > 0) {
if (n & 1)
r *= x;
x *= x;
n >>= 1;
}
return r;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (auto &x : v)
is >> x;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
rep(i, v.size()) {
if (i)
os << ' ';
os << v[i];
}
return os;
}
void solve() {
int A, P;
cin >> A >> P;
P += A * 3;
cout << P / 2 << '\n';
}
| [
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 837,557 | 837,558 | u908318580 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (2 * A + P) / 2 << endl;
} | #include <iostream>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (3 * A + P) / 2 << endl;
} | [
"literal.number.change",
"io.output.change"
] | 837,590 | 837,591 | u627821211 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
int a, p;
cin >> a >> p;
p += 3 * a;
cout << p / 3 << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
int a, p;
cin >> a >> p;
p += 3 * a;
cout << p / 2 << endl;
}
| [
"literal.number.change",
"io.output.change"
] | 837,596 | 837,597 | u945761460 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
for (auto v : (V)) \
cout << v << ' ';
#define PRINT_ENTER() cout << endl;
int main() {
/* code */
int a, p;
cin >> a >> p;
int a_kake = a / 3;
cout << (a_kake * 3 + p) / 2 << '\n';
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
for (auto v : (V)) \
cout << v << ' ';
#define PRINT_ENTER() cout << endl;
int main() {
/* code */
int a, p;
cin >> a >> p;
int a_kake = a * 3;
cout << (a_kake + p) / 2 << '\n';
return 0;
} | [
"expression.operator.arithmetic.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 837,615 | 837,616 | u223960644 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
for (auto v : (V)) \
cout << v << ' ';
#define PRINT_ENTER() cout << endl;
int main() {
/* code */
int a, p;
cin >> a >> p;
int a_kake = a / 3;
cout << (a_kake + p) / 2 << '\n';
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
for (auto v : (V)) \
cout << v << ' ';
#define PRINT_ENTER() cout << endl;
int main() {
/* code */
int a, p;
cin >> a >> p;
int a_kake = a * 3;
cout << (a_kake + p) / 2 << '\n';
return 0;
} | [
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 837,617 | 837,616 | u223960644 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
a *= 3;
cout << (a + p) % 2;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
a *= 3;
cout << (a + p) / 2;
}
| [
"expression.operator.arithmetic.change",
"io.output.change"
] | 837,632 | 837,633 | u873762144 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int A, P;
cin >> A >> P;
cout << (3 * A + P) / 3;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int A, P;
cin >> A >> P;
cout << (3 * A + P) / 2;
return 0;
} | [
"literal.number.change",
"io.output.change"
] | 837,640 | 837,641 | u316491370 | cpp |
p03029 | #include <iostream>
int main() {
int a, p;
std::cin >> a >> p;
std::cout << 3 * a + p / 2 << std::endl;
return 0;
} | #include <iostream>
int main() {
int a, p;
std::cin >> a >> p;
std::cout << (3 * a + p) / 2 << std::endl;
return 0;
}
| [] | 837,642 | 837,643 | u864752370 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a, b;
cout << int((3 * a + b) / 2);
} | #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << int((3 * a + b) / 2);
} | [] | 837,646 | 837,647 | u954703812 | cpp |
p03029 | // Justice will be served
// شهید حاج قاسم سلیمانی
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a * 3 + b;
} | // Justice will be served
// شهید حاج قاسم سلیمانی
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << (a * 3 + b) / 2;
}
| [
"expression.operation.binary.add"
] | 837,648 | 837,649 | u113816634 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << ((a / 3) + p) / 2;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << ((a * 3) + p) / 2;
return 0;
} | [
"expression.operator.arithmetic.change",
"io.output.change"
] | 837,650 | 837,651 | u976082990 | cpp |
p03029 | #include <algorithm>
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (p + 3 * a) % 2 << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (p + 3 * a) / 2 << endl;
return 0;
} | [
"expression.operator.arithmetic.change",
"io.output.change"
] | 837,652 | 837,653 | u476027087 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
int a, p;
cin >> a >> p;
a = a * 3;
int sum = p + a;
cout << sum / 3;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
int a, p;
cin >> a >> p;
a = a * 3;
int sum = p + a;
cout << sum / 2;
return 0;
} | [
"literal.number.change",
"io.output.change"
] | 837,658 | 837,659 | u476305001 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a, b;
a = a * 3;
a += b;
cout << a / 2;
}
| #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
a = a * 3;
a += b;
cout << a / 2;
}
| [] | 837,666 | 837,667 | u225830069 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P, ans;
cin >> A >> P;
if (P % 2 == 0)
ans = (3 * A + P) / 2;
else
ans = (3 * A + P - 1) / 2;
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P, ans;
cin >> A >> P;
if (P % 2 == 0)
ans = (3 * A + P) / 2;
else
ans = (3 * A + P) / 2;
cout << ans << endl;
} | [
"expression.operation.binary.remove"
] | 837,668 | 837,669 | u556774846 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int a, p, k, h;
cin >> a >> p;
p = p + 3 * a;
cout << p;
}
| #include <iostream>
using namespace std;
int main() {
int a, p, k, h;
cin >> a >> p;
p = p + 3 * a;
cout << p / 2;
}
| [
"expression.operation.binary.add"
] | 837,670 | 837,671 | u406246506 | cpp |
p03029 | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
int A, P = 0;
int pie_num = 0;
/* 標準入力 */
cin >> A >> P;
P += (A / 2);
pie_num = P / 2;
cout << pie_num << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
int A, P = 0;
int pie_num = 0;
/* 標準入力 */
cin >> A >> P;
P += A * 3;
pie_num = P / 2;
cout << pie_num << endl;
return 0;
} | [] | 837,681 | 837,682 | u942653486 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define f(i, a, b) for (int i = a; i < b; i++)
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a, p;
cin >> a >> p;
int ans = (3 * a + p) / 3;
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define f(i, a, b) for (int i = a; i < b; i++)
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a, p;
cin >> a >> p;
int ans = (3 * a + p) / 2;
cout << ans << endl;
} | [
"literal.number.change",
"expression.operation.binary.change"
] | 837,689 | 837,690 | u123011509 | cpp |
p03029 | #include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (A * 3 + P) / 3 << endl;
} | #include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (A * 3 + P) / 2 << endl;
} | [
"literal.number.change",
"io.output.change"
] | 837,697 | 837,698 | u323542775 | cpp |
p03029 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;
int gcd(int a, int b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(0);
int a, p;
cin >> a >> p;
cout << a * 3 / 2 << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;
int gcd(int a, int b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(0);
int a, p;
cin >> a >> p;
cout << (a * 3 + p) / 2 << endl;
return 0;
} | [] | 837,703 | 837,704 | u604896914 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a, b;
cout << b / 2 + (b % 2 + a * 3) / 2 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << (b / 2) + ((b % 2 + a * 3) / 2) << endl;
} | [] | 837,739 | 837,740 | u165771525 | cpp |
p03029 | #include <iostream>
#include <string>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
int tip = a * 3;
int pie = tip / 2;
cout << pie << endl;
}
| #include <iostream>
#include <string>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
int tip = a * 3;
int pie = (tip + p) / 2;
cout << pie << endl;
}
| [] | 837,743 | 837,744 | u902803949 | cpp |
p03029 | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(void) {
int a, p;
cin >> a >> p;
p += a * 3;
cout << a / 2 << endl;
return 0;
} | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
p += a * 3;
cout << p / 2 << endl;
return 0;
} | [
"identifier.change",
"io.output.change"
] | 837,747 | 837,748 | u616998927 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << 3 * A + P / 2 << endl;
} | #include <iostream>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (3 * A + P) / 2 << endl;
}
| [] | 837,749 | 837,750 | u144013030 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << 3 * A + P / 2 << endl;
} | #include <iostream>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (3 * A + P) / 2 << endl;
} | [] | 837,749 | 837,751 | u144013030 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (3 * a + p) * 2 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (3 * a + p) / 2 << endl;
}
| [
"expression.operator.arithmetic.change",
"io.output.change"
] | 837,765 | 837,766 | u882039496 | cpp |
p03029 | #include <iostream>
int main(void) {
int A, P;
std::cin >> A;
std::cin >> P;
P = P + 3 * A;
std::cout << P / 3 << std::endl;
return 0;
} | #include <iostream>
int main(void) {
int A, P;
std::cin >> A;
std::cin >> P;
P = P + 3 * A;
std::cout << P / 2 << std::endl;
return 0;
} | [
"literal.number.change",
"expression.operation.binary.change"
] | 837,769 | 837,770 | u122994151 | cpp |
p03029 | #include <iostream>
#define ll long long
using namespace std;
int main() {
ll apple, pieces;
ll pies = 0;
cin >> apple >> pieces;
pies = (pieces + apple * 3) / 2;
cout << pieces;
return 0;
} | #include <iostream>
#define ll long long
using namespace std;
int main() {
ll apple, pieces;
ll pies = 0;
cin >> apple >> pieces;
pies = (pieces + apple * 3) / 2;
cout << pies;
return 0;
} | [
"identifier.change",
"io.output.change"
] | 837,771 | 837,772 | u708351207 | cpp |
p03029 | #include <iostream>
#define ll long long
using namespace std;
int main() {
ll apple, pieces;
ll pies = 0;
cin >> apple >> pieces;
pies = (pieces + apple / 3) / 2;
cout << pieces;
return 0;
} | #include <iostream>
#define ll long long
using namespace std;
int main() {
ll apple, pieces;
ll pies = 0;
cin >> apple >> pieces;
pies = (pieces + apple * 3) / 2;
cout << pies;
return 0;
} | [
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change",
"identifier.change",
"io.output.change"
] | 837,773 | 837,772 | u708351207 | cpp |
p03029 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a, b) memset((a), (b), sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e5 + 10;
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int a, b;
cin >> a >> b;
cout << (a * 2 + b) / 2 << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a, b) memset((a), (b), sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e5 + 10;
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int a, b;
cin >> a >> b;
cout << (a * 3 + b) / 2 << endl;
return 0;
} | [
"literal.number.change",
"io.output.change"
] | 837,774 | 837,775 | u861345985 | cpp |
p03029 | #include <stdio.h>
int main() {
int a, p;
scanf("%d %d", &a, &p);
int t = (a * 3) + p;
printf("%d", t % 2);
}
| #include <stdio.h>
int main() {
int a, p;
scanf("%d %d", &a, &p);
int t = (a * 3) + p;
printf("%d", t / 2);
}
| [
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 837,786 | 837,787 | u405346337 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << ((a * 2 + p) >> 1) << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << ((a * 3 + p) >> 1) << endl;
return 0;
} | [
"literal.number.change",
"io.output.change"
] | 837,788 | 837,789 | u522506260 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << ((a * 2 + p) >> 1) << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << ((a * 3 + p) / 2) << endl;
return 0;
} | [
"literal.number.change",
"io.output.change"
] | 837,788 | 837,790 | u522506260 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (3 * A + P) % 2 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (3 * A + P) / 2 << endl;
} | [
"expression.operator.arithmetic.change",
"io.output.change"
] | 837,798 | 837,799 | u559112776 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (a * 3 + p) / 2.0 << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (a * 3 + p) / 2 << endl;
return 0;
} | [
"literal.number.change",
"io.output.change"
] | 837,809 | 837,810 | u548587261 | cpp |
p03029 | #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 a, p;
cin >> a >> p;
cout << (a * 3 + p) / 3 << endl;
}
| #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 a, p;
cin >> a >> p;
cout << (a * 3 + p) / 2 << endl;
}
| [
"literal.number.change",
"io.output.change"
] | 837,816 | 837,817 | u806149832 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int s, d;
cin >> s >> d;
cout << (2 * s + d) / 2;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int s, d;
cin >> s >> d;
cout << (3 * s + d) / 2 << endl;
}
| [
"literal.number.change",
"io.output.change",
"io.output.newline.add"
] | 837,822 | 837,821 | u103850114 | cpp |
p03029 | #include <stdio.h>
int main() {
int apple;
int pieces1;
scanf("%d", &apple, &pieces1);
printf("%d", ((apple * 3) + pieces1) / 2);
return 0;
}
| #include <stdio.h>
int main() {
int apple;
int pieces1;
scanf("%d %d", &apple, &pieces1);
printf("%d", ((apple * 3) + pieces1) / 2);
return 0;
}
| [
"literal.string.change",
"call.arguments.change"
] | 837,827 | 837,828 | u816631826 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << ((3 * a) + p) / 3;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (((a * 3) + p) / 2);
} | [
"io.output.change",
"literal.number.change"
] | 837,829 | 837,830 | u816631826 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
int A, P;
cin >> A >> P;
cout << 3 * A / P << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
int A, P;
cin >> A >> P;
cout << (3 * A + P) / 2 << endl;
return 0;
} | [
"expression.operator.arithmetic.change",
"io.output.change"
] | 837,831 | 837,832 | u005072763 | cpp |
p03029 | #include <stdio.h>
int main() {
int A;
int P;
scanf("%d %d", &A, &P);
printf("%d", (A * P) / 2);
return 0;
} | #include <stdio.h>
int main() {
int A, P;
scanf("%d %d", &A, &P);
printf("%d", (A * 3 + P) / 2);
return 0;
} | [
"expression.operation.binary.add"
] | 837,845 | 837,846 | u018679195 | cpp |
p03029 | #include <stdio.h>
int main() {
int A;
int P;
scanf("%d %d", &A, &P);
printf("%d", (A * P) / 2);
return 0;
} | #include <stdio.h>
int main() {
int A;
int P;
scanf("%d %d", &A, &P);
printf("%d\n", (3 * A + P) / 2);
return 0;
} | [
"literal.string.change",
"call.arguments.change",
"io.output.change",
"io.output.newline.add",
"identifier.replace.remove",
"literal.replace.add",
"expression.operation.binary.change"
] | 837,845 | 837,847 | u018679195 | cpp |
p03029 | #include <bits/stdc++.h>
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprrev(i, a, b) for (int i = b - 1; i >= a; i--) // [a, b)
#define reprev(i, n) reprrev(i, 0, n)
using ll = long long;
using ull = unsigned long long;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const ll mod = 1e9 + 7;
void chmod(ll &M) {
if (M >= mod)
M %= mod;
else if (M < 0) {
M += (abs(M) / mod + 1) * mod;
M %= mod;
}
}
ll modpow(ll x, ll n) {
if (n == 0)
return 1;
ll res = modpow(x, n / 2);
if (n % 2 == 0)
return res * res % mod;
else
return res * res % mod * x % mod;
}
int getl(int i, int N) { return i == 0 ? N - 1 : i - 1; };
int getr(int i, int N) { return i == N - 1 ? 0 : i + 1; };
long long GCD(long long a, long long b) {
if (b == 0)
return a;
else
return GCD(b, a % b);
}
using namespace std;
/* <----------------------------------------------------------------------------------->
*/
/* <----------------------------------------------------------------------------------->
*/
/* <----------------------------------------------------------------------------------->
*/
/* <----------------------------------------------------------------------------------->
*/
int main() {
int A, P;
cin >> A >> P;
cout << (A * 3 + P) / 3 << endl;
}
| #include <bits/stdc++.h>
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprrev(i, a, b) for (int i = b - 1; i >= a; i--) // [a, b)
#define reprev(i, n) reprrev(i, 0, n)
using ll = long long;
using ull = unsigned long long;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const ll mod = 1e9 + 7;
void chmod(ll &M) {
if (M >= mod)
M %= mod;
else if (M < 0) {
M += (abs(M) / mod + 1) * mod;
M %= mod;
}
}
ll modpow(ll x, ll n) {
if (n == 0)
return 1;
ll res = modpow(x, n / 2);
if (n % 2 == 0)
return res * res % mod;
else
return res * res % mod * x % mod;
}
int getl(int i, int N) { return i == 0 ? N - 1 : i - 1; };
int getr(int i, int N) { return i == N - 1 ? 0 : i + 1; };
long long GCD(long long a, long long b) {
if (b == 0)
return a;
else
return GCD(b, a % b);
}
using namespace std;
/* <----------------------------------------------------------------------------------->
*/
/* <----------------------------------------------------------------------------------->
*/
/* <----------------------------------------------------------------------------------->
*/
/* <----------------------------------------------------------------------------------->
*/
int main() {
int A, P;
cin >> A >> P;
cout << (A * 3 + P) / 2 << endl;
}
| [
"literal.number.change",
"io.output.change"
] | 837,854 | 837,855 | u979078704 | cpp |
p03029 | #include <stdio.h>
int main() {
int a, p, c;
scanf("%d %d", &a, &p);
c = (a * 4 + p) / 2;
printf("%d", c);
return 0;
} | #include <stdio.h>
int main() {
int a, p, ap;
scanf("%d %d", &a, &p);
ap = (a * 3 + p) / 2;
printf("%d", ap);
return 0;
} | [
"identifier.change",
"assignment.variable.change",
"literal.number.change",
"assignment.value.change",
"expression.operation.binary.change",
"call.arguments.change",
"io.output.change"
] | 837,858 | 837,859 | u089230684 | cpp |
p03029 | #include <stdio.h>
int main() {
int X;
int Y;
int Z;
scanf("%d", &X, &Y);
Z = (X * 3 + Y) / 2;
printf("%d", Z);
return 0;
} | #include <stdio.h>
int main() {
int X;
int Y;
int Z;
scanf("%d %d", &X, &Y);
Z = (X * 3 + Y) / 2;
printf("%d", Z);
return 0;
} | [
"literal.string.change",
"call.arguments.change"
] | 837,860 | 837,861 | u353919145 | cpp |
p03029 | #include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
const int MAX = 510000;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int a, p;
cin >> a >> p;
a *= 3;
cout << a / 2 << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
const int MAX = 510000;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int a, p;
cin >> a >> p;
a *= 3;
cout << (a + p) / 2 << endl;
return 0;
} | [] | 837,869 | 837,870 | u371149954 | cpp |
p03029 | // lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll a, b, c, d, e, n, k, maxi = 0, f = 0, mini = INF, sum = 0, q;
string str, stra, straa;
ll x, y, z;
char ca, cb, cc;
cin >> a >> b;
b + a * 3;
cout << b / 2;
return 0;
}
| // lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll a, b, c, d, e, n, k, maxi = 0, f = 0, mini = INF, sum = 0, q;
string str, stra, straa;
ll x, y, z;
char ca, cb, cc;
cin >> a >> b;
b += a * 3;
cout << b / 2;
return 0;
}
| [
"assignment.compound.arithmetic.replace.add",
"expression.operator.arithmetic.replace.remove",
"expression.operation.binary.change"
] | 837,876 | 837,877 | u683769494 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (3 * a + p) / 3 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (3 * a + p) / 2 << endl;
return 0;
}
| [
"literal.number.change",
"io.output.change"
] | 837,891 | 837,892 | u162080911 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (a + 3 * p) / 3 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (3 * a + p) / 2 << endl;
return 0;
}
| [
"expression.operation.binary.remove",
"literal.number.change",
"io.output.change"
] | 837,893 | 837,892 | u162080911 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int apple, A, P;
cin >> A >> P;
apple = (A * 3 + P) % 2;
cout << apple << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int apple, A, P;
cin >> A >> P;
apple = (A * 3 + P) / 2;
cout << apple << endl;
return 0;
}
| [
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 837,917 | 837,918 | u625176086 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (A * 3) / 2 << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int A, P;
cin >> A >> P;
cout << (A * 3 + P) / 2 << endl;
return 0;
} | [
"expression.operation.binary.add"
] | 837,919 | 837,920 | u962942039 | cpp |
p03029 | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << (a * 3) + p / 2 << endl;
} | #include <iostream>
using namespace std;
int main() {
int a, p;
cin >> a >> p;
cout << ((a * 3) + p) / 2 << endl;
} | [] | 837,933 | 837,934 | u553927381 | cpp |
p03029 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int main() {
int a, p;
cin >> a >> p;
int ans = (3 * a + p + 1) / 2 - 1;
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int main() {
int a, p;
cin >> a >> p;
int ans = (3 * a + p) / 2;
cout << ans << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 837,945 | 837,946 | u071554349 | cpp |
p03029 | #define LOCAL
/* 実行時間1s制限の場合
10^6 1,000,000 : 余裕をもって間に合う
10^7 10,000,000 : おそらく間に合う
10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
*/
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
} // Greatest Common Divisor ユークリッドの互除法(aが長辺)
ll lcm(ll a, ll b) {
return a / gcd(a, b) * b;
} // Least Commont Multiple オーバーフローしないように先に割る
const ll INF = LONG_MAX;
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;
}
int main() {
#ifdef LOCAL
// 以降 cin の入力元が 'xxx.txt' になる
std::ifstream in("a.txt");
std::cin.rdbuf(in.rdbuf());
#endif
int a, p;
cin >> a >> p;
cout << (a * 3 + p) / 2;
return 0;
}
/*
- 1e9 : 10^9
- vector
vector<int> A(N);
- loop
for (int i = 0; i < A.size(); i++) {}
for (int elem : A) {}
- sort
std::sort(v.begin(), v.end()); // 昇順
std::sort(v.begin(), v.end(), std::greater<int>()); //降順
- vector<vector<int>> cnt(h, vector<int>(w))
- pair
- pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
- map
- for (auto x : map) {} // x.first:key x.second:value.
- string
- loop
for (char& c : s) {}
*/
| /* 実行時間1s制限の場合
10^6 1,000,000 : 余裕をもって間に合う
10^7 10,000,000 : おそらく間に合う
10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
*/
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
} // Greatest Common Divisor ユークリッドの互除法(aが長辺)
ll lcm(ll a, ll b) {
return a / gcd(a, b) * b;
} // Least Commont Multiple オーバーフローしないように先に割る
const ll INF = LONG_MAX;
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;
}
int main() {
#ifdef LOCAL
// 以降 cin の入力元が 'xxx.txt' になる
std::ifstream in("a.txt");
std::cin.rdbuf(in.rdbuf());
#endif
int a, p;
cin >> a >> p;
cout << (a * 3 + p) / 2;
return 0;
}
/*
- 1e9 : 10^9
- vector
vector<int> A(N);
- loop
for (int i = 0; i < A.size(); i++) {}
for (int elem : A) {}
- sort
std::sort(v.begin(), v.end()); // 昇順
std::sort(v.begin(), v.end(), std::greater<int>()); //降順
- vector<vector<int>> cnt(h, vector<int>(w))
- pair
- pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
- map
- for (auto x : map) {} // x.first:key x.second:value.
- string
- loop
for (char& c : s) {}
*/
| [] | 837,956 | 837,957 | u234248338 | cpp |
p03029 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A;
cin >> A;
int P;
cin >> P;
int a = A / 3;
cout << (a + P) / 2 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A;
cin >> A;
int P;
cin >> P;
int a = A * 3;
cout << (a + P) / 2 << endl;
} | [
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 837,965 | 837,966 | u263220374 | cpp |
p03029 | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, a) FOR(i, 0, a)
using namespace std;
ll A, P;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> A >> P;
cout << P * 3 / 2 << endl;
} | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, a) FOR(i, 0, a)
using namespace std;
ll A, P;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> A >> P;
cout << (P + A * 3) / 2 << endl;
} | [
"expression.operation.binary.add"
] | 837,969 | 837,970 | u533920479 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.