#include using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;} #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(i, n) for (int i = 0; i < int(n); ++i) #define rep2(i, s, n) for (int i = int(s); i < int(n); ++i) #define rep3(i, s, n, d) for(int i = int(s); i < int(n); i+=d) #define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define SUM(a) accumulate(all(a),0LL) #define MIN(a) *min_element(all(a)) #define MAX(a) *max_element(all(a)) #define INT(...) int __VA_ARGS__;input(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;input(__VA_ARGS__) #define STR(...) string __VA_ARGS__;input(__VA_ARGS__) #define CHR(...) char __VA_ARGS__;input(__VA_ARGS__) #define DBL(...) double __VA_ARGS__;input(__VA_ARGS__) #define LD(...) ld __VA_ARGS__;input(__VA_ARGS__) #define pb push_back #define eb emplace_back using ll = long long; using ull = unsigned long long; using ld = long double; using vi = std::vector; using vvi = std::vector; using vl = std::vector; using vvl = std::vector; using vd = std::vector; using vvd = std::vector; using vs = std::vector; using vvs = std::vector; using vb = std::vector; using vvb = std::vector; using vc = std::vector; using vvc = std::vector; using pii = std::pair; using pll = std::pair; using mii = std::map; using mll = std::map; template struct infinity{ static constexpr T max=std::numeric_limits::max(); static constexpr T min=std::numeric_limits::min(); static constexpr T value=std::numeric_limits::max()/2; static constexpr T mvalue=std::numeric_limits::min()/2; }; templateconstexpr T INF=infinity::value; constexpr ll infl=INF; constexpr int inf = INF; constexpr ld PI = 3.1415926535897932384626; template std::istream &operator>>(std::istream&is,std::pair&p){is>>p.first>>p.second;return is;} template std::istream &operator>>(std::istream&is,std::vector&v){for(T &in:v){is>>in;}return is;} inline void scan(int &a) { std::cin >> a; } inline void scan(long long &a) { std::cin >> a; } inline void scan(std::string &a) { std::cin >> a; } inline void scan(char &a) { std::cin >> a; } inline void scan(double &a) { std::cin >> a; } inline void scan(long double &a) { std::cin >> a; } template inline void scan(std::pair &p) { std::cin >> p; } template inline void scan(std::vector &a) { std::cin >> a; } inline void input() {} template inline void input(Head &head, Tail &...tail) {scan(head);input(tail...);} template std::ostream &operator<<(std::ostream&os,const std::vector&v){for(auto it=std::begin(v);it!=std::end(v);){os<<*it<<((++it)!=std::end(v)?" ":"");}return os;} template std::ostream &operator<<(std::ostream&os,const std::pair&p){os< inline void print(const T &t){std::cout< inline void print(const Head &head, const Tail &... tail){std::cout< inline void fin(const T &... a){print(a...);exit(0);} template inline void printl(const T &t){std::cout< inline void printl(const std::vector &a){for(const auto &v : a) std::cout << v << '\n';} template inline void printl(const Head &head, const Tail &... tail){std::cout< void trace(const T &t){std::cerr< void trace(const Head &head, const Tail &... tail){std::cerr< constexpr auto my_max(T... a){ return max(initializer_list>{a...}); } template constexpr auto my_min(T... a){ return min(initializer_list>{a...}); } template bool chmin(T &a, U b) {if (a>b) {a=b;return true;}return false;} template bool chmax(T &a, U b) {if (a std::vector> ROTATE(std::vector> X) { if(X.size() == 0) return X; std::vector> res(X[0].size(),std::vector(X.size())); rep(i,X.size())rep(j,X[0].size())res[j][X.size()-i-1]=X[i][j]; return res; } template struct CumulativeSum { private: std::vector data; bool sorted = false; public: CumulativeSum(int n) : data(n + 1, 0) {} CumulativeSum(const std::vector &v) : data(v.size() + 1, 0) { for(int i = 0; i < (int)v.size(); i++) add(i, v[i]); } void add(int k, const T &val) { data[k + 1] += val; } void build() { assert(!sorted); sorted = true; for(int i = 1; i < (int)data.size(); i++) data[i] += data[i - 1]; } T prod(int r) { assert(sorted); return (r < 0 ? 0 : data[min(r, (int)data.size() - 1)]); } T prod(int l, int r) { assert(sorted); return prod(r) - prod(l); } }; inline constexpr bool is_prime(ll n){ if(n<=1)return false; for(ll i=2;i*i<=n;i++){ if(n%i==0)return false; } return true; } inline constexpr ll my_pow(ll a,ll b){ ll res=1; while(b){ if(b&1)res*=a; a*=a; b>>=1; } return res; } inline constexpr ll mod_pow(ll a,ll b,const ll&mod){ if(mod==1)return 0; a%=mod; ll res=1; while(b){ if(b&1)(res*=a)%=mod; (a*=a)%=mod; b>>=1; } return res; } /** * @brief RollingHash */ struct RollingHash { private: static const uint64_t mod = (1ull << 61ull) - 1; using uint128_t = __uint128_t; std::vector power; const uint64_t base; static inline uint64_t add(uint64_t a, uint64_t b) { if((a += b) >= mod) a -= mod; return a; } static inline uint64_t mul(uint64_t a, uint64_t b) { uint128_t c = (uint128_t)a * b; return add(c >> 61, c & mod); } static inline uint64_t generate_base() { std::mt19937_64 mt(std::chrono::steady_clock::now().time_since_epoch().count()); std::uniform_int_distribution< uint64_t > rand(1, RollingHash::mod - 1); return rand(mt); } inline void expand(size_t sz) { if(power.size() < sz + 1) { int pre_sz = (int)power.size(); power.resize(sz + 1); for(int i = pre_sz - 1; i < sz; i++) { power[i + 1] = mul(power[i], base); } } } public: RollingHash(uint64_t base = generate_base()) : base(base), power{1} {} std::vector build(const std::string &s) const { int sz = s.size(); std::vector hashed(sz + 1); for(int i = 0; i < sz; i++) { hashed[i + 1] = add(mul(hashed[i], base), s[i]); } return hashed; } template std::vector build(const std::vector &s) const { int sz = s.size(); std::vector hashed(sz + 1); for(int i = 0; i < sz; i++) { hashed[i + 1] = add(mul(hashed[i], base), s[i]); } return hashed; } uint64_t hash(const std::vector &s, int l, int r) { expand(r - l); return add(s[r], mod - mul(s[l], power[r - l])); } uint64_t all_hash(const std::vector &s) { return s.back(); } }; /** * @brief ModInt */ template struct uint_least{ static_assert(size<=128,"size must be less than or equal to 128"); using type=typename std::conditional< size<=8,std::uint_least8_t, typename std::conditional< size<=16,std::uint_least16_t, typename std::conditional< size<=32,std::uint_least32_t, typename std::conditional::type>::type>::type>::type; }; template using uint_least_t = typename uint_least::type; namespace internal{ struct modint_base{}; }//naespace internal templateusing is_modint = std::is_base_of; template struct StaticModInt:internal::modint_base{ static_assert(std::is_integral::value, "T must be integral"); static_assert(std::is_unsigned::value, "T must be unsgined"); static_assert(mod>0, "mod must be positive"); static_assert(mod<=INF, "mod*2 must be less than or equal to T::max()"); private: using large_t = typename uint_least::digits * 2>::type; using signed_t = typename std::make_signed::type; T val; public: constexpr StaticModInt():val(0){} template::value&&std::is_unsigned::value>::type* =nullptr> constexpr StaticModInt(U x):val(x%mod){} template::value&&std::is_signed::value>::type* =nullptr> constexpr StaticModInt(U x):val{}{ x%=static_cast(mod); if(x<0)x+=static_cast(mod); val=static_cast(x); } T get()const{return val;} static constexpr T get_mod(){return mod;} static StaticModInt raw(T v){ StaticModInt res; res.val=v; return res; } StaticModInt inv()const{ return mod_inv(val,mod); } StaticModInt& operator++(){ ++val; if(val==mod)val=0; return *this; } StaticModInt operator++(int){ StaticModInt res=*this; ++*this; return res; } StaticModInt& operator--(){ if(val==0)val=mod; --val; return *this; } StaticModInt operator--(int){ StaticModInt res=*this; --*this; return res; } StaticModInt& operator+=(const StaticModInt&x){ val+=x.val; if(val>=mod)val-=mod; return *this; } StaticModInt& operator-=(const StaticModInt&x){ if(val((static_cast(val)*x.val)%mod); return *this; } StaticModInt& operator/=(const StaticModInt&x){ return *this*=x.inv(); } friend StaticModInt operator+(const StaticModInt&l,const StaticModInt&r){return StaticModInt(l)+=r;} friend StaticModInt operator-(const StaticModInt&l,const StaticModInt&r){return StaticModInt(l)-=r;} friend StaticModInt operator*(const StaticModInt&l,const StaticModInt&r){return StaticModInt(l)*=r;} friend StaticModInt operator/(const StaticModInt&l,const StaticModInt&r){return StaticModInt(l)/=r;} StaticModInt operator+()const{return StaticModInt(*this);} StaticModInt operator-()const{return StaticModInt()-*this;} friend bool operator==(const StaticModInt&l,const StaticModInt&r){return l.val==r.val;} friend bool operator!=(const StaticModInt&l,const StaticModInt&r){return l.val!=r.val;} StaticModInt pow(long long a)const{ StaticModInt v=*this,res=1; while(a){ if(a&1)res*=v; v*=v; a>>=1; } return res; } friend std::ostream &operator<<(std::ostream &os,const StaticModInt&x){ return os<>(std::istream &is,StaticModInt&x){ long long tmp; is>>tmp; x=StaticModInt(tmp); return is; } }; templateusing ModInt=StaticModInt; using modint998244353 = ModInt<998244353>; using modint1000000007 = ModInt<1000000007>; using mint = modint1000000007; void _main() { RollingHash rh; STR(S); auto ht = rh.build(S); map memo; function dfs = [&](int l, int r) { if(r < l) return mint(1); if(memo.find({l, r}) != memo.end()) return memo[{l, r}]; mint res = 1; int L = l, R = r; while(L < R) { if(rh.hash(ht, l, L + 1) == rh.hash(ht, R, r + 1)) res += dfs(L + 1, R - 1); L++, R--; } return memo[{l, r}] = res; }; print(dfs(0, S.size() - 1)); }