#pragma once
#include "../../util/util/lib.hpp"
namespace tifa_libs {
template <class T>
CEXP int parity(T x) NE {
CEXP int nd = sizeof(T) * 8;
static_assert(nd <= 128);
CEXP int nd_ull = sizeof(unsigned long long) * 8;
if CEXP (nd <= sizeof(unsigned) * 8) return __builtin_parity(x);
else if CEXP (nd <= sizeof(unsigned long) * 8) return __builtin_parityl(x);
else if CEXP (nd <= nd_ull) return __builtin_parityll(x);
else return __builtin_parityll(x >> nd_ull) ^ __builtin_parityll(x & (unsigned long long)(-1));
}
} // namespace tifa_libs
#line 2 "src/bit/parity/lib.hpp"
#line 2 "src/util/util/lib.hpp"
// https://github.com/Tiphereth-A/CP-lib
#include <bits/extc++.h>
// clang-format off
namespace tifa_libs {
#define CEXP constexpr
#define CEXPE constexpr explicit
#define CR const&
#define CP const*
#define PC *const
#define CPC const*const
#define TPN typename
#define NE noexcept
#define CNE const noexcept
#define ND [[nodiscard]]
#define cT_(...) std::conditional_t<sizeof(__VA_ARGS__) <= sizeof(size_t) * 2, __VA_ARGS__, __VA_ARGS__ CR>
// NOLINTNEXTLINE(misc-const-correctness)
#define flt_(T, i, l, r, ...) for (T i = (l), i##e = (r)__VA_OPT__(, ) __VA_ARGS__; i < i##e; ++i)
#define retif_(cond, if_true, ...) if cond return if_true __VA_OPT__(; else return __VA_ARGS__)
#ifdef ONLINE_JUDGE
#undef assert
#define assert(x) 42
#endif
using namespace std::ranges;
using namespace std::literals;
template <class T>
CEXP T abs(T x) NE { retif_((x < 0), -x, x); }
} // namespace tifa_libs
// clang-format on
#line 4 "src/bit/parity/lib.hpp"
namespace tifa_libs {
template <class T>
CEXP int parity(T x) NE {
CEXP int nd = sizeof(T) * 8;
static_assert(nd <= 128);
CEXP int nd_ull = sizeof(unsigned long long) * 8;
if CEXP (nd <= sizeof(unsigned) * 8) return __builtin_parity(x);
else if CEXP (nd <= sizeof(unsigned long) * 8) return __builtin_parityl(x);
else if CEXP (nd <= nd_ull) return __builtin_parityll(x);
else return __builtin_parityll(x >> nd_ull) ^ __builtin_parityll(x & (unsigned long long)(-1));
}
} // namespace tifa_libs