結果

問題 No.2751 429-like Number
ユーザー 👑 bo9chanbo9chan
提出日時 2024-05-10 21:53:03
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 366 ms / 4,000 ms
コード長 28,359 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 189,032 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-20 05:13:04
合計ジャッジ時間 5,655 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#ifdef __LOCAL
#include <mytemplate.hpp> // ~/local/include/mytemplate.hpp.gch
#else
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <optional>
#include <random>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#endif
using namespace std;
#pragma GCC target "no-avx" // gcc12.2boost使
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using int128 = __int128_t;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
#define REP1(i, n) REP3(i, 0, n, 1)
#define REP2(i, s, n) REP3(i, s, n, 1)
#define REP3(i, s, n, d) for(ll i = (ll)(s); i < (ll)(n); i += (d))
#define REP_OVERLOAD(e1, e2, e3, e4, NAME,...) NAME
#define rep(...) REP_OVERLOAD(__VA_ARGS__, REP3, REP2, REP1)(__VA_ARGS__)
#define DEP1(i, n) DEP3(i, n, -1, 1)
#define DEP2(i, n, s) DEP3(i, n, s, 1)
#define DEP3(i, n, s, d) for(ll i = (ll)(n); (ll)(s) < i; i -= (d))
#define DEP_OVERLOAD(e1, e2, e3, e4, NAME,...) NAME
#define dep(...) DEP_OVERLOAD(__VA_ARGS__, DEP3, DEP2, DEP1)(__VA_ARGS__)
#define fore(e, a) for (auto&& e: (a))
#define len(a) (ll)(a).size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define th third
/********* C O N S T A N T **********/
constexpr ll INF = LONG_LONG_MAX / 2 - 10000LL; // 4,611,686,018,427,377,903 ~= 4.6e+18, 19
const double PI = acos(-1);
/********* P A I R **********/
template<class T, class U> inline pair<T, U>& operator+=(pair<T, U>& a, const pair<T, U> b);
template<class T, class U> inline pair<T, U>& operator-=(pair<T, U>& a, const pair<T, U> b);
template<class T, class U> inline pair<T, U>& operator*=(pair<T, U>& a, const pair<T, U> b);
template<class T, class U> inline pair<T, U>& operator/=(pair<T, U>& a, const pair<T, U> b);
template<class T, class U> inline pair<T, U>& operator%=(pair<T, U>& a, const pair<T, U> b);
template<class T, class U, class V> inline pair<T, U>& operator+=(pair<T, U>& a, const V b);
template<class T, class U, class V> inline pair<T, U>& operator-=(pair<T, U>& a, const V b);
template<class T, class U, class V> inline pair<T, U>& operator*=(pair<T, U>& a, const V b);
template<class T, class U, class V> inline pair<T, U>& operator/=(pair<T, U>& a, const V b);
template<class T, class U, class V> inline pair<T, U>& operator%=(pair<T, U>& a, const V b);
template<class T, class U, class V> inline pair<T, U> operator+(pair<T, U> a, const V& b);
template<class T, class U, class V> inline pair<T, U> operator-(pair<T, U> a, const V& b);
template<class T, class U, class V> inline pair<T, U> operator*(pair<T, U> a, const V& b);
template<class T, class U, class V> inline pair<T, U> operator/(pair<T, U> a, const V& b);
template<class T, class U, class V> inline pair<T, U> operator%(pair<T, U> a, const V& b);
template<class T, class U> inline pair<T, U> operator+(pair<T, U> a);
template<class T, class U> inline pair<T, U> operator-(pair<T, U> a);
template<class T, class U> istream& operator >>(istream& stream, pair<T, U>& a);
template<class T, class U> ostream& operator <<(ostream &stream, const pair<T, U>& a);
/********* V E C T O R **********/
template<class T> inline vector<T>& operator+=(vector<T>& a, const vector<T> b);
template<class T> inline vector<T>& operator-=(vector<T>& a, const vector<T> b);
template<class T> inline vector<T>& operator*=(vector<T>& a, const vector<T> b);
template<class T> inline vector<T>& operator/=(vector<T>& a, const vector<T> b);
template<class T> inline vector<T>& operator%=(vector<T>& a, const vector<T> b);
template<class T, class U> inline vector<T>& operator+=(vector<T>& a, const U b);
template<class T, class U> inline vector<T>& operator-=(vector<T>& a, const U b);
template<class T, class U> inline vector<T>& operator*=(vector<T>& a, const U b);
template<class T, class U> inline vector<T>& operator/=(vector<T>& a, const U b);
template<class T, class U> inline vector<T>& operator%=(vector<T>& a, const U b);
template<class T, class U> inline vector<T> operator+(vector<T> a, const U& b);
template<class T, class U> inline vector<T> operator-(vector<T> a, const U& b);
template<class T, class U> inline vector<T> operator*(vector<T> a, const U& b);
template<class T, class U> inline vector<T> operator/(vector<T> a, const U& b);
template<class T, class U> inline vector<T> operator%(vector<T> a, const U& b);
template<class T> inline vector<T> operator+(vector<T> a);
template<class T> inline vector<T> operator-(vector<T> a);
template<class T> istream& operator >>(istream& stream, vector<T>& a);
template<class T> ostream& operator <<(ostream& stream, const vector<T>& v);
template<class T> ostream& operator <<(ostream& stream, const vector<vector<T>>& vv);
template<class T> inline T Sum(const vector<T>& v) {return reduce(all(v));} // v.size() == 0 T()
template<class T> inline T Max(const vector<T>& v) {assert(v.size()); return *max_element(all(v));}
template<class T> inline T Min(const vector<T>& v) {assert(v.size()); return *min_element(all(v));}
template<class T> inline ll Argmax(const vector<T>& v) {assert(v.size()); return max_element(all(v)) - v.begin();}
template<class T> inline ll Argmin(const vector<T>& v) {assert(v.size()); return min_element(all(v)) - v.begin();}
template<class T, class U> inline bool Contains(const vector<T>& v, const U& a) {return find(all(v), a) != v.end();}
template<class T> inline void Unique(vector<T>& v) {sort(all(v)); v.erase(unique(all(v)), v.end());} // vector,
    O(NlogN).
template<class T, class U> vector<T> make_vector(int n, U v) { return vector<T>(n, v); }
template <class T, class... Args> auto make_vector(int n, Args... args) {auto val = make_vector<T>(args...); return make_vector<decltype(val)>(n,
    move(val));}
/********* S E T **********/
template<class T> istream& operator >>(istream& stream, set<T>& st);
template<class T> ostream& operator <<(ostream& stream, const set<T>& st);
template<class T> inline T Max(const set<T>& st) {assert(st.size()); return *prev(st.end());}
template<class T> inline T Min(const set<T>& st) {assert(st.size()); return *st.begin();}
/********* M U L T I S E T **********/
template<class T> istream& operator >>(istream& stream, multiset<T>& st);
template<class T> ostream& operator <<(ostream& stream, const multiset<T>& st);
template<class T> inline T Max(const multiset<T>& st) {assert(st.size()); return *prev(st.end());}
template<class T> inline T Min(const multiset<T>& st) {assert(st.size()); return *st.begin();}
template<class T> inline bool EraseOne(multiset<T>& st, T x) {auto it=st.find(x); if (it!=st.end()) {st.erase(it); return true;} else return false;}
     // x1. true.
/********* S T R I N G **********/
inline string ToUpper(const string& s) {string t; t.resize(s.size()); std::transform(all(s), t.begin(), ::toupper); return t; }
inline string ToLower(const string& s) {string t; t.resize(s.size()); std::transform(all(s), t.begin(), ::tolower); return t; }
inline char ToUpper(const char& c) {string s{c}, t; t.resize(s.size()); std::transform(all(s), t.begin(), ::toupper); return t[0]; }
inline char ToLower(const char& c) {string s{c}, t; t.resize(s.size()); std::transform(all(s), t.begin(), ::tolower); return t[0]; }
inline bool IsUpper(const char& c) {return isupper(c) > 0; }
inline bool IsLower(const char& c) {return islower(c) > 0; }
/********* T R I O **********/
template<class T1, class T2, class T3> struct trio {
T1 first; T2 second; T3 third;
//
trio() {first=T1(); second=T2(); third=T3();}
trio(const T1& x) : first(x), second(x), third(x) {}
trio(const T1& x, const T2& y, const T3& z) : first(x), second(y), third(z) {}
trio(const trio& t) {first=t.first; second=t.second; third=t.third;} //
trio& operator =(const trio& t) {first=t.first; second=t.second; third=t.third; return *this;}
//
auto operator <=>(const trio&) const = default;
// + -
trio operator +() const { return *this; }
trio operator -() const { return (-1) * (*this); }
//
trio& operator +=(const trio& t) {first += t.first; second += t.second; third += t.third; return *this;}
trio& operator -=(const trio& t) {first -= t.first; second -= t.second; third -= t.third; return *this;}
trio& operator *=(const trio& t) {first *= t.first; second *= t.second; third *= t.third; return *this;}
trio& operator /=(const trio& t) {first /= t.first; second /= t.second; third /= t.third; return *this;}
trio& operator %=(const trio& t) {first %= t.first; second %= t.second; third %= t.third; return *this;}
//
friend trio operator +(const trio& lhs, const trio& rhs) {return trio(lhs) += rhs;}
friend trio operator -(const trio& lhs, const trio& rhs) {return trio(lhs) -= rhs;}
friend trio operator *(const trio& lhs, const trio& rhs) {return trio(lhs) *= rhs;}
friend trio operator /(const trio& lhs, const trio& rhs) {return trio(lhs) /= rhs;}
friend trio operator %(const trio& lhs, const trio& rhs) {return trio(lhs) %= rhs;}
//
template<class U1, class U2, class U3> friend istream& operator >>(istream&, trio<U1, U2, U3>&);
template<class U1, class U2, class U3> friend ostream& operator <<(ostream&, const trio<U1, U2, U3>&);
operator tuple<T1&, T2&, T3&>() {return tie(first, second, third);}
};
using tll = trio<ll, ll, ll>;
/********* R A N D O M **********/
struct Random {
mt19937_64 rnd;
Random() {
random_device seed_gen;
rnd.seed(seed_gen());
}
Random(ll seed) {
rnd.seed(seed);
}
ll randint(ll a, ll b) { // [a, b]
uniform_int_distribution<ll> dist(a, b);
return dist(rnd);
}
double randreal(double a, double b) {
uniform_real_distribution<double> dist(a, b);
return dist(rnd);
}
char randchar(char a, char b) { // [a, b]
uniform_int_distribution<ll> dist(a, b);
return dist(rnd);
}
template<class T> void shuffle(vector<T>& vec) {
std::shuffle(all(vec), rnd);
}
};
/********* T I M E R **********/
struct Timer {
int time_limit;
int start_time;
Timer(double time_limit_sec) {
assert(time_limit_sec > 0);
this->time_limit = time_limit_sec * CLOCKS_PER_SEC;
this->start_time = clock();
}
bool is_time_up() const {
return clock() - this->start_time >= this->time_limit;
}
double get_elapsed_ratio() const {
double ratio = 1.0 * (clock() - this->start_time) / (this->time_limit - this->start_time);
return min(1.0, ratio);
}
};
/********* P R I N T **********/
template<class T> inline void print(const T& e);
template<class H, class... T> inline void print(const H& h, const T&... t);
template<class... T> inline void End(const T&... t);
/********* D E B U G **********/
#ifdef __LOCAL
#define debug(...) if(DEBUG) do{cout << '[' << #__VA_ARGS__ << "] ";debug_(__VA_ARGS__);}while(0)
#else
#define debug(...)
#endif
void dbg_(const long long& e);
template<class T> void dbg_(const T& e);
template<class T, class U> void dbg_(const pair<T, U>& p);
template<class T1, class T2, class T3> void dbg_(const trio<T1, T2, T3>& t);
template<class T> void debug_(const T& e);
template<class T> void debug_(const vector<T>& v);
template<class T> void debug_(const vector<vector<T>>& vv);
template<class T, class U> void debug_(const map<T, U>& mp);
template<class T, class U> void debug_(const vector<map<T, U>>& vm);
template<class T> void debug_(const set<T>& st);
template<class T> void debug_(const multiset<T>& st);
template<class T> void debug_(const vector<set<T>>& vs);
template<class T> void debug_(const vector<multiset<T>>& vs);
template<class H, class... T> void debug_(const H& h, const T&... t);
/********* O T H E R S **********/
template<class T, class U> inline bool chmin(T& a, U b) {if (a > b) {a = b; return true;} return false;} // b!
template<class T, class U> inline bool chmax(T& a, U b) {if (a < b) {a = b; return true;} return false;}
template<class T, class U> inline auto Mod(const T& a, const U& m) {return (a % m + m) % m;} // OK
template<class T, class U> inline auto Ceil(const T& x, const U& y) {return x < 0 ? x/y : (x + y - 1) / y;} // OK
template<class T, class U> inline auto Floor(const T& x, const U& y) {return -(Ceil(-x, y)); } // OK
inline ll Isqrt(ll n) {assert(n >= 0); ll x = round(sqrt(n)); while(x * x > n) --x; return x;}
inline ll Comb(ll n, ll r) {if (r < 0 || n < r) return 0; r = min(r, n - r); ll ret = 1; rep(i, r) {ret *= n - i; ret /= i + 1;} return ret;} // n
    =60, r=30OK
template<class T> inline T Pow(T x, ll n) {assert(n >= 0); T ret = 1; while(1) {if (n % 2) ret *= x; n /= 2; if(!n) return ret; x = x * x;}} //
     mintOK
template<class T> inline T Aseries(T a, T d, ll n) {assert(n >= 0); return a * n + n * (n - 1) / 2 * d;} // mintOK
template<class T> inline T Gseries(T a, T r, ll n) {assert(n >= 0); if (r == 1) return a * n; else return a * (1 - Pow(r, n)) / (1 - r);} //
     mintOK
template<class T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
inline bool Bit(ll b, int i) {assert(0 <= i && i < 64); return (b >> i) & 1;}
inline ll Popcount(ll b) {return __builtin_popcountll(b);}
inline ll Mask(ll n) {assert(0 <= n && n < 63); return (1LL << n) - 1LL;} // [0, n)bit64bit
inline ll Mask(ll n, ll m) {assert(n >= m); return Mask(n) ^ Mask(m);} // [m, n)bit64bit
inline void PrintYesNo(bool b) {b ? print("Yes") : print("No");}
/********* M O D **********/
// #include <atcoder/modint> // https://atcoder.github.io/ac-library/production/document_ja/
// using namespace atcoder;
// using mint = modint998244353; // modint1000000007;
// istream& operator >>(istream& stream, mint& e) {ll n; stream >> n; e = n; return stream; }
// ostream& operator <<(ostream& stream, const mint& e) { stream << e.val(); return stream; }
// using vm = vector<mint>;
// using vvm = vector<vm>;
/***************************************/
constexpr bool DEBUG = true;
// & . LONG_LONG_MAXOK.
struct PrimeFactor {
private:
const ll N = 1000;
vb P; // N
vl primes; // N
// x^n % mod
int128 pow(int128 x, ll n, int128 mod) {
int128 ret = 1;
while(1) {
if (n % 2) ret = (ret * x) % mod;
n >>= 1;
if (!n) return ret;
x = (x * x) % mod;
}
}
//
// 1. n :
// : https://manabitimes.jp/math/1192, Wikipedia
ll polards_rho(ll n) {
assert(n > 3);
// n = 4 22.
if ((n & 1LL) == 0) return 2;
auto f = [&n](int128 x, int128 c) -> ll {
int128 y = (x * x + c) % n;
return (ll)y;
};
ll c = 0;
while(1) {
c++; //
ll x = rand();
ll y = x;
while(1) {
x = f(x, c);
y = f(f(y, c), c);
ll d = gcd(abs(x - y), n);
if (d == n) break;
else if (d > 1) return d;
}
}
}
public:
PrimeFactor() {
// N
P.assign(N, true);
P[0] = P[1] = false;
rep(i, 2, N) {
if (P[i]) {
primes.pb(i);
rep(j, i * i, N, i) P[j] = false;
}
}
}
// , O(k (log n)^3), k : primes.size()
// : https://qiita.com/Kiri8128/items/eca965fe86ea5f4cbb98, Wikipedia
bool is_prime(ll n) {
assert(n > 0);
if (n < N) return P[n]; //
if ((n & 1LL) == 0) return false; //
//
ll d = n - 1;
d /= d & (-d); // 2
// a^d !≡ 1 a^{(2^r)d} !≡ -1 (0 <= r < s) ⇒ n, n - 1 = (2^s)d
fore(a, primes) {
// n <= 2^643712調.
if (a > 37) break;
int128 y = pow(a, d, n);
if (y == 1) continue;
ll d2 = d;
while(1) {
if (y == n - 1) break;
d2 <<= 1;
if (d2 == n - 1) return false;
y = (y * y) % n;
}
}
return true;
}
//
map<ll, ll> get(ll n) {
assert(n > 0);
map<ll, ll> mp;
fore(a, primes) {
while(n % a == 0) {
mp[a]++;
n /= a;
}
if (n == 1) return mp;
}
queue<ll> que;
if (n > 1) que.push(n);
while(!que.empty()) {
n = que.front();
que.pop();
if (is_prime(n)) mp[n]++;
else {
ll p = polards_rho(n);
que.push(p);
que.push(n / p);
}
}
return mp;
}
// . : https://atcoder.jp/contests/abc170/submissions/14359259
vl divisor(ll n) {
auto mp = get(n);
//
ll cnt = 1;
fore(p, mp) cnt *= p.se + 1;
vl ret(cnt);
ret[0] = 1;
cnt = 1; //
fore(p, mp) {
ll d = p.fi;
rep(k, 1, p.se + 1) {
rep(j, cnt) ret[k * cnt + j] = ret[j] * d;
d *= p.fi;
}
cnt *= p.se + 1;
}
return ret;
}
//
ll divisor_count(ll n) {
auto mp = get(n);
ll ret = 1;
fore(p, mp) ret *= p.se + 1;
return ret;
}
};
// PrimeFactor pf;
// auto mp = pf.get(24); // {(2, 3), (3, 1)},
// bool b = pf.is_prime(97); // true,
// vl vec = pf.divisor(12); // {1, 2, 4, 3, 6, 12}.
// ll n = pf.divisor_count(12); // 6.
int main() {
cin.tie(nullptr); cout << fixed << setprecision(10);
ll Q;
cin >> Q;
auto pf = PrimeFactor();
rep(q, Q) {
ll a;
cin >> a;
auto mp = pf.get(a);
ll cnt = 0;
fore(p, mp) cnt += p.se;
PrintYesNo(cnt == 3);
}
}
/********* P A I R **********/
template<class T, class U> inline pair<T, U>& operator+=(pair<T, U>& a, const pair<T, U> b) {a.fi += b.fi; a.se += b.se; return a;}
template<class T, class U> inline pair<T, U>& operator-=(pair<T, U>& a, const pair<T, U> b) {a.fi -= b.fi; a.se -= b.se; return a;}
template<class T, class U> inline pair<T, U>& operator*=(pair<T, U>& a, const pair<T, U> b) {a.fi *= b.fi; a.se *= b.se; return a;}
template<class T, class U> inline pair<T, U>& operator/=(pair<T, U>& a, const pair<T, U> b) {a.fi /= b.fi; a.se /= b.se; return a;}
template<class T, class U> inline pair<T, U>& operator%=(pair<T, U>& a, const pair<T, U> b) {a.fi %= b.fi; a.se %= b.se; return a;}
template<class T, class U, class V> inline pair<T, U>& operator+=(pair<T, U>& a, const V b) {a.fi += b; a.se += b; return a;}
template<class T, class U, class V> inline pair<T, U>& operator-=(pair<T, U>& a, const V b) {a.fi -= b; a.se -= b; return a;}
template<class T, class U, class V> inline pair<T, U>& operator*=(pair<T, U>& a, const V b) {a.fi *= b; a.se *= b; return a;}
template<class T, class U, class V> inline pair<T, U>& operator/=(pair<T, U>& a, const V b) {a.fi /= b; a.se /= b; return a;}
template<class T, class U, class V> inline pair<T, U>& operator%=(pair<T, U>& a, const V b) {a.fi %= b; a.se %= b; return a;}
template<class T, class U, class V> inline pair<T, U> operator+(pair<T, U> a, const V& b) {a += b; return a;}
template<class T, class U, class V> inline pair<T, U> operator-(pair<T, U> a, const V& b) {a -= b; return a;}
template<class T, class U, class V> inline pair<T, U> operator*(pair<T, U> a, const V& b) {a *= b; return a;}
template<class T, class U, class V> inline pair<T, U> operator/(pair<T, U> a, const V& b) {a /= b; return a;}
template<class T, class U, class V> inline pair<T, U> operator%(pair<T, U> a, const V& b) {a %= b; return a;}
template<class T, class U> inline pair<T, U> operator+(pair<T, U> a) {return a;}
template<class T, class U> inline pair<T, U> operator-(pair<T, U> a) {return a * (-1);}
template<class T, class U> istream& operator >>(istream& stream, pair<T, U>& a) {stream >> a.fi >> a.se; return stream;}
template<class T, class U> ostream& operator <<(ostream &stream, const pair<T, U>& a) { stream << a.fi << " " << a.se; return stream; }
/********* V E C T O R **********/
template<class T> inline vector<T>& operator+=(vector<T>& a, const vector<T> b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] += b[i];
    return a;}
template<class T> inline vector<T>& operator-=(vector<T>& a, const vector<T> b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] -= b[i];
    return a;}
template<class T> inline vector<T>& operator*=(vector<T>& a, const vector<T> b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] *= b[i];
    return a;}
template<class T> inline vector<T>& operator/=(vector<T>& a, const vector<T> b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] /= b[i];
    return a;}
template<class T> inline vector<T>& operator%=(vector<T>& a, const vector<T> b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] %= b[i];
    return a;}
template<class T, class U> inline vector<T>& operator+=(vector<T>& a, const U b) {fore(e, a) e += b; return a;}
template<class T, class U> inline vector<T>& operator-=(vector<T>& a, const U b) {fore(e, a) e -= b; return a;}
template<class T, class U> inline vector<T>& operator*=(vector<T>& a, const U b) {fore(e, a) e *= b; return a;}
template<class T, class U> inline vector<T>& operator/=(vector<T>& a, const U b) {fore(e, a) e /= b; return a;}
template<class T, class U> inline vector<T>& operator%=(vector<T>& a, const U b) {fore(e, a) e %= b; return a;}
template<class T, class U> inline vector<T> operator+(vector<T> a, const U& b) {a += b; return a;}
template<class T, class U> inline vector<T> operator-(vector<T> a, const U& b) {a -= b; return a;}
template<class T, class U> inline vector<T> operator*(vector<T> a, const U& b) {a *= b; return a;}
template<class T, class U> inline vector<T> operator/(vector<T> a, const U& b) {a /= b; return a;}
template<class T, class U> inline vector<T> operator%(vector<T> a, const U& b) {a %= b; return a;}
template<class T> inline vector<T> operator+(vector<T> a) {return a;}
template<class T> inline vector<T> operator-(vector<T> a) {return a * (-1);}
template<class T> istream& operator >>(istream& stream, vector<T>& a) {fore(e, a) stream >> e; return stream;}
template<class T> ostream& operator <<(ostream& stream, const vector<T>& v) {if(v.size()){stream << v[0]; rep(i, 1, v.size()) cout << " " << v[i];}
    return stream;}
template<class T> ostream& operator <<(ostream& stream, const vector<vector<T>>& vv) {if(vv.size()){stream << vv[0]; rep(i, 1, vv.size()) cout <<
    '\n' << vv[i];} return stream;}
/********* S E T **********/
template<class T> istream& operator >>(istream& stream, set<T>& st) {T e; stream >> e; st.insert(e); return stream;}
template<class T> ostream& operator <<(ostream& stream, const set<T>& st) {if(st.size()){auto it=st.begin(); stream << *it++; for(; it!=st.end(); it
    ++) cout << " " << *it;} return stream;}
/********* M U L T I S E T **********/
template<class T> istream& operator >>(istream& stream, multiset<T>& st) {T e; stream >> e; st.insert(e); return stream;}
template<class T> ostream& operator <<(ostream& stream, const multiset<T>& st) {if(st.size()){auto it=st.begin(); stream << *it++; for(; it!=st.end
    (); it++) cout << " " << *it;} return stream;}
/********* P R I N T **********/
template<class T> inline void print(const T& e) {cout << e << '\n';}
template<class H, class... T> inline void print(const H& h, const T&... t) {cout << h << ' '; print(t...);}
template<class... T> inline void End(const T&... t) {print(t...); exit(0);}
/********* D E B U G **********/
void dbg_(const long long& e) {if (e == INF) cout << "INF"; else if (e == -INF) cout << "-INF"; else cout << e;}
template<class T> void dbg_(const T& e) {cout << e;}
template<class T, class U> void dbg_(const pair<T, U>& p) {cout << '('; dbg_(p.first); cout << ' '; dbg_(p.second); cout << ')';}
template<class T1, class T2, class T3> void dbg_(const trio<T1, T2, T3>& t) {cout << '('; dbg_(t.first); cout << ' '; dbg_(t.second); cout << ' ';
    dbg_(t.third); cout << ')';}
template<class T> void debug_(const T& e) {dbg_(e); cout << '\n';}
template<class T> void debug_(const vector<T>& v) {if (v.size()){auto it=v.begin(); dbg_(*it++); for(; it!=v.end(); ++it){cout << ' '; dbg_(*it);}}
    cout << '\n';}
template<class T> void debug_(const vector<vector<T>>& vv) {cout << '\n'; ll cnt=0; for(auto&& v : vv){cout << cnt++ << ": "; debug_(v);}}
template<class T, class U> void debug_(const map<T, U>& mp) {if (mp.size()) {auto it = mp.begin(); dbg_(*it++); for(; it != mp.end(); ++it) {cout <<
    ' '; dbg_(*it);}} cout << '\n';}
template<class T, class U> void debug_(const vector<map<T, U>>& vm){cout << '\n'; ll cnt=0; for(auto&& mp : vm){cout << cnt++ << ": "; debug_(mp);}}
template<class T> void debug_(const set<T>& st) {if(st.size()){auto it=st.begin(); dbg_(*it++); for(; it!=st.end(); ++it) {cout << ' '; dbg_(*it
    );}}cout << '\n';}
template<class T> void debug_(const multiset<T>& st) {if(st.size()) {auto it=st.begin(); dbg_(*it++); for(; it != st.end(); ++it) {cout << ' '; dbg_
    (*it);}} cout << '\n';}
template<class T> void debug_(const vector<set<T>>& vs) {cout << '\n'; ll cnt=0; for(auto&& st : vs){cout << cnt++ << ": "; debug_(st);}}
template<class T> void debug_(const vector<multiset<T>>& vs) {cout << '\n'; ll cnt=0;for(auto&& st : vs){cout << cnt++ << ": "; debug_(st);}}
template<class H, class... T> void debug_(const H& h, const T&... t) {dbg_(h); cout << ", "; debug_(t...);}
/********* T R I O **********/
template<class T1, class T2, class T3> istream& operator >>(istream &stream, trio<T1, T2, T3>& t) {return stream >> t.first >> t.second >> t.third;}
template<class T1, class T2, class T3> ostream& operator <<(ostream &stream, const trio<T1, T2, T3>& t) {return stream << t.first << " " << t.second
    << " " << t.third;}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0