QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#292957#4882. String Strange SumKING_UTAC ✓697ms131180kbC++2023.6kb2023-12-28 17:43:142023-12-28 17:43:15

Judging History

你现在查看的是最新测评结果

  • [2023-12-28 17:43:15]
  • 评测
  • 测评结果:AC
  • 用时:697ms
  • 内存:131180kb
  • [2023-12-28 17:43:14]
  • 提交

answer

#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#endif

#include <bits/stdc++.h>
using namespace std;

using ll=long long;
//#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
void dmpr(ostream&os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ";
	dmpr(os,args...);
}
#define dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif

using uint=unsigned;
using ull=unsigned long long;

template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
	return os<<vc<t>(all(a));
}

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

pi readpi(int off=0){
	int a,b;cin>>a>>b;
	return pi(a+off,b+off);
}

template<class t>
void print_single(t x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<"\n";
	if(suc==2)
		cout<<" ";
}

template<class t,class u>
void print_single(const pair<t,u>&p,int suc=1){
	print_single(p.a,2);
	print_single(p.b,suc);
}

template<class T>
void print_single(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print_single(v[i],i==int(v.size())-1?suc:2);
}

template<class T>
void print_offset(const vector<T>&v,ll off,int suc=1){
	rep(i,v.size())
		print_single(v[i]+off,i==int(v.size())-1?suc:2);
}

template<class T,size_t N>
void print_single(const array<T,N>&v,int suc=1){
	rep(i,N)
		print_single(v[i],i==int(N)-1?suc:2);
}

template<class T>
void print(const T&t){
	print_single(t);
}

template<class T,class ...Args>
void print(const T&t,const Args&...args){
	print_single(t,2);
	print(args...);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
//#define CAPITAL
/*
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<"\n";
	#else
	cout<<"Yes"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<"\n";
	#else
	cout<<"No"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}*/
void possible(bool ex=true){
	#ifdef CAPITAL
	cout<<"POSSIBLE"<<"\n";
	#else
	cout<<"Possible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void impossible(bool ex=true){
	#ifdef CAPITAL
	cout<<"IMPOSSIBLE"<<"\n";
	#else
	cout<<"Impossible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int topbit(ull t){
	return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
	return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
	return a==0?64:__builtin_ctzll(a);
}
int botbit(ull a){
	return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
int popcount(ull t){
	return __builtin_popcountll(t);
}
int bitparity(ll t){
	return __builtin_parityll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}
ll mask(int i){
	return (ll(1)<<i)-1;
}
ull umask(int i){
	return (ull(1)<<i)-1;
}
ll minp2(ll n){
	if(n<=1)return 1;
	else return ll(1)<<(topbit(n-1)+1);
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll rand_int(ll l, ll r) { //[l, r]
	//#ifdef LOCAL
	static mt19937_64 gen;
	/*#else
	static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
	#endif*/
	return uniform_int_distribution<ll>(l, r)(gen);
}

ll rand_int(ll k){ //[0,k)
	return rand_int(0,k-1);
}

template<class t>
void myshuffle(vc<t>&a){
	rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}

template<class t,class u>
int lwb(const vc<t>&v,const u&a){
	return lower_bound(all(v),a)-v.bg;
}
template<class t,class u>
bool bis(const vc<t>&v,const u&a){
	return binary_search(all(v),a);
}

vvc<int> readGraph(int n,int m){
	vvc<int> g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		//sc.read(a,b);
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	return g;
}

vvc<int> readTree(int n){
	return readGraph(n,n-1);
}

template<class t>
vc<t> presum(const vc<t>&a){
	vc<t> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
vc<ll> presum(const vi&a){
	vc<ll> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
//BIT で数列を管理するときに使う (CF850C)
template<class t>
vc<t> predif(vc<t> a){
	gnr(i,1,si(a))a[i]-=a[i-1];
	return a;
}
template<class t>
vvc<ll> imos(const vvc<t>&a){
	int n=si(a),m=si(a[0]);
	vvc<ll> b(n+1,vc<ll>(m+1));
	rep(i,n)rep(j,m)
		b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j];
	return b;
}

//verify してないや
void transvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void transvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[j][i]=a[i][j];
	}
	a.swap(b);
	transvvc(n,m,args...);
}
//CF854E
void rotvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void rotvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[m-1-j][i]=a[i][j];
	}
	a.swap(b);
	rotvvc(n,m,args...);
}

//ソートして i 番目が idx[i]
//CF850C
template<class t>
vi sortidx(const vc<t>&a){
	int n=si(a);
	vi idx(n);iota(all(idx),0);
	sort(all(idx),[&](int i,int j){return a[i]<a[j];});
	return idx;
}
//vs[i]=a[idx[i]]
//例えば sortidx で得た idx を使えば単にソート列になって返ってくる
//CF850C
template<class t>
vc<t> a_idx(const vc<t>&a,const vi&idx){
	int n=si(a);
	assert(si(idx)==n);
	vc<t> vs(n);
	rep(i,n)vs[i]=a[idx[i]];
	return vs;
}
//CF850C
vi invperm(const vi&p){
	int n=si(p);
	vi q(n);
	rep(i,n)q[p[i]]=i;
	return q;
}

template<class t,class s=t>
s SUM(const vc<t>&a){
	return accumulate(all(a),s(0));
}
template<class t,size_t K,class s=t>
s SUM(const array<t,K>&a){
	return accumulate(all(a),s(0));
}

template<class t>
t MAX(const vc<t>&a){
	return *max_element(all(a));
}

template<class t>
pair<t,int> MAXi(const vc<t>&a){
	auto itr=max_element(all(a));
	return mp(*itr,itr-a.bg);
}

template<class A>
auto MIN(const A&a){
	return *min_element(all(a));
}

template<class t>
pair<t,int> MINi(const vc<t>&a){
	auto itr=min_element(all(a));
	return mp(*itr,itr-a.bg);
}

vi vid(int n){
	vi res(n);iota(all(res),0);
	return res;
}

template<class S>
void soin(S&s){
	sort(all(s));
}

template<class S,class F>
void soin(S&s,F&&f){
	sort(all(s),forward<F>(f));
}

template<class S>
S soout(S s){
	soin(s);
	return s;
}

template<class S>
void rein(S&s){
	reverse(all(s));
}

template<class S>
S reout(S s){
	rein(s);
	return s;
}

template<class t,class u>
pair<t,u>&operator+=(pair<t,u>&a,pair<t,u> b){
	a.a+=b.a;a.b+=b.b;return a;}
template<class t,class u>
pair<t,u>&operator-=(pair<t,u>&a,pair<t,u> b){
	a.a-=b.a;a.b-=b.b;return a;}
template<class t,class u>
pair<t,u> operator+(pair<t,u> a,pair<t,u> b){return mp(a.a+b.a,a.b+b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a,pair<t,u> b){return mp(a.a-b.a,a.b-b.b);}

template<class t>
t gpp(vc<t>&vs){
	assert(si(vs));
	t res=move(vs.back());
	vs.pop_back();
	return res;
}

template<class t,class u>
void pb(vc<t>&a,const vc<u>&b){
	a.insert(a.ed,all(b));
}

template<class t,class...Args>
vc<t> cat(vc<t> a,Args&&...b){
	(pb(a,forward<Args>(b)),...);
	return a;
}

template<class t,class u>
vc<t>& operator+=(vc<t>&a,u x){
	for(auto&v:a)v+=x;
	return a;
}

template<class t,class u>
vc<t> operator+(vc<t> a,u x){
	return a+=x;
}

template<class t>
vc<t> operator+(const vc<t>&a,const vc<t>&b){
	vc<t> c(max(si(a),si(b)));
	rep(i,si(a))c[i]+=a[i];
	rep(i,si(b))c[i]+=b[i];
	return c;
}

template<class t,class u>
vc<t>& operator-=(vc<t>&a,u x){
	for(auto&v:a)v-=x;
	return a;
}

template<class t,class u>
vc<t>& operator-(vc<t> a,u x){
	return a-=x;
}

template<class t,class u>
void remval(vc<t>&a,const u&v){
	a.erase(remove(all(a),v),a.ed);
}

template<class VS,class u>
void fila(VS&vs,const u&a){
	fill(all(vs),a);
}

template<class t,class u>
int findid(const vc<t>&vs,const u&a){
	auto itr=find(all(vs),a);
	if(itr==vs.ed)return -1;
	else return itr-vs.bg;
}

template<class t>
void rtt(vc<t>&vs,int i){
	rotate(vs.bg,vs.bg+i,vs.ed);
}

//N() が単位元
//VERIFY: yosupo
//CF407E
template<class N>
struct segtree{
	vc<N> x;
	int n,s;
	segtree(){}
	template<class t>
	segtree(const vc<t>&a){
		n=a.size();
		s=1;
		while(s<n){s*=2;}
		x.resize(s*2);
		rep(i,n)
			x[s+i]=N(a[i]);
		gnr(i,1,s)
			x[i]=N::merge(x[i*2],x[i*2+1]);
	}
	//NOT Verified
	segtree(int nn){
		resize(nn);
	}
	void resize(int nn){
		n=nn;
		s=1;
		while(s<n){s*=2;}
		x.assign(s*2,N());
		gnr(i,1,s)
			x[i]=N::merge(x[i*2],x[i*2+1]);
	}
	template<class t>
	void load(const vc<t>&a){
		n=a.size();
		s=1;
		while(s<n){s*=2;}
		x.resize(s*2);
		rep(i,n)
			x[s+i]=N(a[i]);
		rng(i,n,s)
			x[s+i]=N();
		gnr(i,1,s)
			x[i]=N::merge(x[i*2],x[i*2+1]);
	}
	void clear(){
		rep(i,n)
			x[s+i]=N();
		gnr(i,1,s)
			x[i]=N::merge(x[i*2],x[i*2+1]);
	}
	N point_get(int i){
		assert(inc(0,i,n-1));
		return x[i+s];
	}
	void point_set(int i,const N&t){
		assert(inc(0,i,n-1));
		i+=s;
		x[i]=t;
		while(i>>=1)x[i]=N::merge(x[i*2],x[i*2+1]);
	}
	void point_merge(int i,const N&t){
		assert(inc(0,i,n-1));
		i+=s;
		x[i]=N::merge(x[i],t);
		while(i>>=1)x[i]=N::merge(x[i*2],x[i*2+1]);
	}
	template<class F,class...Args>
	void point_change(int i,F f,Args&&...args){
		assert(inc(0,i,n-1));
		i+=s;
		(x[i].*f)(forward<Args>(args)...);
		while(i>>=1)x[i]=N::merge(x[i*2],x[i*2+1]);
	}
	N composite(int b,int e){
		assert(0<=b&&b<=e&&e<=n);
		N lf,rt;
		for(int l=b+s,r=e+s;l<r;l>>=1,r>>=1){
			if (l&1){
				lf=N::merge(lf,x[l]);
				l++;
			}
			if (r&1){
				r--;
				rt=N::merge(x[r],rt);
			}
		}
		return N::merge(lf,rt);
	}
	N getall(){
		return x[1];
	}
	//UTPC2020E
	//n 超えるかもしれない
	template <class F,class... Args> 
	pair<int,N> max_right(int l,F f,Args&&... args){
		assert((N().*f)(forward<Args>(args)...));
		assert(0<=l&&l<=n);
		if(l==n)return mp(n,N());
		l+=s;
		
		N sm;
		assert((sm.*f)(forward<Args>(args)...));
		do {
			while (l % 2 == 0) l >>= 1;
			if (!(N::merge(sm,x[l]).*f)(forward<Args>(args)...)){
				while (l < s) {
					l = (2 * l);
					N tmp=N::merge(sm,x[l]);
					if ((tmp.*f)(forward<Args>(args)...)) {
						sm = tmp;
						l++;
					}
				}
				return mp(l - s,sm);
			}
			sm = N::merge(sm, x[l]);
			l++;
		} while ((l & -l) != l);
		return mp(n,sm);
	}
	//UTPC2020E
	template <class F,class... Args> 
	pair<int,N> min_left(int r,F f,Args&&... args){
		assert((N().*f)(forward<Args>(args)...));
		assert(0<=r&&r<=n);
        if(r==0)return mp(0,N());
        r+=s;
        N sm;
        do {
            r--;
            while (r > 1 && (r % 2)) r >>= 1;
            if (!(N::merge(x[r],sm).*f)(forward<Args>(args)...)) {
                while (r < s) {
                    r = (2 * r + 1);
                    N tmp=N::merge(x[r],sm);
                    if ((tmp.*f)(forward<Args>(args)...)) {
                        sm = tmp;
                        r--;
                    }
                }
                return mp(r + 1 - s,sm);
            }
            sm = N::merge(x[r], sm);
        } while ((r & -r) != r);
        return mp(0,sm);
    }
    //行列とか乗せて必要なのはベクトルとの積,みたいなときに使える?
    //CF Goodbye 2016 E
    //CF 896 F
	template<class F,class T,class... Args>
	T accumulate(int l,int r,F f,T t,Args&&... args) {
		assert(0<=l&&l<=r&&r<=n);
		static int buf[2][30];
		int cnt[2]{};
		for(l+=s,r+=s;l<r;l>>=1,r>>=1){
			if(l&1)buf[0][cnt[0]++]=l;
			if(r&1)buf[1][cnt[1]++]=r-1;
			l++;
		}
		rep(i,cnt[0])t=(x[buf[0][i]].*f)(t,forward<Args>(args)...);
		per(i,cnt[1])t=(x[buf[1][i]].*f)(t,forward<Args>(args)...);
		return t;
	}
};

struct MaxNode{
	int v;
	MaxNode(int vv=-inf):v(vv){}
	static MaxNode merge(const MaxNode&a,const MaxNode&b){
		return MaxNode(max(a.v,b.v));
	}
	bool ok(int x){return v<x;}
};

//内部でグラフをいじるから in,out を使うときは注意
//hei[v] -> heavy edge で潜っていった時,自分含めて何個あるか
//pe[v]: v->par[v] の辺の情報
//-有向木のときは上から下の辺を入れてる
//-無向木のときは下から上の辺を入れてる
//VERIFY: yosupo
//CF530F
//CodeChef Persistent Oak
//AOJ GRL5C
template<class E>
struct HLD{
	vvc<E> g;
	int n,rt,cnt;
	vi sub,in,out,par,head,dep,hei,ni;
	vc<E> pe;
	int dfs1(int v,int p,int d){
		par[v]=p;
		dep[v]=d;
		for(auto itr=g[v].bg;itr!=g[v].ed;itr++)
			if(*itr==p){
				pe[v]=*itr;
				g[v].erase(itr);
				break;
			}
		for(auto&e:g[v]){
			pe[e]=e;
			sub[v]+=dfs1(e,v,d+1);
			if(sub[g[v][0]]<sub[e])
				swap(g[v][0],e);
		}
		return sub[v];
	}
	void dfs2(int v,int h){
		in[v]=cnt++;
		head[v]=h;
		for(int to:g[v])
			dfs2(to,to==g[v][0]?h:to);
		out[v]=cnt;
		if(si(g[v]))hei[v]=hei[g[v][0]]+1;
	}
	HLD(){}
	HLD(const vvc<E>&gg,int rr):g(gg),n(g.size()),rt(rr),cnt(0),
		sub(n,1),in(n),out(n),par(n,-1),head(n),dep(n),hei(n,1),ni(n),
		pe(n){
		dfs1(rt,-1,0);
		dfs2(rt,rt);
		rep(i,n)ni[in[i]]=i;
	}
	int lca(int a,int b){
		while(head[a]!=head[b]){
			if(dep[head[a]]>dep[head[b]])
				swap(a,b);
			b=par[head[b]];
		}
		if(dep[a]>dep[b])
			swap(a,b);
		return a;
	}
	int len(int a,int b){
		return dep[a]+dep[b]-dep[lca(a,b)]*2;
	}
	bool asde(int a,int b){
		return in[a]<=in[b]&&out[b]<=out[a];
	}
	//UCUP 1-22 F
	int adv(int a,int d){
		if(hei[a]<=d)return -1;
		else return ni[in[a]+d];
	}
	//CF692F
	int getpar(int v,int len){
		assert(dep[v]>=len);
		int tar=dep[v]-len;
		while(1){
			int h=head[v];
			if(dep[h]<=tar){
				return ni[in[h]+(tar-dep[h])];
			}
			v=par[h];
		}
		assert(false);
	}
	//1st UCUP 13 G
	int jump(int a,int b,int d){
		int c=lca(a,b);
		if(d<=(dep[a]-dep[c])){
			return getpar(a,d);
		}else{
			d=(dep[a]+dep[b]-dep[c]*2)-d;
			assert(d>=0);
			return getpar(b,d);
		}
	}
	//XX Opencup GP of Korea
	//CF625 F
	//2020 Multi-Uni Contest Day5 G
	//CF415E
	//Universal Cup 2023 Stage 1 G
	vi index;
	//vs を含む virtual tree を返す
	//返すのは virtual tree に使われた頂点と,辺の集合
	//辺の端点は,virtual tree における番号
	//元の木における番号を virtual tree の頂点番号に写すのが,index という変数
	//辺は ch->par の順
	//virtual tree は行き掛け順で番号がついている
	//特に,頂点 0 が根になるようにできている
	//pair<vi,vc<pi>> tree_compress(vi vs){
	void tree_compress(vi&vs,vc<pi>&es){
		if(si(index)==0)index.resize(n);
		assert(index.size());
		auto comp = [&](int x,int y){
			return in[x] < in[y];
		};
		sort(all(vs),comp);
		assert(is_sorted(all(vs),comp));
		vs.erase(unique(all(vs)),vs.ed);
		int k = vs.size();
		rep(i,k-1){
			vs.pb(lca(vs[i],vs[i+1]));
		}
		sort(all(vs),comp);
		vs.erase(unique(all(vs)),vs.ed);
		k = vs.size();
		rep(i,k) index[vs[i]] = i;
		es.clear();
		rng(i,1,k){
			int p = lca(vs[i-1],vs[i]);
			es.eb(i,index[p]);
		}
		//return mp(vs,es);
	}
	//assume a is desdendant of b
	//ex=true <=> exclude b
	template<class F>
	void subpath_work(int a,int b,bool ex,F f){
		while(1){
			if(head[a]==head[b]){
				f(in[b]+ex,in[a]+1);
				break;
			}else{
				int h=head[a];
				f(in[h],in[a]+1);
				a=par[h];
			}
		}
	}
	//KUPC2021E
	//パスに対する操作順に注意
	//euler-tour 順にしたときの区間に作用していることに注意
	//ex=true exclude lca(a,b) (=apply path edges)
	template<class F>
	void path_work(int a,int b,bool ex,F f){
		int c=lca(a,b);
		subpath_work(a,c,ex,f);
		subpath_work(b,c,true,f);
	}
	//v->false
	//-1->true
	//root-v パス上で f(x)=true となる最も深い頂点を返す
	//CF857G
	template<class F>
	int find_lowest(int v,F f)const{
		while(v>=0){
			int h=head[v];
			if(!f(h)){
				v=par[h];
			}else{
				int l=0,r=dep[v]-dep[h]+1;
				while(r-l>1){
					const int mid=(l+r)/2;
					if(f(ni[in[h]+mid]))l=mid;
					else r=mid;
				}
				return ni[in[h]+l];
			}
		}
		return -1;
	}
	//-1->false
	//v->true
	//root-v パス上で f(x)=true となる最も浅い頂点を返す
	//Yandex Cup 2023 Semifinal F (TLE...)
	template<class F>
	int find_highest(int v,F f)const{
		while(1){
			int h=head[v];
			int p=par[h];
			if(p!=-1&&f(p)){
				v=p;
			}else{
				int l=-1,r=dep[v]-dep[h];
				while(r-l>1){
					const int mid=(l+r)/2;
					if(f(ni[in[h]+mid]))r=mid;
					else l=mid;
				}
				return ni[in[h]+r];
			}
		}
		assert(false);
	}
};

//suffix automaton
//extend(a,c): ノード a から c の遷移を生やし,遷移先のノードを返す
//文字列集合に対するオートマトンも構築できる
//一般の trie が与えられたら計算量が爆発炎上する
//yosupo number of substrings
//USACO 2017 Dec Platinum 1
template<class C>
struct suffixautomaton{
	struct N{
		//len:ノードに対応する文字列の最長の長さ
		//suf:suffix link
		//org:clone元のノード
		int len,suf,org;
		map<C,int> to;
	};
	vc<N> x;
	suffixautomaton():x{N{0,-1,-1,{}}}{}
	int add(int a,C c){
		assert(x[a].to.count(c));
		int b=x[a].to[c];
		if(x[a].len+1==x[b].len)
			return b;
		else{
			int w=x.size();
			x.pb(x[b]);
			x[w].len=x[a].len+1;
			x[w].org=b;
			while(a!=-1&&x[a].to[c]==b){
				x[a].to[c]=w;
				a=x[a].suf;
			}
			return x[b].suf=w;
		}
	}
	int extend(int a,C c){
		if(x[a].to.count(c))return add(a,c);
		int cur=x.size();
		x.pb(N{x[a].len+1,0,-1,{}});
		while(a!=-1&&!x[a].to.count(c)){
			x[a].to[c]=cur;
			a=x[a].suf;
		}
		if(a!=-1){
			int z=add(a,c);
			x[cur].suf=z;
		}
		return cur;
	}
	vi toposort(){
		int n=x.size();
		vi c(n);
		rep(i,n)for(auto kv:x[i].to)c[kv.b]++;
		vi res(n);
		int b=0,e=0;
		rep(i,n)if(c[i]==0)res[e++]=i;
		while(e<n){
			int i=res[b++];
			for(auto kv:x[i].to)if(--c[kv.b]==0)res[e++]=kv.b;
		}
		return res;
	}
	//Codechef 2021 August Lunchtime Longest Spanning Substrings
	//suf によってできる木の葉から順に削って行ったときの順序を返す
	//DP などに使えると言われている
	vi treeindex(){
		int n=x.size();
		vi c(n);
		rng(i,1,n)c[x[i].suf]++;
		vi res;
		rep(i,n)if(c[i]==0)res.pb(i);
		rep(i,n-1){
			int v=res[i];
			if(--c[x[v].suf]==0)res.pb(x[v].suf);
		}
		return res;
	}
	int size()const{return si(x);}
	N& operator[](int i){
		return x[i];
	}
	void show(){
		int n=si(x);
		vc<string> buf(n);
		rep(i,n){
			for(auto [c,to]:x[i].to){
				string tmp=buf[i]+c;
				if(si(buf[to])<si(tmp))
					buf[to]=tmp;
			}
			cerr<<i<<" "<<buf[i]<<endl;
		}
	}
};

//CF530F
struct ste{
	int to,l,r;
	operator int()const{return to;}
};
ostream&operator<<(ostream&os,const ste&a){
	return os<<"ste{"<<a.to<<","<<a.l<<" "<<a.r<<"}";
}
//0 が root
//idx[i]: s[i:n) に対応するノードの index
//辺に対応する [l,r) は多分 l 最小だが未検証
template<class t>
tuple<vvc<ste>,vi,vi> stree(t a){
	int n=si(a);
	vi idx(n+1);
	suffixautomaton<int> sa;
	per(i,n)idx[i]=sa.extend(idx[i+1],a[i]);
	int s=si(sa.x);
	vi l(s,inf);
	vi ord=sa.treeindex();
	rep(i,n+1)l[idx[i]]=i;
	vvc<ste> g(s);
	for(auto i:ord)if(i>0){
		int j=sa[i].suf;
		chmin(l[j],l[i]);
		g[j].pb({i,l[i]+sa[j].len,l[i]+sa[i].len});
	}
	//ノードの子を辞書順に並べる,skip 可
	for(auto&es:g)sort(all(es),[&](ste x,ste y){
		return a[x.l]<a[y.l];
	});
	vi len(s);
	rep(i,s)len[i]=sa[i].len;
	return mt(move(g),move(idx),move(len));
}

bool dbg=false;

struct N{
	vc<pi> lr;
	void add(int l,int r){
		lr.eb(l,r);
	}
	segtree<MaxNode> seg;
	void init(){
		assert(is_sorted(all(lr)));
		vi rs(si(lr));
		rep(i,si(lr))rs[i]=lr[i].b;
		seg.load(rs);
	}
	int query(int r,int can){
		int pos=lwb(lr,pi(r,-1));
		pos=seg.min_left(pos,&MaxNode::ok,r).a;
		pos--;
		if(pos==-1)return -inf;
		int res=lr[pos].a;
		if(res<r-can)return -inf;
		return res;
	}
};

void slv(){
	string s;cin>>s;
	int n=si(s);
	
	auto [t,idx,len]=stree(s);
	HLD<ste> hld(t,0);
	vc<N> buf(si(t));
	rep(i,n){
		int v=idx[i],prelen=n-i;
		while(v!=-1){
			int h=hld.head[v];
			int p=hld.par[h];
			int curlen=p==-1?0:len[p];
			buf[h].add(i+curlen,i+prelen);
			prelen=curlen;
			v=p;
		}
	}
	rep(i,si(t))if(hld.head[i]==i)buf[i].init();
	
	auto minlen=[&](int l,int r){
		assert(l<=r);
		int pos=-inf;
		int v=idx[r],prelen=n-r;
		while(v!=-1){
			int h=hld.head[v];
			int p=hld.par[h];
			int curlen=p==-1?0:len[p];
			chmax(pos,buf[h].query(l,prelen-curlen)-curlen);
			prelen=curlen;
			v=p;
		}
		if(pos<0)return -1;
		return l-pos;
	};
	
	vvc<int> l_list(n+1);
	rep(i,n+1){
		int w=minlen(i,i);
		if(w!=-1){
			l_list[i+w].pb(i);
		}
	}
	vi lim=vid(n+1);
	ll ans=0,cur=0;
	rng(r,1,n+1){
		soin(l_list[r]);
		for(auto l:l_list[r]){
			int nx=lim[l]-(r-l);
			nx=lim[nx];
			cur+=lim[l]-nx;
			lim[l]=nx;
			int w=minlen(nx,l);
			if(w!=-1){
				l_list[l+w].pb(l);
			}
		}
		ans+=cur;
	}
	print(ans);
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	if(dbg){
		while(1)slv();
	}else{
		int t;cin>>t;rep(_,t)
		slv();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3580kb

input:

8
aa
ab
ababa
abaaba
abacaba
abaaababaab
aababcabcbc
abcdabcabaabcd

output:

1
0
6
7
0
74
51
20

result:

ok 8 numbers

Test #2:

score: 0
Accepted
time: 98ms
memory: 3572kb

input:

100000
ff
ki
wb
vc
bb
cq
tt
gl
xb
tt
ll
it
bb
yy
dd
yg
tt
vq
gg
ua
ff
nn
aa
yq
ee
ae
sj
yy
cd
qk
vk
ts
tt
cm
rr
yk
sh
fv
vm
rr
tl
vv
bb
rl
jx
pv
tx
ib
dp
oo
lx
jo
bb
dl
sj
sn
db
kk
oo
rk
yy
gz
ff
ha
ja
ax
hn
ww
ms
yy
kf
zz
ss
ii
km
uv
mn
si
ng
hh
yq
lq
bq
ed
bb
bw
jj
pp
ss
xg
ff
gm
ee
cc
fn
vv
rc
nn...

output:

1
0
0
0
1
0
1
0
0
1
1
0
1
1
1
0
1
0
1
0
1
1
1
0
1
0
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1
1
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
1
0
1
0
1
0
0
0
0
1
0
1
0
1
1
1
0
0
0
0
0
1
0
0
0
0
1
0
1
1
1
0
1
0
1
1
0
1
0
1
0
0
1
1
1
0
0
0
1
1
0
0
1
1
1
0
1
1
1
1
1
0
0
1
0
0
0
1
1
1
0
0
1
0
1
1
1
1
1
1
0
0
0
0
0
1
0
1
0
0
0
1
...

result:

ok 100000 numbers

Test #3:

score: 0
Accepted
time: 84ms
memory: 3544kb

input:

40000
nbbnn
tttuu
rfeer
omhom
qqcmq
yyiyi
tlttt
jhjtj
ixiyx
bnnon
iwpiw
uzluz
ffqfj
dyddl
szkss
dauud
dddiy
gggtt
ebbee
uboob
nnnnv
rrjrj
cjccj
xnnyy
mwmjw
wyyyq
vvuvp
vyzyv
sssss
vvsvs
rhxxr
pkkpk
xsxss
ngncn
wzwjz
khkth
jjjjj
vvvbb
unnxn
aqlqq
mmgmg
iiiji
lyllv
luuuu
itizt
fsffs
xggii
jqqtj
mummd
...

output:

4
11
2
0
4
7
4
0
0
3
0
0
4
2
1
2
10
11
4
2
16
7
4
4
0
7
4
0
20
7
2
3
5
0
0
0
20
11
3
1
7
10
2
10
0
4
4
3
2
3
4
6
1
4
10
3
6
10
10
16
7
7
0
10
5
0
2
16
0
6
1
0
1
2
5
2
5
6
20
10
0
8
10
3
16
7
0
8
4
3
0
1
7
0
2
4
4
5
3
7
2
4
16
4
1
8
10
7
4
3
4
4
6
2
2
4
6
2
4
5
4
3
10
5
0
4
16
2
3
0
3
4
1
1
4
4
11
2
...

result:

ok 40000 numbers

Test #4:

score: 0
Accepted
time: 109ms
memory: 3808kb

input:

20000
iijjijiijj
fxffxfffxx
kkiiiiiiii
oppopopppo
iiooiioooi
gggxxxxggg
oxxoxxxoox
puuuppupuu
ppssspspps
eefffeefff
xxtxxxttxt
yyppypyppp
kkwwkkwwkk
bvvvbvbbbv
attataaaat
boooobbobo
hhhhfhhhff
nnhhhnhhhh
cdccccdccd
axxxaxaxxa
qqnnnnnqnq
eeexxeeeex
ppkkkkkkkp
uusussusss
iwiwiiwiii
gglgllgggg
wwwrrrwr...

output:

40
58
93
52
52
57
56
34
44
46
52
46
57
47
41
47
87
48
56
52
65
47
86
56
61
50
51
34
58
41
52
47
60
92
61
56
64
55
65
48
56
77
80
62
55
57
41
58
44
93
63
49
54
59
50
55
111
58
52
52
39
35
63
50
111
84
140
75
78
40
99
56
49
40
68
45
87
54
47
59
52
59
50
86
82
54
48
59
33
121
84
44
33
40
62
55
46
121
6...

result:

ok 20000 numbers

Test #5:

score: 0
Accepted
time: 151ms
memory: 3628kb

input:

10000
jlljjjlllljjjjljllll
uooooouuouoouoooouuo
utttutuuttuuuutttutu
xccxxxccxxccccxcxxxc
sjjsjjsjjssjjsssjjjs
fgffffgfgggfgfgfffgf
ddaaadaadadddadadaaa
tbbbbttttttbtttbtbtt
eeeeeekkkekeeeekeeke
dddddmdmmmmdddmmddmm
yykkkkykkykykkkkyykk
ededeedddededeedddee
kktttkktktkktkkkttkk
fcfcfcffffcffcccccfc
...

output:

339
332
348
341
662
367
363
432
395
371
452
460
353
472
416
420
464
365
589
476
516
407
446
376
501
364
354
424
366
438
330
590
553
491
662
317
467
374
422
406
492
484
405
328
396
654
300
410
447
404
389
487
534
688
489
370
396
474
396
467
364
424
380
236
480
506
506
339
297
316
457
626
338
349
351
...

result:

ok 10000 numbers

Test #6:

score: 0
Accepted
time: 179ms
memory: 3912kb

input:

4000
urrrrrrrrururrruruuuuuuuuruurruuruuuurrruurruurruu
hthtthttthhhtttthhhhthhhhthhhttthtthhtthhtttttthhh
ttssssssttsststttsttttssstsssstsstssttssststttstst
iiniiiiiniinnniiniiiiniiiinnniiinniiininniinnnnnni
dddpdpddpdpdppppdpdppdpdpddppppddddpdpdddppppdppdp
mmmsmmmmsmmmmmmsmmmmsmmmmsssmmssmssmsmsm...

output:

5599
5287
4294
4818
5746
7893
3623
3453
5390
5812
5608
5541
6069
5655
3743
3847
4866
5059
3876
3925
5018
4379
5016
5747
5333
5271
3890
5894
5141
3773
4196
4880
5111
5510
4334
3825
6188
5960
4893
5359
4720
4167
4042
4051
5011
6457
3807
3837
4612
4859
5044
6861
4330
5967
5001
4857
4340
3957
4152
4230
...

result:

ok 4000 numbers

Test #7:

score: 0
Accepted
time: 197ms
memory: 3904kb

input:

2000
ffffccfcfcfcfccffcccfcccfcfccfcccccfcfcccfccfcccccffffcccfcccffffffcffffccccffffffccffffcccfcccfcfff
enneeenneneennnnneeeeeenenneeennnnneneneneenneenneennnnnnnnenennennnneneneneeenennnneennnenneennnnne
mzmzmmzzmzzmzzmmzmmmzzmmmzzzzmmmzmmzzmzzmmmzzmzmzmmzzmmmmzmmmmmmzzmmmzmmmmzmmzmzmmzzmzmmmmmzm...

output:

32329
22810
31196
27570
28177
29004
24676
27293
26336
28196
28972
25095
34989
26711
26498
29643
24727
22723
31605
30180
43766
27097
25766
26819
28516
28122
34935
27399
33153
32281
26033
24708
41701
21704
24011
27481
26913
23270
31778
27676
25970
38135
25776
23316
44300
29424
24305
23476
29598
24423
...

result:

ok 2000 numbers

Test #8:

score: 0
Accepted
time: 215ms
memory: 3792kb

input:

1000
udduuddduududddudduuduuuduuududdduuduuduudududdduuddddduuuuddduuuuudduddduuddddududduuduuuuuduuduudduuuuuuuddduuduuduuuudududduuuuududuudduduuduuduududddudududdududuududuudududdduddduuuuuuuuuuuddduduu
kykykkykyykkykkkkkkyykkyyyyyykyyykkkyykkyykyyyykkykykkkykkykkkyyykyyyyykkkyyykykykkkkyyykkyyyy...

output:

153694
145776
132786
133300
133959
177645
148786
132135
169466
159430
133110
171068
168822
120233
160090
125272
130139
138522
163688
161504
146208
170689
149990
147133
129161
146576
129200
138709
133553
154659
136204
167106
167771
151156
129986
137285
131065
131582
159289
158241
141081
128564
167348...

result:

ok 1000 numbers

Test #9:

score: 0
Accepted
time: 253ms
memory: 4544kb

input:

200
zzzzzzzzzzzzzzzazzzazzzzzzzaazzaaaazaazzaazzazaazazazazzzazazaazzazzaazaaaazaaazzzzzazzzazzaaazzazzazazaazzzazaaaaaazzzaazzzazaazzzzzaaaazazazazzzzaaaaazaazzzzazzzazazaaazazzzaazaazazazzzzazaazaazaaaazzzzzazzazzzazzzzzzazzaazzzazzzzazzzzaaazzzaaazzzzzazzaazzzzazaazzaaaaazzazazzaaaaazzzzzaaazzazz...

output:

6229118
5438629
6162119
5350067
5263770
5443998
6419968
6592325
5876576
5249432
6397577
5947645
5851620
6059174
6048260
5774316
6323371
6103930
5794311
5297842
5559753
6109729
5724850
5095495
5263069
5635785
5916607
5959557
5261499
5446440
5526488
5504207
7229030
5767214
5191558
5475249
5537449
6169...

result:

ok 200 numbers

Test #10:

score: 0
Accepted
time: 361ms
memory: 11128kb

input:

20
nnnllllnlnnllllllllllllnnnnllnnlllnnnnnnnlnlnnlnllnnlnnnnnnnnnllllnlllnnnlnllnnnlnnllnnlnnllnnnllnlnllnllllnnnlllnllllnlnnllnllllnnlllnnnlllnlnnnnlllnnnlnlnnlnllnnlnllnlllllllnnnnnnnnlnnlllnlnnnllnlllllnlnnllnllllnnnnnnnnnlnnnnnnnnlnlnnnllllllnllnlllnnnlnllnllnnllllllllllnnllnllllnlllnlllnlnnnlll...

output:

894196857
938803119
931699133
881434935
917400222
988704236
829814492
910180484
875107867
927874072
861165839
857715013
907953346
879864017
925887954
884818843
920746630
936583374
887419288
927606368

result:

ok 20 numbers

Test #11:

score: 0
Accepted
time: 468ms
memory: 35464kb

input:

5
omomomommomommommoooommmommmoommmomommmoomoomoomomomoooommmmmmoomomomoommoooommommmooommomoomomommmmmmomooomoommomoommomoooooomoomomooommmommmmooooooomoooommmmomooomoommmmmomoooomommomomomommmomommmommoooomooommomooomoomoommmmmmmoomoommoomommommmmommmmmmmmmoooomomoooomoommmmoomooomomooommmmmoommom...

output:

17174226584
17605268588
18296766446
17539695533
18766633585

result:

ok 5 number(s): "17174226584 17605268588 18296766446 17539695533 18766633585"

Test #12:

score: 0
Accepted
time: 584ms
memory: 67188kb

input:

2
ddvddvvvvvddddvddddddddddddvvdvvvvvvvddvddddddddvvvvdvvddvvdvvvdvdddvdddvvvvdvvvvdvdvdvddvvvddvdvdddvdddvdvvdvvvvdvdvvvvvvdvdvvdddvdddvvvdddvvddvvvdvdddvdddvvdvvddvddvdvdvddvvvvvvdvdddvvddvdddvdddvdvvvvdvvvvdvvddvvvddvvdddvvddvdddvdvdvddvvvddvddvvddvddvvddddvdddvddvvvdvdvvvvvdvvvvddddvdddvddvdvvdd...

output:

132896961339
129565821251

result:

ok 2 number(s): "132896961339 129565821251"

Test #13:

score: 0
Accepted
time: 291ms
memory: 66152kb

input:

1
aaaattttattataatattaatattatttatatataaaaaaaattttttaaaaataatttattaaaaaatttttataataataaattttatattatattaaaaatttaaatatatttataaattaatatatataaatataaataaattttattttattaaaatttataaaaatattaattataaaattattaaaatttataaaatataaataatatataaattttaaaaatattaattattattaaaaaaaataatttaataaatattataattaattattaataataatattatatt...

output:

119827510026

result:

ok 1 number(s): "119827510026"

Test #14:

score: 0
Accepted
time: 697ms
memory: 131000kb

input:

1
wzwzzzwzzzwzwwzzwzzzwzzwzzzzwwzzzzzzwzzwzwzzwzwwzwzzwzzwwwwwwwzwzwzzzwzzzwwwwwwzwwwzzzwwwzzwwzwzwzzwzwzwwwwzwzwzzzzwwzwzzzwwwzwwzzwwzzzwzzzzzwwwzzzzwwwwwwzwwzzzwzwzzzwwwzwzzzzzwzwzzwwwwzwwzwzzzzwwwwwwwzwwzzwzwzwwwzwwwwwwzzzwwzzwwzzzzzzzwzzzwwwzwwwzzwwzzzzwzzzwzzwzwzwwwwzzwwwzwzwzwzzwzzzzzwwwwwzwww...

output:

554193679678

result:

ok 1 number(s): "554193679678"

Test #15:

score: 0
Accepted
time: 692ms
memory: 131040kb

input:

1
eeeewweeewwweeeewewweweeweeeewweweeewweeewweewwwewwewwwewwewwwewewewwweewwwwweeeweweeeeeeewweewweewwwewwweweeeweweweeweeewwwwewweweewwewwwweeweeeewwwwewewwwewwwwewwewwewewwwwwweeweewweewweeewwwwewewewewwwwwweweeewwwwwewwwwweeewweeweewewwweewweeeewwewewewewweeeewwweweewewwwwewwwwwwwewwweeeeeewewewe...

output:

529663865648

result:

ok 1 number(s): "529663865648"

Test #16:

score: 0
Accepted
time: 663ms
memory: 131180kb

input:

1
vvvvvaaavavaaavaavavvavaaaavavavaaaaavavvvvvvavvvvvaaaavvvvavaaavvvaavaaavavaaaavvvvvvavavaavvaavvvaavvvaavvvaaaaaavavavavvaavavvavavvvvvaavvavavvvavavvvvavavvaaavvvvavvvvvvaavvavvvaavvavaavvvvavvaaaaavvvaavvaaaaavaavvavvvaavavaaaavaavvaavvavvavvavvvvvaavvvavvaaavaavavaaavavavvaavaavavaavavvavvvaa...

output:

556151200408

result:

ok 1 number(s): "556151200408"

Test #17:

score: 0
Accepted
time: 696ms
memory: 130872kb

input:

1
lslsslslssslllllslssllsssllllslllsllssllslllsslslslssllssslsssllsllslllllsssssllslslssslllslssslssslsslsllssllssslllllslslslsslssssssslsllslssslsslslllsssssslsslslslllslsssllsssslsllsssslssllslsllsllsssllslslllsslsllslsssslsssslslslsssllsslllsssssslsssllssllslllsllssslsssslllslslllllsslllsllsllsll...

output:

528149019431

result:

ok 1 number(s): "528149019431"

Test #18:

score: 0
Accepted
time: 545ms
memory: 117436kb

input:

1
lllrllalaalllalaaraarlaralaaaalaarrrrralllllaarllllaarrlllalalrrlaarllraaaalrarrarrrlallrlaralraarlrrraallralrrlaraallralarrallarrrrarlllrrrarrlllllaaarlaararrlalalraallrlararalallalrrlrlrarlrraararrarllaaaaallalrlaaarllraaaalraalaarrrralllrlalalralalrrllrrallarllalraaalralrrlalrlarrralrlrrraraaal...

output:

22333600841

result:

ok 1 number(s): "22333600841"

Test #19:

score: 0
Accepted
time: 475ms
memory: 108084kb

input:

1
iixvjvjjijijiijvvxjvxvjjjjjiixijvvxxvjxvvvivxixjixiivivijjiixvxvixxvvjjxiijvixjivjvxixxivxvxxjiixjxivjvivivjxxxjxiiviijjxxvxiijjvxxjjvjvjxixivxxjijjiiivjvvvjiijijxvvivivxixiijjvxxvxxvjjijjjjvvxjxxvjxixvvjijivjjjviixviivijvjjjvjjxvjjxiivxxxjxxjvxxvjxijjxxvxjjvvvvjivxjvjvxxiivvvxiivijxxjxjxjxvivvvxv...

output:

11581008357

result:

ok 1 number(s): "11581008357"

Test #20:

score: 0
Accepted
time: 64ms
memory: 71648kb

input:

1
llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll...

output:

1333333333300000

result:

ok 1 number(s): "1333333333300000"

Test #21:

score: 0
Accepted
time: 71ms
memory: 3604kb

input:

10000
voovvoovvoovvoovvoov
iiifiiifiiifiiifiiif
cccccccccccccccccccc
ffaaffaaffaaffaaffaa
vvvvvvvvvvvvvvvvvvvv
pppppppppppppppppppp
eeeeeeeeeeeeeeeeeeee
rttrrttrrttrrttrrttr
ifffifffifffifffifff
auaaauaaauaaauaaauaa
ygygygygygygygygygyg
sooosooosooosooosooo
qyqyqyqyqyqyqyqyqyqy
bnbbbnbbbnbbbnbbbnbb
...

output:

730
867
1330
772
1330
1330
1330
730
820
765
1050
820
1050
765
1330
772
772
795
730
765
730
1050
1330
820
1330
730
1330
820
765
795
730
765
765
795
772
765
730
772
867
1330
730
772
730
765
1330
730
1050
867
730
765
867
730
795
765
765
730
1050
820
1330
765
1330
730
795
1330
730
765
820
765
1050
765
1...

result:

ok 10000 numbers

Test #22:

score: 0
Accepted
time: 119ms
memory: 3968kb

input:

1000
dwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwddwwwddwdwwdwwd
nnununuuunnuuunnununuuunnuuunnununuuunnuuunnununuuunnuuunnununuuunnuuunnununuuunnuuunnununuuun...

output:

1081353
1118393
1088918
1090191
1116529
1064770
1075776
1129102
1074591
1115280
1162865
1087780
1074274
1052530
1096934
1118610
1088713
1115380
1131098
1078760
1083054
1105100
1079841
1078832
1097238
1117021
1076154
1121333
1084532
1166455
1089413
1138232
1124277
1088094
1074886
1136986
1105960
1128...

result:

ok 1000 numbers

Test #23:

score: 0
Accepted
time: 219ms
memory: 12388kb

input:

10
iwwiwiwiwiwwiwwiwiwiiwwwwwiwiiiwwiiwwwiwwwwiiwwwiiiwwwwwiwwwwiwiiwiiwwiiwwiiwwwwwwwwiwwiiiwwiiwiwiwwiiiiiwiwiwwiiwwwwwwiwiwiwwiiiiiwwwiwwiiiwiwwiwiwiwiwwiwwiwiwiiwwwwwiwiiiwwiiwwwiwwwwiiwwwiiiwwwwwiwwwwiwiiwiiwwiiwwiiwwwwwwwwiwwiiiwwiiwiwiwwiiiiiwiwiwwiiwwwwwwiwiwiwwiiiiiwwwiwwiiiwiwwiwiwiwiwwiww...

output:

1295376087708
1295178117419
1295587801659
1295313428121
1296115944696
1295231802325
1295170936996
1295379554897
1295313977212
1295364009371

result:

ok 10 numbers

Test #24:

score: 0
Accepted
time: 307ms
memory: 77144kb

input:

1
ngngggngggngnnggngggnggnggggnnggggggnggngnggngnngnggnggnnnnnnngngngggngggnnnnnngnnngggnnnggnngngnggngngnnnngngnggggnngngggnnngnnggnngggngggggnnnggggnnnnnngnngggngngggnnngngggggngnggnnnngnngnggggnnnnnnngnnggngngnnngnnnnnngggnnggnngggggggngggnnngnnnggnnggggngggnggngngnnnnggnnngngngnggngggggnnnnngnnn...

output:

1320450315151483

result:

ok 1 number(s): "1320450315151483"

Test #25:

score: 0
Accepted
time: 245ms
memory: 74664kb

input:

1
vvvfvvrvrrvvvrvrrfrrfvrfrvrrrrvrrfffffrvvvvvrrfvvvvrrffvvvrvrvffvrrfvvfrrrrvfrffrfffvrvvfvrfrvfrrfvfffrrvvfrvffvrfrrvvfrvrffrvvrffffrfvvvfffrffvvvvvrrrfvrrfrffvrvrvfrrvvfvrfrfrvrvvrvffvfvfrfvffrrfrffrfvvrrrrrvvrvfvrrrfvvfrrrrvfrrvrrffffrvvvfvrvrvfrvrvffvvffrvvrfvvrvfrrrvfrvffvrvfvrfffrvfvfffrfrrrv...

output:

1320037988306839

result:

ok 1 number(s): "1320037988306839"

Test #26:

score: 0
Accepted
time: 158ms
memory: 69784kb

input:

1
vqducvmoheimtxbtezzhinvgpltrtlgdacurdwpddmybmtvlyzxedvvximthlnpphlfnpjfrwofqwcsiyllrpeotqjpjpwcuohpkakdwedioksrzmzzyalfmvsitadyvltamltccnakjcnchmcycwmllrxnpsrpfafaogkbjpnxpufizpdvyosypyfyfddhebgunajssmtzzpenvsitafxvjonoyaaskglenhvfamuzqxtntcxcqoupkmutslthtdowxaqzvmpgiqsuvuyditcbaxhigdrfhcokapnjqpp...

output:

1319998788614514

result:

ok 1 number(s): "1319998788614514"

Test #27:

score: 0
Accepted
time: 432ms
memory: 117424kb

input:

1
jjbjjbpjjbjjbpejjbjjbpjjbjjbpesjjbjjbpjjbjjbpejjbjjbpjjbjjbpescjjbjjbpjjbjjbpejjbjjbpjjbjjbpesjjbjjbpjjbjjbpejjbjjbpjjbjjbpesczjjbjjbpjjbjjbpejjbjjbpjjbjjbpesjjbjjbpjjbjjbpejjbjjbpjjbjjbpescjjbjjbpjjbjjbpejjbjjbpjjbjjbpesjjbjjbpjjbjjbpejjbjjbpjjbjjbpescznjjbjjbpjjbjjbpejjbjjbpjjbjjbpesjjbjjbpjjbjj...

output:

405176488446365

result:

ok 1 number(s): "405176488446365"

Test #28:

score: 0
Accepted
time: 272ms
memory: 21868kb

input:

10
ccjccjuccjccjutccjccjuccjccjutvccjccjuccjccjutccjccjuccjccjutvbccjccjuccjccjutccjccjuccjccjutvccjccjuccjccjutccjccjuccjccjutvbyccjccjuccjccjutccjccjuccjccjutvccjccjuccjccjutccjccjuccjccjutvbccjccjuccjccjutccjccjuccjccjutvccjccjuccjccjutccjccjuccjccjutvbypccjccjuccjccjutccjccjuccjccjutvccjccjuccjc...

output:

427679431877
427679431877
427679431877
427679431877
427679431877
427679431877
427679431877
427679431877
427679431877
427679431877

result:

ok 10 numbers

Test #29:

score: 0
Accepted
time: 170ms
memory: 4712kb

input:

100
yyeyyeayyeyyeasyyeyyeayyeyyeasmyyeyyeayyeyyeasyyeyyeayyeyyeasmgyyeyyeayyeyyeasyyeyyeayyeyyeasmyyeyyeayyeyyeasyyeyyeayyeyyeasmghyyeyyeayyeyyeasyyeyyeayyeyyeasmyyeyyeayyeyyeasyyeyyeayyeyyeasmgyyeyyeayyeyyeasyyeyyeayyeyyeasmyyeyyeayyeyyeasyyeyyeayyeyyeasmghbyyeyyeayyeyyeasyyeyyeayyeyyeasmyyeyyeayye...

output:

337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
337450031
...

result:

ok 100 numbers

Test #30:

score: 0
Accepted
time: 425ms
memory: 117284kb

input:

1
qqeqqelqqeqqelrqqeqqelqqeqqelrvqqeqqelqqeqqelrqqeqqelqqeqqelrvbqqeqqelqqeqqelrqqeqqelqqeqqelrvqqeqqelqqeqqelrqqeqqelqqeqqelrvbmqqeqqelqqeqqelrqqeqqelqqeqqelrvqqeqqelqqeqqelrqqeqqelqqeqqelrvbqqeqqelqqeqqelrqqeqqelqqeqqelrvqqeqqelqqeqqelrqqeqqelqqeqqelrvbmxqqeqqelqqeqqelrqqeqqelqqeqqelrvqqeqqelqqeqq...

output:

405176488446365

result:

ok 1 number(s): "405176488446365"

Test #31:

score: 0
Accepted
time: 449ms
memory: 117300kb

input:

1
zznzznwzznzznwbzznzznwzznzznwbrzznzznwzznzznwbzznzznwzznzznwbrxzznzznwzznzznwbzznzznwzznzznwbrzznzznwzznzznwbzznzznwzznzznwbrxezznzznwzznzznwbzznzznwzznzznwbrzznzznwzznzznwbzznzznwzznzznwbrxzznzznwzznzznwbzznzznwzznzznwbrzznzznwzznzznwbzznzznwzznzznwbrxeizznzznwzznzznwbzznzznwzznzznwbrzznzznwzznzz...

output:

405176488446365

result:

ok 1 number(s): "405176488446365"

Test #32:

score: 0
Accepted
time: 470ms
memory: 104312kb

input:

1
aaoaaoxaaoaaoxwaaoaaoxaaoaaoxwpaaoaaoxaaoaaoxwaaoaaoxaaoaaoxwpbaaoaaoxaaoaaoxwaaoaaoxaaoaaoxwpaaoaaoxaaoaaoxwaaoaaoxaaoaaoxwpbraaoaaoxaaoaaoxwaaoaaoxaaoaaoxwpaaoaaoxaaoaaoxwaaoaaoxaaoaaoxwpbaaoaaoxaaoaaoxwaaoaaoxaaoaaoxwpaaoaaoxaaoaaoxwaaoaaoxaaoaaoxwpbrzaaoaaoxaaoaaoxwaaoaaoxaaoaaoxwpaaoaaoxaaoaa...

output:

497781730884919

result:

ok 1 number(s): "497781730884919"

Test #33:

score: 0
Accepted
time: 441ms
memory: 104364kb

input:

1
xxexxecxxexxeckxxexxecxxexxeckfxxexxecxxexxeckxxexxecxxexxeckfpxxexxecxxexxeckxxexxecxxexxeckfxxexxecxxexxeckxxexxecxxexxeckfpdxxexxecxxexxeckxxexxecxxexxeckfxxexxecxxexxeckxxexxecxxexxeckfpxxexxecxxexxeckxxexxecxxexxeckfxxexxecxxexxeckxxexxecxxexxeckfpdqxxexxecxxexxeckxxexxecxxexxeckfxxexxecxxexx...

output:

497781730884919

result:

ok 1 number(s): "497781730884919"

Test #34:

score: 0
Accepted
time: 421ms
memory: 97456kb

input:

1
iiwiiwfiiwiiwfbiiwiiwfiiwiiwfbmiiwiiwfiiwiiwfbiiwiiwfiiwiiwfbmeiiwiiwfiiwiiwfbiiwiiwfiiwiiwfbmiiwiiwfiiwiiwfbiiwiiwfiiwiiwfbmehiiwiiwfiiwiiwfbiiwiiwfiiwiiwfbmiiwiiwfiiwiiwfbiiwiiwfiiwiiwfbmeiiwiiwfiiwiiwfbiiwiiwfiiwiiwfbmiiwiiwfiiwiiwfbiiwiiwfiiwiiwfbmehaiiwiiwfiiwiiwfbiiwiiwfiiwiiwfbmiiwiiwfiiwii...

output:

807861657180251

result:

ok 1 number(s): "807861657180251"

Test #35:

score: 0
Accepted
time: 315ms
memory: 82644kb

input:

1
oopoopdoopoopdzoopoopdoopoopdzgoopoopdoopoopdzoopoopdoopoopdzgvoopoopdoopoopdzoopoopdoopoopdzgoopoopdoopoopdzoopoopdoopoopdzgvroopoopdoopoopdzoopoopdoopoopdzgoopoopdoopoopdzoopoopdoopoopdzgvoopoopdoopoopdzoopoopdoopoopdzgoopoopdoopoopdzoopoopdoopoopdzgvrwoopoopdoopoopdzoopoopdoopoopdzgoopoopdoopoo...

output:

1292889259936437

result:

ok 1 number(s): "1292889259936437"

Test #36:

score: 0
Accepted
time: 242ms
memory: 75336kb

input:

1
iiaiiajiiaiiajeiiaiiajiiaiiajeciiaiiajiiaiiajeiiaiiajiiaiiajecliiaiiajiiaiiajeiiaiiajiiaiiajeciiaiiajiiaiiajeiiaiiajiiaiiajeclviiaiiajiiaiiajeiiaiiajiiaiiajeciiaiiajiiaiiajeiiaiiajiiaiiajecliiaiiajiiaiiajeiiaiiajiiaiiajeciiaiiajiiaiiajeiiaiiajiiaiiajeclvpiiaiiajiiaiiajeiiaiiajiiaiiajeciiaiiajiiaii...

output:

1328201924096597

result:

ok 1 number(s): "1328201924096597"

Test #37:

score: 0
Accepted
time: 157ms
memory: 68528kb

input:

1
yygyygvyygyygvoyygyygvyygyygvouyygyygvyygyygvoyygyygvyygyygvouyygyygvyygyygvoyygyygvyygyygvouyygyygvyygyygvoyygyygvyygyygvouyygyygvyygyygvoyygyygvyygyygvouyygyygvyygyygvoyygyygvyygyygvouyygyygvyygyygvoyygyygvyygyygvouyygyygvyygyygvoyygyygvyygyygvouyygyygvyygyygvoyygyygvyygyygvouyygyygvyygyygvoyygy...

output:

1332701853158829

result:

ok 1 number(s): "1332701853158829"

Test #38:

score: 0
Accepted
time: 111ms
memory: 64376kb

input:

1
hhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfhhfkhhfh...

output:

1333199053599917

result:

ok 1 number(s): "1333199053599917"

Test #39:

score: 0
Accepted
time: 437ms
memory: 124312kb

input:

1
cxcxccxcxcxccxcccxccccxcxccxcccxcccxcxccxccccxcxccxcccxcccxcxccxcccxccccxcxccxccccxcxccxcxcxccxcccxccccxcxccxcccxcccxcxccxccccxcxccxcccxcccxcxccxcccxccccxcxccxcccxcccxcxccxccccxcxccxcccxccccxcxccxcccxcccxcxccxccccxcxccxcccxccccxcxccxcccxcccxcxccxcxccxcccxcccxcxccxcccxcxccxcccxcccxcxccxccccxcxccxcc...

output:

532325876704019

result:

ok 1 number(s): "532325876704019"

Test #40:

score: 0
Accepted
time: 437ms
memory: 123264kb

input:

1
aqaqaqaqaaqaaqaqaqaqaaqaqaaqaqaaaaqaaqaqaaqaqaqaqaaqaqaaqaqaaaaqaaqaqaaqaqaaqaqaaaaqaqaaaqaqaaqaqaaaaaqaqaqaqaaqaaqaqaqaqaaqaqaqaqaqaqaaqaaqaqaqaqaaqaqaaqaqaaaaqaaqaqaqaqaqaqaaqaaqaqaqaqaaqaqaaqaqaaaaqaaqaqaaqaqaqaqaaqaqaaqaqaaaaqaaqaqaaqaqaaqaqaaaaqaqaaaqaqaaqaqaaaaaqaqaqaqaaqaaqaqaqaqaaqaqaqaqaq...

output:

489819092586073

result:

ok 1 number(s): "489819092586073"

Test #41:

score: 0
Accepted
time: 375ms
memory: 122012kb

input:

1
zzzzjzjjzzzzjzjjzzzzzzzjzjzzzzjzjjzzzzzzzjzjjzzzzjzjjzzzzjzjjzzzzjzjjzzzzjzjjzzzzzzzzjzjjzzzzjzjjzzzzzzzjzjzzzzjzjjzzzzzzzjzjjzzzzjzjjzzzzjzjjzzzzjzjjzzzzjzjjzzzzjzjjzzzzjzzzzzjzjjzzzzzzzjzjjzzzzjzjjzzzzzzzjzjzzzzjzjjzzzzzzzjzjjzzzzjzjjzzzzjzjjzzzzjzjjzzzzjzjjzzzzzzzzjzjjzzzzjzjjzzzzzzzjzjzzzzjzjj...

output:

390591892081557

result:

ok 1 number(s): "390591892081557"

Test #42:

score: 0
Accepted
time: 422ms
memory: 122336kb

input:

1
ddgddgdgdgdgdggdddggdggggddgddggggdgddgdggddggdggddgddgdgdgdgdggdddggdggggddgddggggdgddgdggddggdddgddgdgdgdgdggdddggdggggddgddggggdgddgdggddggdggddgddgdgdgdgdggdddggdggggddgddggggdgddgdggddggdggdgdgdggdddddgdddgggdggddggdgdddgdgddggddddgddgdgddggdgdgdggggddddgddgdgdgdgdggdddggdggggddgdddgddddgddgd...

output:

88340030443020

result:

ok 1 number(s): "88340030443020"

Test #43:

score: 0
Accepted
time: 471ms
memory: 125508kb

input:

1
bbbbllblblllbllbllblbbllblbllbblblblbblblllblllblllblbllbbbbbllllblllbbblllbllbbbblblbblbllbbbblbllbbbllbbbbbbbbbbbbbbbbllblblllbllbllblbbllblbllbbbbbbllblblllbllbllblbbllblbllbblblblbblblllblllblllblbllbbbbbllllblllbbblllbllbbbblblbblbllbbbblbllbbbllbbbbbbbbbbbbbbbbllblblllbllbllblbbllblbllbblblb...

output:

21558624570815

result:

ok 1 number(s): "21558624570815"

Test #44:

score: 0
Accepted
time: 550ms
memory: 129452kb

input:

1
smmsmsmssmmssmmmssmssmmsmmmmmmsmmmssmmsssmssmmsmmsmmsssmsmsmmssssmmmmmmsmsmsmsmsmmssssmmmmsmsssmmsssmsmmmsmssmsssmmmsmmmmsssmsmmmmmssssssssmmmssssmmmmmmsssmsmmsmmmmsssmmmmmmmmsmmmsmssmmsmmssmmmssmmssmmsmsmmssmsmsmsmmmssmsmsssmssssmssmssmsmsmsmsmmmmsmmssmsssmsssmssmssmmsmmsssmmsssssmmsmmsmssmsmmmms...

output:

3080126774871

result:

ok 1 number(s): "3080126774871"

Test #45:

score: 0
Accepted
time: 609ms
memory: 119488kb

input:

1
pqpppppqqqqqpqqpppqqqqpqpqqppqqppqqqppqqqqqppqqppqpqppqppqqpppppqppppqqppppqpppqppqpqpqqppppqqpqqppppqpqqpppqqpqpppqqpqqqppqqqpqppqqqqqqqqqpppqqqqqqpqppqppqqpqppqqpqpqpqppppqqqqpqpqqqqqpqqpppqqppqqpqqqqqpqqppqpqqpqqqqqqpppqppqppqqqpqqpqqqqqpqppppqqpqpqqppppqqqqqpqqppppqqqqppqpqqqpqpqqppqqppqqqqpqq...

output:

859785574356

result:

ok 1 number(s): "859785574356"

Test #46:

score: 0
Accepted
time: 478ms
memory: 124280kb

input:

1
sjsjsjssjsjsjsjsjsjsjsssjsjssjssjsjsjsjssjsjsjssjsjsjsjsjssjsjssjsjssjssjsjsjssjssjsjsjssjsjsjsjsjsjssjssjsjsjssjssjsjssjsjsjsjssjsjsjsjssjsjsjsjsssjsjsjssjsjsjsssjsjsssjsjssjssjsjssjssjsjsjssjssjsjsjssjsjsjsjssjsjsjssjsjssjsjssjsjssjsjsjssjssjsjsjssjsjsjsssjsjsjssjssjsjsjssjsjsjssjsjsjsjssjsjsjsj...

output:

535123487680607

result:

ok 1 number(s): "535123487680607"

Test #47:

score: 0
Accepted
time: 484ms
memory: 125016kb

input:

1
vrvrvvrvrvrvrvvvvrvrvrvvrvrvrvrvvvvrvrvrvrvrvrvvvvrvrvrvrvvvrvrvrvvrvrvrvrvvvvrvrvrvrvvvrvrvrvvrvrvrvrvrvvvvrvrvrvrvvvrvrvrvvrvrvrvrvvvvrvrvrvrvvvrvrvrvrvvrvrvrvrvvrvvrvrvrvrvvrvrvrvrvvrvvrvrvrvrvvrvrvrvrvrvvrvrvrvrvrvrvvrvvrvrvrvrvrvrvvrvvrvrvrvrvrvrvvrvvrvrvrvrvrvvrvrvvrvvrvrvrvrvrvvrvrvvrvrvrvr...

output:

532834873916524

result:

ok 1 number(s): "532834873916524"

Test #48:

score: 0
Accepted
time: 429ms
memory: 123924kb

input:

1
xzxzxxxxzxzxxxzxzxxzxzxxzxzxxzxzxxzxzxzxxzxzxxxxzxzxxxzxzxxzxzxxzxzxxzxzxxzxzxxzxzxxxxzxzxxxzxzxxzxzxxzxzxxzxzxxzxzxzxxzxzxxxxzxzxxxzxzxxzxzxxzxzxxzxzxxzxzxzxxzxzxzxxxxzxzxxxzxzxxzxzxxzxzxxzxzxxzxzxzxxzxzxxzxzxxxzxzxxzxzxxzxzxxzxzxxzxzxzxxzxzxxzxzxzxxxzxzxxzxzxxzxzxxzxzxxzxzxzxxzxzxxzxzxxxzxzxxzxz...

output:

543877851845068

result:

ok 1 number(s): "543877851845068"

Test #49:

score: 0
Accepted
time: 345ms
memory: 121608kb

input:

1
duddudududduddudududududududududduddudududduddududududududududududduddududududdudududduddududududududududududduddudududduddududududududududududududdudududududdududududududududduddudududduddududududududududududududdudududdudududduddudududududududududduddudududduddududududududududududduddududududdud...

output:

383753618060522

result:

ok 1 number(s): "383753618060522"

Test #50:

score: 0
Accepted
time: 278ms
memory: 116736kb

input:

1
pupuuupuuujrpupuuupuuupuuujrpupupupupuuupuuujrpupuuupuuupuuujrpupupuuupuuujrpupupuuupuuujrpupuuupuuupuuujrpuppupuuupuuujrpupuuupuuupuuujrpupupuuupuuujrpupupupuuupuuujrpupuuupuuupuuujrpupupuuupuuujrpupupuuupuuujrpupuuupuuupuuujrpuppupuuupuuujrpupuuupuuupuuujrpupupuuupuuujrpupupuuupupuuupuuujrpupuuu...

output:

83495817302527

result:

ok 1 number(s): "83495817302527"

Test #51:

score: 0
Accepted
time: 222ms
memory: 112456kb

input:

1
cgvcgvcgvcgvpfghxjcgvcgvpfghxjezcgvcgvpfghxjcgvcgvpfghxjezthvmijtclnqdcgvpfghxjezthvmijtclnqdcsiabaeklvpotstfhwzucsuoftiuyxwxgwwuycgvcgvpfghxjcgvcgvpfghxjezcgvcgvpfghxjcgvcgvpfghxjezthvmijtclnqdcgvccgvcgvpfghxjcgvcgvpfghxjezcgvcgvpfghxjcgvcgvpfghxjezthvmijtclnqdcgvpfghxjezthvmijtclnqdcsiabaeklvpot...

output:

20342734124692

result:

ok 1 number(s): "20342734124692"

Test #52:

score: 0
Accepted
time: 217ms
memory: 111500kb

input:

1
laiebobdjvjnwoldexhhwwphnpevihgcjtgzjmzdlzdwzuahhiwztjxuozcmffypqtitqoqpwmbhzrdgxoyziqvisaupzmbttggrsqafcsvgwsknanhqzaehnzgnouxtmcgoilopckmsukvzbpffpaiaksguxkcxkypdkuhezpvzgoobqzhlaiebobdjvjnwoldexhhwwphnpevihgcjtgzjmzdlzdwzuahhiwztjxuozcmffypqtitqoqpwmbhzrdgxoyziqvisaupzmbttggrsqafcsvgwsknanhqzae...

output:

2039003270945

result:

ok 1 number(s): "2039003270945"

Test #53:

score: 0
Accepted
time: 232ms
memory: 108260kb

input:

1
vyubllhxsbxevsoihfkmdnvmntrqxeukvcqogklkxqbmkprnovsdkmfzstudxhtfweaocdiiqmndherttmfrngayfgdycjcgclgosajtbcvtkhryihwvrthgcmqnqkkqnzktawxuomaruaytivculcoglecgnazxinyyfjzadqeikhguipxadpnbzvqwupdojnelspwbbunderebfcqjwxmfsgyemmatqgryxyrbjcyyfxhaymmgdpxhiudhdhswtfvmskfqshupmarusazrinmyifneslvealmqllfuvs...

output:

108525645541

result:

ok 1 number(s): "108525645541"

Test #54:

score: 0
Accepted
time: 252ms
memory: 87048kb

input:

1
atwxvutxruyvpnlodfnjzdbihsrjlvgoevkdfiezamcgbhiheecxuppdodeewrngsdtpxahhmmjikwbmvwytjxczvscewuexadslctikvmnumoipbapbhruzbublpfqtbmmqszobriiffznezlmoitosylcrqzmbqjefjjpxnmcoskxwvanhobiyujmiczfwhfcvtboddamyozkshzzxzdxbhyrjjkdmyntqejybofceheasspwsxnflvqmordujwtxezlsfnkeucizhpwwjdfnlijrrchfcffjhnawaal...

output:

15326358668

result:

ok 1 number(s): "15326358668"

Test #55:

score: 0
Accepted
time: 423ms
memory: 123068kb

input:

1
qqjqqqjqqqjqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqqqjqqqjqqqjqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqjqqqjqqjqqqjqqqjqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqqqjqqqjqqqjqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqjqqqjqqqjqqjqqqjqqqjqqqjqqqjqqqjqqqjqqqjqqjqqqjqqqqqjqqqqqjq...

output:

495209269441827

result:

ok 1 number(s): "495209269441827"

Test #56:

score: 0
Accepted
time: 334ms
memory: 120248kb

input:

1
dididdxidididddididdxidididdxiiddiddididididdxidididdxiiddiddididdxiiddididididdxidididdxiiddididdxidididddididdxidididdxiiddiddididididdxidididdxiiddiddididdxiiddididididdxidididdxiiddiddididdxiiddididdxiidiididididididdxidididdxiiddiddididididdxidididddididdxidididdxiiddiddididididdxidididdxiidd...

output:

87336487474432

result:

ok 1 number(s): "87336487474432"

Test #57:

score: 0
Accepted
time: 324ms
memory: 119236kb

input:

1
cwnwnwcwnwnwnwcwnwnwcwnwnwnwnncnwwccwnwnwnwnncwnwnwnwnncncwnwnwcwnwcwnwnwcwnwnwnwcwnwnwcwnwnwnwnncnwwccwnwnwnwnncwnwnwnwnncncwnwnwcwnwnwnwncwnwnwcwnwnwcwnwnwcwnwnwnwnncnwwccwnwnwnwnncwcwnwnwcwnwnwnwcwnwnwcwnwnwnwnncnwwccwnwnwnwnncwnwnwnwnncncwnwnwcwnwnwnwncwnwnwcwnwnwcwnwnwcwnwnwnwnncnwwccwnwnwnwn...

output:

28464613072032

result:

ok 1 number(s): "28464613072032"

Test #58:

score: 0
Accepted
time: 389ms
memory: 123940kb

input:

1
gyggygygyggygyggygyggygyggygyggyggygygggyggygygyggygyggygyggyggyggygygyggygyggygyggygyggygyggyggygygggyggygygyggygyggygyggygyggygyggyggygyggygyggygyggygyggygygyggygyggygyggygyggygyggyggygygggyggygygyggygyggygyggyggygggyggygygyggygyggygyggygyggygyggyggygygggyggygygyggygyggygyggyggyggygygyggygyggygy...

output:

510728187699973

result:

ok 1 number(s): "510728187699973"

Test #59:

score: 0
Accepted
time: 285ms
memory: 117452kb

input:

1
qiqiiqqffjqiqiiqqffqiqiiqqffjqiqiiqqffjqfqiqiqiiqqffjqfqiaaiiiijiaifiqiqqiqiqiiqqqiqiiqqffjqiqiiqqffjqfqiqiqiiqqffjqfqiqiqiiqqffjqiqiiqqffqiqqiqiiqqffjqiqiiqqffqiqiiqqffjqiqiiqqffjqfqiqiqiiqqffjqfqiaaiiiijiaifiqiqqiqiqiiqqqiqiiqqffjqiqiiqqffjqfqiqiqiiqqffjqfqiqiqiiqqffjqiqiiqqffqiqiiqqffjqiqiiqqff...

output:

50871054628589

result:

ok 1 number(s): "50871054628589"

Test #60:

score: 0
Accepted
time: 292ms
memory: 116752kb

input:

1
mmtqllmmtqlltqqqommtqllmmtqlltqqqotmmtqllmmtqlltqqqommtqllmmtqlltqqqotmoomtoltottmtqottotqooollllttmmtqllmmtqlltqqqommtqllmmtqlltqqqotmoomtoltottmtqottotqmmtqllmmtqlltqqqommtqllmmtqlltqqqotmoomtoltottmtqottotqooollllttmmtqllmmtqlltqqqommtqllmmtqlltqqqotmoomtoltottmtqottotqooollllttommtqllmmtqlltqq...

output:

51284405737644

result:

ok 1 number(s): "51284405737644"

Test #61:

score: 0
Accepted
time: 346ms
memory: 115316kb

input:

1
hmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmhmhhmhmhmhhmhmmhmhmhhmhmhmhhmhmmhmhmhmhhmhmhmhhm...

output:

284623096285415

result:

ok 1 number(s): "284623096285415"

Test #62:

score: 0
Accepted
time: 317ms
memory: 118024kb

input:

1
amaamaamaaamaaamaamaamaaamaamaamaamamaammamamaamamaamaamaaamaamaamaaamaaamaamaamaaamaamaamaamamaammamamaamamaamaamaaamaaamaamaamaaamaamaamaamamaammamamaamaamaamaamaamamaamaamaamamaammamamaamaamaaamaamaamaaamaaamaamaamaaamaamaamaamamaammamamaamamaamaamaaamaamaamaaamaaamaamaamaaamaamaamaamamaammamam...

output:

359135170761701

result:

ok 1 number(s): "359135170761701"

Test #63:

score: 0
Accepted
time: 294ms
memory: 113000kb

input:

1
oollolllooloooollloollolllooloooolllooloooollooollolllooloooollloollolllooloooolllooloooollolllooloooollloolooollolllooloooollloollolllooloooolllooloooooollolllooloooollloollolllooloooolllooloooollooollolllooloooollloollolllooloooolllooloooollolllooloooollloolooollolllooloooollloollolllooloooolllo...

output:

255239125866786

result:

ok 1 number(s): "255239125866786"

Test #64:

score: 0
Accepted
time: 315ms
memory: 107544kb

input:

1
itttttittiitittiiiiititttiittiiitittitttttiitttttittiitittiiiiititttiittiiitittitttttittiitittiiiiititttiittiiitittititiiitiiiitttttittiitittiiiiititttiittiiitittitttttittiitittiiiiititttiittiiitittititiiitiiittiiiitittittiitiiiititittttiitittttitittiitttttittiitittiiiiititttiitttttittiitittiiiiit...

output:

76141819635053

result:

ok 1 number(s): "76141819635053"

Test #65:

score: 0
Accepted
time: 378ms
memory: 124532kb

input:

1
vlvllvvlvvvvlvlvlvlllvllvvlvlllvvlvlllvlvvvvvllllvvvlllvvvvvlllvlvvlvvllvvvvlvllvvvllvvvllllvllllvvlvvlllvllvlvvvvlvvvllvlllvlvlvvllvlllvvvlllvlvvlllllvvvvvvlvlllvvllllvvvlvllvvlvvvvlvlvlvlllvllvvlvlllvvlvlllvlvvvvvllllvvvlllvvvvvlllvlvvlvvllvvvvlvllvvvllvvvllllvllllvvlvvlllvllvlvvvvlvvvllvlllvlvl...

output:

68479316171591

result:

ok 1 number(s): "68479316171591"

Test #66:

score: 0
Accepted
time: 407ms
memory: 124796kb

input:

1
wwwwtwtttttwttwtwtwtwttwwttttttwwwtwwwtwtttwtwwtttwtwtwttwttwtwwwwtwttwttwttwtwtwwtttwwwwttwtwwttwwtwwwwwwtwtttttwttwtwtwtwttwwttttttwwwtwwwtwtttwtwwtttwtwtwttwttwtwwwwtwttwttwttwtwtwwtttwwwwttwtwwttwwtwwwwwwwwtttwttttttwwwtttwwtwtwtwwtwwwwtwwtwtwwwwwttwttttwwtwwwtttwtwttwtttwttwtttwwwtwtwwtwwwwtw...

output:

17691884809795

result:

ok 1 number(s): "17691884809795"

Test #67:

score: 0
Accepted
time: 392ms
memory: 107236kb

input:

1
ggrggrgrgrgrgrrgggrrgrrrrggrggrrrrgrggrgrrggrrgrrgrgrgrrgggggrgggrrrgrrggrrgrgggrgrggrrggggrggrgrggrrgrgrgrrrrgggrgrggrrggrgggggrgrrrgrgrgggrgrrrggrrrrggrrgrgrgrgrggggrgrggrggrgrrgrgrrrrgrrrrrgrrgrggrggrrgrgrggrrrgrgrgrgrrgrrrgggggrgrrrrgrgggggggrgrgrrrgrrrgrrgrrgrrrrrgrggrrgrrgrggggrgrrgrgrggggrg...

output:

9683989352823

result:

ok 1 number(s): "9683989352823"

Test #68:

score: 0
Accepted
time: 464ms
memory: 122848kb

input:

1
ppppxxpxpxxxpxxpxxpxppxxpxpxxppxpxpxppxpxxxpxxxpxxxpxpxxpppppxxxxpxxxpppxxxpxxppppxpxppxpxxppppxpxxpppxxppppppppppppppppxxpxpxpxppxpppxpxppppxxpxpxxpxxppxpxxxpppxpppppxpxxxxpxpppxxpxxpppxppxxxxxpxpxxxppxpxpxpxxppxpxxxxxpxppxppxxpxpxxppppxppxpxpxpxxpxpxxxxpxxpxpxppxpppppxpppppxxxpxpxxppxpppxpxpxxxx...

output:

7205972642722

result:

ok 1 number(s): "7205972642722"

Test #69:

score: 0
Accepted
time: 535ms
memory: 124040kb

input:

1
ejjejejeejjeejjjeejeejjejjjjjjejjjeejjeeejeejjejjejjeeejejejjeeeejjjjjjejejejejejjeeeejjjjejeeejjeeejejjjejeejeeejjjejjjjeeejejjjjjeeeeeeeejjjeeeejjjjjjeeejejjejjjjeeejjjjjjjjejjjejeejjejjeejjjeejjeejjejejjeejejejejjjeejejeeejeeeejeejeejejejejejjjjejjeejeeejeeejeejeejjejjeeejjeeeeejjejjejeejejjjje...

output:

2039730367815

result:

ok 1 number(s): "2039730367815"

Test #70:

score: 0
Accepted
time: 649ms
memory: 130212kb

input:

1
pqpppppqqqqqpqqpppqqqqpqpqqppqqppqqqppqqqqqppqqppqpqppqppqqpppppqppppqqppppqpppqppqpqpqqppppqqpqqppppqpqqpppqqpqpppqqpqqqppqqqpqppqqqqqqqqqpppqqqqqqpqppqppqqpqppqqpqpqpqppppqqqqpqpqqqqqpqqpppqqppqqpqqqqqpqqppqpqqpqqqqqqpppqppqppqqqpqqpqqqqqpqppppqqpqpqqppppqqqqqpqqppppqqqqppqpqqqpqpqqppqqppqqqqpqq...

output:

973434443636

result:

ok 1 number(s): "973434443636"

Test #71:

score: 0
Accepted
time: 233ms
memory: 109436kb

input:

1
nsnspgyvnnspgyvnnsnspgyvnnspgyvnspgnspgyvnnspgynspgyvnsnspgyvnnspgyvnnsnspgyvnnspgyvnspgnspgyvnnspgynspgyvnnspgyvnspgnspgyvnnspgynspgyvnnsnsnspgyvnnspgyvnspgnspgyvnnspgynspgyvnnspgyvnnsnspgyvnnspgyvnspgnspgyvnnspgynspgyvnnspgyvnspgnnsnspgyvnnspgyvnspgnspgyvnnspgynspgyvnnspgyvnspgnspgyvnnspgynspgyv...

output:

166159096418848

result:

ok 1 number(s): "166159096418848"

Test #72:

score: 0
Accepted
time: 222ms
memory: 107512kb

input:

1
ajdziajajdziajdaajajdziajajdziajdaajdziajajdziaajdziajaajdajdziajajdziajdaajdziajajdziaajdziajaajdziajajdziajdaajdziajajdziaajdziajajdziajdaajdziajajdziajdajdziajajdziajdziiizwephdgwmohngmcecsuajdziajajdziajdaajajdziajajdziajdaajdziajajdziaajdziajaajdajdziajajajdziajajdziajdaajajdziajajdziajdaajdz...

output:

102050081004728

result:

ok 1 number(s): "102050081004728"

Test #73:

score: 0
Accepted
time: 174ms
memory: 99728kb

input:

1
iqqbngyezahmrjxpyqslknxkvljgwlbftmsqmlnjiqqbngyezahmrjxpyqsiqqbngyezahmrjxpyqslknxkvljgwlbftmsqmlnjiqqbngyezahmrjxpyqslknxkvljgwlbftmsqmlnjqgqtzfyqvgzzayqiqqbngyezahmrjxpyqslknxkvljgwlbftmsqiqqbngyezahmrjxpyqslknxkvliqqbngyezahmrjxiqqbngyezahmrjxpyqslknxkvljgwlbftmsqmlnjiqqbngyezahmrjxpyqsiqqbngye...

output:

10274882153888

result:

ok 1 number(s): "10274882153888"

Test #74:

score: 0
Accepted
time: 199ms
memory: 105496kb

input:

1
skcfwksjxcarruibvgsmuqjisbipxukcteuedhjwkkhgstysyhjonndfkjdqswqvoufusxaoxvimegxvipioyhgxlkgougdeaaqkoscseahwrlolreitbrfjyhtctjkeyulodbxttwirspwnlhqgdmsuuovgntiqrmlsskcfwksjxcarruibvgsmuqjisbipxukcteuedhjwkkhgstysyhjonndfkjdqswqvoufusxaoxvimegxvipioyhgxlkgougdeaaqkoscseahwrlolreitbrfjyhtctjkeyulodb...

output:

3670322981913

result:

ok 1 number(s): "3670322981913"

Test #75:

score: 0
Accepted
time: 181ms
memory: 103540kb

input:

1
ulllqynfnacytluecglprkrdojvwttvznkamgqptxfbfodtnggqthcqrqtxokdcjesshjnnjmvbchjgsqghdrgnxutakrgsdkbaxyvfqxbeyrifwdqlhveceozuehcshqhdkulkgrgvrjlulfebvckpptybbxktagbkhjlxglczpfetutyrngxzhrwrlglticuhdsbhnysdjgwpaparpvwudccczlvhjdwtvbbozvfaflqohobdsbfkmwmtvhmtqxwghyhfygibbctnptdtesemarxcuxikvyktmfrciae...

output:

3178609760355

result:

ok 1 number(s): "3178609760355"

Test #76:

score: 0
Accepted
time: 215ms
memory: 105388kb

input:

1
qljkclxuyhroxjsbyoqzagiqtbmfmhvzjkpotocxnrdqtdpcobdeunulnndecubxnenptxpprrqpksmcgxmqthcvychdfmelnjlgbdhcmsgmqfbzrmttjpjjzjafsqzqqhwpohqgvztmeuatmpahteraweffrvrnmvsxsfosvlqhogooknxrlbnhdemrjhvrelwvftenxalkzpcbfdizmjechowvddmkrzaxoeecwxduunozyevezlkfjfnygwhwuvodnugyrdptxipqrrwflrpwdfeboidohndhegxrpv...

output:

231098330295

result:

ok 1 number(s): "231098330295"

Test #77:

score: 0
Accepted
time: 198ms
memory: 90948kb

input:

1
ahvxjejsrurnteasxdccttbcnbxuvcqfryqlrwlsalstlghccvtlyrdgelfwkkpboyvyoeobtwjclmsqdeplvouvzhgblwjyyqqmzohkfzuqtzinhncolhxcnlqnegdywfqevaebfiwzgiuljbkkbhvhizqgdifdipbsigcxlbulqeejolcpoywjxxivydiwdiofqhwcdfpbwqagfiuptyslvmlxemvmtgmxtzeuqcxwwjsdoozrxsvyevugtakwfeibijmrbxlpwbmtejofxhcllptzqxvllndlrgxxcz...

output:

115451201273

result:

ok 1 number(s): "115451201273"

Test #78:

score: 0
Accepted
time: 223ms
memory: 89512kb

input:

1
lauqzzvdtqdjlthyvkwpxolpobgcdjuwlnchrwzwdcqpwmgohltxwpkstbuxdvbkfjihnxyycpoxvjgbbpkgoriakrxanenrnzrhtiebqnlbwvgayvflgbvrnpcocwwcoswbifduhpiguiabylnuznhrzjnroisdyoaakesixcjywvruymdixmoqslcfumxheojztmfqquoxjgjqkncefdpktrajppibcrgadagqenaakdviapprxmdvyuxvxvtfbklptwkctvumpigutisgyopaykojtzljizpczzkult...

output:

35638571793

result:

ok 1 number(s): "35638571793"

Test #79:

score: 0
Accepted
time: 242ms
memory: 90092kb

input:

1
bupceluctlyeiqvdgsqrhgmnoxtrvekdaejgsnahbzwkmonoaawcliigdgaaptqkxguicboozzrnjpmzepyurcwhexwaplacbgxvwunjezqlzdnimbimotlhmlmvisfumzzfxhdmtnnsshqahvzdnudxyvwtfhzmfrasrricqzwdxjcpebqodmnylrznwhsposweumdggbzydhjxohhchgcmoytrrjgzyqufarymdswaoabxxipxcqsvefzdtglrpucahvxsqjalwnhoipprgsqvnrttwoswssroqbpbbv...

output:

5200701650

result:

ok 1 number(s): "5200701650"

Test #80:

score: 0
Accepted
time: 245ms
memory: 101440kb

input:

1
iiuuiuiuhuiuiuhiuihiihuhihiuiiuuiuiuhuiuiuhiuihiihuhihiuiuuhihhuuhhiiiuihuuhuiuhhuuhiiuuiuiuhuiuiuhiuihiihuhihiuiiuuiuiuhuiuiuhiuihiihuhihiuiuuhiiuuiuiuhuiuiuhiuihiihuhihiuiiuuiuiuhuiuiuhiuihiihuhihiuiuuhihhiiuuiuiuhuiuiuhiuihiihuhihiuiiuuiuiuhuiuiuhiuihiihuhihiuiuuhihhuuhhiiiuihuuhuiuhhuuhiiuuiui...

output:

17892681445892

result:

ok 1 number(s): "17892681445892"

Test #81:

score: 0
Accepted
time: 253ms
memory: 107768kb

input:

1
pippfiipiipfppifffpiffiifffipfipfiffpppfffiiifpfififffpiffippipffpifffpifpppffpiifiifiipiffiffffppfififippfipfppipipiipfifpiiififfffpifffipfpfiffiippfpiiifffififififfpffpiffippiipppipipfppiippfpipfipifipifpipfiipfppppipifppippffffpiiipfpppifpipfffpppipipipppfppppfippiifffpiiiiipfifppppffififfpipfp...

output:

2237974405555

result:

ok 1 number(s): "2237974405555"

Test #82:

score: 0
Accepted
time: 334ms
memory: 110256kb

input:

1
lovovovovvlvoolvollovloovlllvllvllloloovlvllllvlvovooovlvovvlooooovlvovvovovovvlvlvolvllovoolovvvvvlvvoolovllovvlovllolvllloovvvloovlooovovlovlooovvvvolooolvlvllllvvovlvllooolovlloovvlollolvovlooololllooolvlvoolvolvlllllovoloololovooolovvvolvoloolvvlovvolvvvvvoloovvololvvlvvlvvoollololovovloovoolv...

output:

583505052506

result:

ok 1 number(s): "583505052506"

Test #83:

score: 0
Accepted
time: 243ms
memory: 110112kb

input:

1
yqvyqubuqyybbbuqbvbqyyqyvqbvyuyqvbqvvyqubbyqyybubqvqqvvyvyvyuvqqvqvbvbbybvvuybububquuqqbyyvyqqbvbqubuuqbbvuyqqubyqvyqubuqyybbbuqbvbqyyqyvqbvyuyqvbqvvyquyqvyqubuqyybbbuqbvbqyyqyvqbvyuyqvbqvvyqubbyqyybubqvqqvvyvyvyuvqqvqvbvbbybvvuybububquuqqbyqvyqubuqyybbbuqbvbqyyqyvqbvyuyqvbqvvyqubbyqyybubqvqqvvyvy...

output:

6298690918420

result:

ok 1 number(s): "6298690918420"

Test #84:

score: 0
Accepted
time: 250ms
memory: 103308kb

input:

1
mllmmddumdmlhhllllulhldluhmludmmdmuhlmhuhduldhhdmmmlmlhhmlhmllhmluhumlmlluhmmhluuddmmluuulumldudhdhudummldumhmduuuldullmudhlumduuuuhmdmlmdmuhhhduudllmlhdhlmdlldluldlmhullmdlhdlhmlhuduldldhllhhdddhhlummldmhuhlluuhhhuhhdhhumdumdhhmmhmudlmmmumuhuddmddhlmuumluluummhddhuhlhludllmlmuluhuhlduulhdhhddhlud...

output:

958602500960

result:

ok 1 number(s): "958602500960"

Test #85:

score: 0
Accepted
time: 251ms
memory: 102552kb

input:

1
rrfdppfdddxfrxxrfxpfxffrfdxffxfdxxxppppffxpdpxffdprdfrpxxfprfrdprpdfrrfxrdfffddrdpdxddffpfrprpdrfdxffxpfpfxxpxppxppfxddfpfxxrfpppdxprffpxxddrxdxdrpxffxrffrrrdrpfxprdrxfxrxppprppdfpfrfpdxfpxrrpppdrpdpprfxrprdpdxfxrfprrdrddfprxrfrxpfdpxpdffxrrfppppfprrrppdrxffpxfdxffddprpfxxxpxpxprxpfxfpxfdrrrdddfrp...

output:

1123136417942

result:

ok 1 number(s): "1123136417942"