QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#610914#9425. Generated StringKevin5307AC ✓838ms83196kbC++2310.6kb2024-10-04 18:01:462024-10-14 17:49:46

Judging History

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

  • [2024-10-14 17:49:46]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:838ms
  • 内存:83196kb
  • [2024-10-14 17:49:05]
  • hack成功,自动添加数据
  • (/hack/995)
  • [2024-10-13 20:41:57]
  • 管理员手动重测本题所有得分≥97分的提交记录
  • 测评结果:100
  • 用时:796ms
  • 内存:81840kb
  • [2024-10-04 18:01:46]
  • 评测
  • 测评结果:100
  • 用时:1122ms
  • 内存:81864kb
  • [2024-10-04 18:01:46]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
mt19937_64 rng(time(0));
const ll mod=998244353,base=114514+rng()%1919810;
int n,q;
string S,rS;
ll H[400100],H2[400100],pw[400100];
char ch[400100];
vector<int> vl[400200],vr[400200],vl2[400200],vr2[400200];
ll Len[400200],Len2[400200];
int tot,tot2;
inline void Reverse(vector<int> &v)
{
	rev(v);
	for(auto &x:v)
		x=n+1-x;
}
inline ll getH(int l,int r){return (H[r]-H[l-1]*pw[r-l+1]%mod+mod)%mod;}
inline ll getH2(int l,int r){return (H2[r]-H2[l-1]*pw[r-l+1]%mod+mod)%mod;}
int Less(int u,int v)
{
	int lenu=sz(vl[u]);
	int lenv=sz(vl[v]);
	int pu=0,pv=0;
	int cu=0,cv=0;
	ll tot=0;
	ll totu=0,totv=0;
	for(int i=0;i<lenu;i++)
		totu+=vr[u][i]-vl[u][i]+1;
	for(int i=0;i<lenv;i++)
		totv+=vr[v][i]-vl[v][i]+1;
	while(pu<lenu&&pv<lenv)
	{
		if(cu==vr[u][pu]-vl[u][pu]+1)
		{
			pu++;
			cu=0;
			continue;
		}
		if(cv==vr[v][pv]-vl[v][pv]+1)
		{
			pv++;
			cv=0;
			continue;
		}
		int len=min(vr[u][pu]-vl[u][pu]+1-cu,vr[v][pv]-vl[v][pv]+1-cv);
		int stu=vl[u][pu]+cu;
		int stv=vl[v][pv]+cv;
		if(getH(stu,stu+len-1)==getH(stv,stv+len-1))
		{
			cu+=len;
			cv+=len;
			tot+=len;
		}
		else
		{
			int L=0,R=len;
			while(L<R)
			{
				int mid=(L+R+1)/2;
				if(getH(stu,stu+mid-1)==getH(stv,stv+mid-1))
					L=mid;
				else
					R=mid-1;
			}
			tot+=L;
			break;
		}
	}
	if(tot==totv) return 0;
	if(tot==totu) return 1;
	char chu,chv;
	pu=pv=0;
	tot++;
	ll tmp=tot;
	while(tmp>vr[u][pu]-vl[u][pu]+1)
	{
		tmp-=vr[u][pu]-vl[u][pu]+1;
		pu++;
	}
	chu=S[vl[u][pu]+tmp-2];
	tmp=tot;
	while(tmp>vr[v][pv]-vl[v][pv]+1)
	{
		tmp-=vr[v][pv]-vl[v][pv]+1;
		pv++;
	}
	chv=S[vl[v][pv]+tmp-2];
	return chu<chv;
}
int Less2(int u,int v)
{
	int lenu=sz(vl2[u]);
	int lenv=sz(vl2[v]);
	int pu=0,pv=0;
	int cu=0,cv=0;
	ll tot=0;
	ll totu=0,totv=0;
	for(int i=0;i<lenu;i++)
		totu+=vr2[u][i]-vl2[u][i]+1;
	for(int i=0;i<lenv;i++)
		totv+=vr2[v][i]-vl2[v][i]+1;
	while(pu<lenu&&pv<lenv)
	{
		if(cu==vr2[u][pu]-vl2[u][pu]+1)
		{
			pu++;
			cu=0;
			continue;
		}
		if(cv==vr2[v][pv]-vl2[v][pv]+1)
		{
			pv++;
			cv=0;
			continue;
		}
		int len=min(vr2[u][pu]-vl2[u][pu]+1-cu,vr2[v][pv]-vl2[v][pv]+1-cv);
		int stu=vl2[u][pu]+cu;
		int stv=vl2[v][pv]+cv;
		if(getH2(stu,stu+len-1)==getH2(stv,stv+len-1))
		{
			cu+=len;
			cv+=len;
			tot+=len;
		}
		else
		{
			int L=0,R=len;
			while(L<R)
			{
				int mid=(L+R+1)/2;
				if(getH2(stu,stu+mid-1)==getH2(stv,stv+mid-1))
					L=mid;
				else
					R=mid-1;
			}
			tot+=L;
			break;
		}
	}
	if(tot==totv) return 0;
	if(tot==totu) return 1;
	char chu,chv;
	pu=pv=0;
	tot++;
	ll tmp=tot;
	while(tmp>vr2[u][pu]-vl2[u][pu]+1)
	{
		tmp-=vr2[u][pu]-vl2[u][pu]+1;
		pu++;
	}
	chu=rS[vl2[u][pu]+tmp-2];
	tmp=tot;
	while(tmp>vr2[v][pv]-vl2[v][pv]+1)
	{
		tmp-=vr2[v][pv]-vl2[v][pv]+1;
		pv++;
	}
	chv=rS[vl2[v][pv]+tmp-2];
	return chu<chv;
}
int lca(int u,int v)
{
	int lenu=sz(vl[u]);
	int lenv=sz(vl[v]);
	int ret=++tot;
	int pu=0,pv=0;
	int cu=0,cv=0;
	ll tot=0;
	ll totu=0,totv=0;
	for(int i=0;i<lenu;i++)
		totu+=vr[u][i]-vl[u][i]+1;
	for(int i=0;i<lenv;i++)
		totv+=vr[v][i]-vl[v][i]+1;
	while(pu<lenu&&pv<lenv)
	{
		if(cu==vr[u][pu]-vl[u][pu]+1)
		{
			pu++;
			cu=0;
			continue;
		}
		if(cv==vr[v][pv]-vl[v][pv]+1)
		{
			pv++;
			cv=0;
			continue;
		}
		int len=min(vr[u][pu]-vl[u][pu]+1-cu,vr[v][pv]-vl[v][pv]+1-cv);
		int stu=vl[u][pu]+cu;
		int stv=vl[v][pv]+cv;
		if(getH(stu,stu+len-1)==getH(stv,stv+len-1))
		{
			cu+=len;
			cv+=len;
			tot+=len;
		}
		else
		{
			int L=0,R=len;
			while(L<R)
			{
				int mid=(L+R+1)/2;
				if(getH(stu,stu+mid-1)==getH(stv,stv+mid-1))
					L=mid;
				else
					R=mid-1;
			}
			tot+=L;
			break;
		}
	}
	Len[ret]=tot;
	if(tot==totu) return u;
	if(tot==totv) return v;
	if(!tot) return ret;
	if(lenu>lenv) swap(u,v);
	int p=0;
	while(tot>vr[u][p]-vl[u][p]+1)
	{
		vl[ret].pb(vl[u][p]);
		vr[ret].pb(vr[u][p]);
		tot-=vr[u][p]-vl[u][p]+1;
		p++;
	}
	vl[ret].pb(vl[u][p]);
	vr[ret].pb(vl[u][p]+tot-1);
	return ret;
}
int lca2(int u,int v)
{
	int lenu=sz(vl2[u]);
	int lenv=sz(vl2[v]);
	int ret=++tot2;
	int pu=0,pv=0;
	int cu=0,cv=0;
	ll tot=0;
	ll totu=0,totv=0;
	for(int i=0;i<lenu;i++)
		totu+=vr2[u][i]-vl2[u][i]+1;
	for(int i=0;i<lenv;i++)
		totv+=vr2[v][i]-vl2[v][i]+1;
	while(pu<lenu&&pv<lenv)
	{
		if(cu==vr2[u][pu]-vl2[u][pu]+1)
		{
			pu++;
			cu=0;
			continue;
		}
		if(cv==vr2[v][pv]-vl2[v][pv]+1)
		{
			pv++;
			cv=0;
			continue;
		}
		int len=min(vr2[u][pu]-vl2[u][pu]+1-cu,vr2[v][pv]-vl2[v][pv]+1-cv);
		int stu=vl2[u][pu]+cu;
		int stv=vl2[v][pv]+cv;
		if(getH2(stu,stu+len-1)==getH2(stv,stv+len-1))
		{
			cu+=len;
			cv+=len;
			tot+=len;
		}
		else
		{
			int L=0,R=len;
			while(L<R)
			{
				int mid=(L+R+1)/2;
				if(getH2(stu,stu+mid-1)==getH2(stv,stv+mid-1))
					L=mid;
				else
					R=mid-1;
			}
			tot+=L;
			break;
		}
	}
	Len2[ret]=tot;
	if(tot==totu) return u;
	if(tot==totv) return v;
	if(!tot) return ret;
	if(lenu>lenv) swap(u,v);
	int p=0;
	while(tot>vr2[u][p]-vl2[u][p]+1)
	{
		vl2[ret].pb(vl2[u][p]);
		vr2[ret].pb(vr2[u][p]);
		tot-=vr2[u][p]-vl2[u][p]+1;
		p++;
	}
	vl2[ret].pb(vl2[u][p]);
	vr2[ret].pb(vl2[u][p]+tot-1);
	return ret;
}
int RealIndex[400200],RealIndex2[400200];
vector<int> G[400200],G2[400200];
int in[400200],out[400200],in2[400200],out2[400200];
int dfn,dfn2;
void dfs(int u)
{
	in[u]=++dfn;
	for(auto v:G[u])
		dfs(v);
	out[u]=dfn;
}
void dfs2(int u)
{
	in2[u]=++dfn2;
	for(auto v:G2[u])
		dfs2(v);
	out2[u]=dfn2;
}
int X[400100],Y[400100],D[400100];
int Answer[400100];
int bit[400200];
inline void update(int p,int v)
{
	while(p<400200)
	{
		bit[p]+=v;
		p+=(p&(-p));
	}
}
inline int query(int p)
{
	int ans=0;
	while(p)
	{
		ans+=bit[p];
		p-=(p&(-p));
	}
	return ans;
}
void solve(int L,int R)
{
	if(L==R) return ;
	int mid=(L+R)/2;
	solve(L,mid);
	solve(mid+1,R);
	vector<pair<pii,pii>> vect;
	for(int i=L;i<=mid;i++)
		if(ch[i]=='+'||ch[i]=='-')
			vect.pb(mp(X[i],Y[i]),mp(1,D[i]));
	for(int i=mid+1;i<=R;i++)
		if(ch[i]=='?')
		{
			int L1=in[RealIndex[i]],R1=out[RealIndex[i]];
			int L2=in2[RealIndex2[i]],R2=out2[RealIndex2[i]];
			vect.pb(mp(R1,R2),mp(i+114514,1));
			vect.pb(mp(L1-1,R2),mp(i+114514,-1));
			vect.pb(mp(R1,L2-1),mp(i+114514,-1));
			vect.pb(mp(L1-1,L2-1),mp(i+114514,1));
		}
	srt(vect);
	for(auto pr:vect)
		if(pr.second.first==1)
			update(pr.first.second,pr.second.second);
		else
			Answer[pr.second.first-114514]+=pr.second.second*query(pr.first.second);
	for(auto pr:vect)
		if(pr.second.first==1)
			update(pr.first.second,-pr.second.second);
}
int GetInd[100100];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>q>>S;
	tot=tot2=q;
	rS=S;
	rev(rS);
	for(int i=1;i<=n;i++)
		H[i]=(H[i-1]*base+S[i-1])%mod;
	for(int i=1;i<=n;i++)
		H2[i]=(H2[i-1]*base+rS[i-1])%mod;
	pw[0]=1;
	for(int i=1;i<=n;i++)
		pw[i]=pw[i-1]*base%mod;
	for(int i=1;i<=q;i++)
	{
		cin>>ch[i];
		if(ch[i]=='+')
		{
			int k;
			cin>>k;
			vl[i].resize(k);
			vr[i].resize(k);
			for(int j=0;j<k;j++)
				cin>>vl[i][j]>>vr[i][j];
			vl2[i]=vr[i];
			vr2[i]=vl[i];
			Reverse(vl2[i]);
			Reverse(vr2[i]);
			for(int j=0;j<k;j++)
				Len[i]+=vr[i][j]-vl[i][j]+1;
			Len2[i]=Len[i];
		}
		if(ch[i]=='-')
		{
			int x;
			cin>>x;
			GetInd[i]=x;
			vl[i]=vl[x];
			vr[i]=vr[x];
			vl2[i]=vl2[x];
			vr2[i]=vr2[x];
			Len[i]=Len[x];
			Len2[i]=Len2[x];
		}
		if(ch[i]=='?')
		{
			int k;
			cin>>k;
			vl[i].resize(k);
			vr[i].resize(k);
			for(int j=0;j<k;j++)
				cin>>vl[i][j]>>vr[i][j];
			int m;
			cin>>m;
			vl2[i].resize(m);
			vr2[i].resize(m);
			for(int j=0;j<m;j++)
				cin>>vl2[i][j]>>vr2[i][j];
			Reverse(vl2[i]);
			Reverse(vr2[i]);
			swap(vl2[i],vr2[i]);
			for(int j=0;j<k;j++)
				Len[i]+=vr[i][j]-vl[i][j]+1;
			for(int j=0;j<m;j++)
				Len2[i]+=vr2[i][j]-vl2[i][j]+1;
		}
	}
	vector<int> vec,tmp;
	for(int i=1;i<=q;i++)
		if(ch[i]=='+'||ch[i]=='?')
			vec.pb(i);
	stable_sort(ALL(vec),Less);
	int p=0;
	for(int i=0;i<sz(vec);i++)
	{
		if(i!=p&&Less(vec[p],vec[i])) p=i;
		RealIndex[vec[i]]=vec[p];
		if(p==i)
			tmp.pb(vec[i]);
	}
	vec=move(tmp);
	vector<int> st;
	for(auto x:vec)
	{
		if(!sz(st))
		{
			st.pb(x);
			continue;
		}
		int z=lca(x,st.back());
		while(sz(st)>1&&Len[z]<Len[st[sz(st)-2]])
		{
			G[st[sz(st)-2]].pb(st.back());
			st.pop_back();
		}
		int lst=-1;
		if(sz(st)&&Len[z]<Len[st.back()])
		{
			lst=st.back();
			st.pop_back();
		}
		if(!sz(st)||Len[z]>Len[st.back()])
			st.pb(z);
		if(~lst)
			G[st.back()].pb(lst);
		st.pb(x);
	}
	while(sz(st)>1)
	{
		if(sz(st)>1) G[st[sz(st)-2]].pb(st.back());
		st.pop_back();
	}
	int rt=st.back();
	vector<int> vec2,tmp2;
	for(int i=1;i<=q;i++)
		if(ch[i]=='+'||ch[i]=='?')
			vec2.pb(i);
	stable_sort(ALL(vec2),Less2);
	p=0;
	for(int i=0;i<sz(vec2);i++)
	{
		if(i!=p&&Less2(vec2[p],vec2[i])) p=i;
		RealIndex2[vec2[i]]=vec2[p];
		if(p==i)
			tmp2.pb(vec2[i]);
	}
	vec2=move(tmp2);
	vector<int> st2;
	for(auto x:vec2)
	{
		if(!sz(st2))
		{
			st2.pb(x);
			continue;
		}
		int z=lca2(x,st2.back());
		while(sz(st2)>1&&Len2[z]<Len2[st2[sz(st2)-2]])
		{
			G2[st2[sz(st2)-2]].pb(st2.back());
			st2.pop_back();
		}
		int lst=-1;
		if(sz(st2)&&Len2[z]<Len2[st2.back()])
		{
			lst=st2.back();
			st2.pop_back();
		}
		if(!sz(st2)||Len2[z]>Len2[st2.back()])
			st2.pb(z);
		if(~lst)
			G2[st2.back()].pb(lst);
		st2.pb(x);
	}
	while(sz(st2)>1)
	{
		if(sz(st2)>1) G2[st2[sz(st2)-2]].pb(st2.back());
		st2.pop_back();
	}
	int rt2=st2.back();
	dfs(rt);
	dfs2(rt2);
	for(int i=1;i<=q;i++)
		if(ch[i]=='+')
		{
			X[i]=in[RealIndex[i]];
			Y[i]=in2[RealIndex2[i]];
			assert(X[i]);
			assert(Y[i]);
			D[i]=1;
		}
		else if(ch[i]=='-')
		{
			X[i]=X[GetInd[i]];
			Y[i]=Y[GetInd[i]];
			D[i]=-1;
		}
	solve(1,q);
	for(int i=1;i<=q;i++)
		if(ch[i]=='?')
			cout<<Answer[i]<<'\n';
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 22228kb

input:

8 7
abcaabbc
+ 3 1 3 2 4 3 8
+ 2 1 4 1 8
+ 1 2 4
? 1 5 6 1 7 8
- 3
+ 1 2 5
? 1 2 3 1 5 5

output:

2
1

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 3ms
memory: 23128kb

input:

5 2000
bbaab
+ 1 3 5
+ 2 5 5 3 5
- 2
? 1 1 3 3 3 3 4 5 2 5
- 1
? 3 1 1 2 4 1 5 1 3 4
? 1 1 2 2 2 4 4 4
? 1 1 5 1 5 5
+ 3 1 2 1 5 1 4
? 2 1 5 1 3 2 1 2 5 5
? 1 3 4 1 4 5
- 9
? 1 1 4 1 2 3
+ 2 1 5 1 2
+ 1 1 4
- 15
- 14
? 2 2 5 2 5 1 3 4
+ 1 2 3
- 19
+ 3 1 4 1 5 4 5
- 21
+ 1 2 5
? 3 1 5 5 5 1 5 1 3 5
?...

output:

0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
2
0
3
1
0
0
0
0
1
0
0
0
0
0
0
0
0
2
0
0
0
0
0
1
0
0
0
0
0
0
0
3
1
0
1
0
2
0
0
0
3
0
1
0
0
2
0
0
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0
0
0
0
0
0
0
4
0
0
0
0
0
0
0
0
2
0
8
0
0
0
0
0
0
0
2
0
0
...

result:

ok 33212 lines

Test #6:

score: 0
Accepted
time: 438ms
memory: 63632kb

input:

100000 100000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

0
1
0
1
0
1
0
5
0
4
1
1
1
1
2
0
3
0
0
0
0
1
1
0
0
2
2
0
0
1
5
1
0
0
3
3
5
2
5
0
8
2
2
2
13
2
2
0
2
4
11
9
5
3
14
4
9
19
12
4
12
11
6
7
8
2
22
7
3
20
7
9
6
0
5
5
17
2
9
9
0
2
7
10
11
0
9
3
4
5
12
6
10
0
2
21
2
9
1
3
1
2
2
10
22
8
21
4
3
16
3
8
2
12
9
0
2
12
4
5
19
16
7
5
4
4
3
8
5
11
4
6
5
13
0
6
5
1...

result:

ok 33583 lines

Test #7:

score: 0
Accepted
time: 505ms
memory: 81240kb

input:

100000 100000
baabbabaabaaaabbaaababaaabbbbbaabbababbabbbaabbaaabbbbababaababbbbbababaabaaabaaababaabbbbaaababbbbabaabbaaaaaabbbabbbabababababaabbabbbbbaaabababbbaabababbbaaababaabbaaaabbabbaabbababaabbaaaababaabbbbbababbaaabbbaababbaaaaaabbbbabbbbbbabbaabababbbaaaaaabbabbabaaaaaabbbaaaaaabaabaaabab...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 33381 lines

Test #8:

score: 0
Accepted
time: 412ms
memory: 60040kb

input:

100000 100000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

2
2
0
2
1
1
2
2
2
2
0
0
0
0
0
1
0
0
1
0
0
0
2
2
2
0
1
0
0
0
0
1
0
2
3
0
1
0
1
0
0
1
1
2
2
2
1
1
1
0
0
0
2
0
3
0
0
0
0
0
1
2
0
0
1
1
0
0
0
1
1
2
0
2
1
2
0
0
1
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
1
2
2
1
2
4
3
2
0
2
0
0
1
4
0
0
1
1
5
1
0
1
0
0
2
1
0
3
3
1
0
1
1
2
2
3
0
1
3
7
6
0
7
1
1
1
5
2
5
0
2
6
2
2
2
5
...

result:

ok 33565 lines

Test #9:

score: 0
Accepted
time: 574ms
memory: 83196kb

input:

100000 100000
aaabbbabbaababbbbbbaaababbbaaaaaabbaaaabababbabababbabbabbbaababbbbabaabaaabbaaabbabababbaaabbabbaaaaabbabababbaaaaababbbbabbabaaabbbaabaabbbaaababbbbbabaaabaaaaabbaabaabbabababbabaaabbbbbbbbaababaabbbabaabbabaaabbbbbababaaabbbbbaaaaaaabbbabbbaabbaabbaaaaaaabbbaabbbaabbaaaababbabaababb...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 33118 lines

Test #10:

score: 0
Accepted
time: 482ms
memory: 68128kb

input:

100000 100000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

0
1
0
0
0
2
0
0
0
0
0
0
0
1
0
0
1
0
0
3
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
4
0
1
0
0
0
0
2
0
3
4
4
5
8
7
9
5
0
9
3
8
2
9
0
5
7
1
7
9
0
1
4
1
5
8
5
1
0
0
5
0
4
12
0
9
5
11
10
3
1
8
1
9
2
1
0
5
5
5
0
2
5
1
1
0
0
12
8
11
11
1
4
11
10
3
7
9
9
4
12
11
5
9
6
1
2
8
10
11
4
17
11
6
3
2
4
1
1
3
1
3
2
3
6
5
4
8
12...

result:

ok 33215 lines

Test #11:

score: 0
Accepted
time: 633ms
memory: 76668kb

input:

100000 100000
mwtmtwnsgaynckkprtjhfnmyzylblnkmrismcyyksqxcikyhrsannbmflvloshydnfvydmuoyphxpjgxsfmyqozidivsigleuvmnyniccdqjekyzjtytudpjbwjmsulfipurvjuxququmkfbrigctewalryoiilmqapofcwpllcwjnzmbtirmfmyhbuqkwqhzidrqbxnulklkjmrnzzclykjoflrbimnshtruucmjiukgvzoekyjnjpkkpwcgrbidyuyodlqaaywfsnbcczuxwsbnrcprq...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 33475 lines

Test #12:

score: 0
Accepted
time: 387ms
memory: 51932kb

input:

100000 100000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

0
0
1
1
1
1
3
1
3
4
3
3
4
5
7
4
4
4
5
3
4
6
1
0
4
4
12
3
9
9
9
3
7
10
6
9
2
9
4
8
8
7
4
7
7
6
1
5
6
6
4
5
4
3
0
1
1
1
0
0
0
0
0
0
0
0
0
1
0
1
1
0
2
0
0
0
0
0
0
0
0
0
0
1
0
1
1
3
1
1
1
4
4
1
0
4
3
2
0
2
1
0
0
0
0
6
5
0
2
4
2
0
0
0
0
1
0
1
0
0
0
2
4
4
1
3
5
1
0
0
0
0
0
0
2
2
2
0
0
0
0
0
0
0
0
2
2
3
1
...

result:

ok 33689 lines

Test #13:

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

input:

100000 100000
bbbbbaabbbbbaaabaabaaabbbbaabaaabaabbababbaaaaaaaabbababbbbabbababaabbabaabbaaaabbbbabaabbababbbbbbbaaabaabbabbbbbbaaaaababaaabbbabbaabaabaaabbbabbaaabaaaababbaaabaabbabaaaaaaababababbbbaabbaaaabaabbbbaaaababbabbbbabaabbbaaabbbaabaaabbbaaabaabbbbbabbaaabbaabbabbaababbbabbababbabbaabbbb...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 33438 lines

Test #14:

score: 0
Accepted
time: 266ms
memory: 53572kb

input:

100000 100000
aaabbbbabbaababbabaabbabababaaaaabbababababaabbaaabbbaaaaaabaaabbabbabbbabaabbaabbabbbbbbbaabaaababaaaaabaaaabbbaaaabbaabbaabbbbaaababbabababbaaaaabbbababababaabaabababbabbbbbabbabbbbaaababbbbaabbaaabababaabbbaaabaaaabbabbaabbbaabbbbabbbababbbabaabbaababaaaabbaabaaabbaaabaaaaabbbbbbbab...

output:

0
0
0
0
0
0
0
2
1
4
0
0
1
1
0
0
0
2
0
0
0
8
2
0
2
0
0
0
0
0
0
7
0
0
0
0
10
5
4
4
0
1
4
0
0
2
4
4
0
0
0
6
0
4
0
0
0
7
4
7
3
5
0
0
0
7
0
7
7
0
8
7
3
0
0
11
0
0
4
11
0
2
2
0
11
9
2
11
3
2
12
3
0
13
0
0
3
0
4
5
0
0
0
4
6
0
0
6
0
4
4
0
0
0
5
5
0
0
6
0
7
0
7
8
7
0
6
6
7
7
7
6
17
6
8
7
7
3
15
0
14
6
0
0
14...

result:

ok 33321 lines

Test #15:

score: 0
Accepted
time: 2ms
memory: 24708kb

input:

5 1000
glbdh
+ 2 2 2 1 2
? 2 1 2 3 4 1 1 5
? 1 3 4 3 2 3 4 4 1 5
- 1
? 1 1 2 2 1 2 1 4
+ 1 1 3
+ 2 1 4 1 2
? 2 4 5 1 2 3 2 3 3 4 1 2
? 2 4 4 1 1 2 3 4 1 3
? 1 1 2 1 1 3
- 7
+ 1 1 5
? 1 3 3 1 1 2
? 3 3 4 4 4 2 3 1 1 2
+ 3 1 5 2 5 1 2
? 1 1 1 3 1 2 3 3 1 2
? 2 4 5 3 3 2 3 3 1 2
? 1 2 3 2 3 4 1 2
? 1 1...

output:

0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
0
0
0
0
0
0
0
0
0
0
0
0
0
11
0
0
0
0
0
0
0
0
0
1
0
0
0
9
0
0
0
0
3
0
1
0
1
0
1
11
0
0
11
0
0
0
0
0
0
12
0
12
0
0
1
0
0
1
0
0
0
0
0
0
0
11
0
0
0
0
0
0
0
3
0
0
13
0
0
0
0
13
0
0
0
0
0
1
0
0
0
0
0
0
5
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 525 lines

Test #16:

score: 0
Accepted
time: 655ms
memory: 73020kb

input:

100000 100000
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm...

output:

0
0
0
1
0
0
0
2
0
0
0
0
2
0
0
0
0
1
0
0
2
0
0
1
1
1
1
0
1
2
2
0
2
1
1
1
0
2
1
1
1
1
1
1
0
2
3
3
1
1
1
1
4
1
3
4
0
2
2
2
2
3
2
3
2
0
2
1
3
4
4
3
1
4
2
0
0
3
2
3
3
3
2
3
0
3
3
3
3
3
5
4
0
4
3
4
3
4
4
1
3
3
4
5
4
5
1
6
5
6
8
6
3
6
8
6
3
5
2
1
6
4
3
6
3
1
1
3
4
3
5
8
4
3
5
6
3
6
1
7
3
7
8
6
4
7
4
3
1
5
...

result:

ok 49940 lines

Test #17:

score: 0
Accepted
time: 722ms
memory: 77060kb

input:

100000 100000
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...

output:

0
6
5
7
5
8
6
6
17
13
14
20
26
23
16
21
20
17
39
26
31
32
46
39
36
52
36
28
28
28
26
29
46
53
48
55
18
43
44
40
49
25
59
42
57
60
42
36
65
50
52
59
25
56
42
42
16
77
43
42
65
57
57
52
44
48
42
19
43
72
65
56
101
69
37
69
73
106
72
55
66
22
70
60
40
73
81
78
60
79
94
63
74
62
74
78
110
76
107
113
108...

result:

ok 9964 lines

Test #18:

score: 0
Accepted
time: 493ms
memory: 73216kb

input:

100000 100000
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0
1
3
1
0
1
1
0
3
3
3
0
6
3
0
3
0
0
1
3
3
2
3
4
0
1
3
1
3
1
1
6
5
4
8
2
1
3
4
3
0
0
6
8
10
1
4
11
2
4
0
0
0
4
3
9
3
2
10
10
7
3
1
1
3
8
5
0
3
1
8
1
3
0
8
1
6
1
4
1
8
8
6
1
7
0
1
6
9
1
6
4
3
1
2
6
7
1
9
10
3
7
2
2...

result:

ok 49932 lines

Test #20:

score: 0
Accepted
time: 838ms
memory: 78192kb

input:

100000 100000
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...

output:

1
1
1
0
1
2
2
1
4
4
4
6
6
7
7
9
12
12
11
15
8
21
3
4
8
8
26
11
15
11
20
21
22
29
14
26
25
31
34
26
19
11
29
33
17
20
20
27
33
29
29
43
31
33
33
16
35
30
17
24
40
36
41
19
33
38
51
32
64
28
21
50
42
41
46
29
48
51
62
56
30
45
62
37
54
38
22
43
38
45
43
40
59
53
73
73
72
45
68
27
68
64
62
72
51
65
39
...

result:

ok 10030 lines

Test #21:

score: 0
Accepted
time: 563ms
memory: 70568kb

input:

100000 100000
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp...

output:

0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
1
1
2
0
0
0
1
1
1
1
1
0
1
3
1
1
1
2
0
1
2
3
3
0
1
1
1
1
1
1
2
2
2
0
2
3
1
1
1
1
0
1
1
0
2
0
2
0
1
0
2
3
2
1
1
1
1
1
5
3
0
2
2
2
0
2
2
2
1
2
4
5
2
2
5
2
1
2
5
0
2
5
3
5
5
0
2
2
3
0
4
2
4
0
2
1
2
1
2
2
1
0
2
1
3
1
0
2
0
2
2
0
3
3
3
5
2
2
5
3
6
5
3
3
...

result:

ok 90160 lines

Test #22:

score: 0
Accepted
time: 400ms
memory: 66028kb

input:

100000 100000
faxyuxswncplvrzynzvlbjqvkdhqfmdddimahxygchjxwqaouebuiijkydypsvhlqeoelcnizmzcnuzvxzqilitcmbrhwjtbastbqyktczoarrihswnbsjtzvkrdjkwzijqkcziwqndcfgyvpepsokrgtlvrwxwjbtctdluemgbpzneomxcqdxxaoxdrgdzrherrygznacprcimyudgbjpelkpxotckckzihjuxnlmkczsutackpunsfnkwvhkadjfnhmvplqfgzmkssoacpuxaipepwro...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
...

result:

ok 49806 lines

Test #23:

score: 0
Accepted
time: 414ms
memory: 69976kb

input:

100000 100000
twdczjujsjrmpsipsunndczjujsjrmpsipsuwynwdczjujsjrmpsipsuwjwdczjujsjrmpsipsuyhtwdczjujsjrmpsipsuwwddczjujsjrmpsipsudczjujsjrmpsipsuybtwdczjujsjrmpsipsuwexdczjujsjrmpsipsuwevtwdczjujsjrmpsipsuwexatwdczjujsjrmpsipsuapwdczjujsjrmpsipsuwepwdczjujsjrmpsipsuwowdczjujsjrmpsipsudczjujsjrmpsipsu...

output:

0
1
0
0
0
1
0
0
1
1
7
0
0
0
0
3
3
0
3
3
1
1
0
0
0
0
0
3
9
13
0
14
5
0
2
10
6
5
2
9
3
9
3
5
6
2
1
0
4
2
1
0
0
10
3
5
2
0
7
0
30
27
0
3
13
0
0
0
1
0
22
0
0
1
0
0
27
0
35
1
0
1
17
0
0
0
1
10
0
0
0
2
2
15
0
52
0
4
14
0
0
36
6
0
25
0
12
0
6
1
0
1
0
0
0
3
9
2
0
60
38
16
15
11
0
0
0
2
13
0
0
6
0
7
0
0
0
25...

result:

ok 9909 lines

Test #24:

score: 0
Accepted
time: 262ms
memory: 53316kb

input:

100000 100000
gqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxi...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
5
5
5
5
5
6
6
6
6
7
7
7
7
7
7
7
8
8
8
8
8
8
8
8
8
8
8
9
9
9
10
10
11
11
11
11
11
11
11
11
12
12
12
12
12
12
13
13
13
13
13
13
13
14
14
14
15
15
15
15
15
1...

result:

ok 90066 lines

Test #25:

score: 0
Accepted
time: 435ms
memory: 67904kb

input:

100000 100000
nbaiostoyrvtrkngnuatnddlyjzqnfgufkqtmahrkmxxstxnqszjxibrnymsyujvzvazdmernpfoapfefjnbberzsmfmfqjwyyrqmbgdzppkratnddlyjzqnfgufkqtmahrkmxxstxnqszjxibrnymsyujvzvazdmernpfoapfefjnbberzsmfmfqjwyyrqvazynjzqnfgufkqtmahrkmxxstxnqszjxibrnymsyujvzvazdmernpfoapfefjnbberzsjzqnfgufkqtmahrkmxxstxnqsz...

output:

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

result:

ok 50106 lines

Test #26:

score: 0
Accepted
time: 297ms
memory: 52544kb

input:

100000 100000
avrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpo...

output:

2
2
13
28
31
64
83
95
108
119
121
127
134
141
157
158
162
164
175
181
181
195
201
201
209
210
215
218
253
259
263
263
273
274
280
303
310
317
318
325
328
342
360
368
376
392
393
420
427
431
434
440
456
457
485
501
502
533
556
593
601
601
605
606
614
617
644
654
687
700
721
723
728
728
731
731
738
74...

result:

ok 9852 lines

Test #27:

score: 0
Accepted
time: 428ms
memory: 60892kb

input:

100000 100000
nzqcglfwczqmzqcglfwczazqcglfwczzmzqcglfwczzqcglfwczpmzqcglfwczzqcglfwcxmzqcglfwcznzqcglfwczqcglfwcmzqcglfwczmzqcglfwcjmzqcglfwczzqcglfwczrzqcglfwczqcglfwczqcglfwczmzqcglfwczwzqcglfwczqcglfwcjzqcglfwcmzqcglfwcmzqcglfwczzqcglfwcizqcglfwcomzqcglfwcmzqcglfwczzqcglfwcjmzqcglfwczmzqcglfwczmz...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
2
0
1
0
0
3
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
3
0
0
0
0
0
0
0
1
2
0
0
0
0
1
0
1
0
1
0
0
...

result:

ok 90005 lines

Test #28:

score: 0
Accepted
time: 522ms
memory: 69020kb

input:

100000 100000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

5379
21600
8676
17796
6561
7062
8794
24490
12428
13642
26349
12930
17230
4054
29012
19503
23951
2084
14612
6542
11110
18521
5532
30725
21338
30107
893
12051
20828
7845
32580
8063
4190
21112
8005
33480
15470
3466
1311
10240
13981
29868
3358
35905
19687
9180
46665
11173
4030
5610
14002
22315
28887
629...

result:

ok 49879 lines

Extra Test:

score: 0
Extra Test Passed