QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#771813#7219. The Mighty SpellSymbolizeTL 1816ms109132kbC++142.1kb2024-11-22 15:50:422024-11-22 15:50:43

Judging History

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

  • [2024-11-22 16:49:37]
  • hack成功,自动添加数据
  • (/hack/1236)
  • [2024-11-22 15:50:43]
  • 评测
  • 测评结果:TL
  • 用时:1816ms
  • 内存:109132kb
  • [2024-11-22 15:50:42]
  • 提交

answer

/*
	Luogu name: Symbolize
	Luogu uid: 672793
*/
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define rep1(i,l,r) for(register int i=l;i<=r;++i)
#define rep2(i,l,r) for(register int i=l;i>=r;--i)
#define rep3(i,x,y,z) for(register int i=x[y];~i;i=z[i])
#define rep4(i,x) for(auto i:x)
#define debug() puts("----------")
const int N=2e5+10;
const int M=50+10;
const int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
using namespace std;
int n,m,a[N],f[N],g[N],last[N],pre[N],cnt[N][M],id[N],d[N],prod[N];
bool vis[M];
vector<int> v;
int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return f*x;
}
int power(int a,int b,int p)
{
	int ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%p;
		a=a*a%p;
		b>>=1;
	}
	return ans; 
}
signed main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	m=read();
	prod[0]=1;
	rep1(i,1,n)
	{
		a[i]=read();
		pre[i]=last[a[i]];
		last[a[i]]=i;
		rep1(j,1,m) cnt[i][j]=cnt[i-1][j];
		++cnt[i][a[i]];
		prod[i]=prod[i-1]*2%mod;
	}
	pre[n+1]=n+1;
	rep1(i,1,n) f[i]=(2*i%mod*i%mod*i%mod+3*i%mod*i%mod+3*i%mod+3)%mod;
	g[1]=f[1];
	rep1(i,2,n) g[i]=((f[i]-f[i-1]+mod)%mod-(f[i-1]-f[i-2]+mod)%mod+mod)%mod;
	rep1(i,1,m) id[i]=n+1;
	rep2(i,n,1)
	{
		v.clear();
		id[a[i]]=i;
		rep1(j,1,m) 
		{
			if(pre[id[j]]<=i) v.push_back(id[j]);
			vis[j]=0;
		}
		v.push_back(n+1);
		sort(v.begin(),v.end());
		int len=v.size()-1;
		rep1(j,0,len-1)
		{
			vis[a[v[j]]]=1;
			int ans=1;
			rep1(k,1,m) 
			{
				int Cnt=cnt[i-1][k]+(cnt[n][k]-cnt[v[j]][k]);
				if(!vis[k]) ans=ans*(prod[Cnt]-1)%mod;
				else ans=ans*prod[Cnt]%mod;
			}
			d[v[j]-i+1]=(d[v[j]-i+1]+ans*prod[v[j]-i+1]%mod)%mod;
			d[v[j+1]-i+1]=(d[v[j+1]-i+1]-ans*prod[v[j]-i+1]%mod+mod)%mod;
		}
	}
	int ans=0;
	rep1(i,1,n)
	{
		d[i]=(d[i]+d[i-1])%mod;
		ans=(ans+d[i]*g[i]%mod*power(prod[i],mod-2,mod)%mod)%mod;
	}
	cout<<ans<<"\n";
	return 0;
}

详细

Test #1:

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

input:

3 2
1 2 2

output:

152

result:

ok answer is '152'

Test #2:

score: 0
Accepted
time: 1ms
memory: 9808kb

input:

4 3
1 2 1 2

output:

0

result:

ok answer is '0'

Test #3:

score: 0
Accepted
time: 1ms
memory: 9772kb

input:

6 3
1 2 3 3 2 1

output:

3627

result:

ok answer is '3627'

Test #4:

score: 0
Accepted
time: 1ms
memory: 9784kb

input:

5 5
1 4 5 3 2

output:

343

result:

ok answer is '343'

Test #5:

score: 0
Accepted
time: 0ms
memory: 9856kb

input:

5 5
1 5 4 3 2

output:

343

result:

ok answer is '343'

Test #6:

score: 0
Accepted
time: 0ms
memory: 9880kb

input:

5 5
3 1 5 4 2

output:

343

result:

ok answer is '343'

Test #7:

score: 0
Accepted
time: 1ms
memory: 11852kb

input:

5 5
4 1 2 3 5

output:

343

result:

ok answer is '343'

Test #8:

score: 0
Accepted
time: 1ms
memory: 9880kb

input:

5 5
2 3 2 2 2

output:

0

result:

ok answer is '0'

Test #9:

score: 0
Accepted
time: 1ms
memory: 11932kb

input:

5 5
1 2 2 2 5

output:

0

result:

ok answer is '0'

Test #10:

score: 0
Accepted
time: 0ms
memory: 11792kb

input:

5 5
4 2 1 3 5

output:

343

result:

ok answer is '343'

Test #11:

score: 0
Accepted
time: 1ms
memory: 9816kb

input:

5 5
2 3 4 5 1

output:

343

result:

ok answer is '343'

Test #12:

score: 0
Accepted
time: 0ms
memory: 11848kb

input:

5 5
4 3 5 2 1

output:

343

result:

ok answer is '343'

Test #13:

score: 0
Accepted
time: 0ms
memory: 11856kb

input:

5 5
3 4 5 2 1

output:

343

result:

ok answer is '343'

Test #14:

score: 0
Accepted
time: 1ms
memory: 11784kb

input:

5 5
4 3 3 5 2

output:

0

result:

ok answer is '0'

Test #15:

score: 0
Accepted
time: 1ms
memory: 9804kb

input:

5 5
1 4 4 1 1

output:

0

result:

ok answer is '0'

Test #16:

score: 0
Accepted
time: 1ms
memory: 9804kb

input:

5 5
1 5 2 4 3

output:

343

result:

ok answer is '343'

Test #17:

score: 0
Accepted
time: 1ms
memory: 11920kb

input:

5 5
4 2 5 3 1

output:

343

result:

ok answer is '343'

Test #18:

score: 0
Accepted
time: 1ms
memory: 11840kb

input:

5 5
3 1 4 5 2

output:

343

result:

ok answer is '343'

Test #19:

score: 0
Accepted
time: 0ms
memory: 11780kb

input:

5 5
5 1 3 4 2

output:

343

result:

ok answer is '343'

Test #20:

score: 0
Accepted
time: 0ms
memory: 11848kb

input:

5 5
4 5 3 5 5

output:

0

result:

ok answer is '0'

Test #21:

score: 0
Accepted
time: 1ms
memory: 11776kb

input:

5 5
2 2 3 4 2

output:

0

result:

ok answer is '0'

Test #22:

score: 0
Accepted
time: 1ms
memory: 11780kb

input:

5 5
4 5 1 2 3

output:

343

result:

ok answer is '343'

Test #23:

score: 0
Accepted
time: 1ms
memory: 9864kb

input:

5 5
3 5 1 2 4

output:

343

result:

ok answer is '343'

Test #24:

score: 0
Accepted
time: 1ms
memory: 9820kb

input:

5 5
5 4 1 2 3

output:

343

result:

ok answer is '343'

Test #25:

score: 0
Accepted
time: 1ms
memory: 9868kb

input:

5 5
5 3 4 1 2

output:

343

result:

ok answer is '343'

Test #26:

score: 0
Accepted
time: 1ms
memory: 9744kb

input:

5 5
3 1 2 1 5

output:

0

result:

ok answer is '0'

Test #27:

score: 0
Accepted
time: 1ms
memory: 9820kb

input:

5 5
3 1 4 2 5

output:

343

result:

ok answer is '343'

Test #28:

score: 0
Accepted
time: 1ms
memory: 9720kb

input:

5 5
1 2 4 5 3

output:

343

result:

ok answer is '343'

Test #29:

score: 0
Accepted
time: 0ms
memory: 9804kb

input:

5 5
4 3 1 5 2

output:

343

result:

ok answer is '343'

Test #30:

score: 0
Accepted
time: 1ms
memory: 11780kb

input:

5 5
2 1 3 4 5

output:

343

result:

ok answer is '343'

Test #31:

score: 0
Accepted
time: 1ms
memory: 11792kb

input:

5 5
4 2 1 3 5

output:

343

result:

ok answer is '343'

Test #32:

score: 0
Accepted
time: 1ms
memory: 11792kb

input:

5 5
4 3 1 4 3

output:

0

result:

ok answer is '0'

Test #33:

score: 0
Accepted
time: 1ms
memory: 11788kb

input:

5 5
3 4 1 1 3

output:

0

result:

ok answer is '0'

Test #34:

score: 0
Accepted
time: 1ms
memory: 11792kb

input:

20 5
5 2 5 1 5 5 2 4 5 5 2 5 5 5 5 4 2 5 3 4

output:

102882880

result:

ok answer is '102882880'

Test #35:

score: 0
Accepted
time: 1ms
memory: 11876kb

input:

20 5
3 2 1 2 2 2 2 2 4 3 2 2 3 3 5 2 2 1 2 5

output:

134653185

result:

ok answer is '134653185'

Test #36:

score: 0
Accepted
time: 0ms
memory: 9812kb

input:

20 5
1 2 3 2 1 3 5 1 2 4 5 2 3 4 5 1 4 3 4 5

output:

315505338

result:

ok answer is '315505338'

Test #37:

score: 0
Accepted
time: 0ms
memory: 9812kb

input:

20 5
5 2 2 4 2 3 5 1 1 3 1 5 2 4 4 3 1 4 3 5

output:

312062382

result:

ok answer is '312062382'

Test #38:

score: 0
Accepted
time: 0ms
memory: 9748kb

input:

20 5
3 4 2 5 4 5 5 4 1 4 3 3 4 3 4 2 3 2 5 3

output:

188515821

result:

ok answer is '188515821'

Test #39:

score: 0
Accepted
time: 0ms
memory: 11924kb

input:

20 5
3 5 1 3 3 4 5 2 1 1 3 1 2 5 2 1 1 2 5 2

output:

197857329

result:

ok answer is '197857329'

Test #40:

score: 0
Accepted
time: 0ms
memory: 9776kb

input:

20 10
3 8 6 8 9 2 1 5 8 6 7 8 4 8 6 8 10 8 8 8

output:

4905343

result:

ok answer is '4905343'

Test #41:

score: 0
Accepted
time: 0ms
memory: 11880kb

input:

20 10
10 5 1 8 7 2 7 2 6 2 2 2 2 2 4 2 3 7 9 7

output:

3724041

result:

ok answer is '3724041'

Test #42:

score: 0
Accepted
time: 0ms
memory: 11860kb

input:

20 10
5 1 9 6 10 4 5 3 2 4 8 3 7 1 8 6 2 9 10 7

output:

52978806

result:

ok answer is '52978806'

Test #43:

score: 0
Accepted
time: 0ms
memory: 11868kb

input:

20 10
5 8 6 2 1 10 3 8 9 7 6 5 10 9 1 7 3 4 4 2

output:

53309955

result:

ok answer is '53309955'

Test #44:

score: 0
Accepted
time: 1ms
memory: 9868kb

input:

20 10
1 8 1 7 9 7 9 9 7 4 1 6 2 7 8 6 6 9 6 7

output:

0

result:

ok answer is '0'

Test #45:

score: 0
Accepted
time: 1ms
memory: 11848kb

input:

20 10
1 10 10 10 2 9 1 1 7 2 3 9 5 10 8 4 1 4 2 5

output:

0

result:

ok answer is '0'

Test #46:

score: 0
Accepted
time: 1ms
memory: 11940kb

input:

20 20
9 16 3 18 8 19 6 4 2 17 1 15 10 11 5 13 12 7 14 20

output:

17263

result:

ok answer is '17263'

Test #47:

score: 0
Accepted
time: 1ms
memory: 11768kb

input:

20 20
2 17 18 12 15 20 11 9 10 5 6 16 7 8 4 13 3 1 19 14

output:

17263

result:

ok answer is '17263'

Test #48:

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

input:

20 20
14 15 19 8 3 20 9 12 18 7 5 11 4 2 16 6 1 17 10 13

output:

17263

result:

ok answer is '17263'

Test #49:

score: 0
Accepted
time: 1ms
memory: 11852kb

input:

20 20
18 9 3 4 13 12 15 11 2 16 19 7 10 20 17 8 6 1 14 5

output:

17263

result:

ok answer is '17263'

Test #50:

score: 0
Accepted
time: 0ms
memory: 9900kb

input:

20 20
7 6 4 14 20 13 1 15 5 18 16 10 1 16 12 14 5 13 1 3

output:

0

result:

ok answer is '0'

Test #51:

score: 0
Accepted
time: 0ms
memory: 9744kb

input:

20 20
17 17 5 16 9 14 14 1 2 4 19 8 9 5 9 20 5 16 20 9

output:

0

result:

ok answer is '0'

Test #52:

score: 0
Accepted
time: 1ms
memory: 11852kb

input:

20 20
20 1 16 5 19 11 8 7 2 3 12 6 17 14 13 18 4 10 15 9

output:

17263

result:

ok answer is '17263'

Test #53:

score: 0
Accepted
time: 1ms
memory: 11916kb

input:

20 20
2 13 6 1 17 3 11 9 8 10 7 5 16 14 4 15 18 19 20 12

output:

17263

result:

ok answer is '17263'

Test #54:

score: 0
Accepted
time: 1ms
memory: 9904kb

input:

20 20
17 11 13 5 2 14 18 7 6 9 10 3 16 15 8 1 19 4 12 20

output:

17263

result:

ok answer is '17263'

Test #55:

score: 0
Accepted
time: 1ms
memory: 11848kb

input:

20 20
7 13 1 15 9 2 8 20 4 5 12 3 11 14 10 18 6 17 16 19

output:

17263

result:

ok answer is '17263'

Test #56:

score: 0
Accepted
time: 1ms
memory: 11792kb

input:

20 20
11 8 17 7 10 20 20 12 7 3 7 14 15 4 14 7 11 1 12 20

output:

0

result:

ok answer is '0'

Test #57:

score: 0
Accepted
time: 0ms
memory: 11940kb

input:

20 20
20 18 17 14 11 2 13 3 10 1 16 3 1 16 10 8 4 8 13 3

output:

0

result:

ok answer is '0'

Test #58:

score: 0
Accepted
time: 1ms
memory: 11872kb

input:

20 20
1 20 7 4 18 11 9 8 3 6 16 13 19 2 12 14 15 17 10 5

output:

17263

result:

ok answer is '17263'

Test #59:

score: 0
Accepted
time: 0ms
memory: 11920kb

input:

20 20
8 4 5 18 16 15 19 2 13 1 14 7 10 12 17 3 6 9 20 11

output:

17263

result:

ok answer is '17263'

Test #60:

score: 0
Accepted
time: 1ms
memory: 11800kb

input:

20 20
13 14 8 9 18 17 20 6 15 3 2 16 12 11 1 10 19 4 7 5

output:

17263

result:

ok answer is '17263'

Test #61:

score: 0
Accepted
time: 1ms
memory: 11928kb

input:

20 20
4 10 17 8 19 1 16 3 14 6 7 11 13 15 20 9 12 5 2 18

output:

17263

result:

ok answer is '17263'

Test #62:

score: 0
Accepted
time: 1ms
memory: 11852kb

input:

20 20
19 17 19 8 7 1 18 13 16 16 20 11 5 8 17 19 11 14 4 8

output:

0

result:

ok answer is '0'

Test #63:

score: 0
Accepted
time: 1ms
memory: 11796kb

input:

20 20
7 1 14 13 20 16 10 18 16 12 5 7 16 14 6 12 11 20 10 19

output:

0

result:

ok answer is '0'

Test #64:

score: 0
Accepted
time: 1ms
memory: 12056kb

input:

500 5
3 5 5 3 5 3 5 5 3 3 3 3 3 3 1 3 3 3 3 3 3 3 5 3 3 3 1 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 5 3 3 3 5 3 3 5 2 3 3 3 5 3 3 3 3 1 3 3 5 3 3 5 3 3 5 3 5 3 3 3 3 3 3 5 3 5 3 3 5 3 5 3 5 3 3 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 5 3 3 5 5 3 3 3 3 3 5 3 5 3 3 3 3 5 3 3 3 3 3 3 3 3 3 ...

output:

255072751

result:

ok answer is '255072751'

Test #65:

score: 0
Accepted
time: 1ms
memory: 12088kb

input:

500 5
1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 5 1 5 5 1 1 1 1 1 5 5 1 1 1 1 5 4 5 4 1 1 1 1 1 1 5 1 1 5 1 1 5 1 5 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 4 1 5 1 5 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 1 1 3 4 5 1 5 1 1 1 1 5 5 1 1 1 1 1 1 1 1 5 1 1 1 5 1 1 1 1 5 1 5 1 4 1 1 1 4 5 5 1 ...

output:

825435010

result:

ok answer is '825435010'

Test #66:

score: 0
Accepted
time: 1ms
memory: 12144kb

input:

500 5
1 2 4 3 2 2 4 5 4 2 4 2 5 5 5 5 1 4 1 2 4 4 2 1 2 5 4 3 1 1 2 4 3 3 2 3 4 5 4 1 3 2 3 3 5 2 2 3 2 2 3 2 5 2 1 1 3 1 4 2 4 3 3 2 4 1 5 2 4 3 3 3 2 2 3 3 4 5 2 1 4 3 5 5 2 2 3 4 3 1 5 4 3 1 3 1 5 1 3 1 3 2 5 3 1 2 2 5 4 4 5 5 4 1 2 1 4 5 1 4 3 5 4 1 4 5 3 3 4 3 4 2 2 5 5 3 4 5 3 5 3 5 3 1 2 2 2 ...

output:

451686600

result:

ok answer is '451686600'

Test #67:

score: 0
Accepted
time: 1ms
memory: 10072kb

input:

500 5
4 1 3 1 1 1 4 1 1 5 1 5 3 5 4 1 1 4 2 5 5 5 2 5 2 2 5 3 1 5 3 3 2 5 4 5 1 3 4 3 5 1 5 3 1 3 5 2 2 3 2 4 2 3 5 5 3 1 5 3 2 4 2 1 2 1 5 4 3 5 2 5 5 4 2 3 1 5 4 4 3 1 3 3 1 3 3 4 3 1 2 2 3 4 3 1 2 3 4 1 1 1 5 4 2 3 4 5 4 1 2 4 3 3 4 5 3 3 4 4 2 4 5 5 3 2 2 1 5 2 4 2 2 2 2 1 4 3 5 3 4 3 5 5 3 3 5 ...

output:

377242617

result:

ok answer is '377242617'

Test #68:

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

input:

500 5
1 3 2 1 1 5 2 5 5 1 4 4 1 3 2 2 4 1 4 2 4 3 5 4 4 3 2 1 2 2 2 2 4 5 4 1 2 3 3 4 4 3 3 2 4 5 3 5 1 1 1 3 4 5 2 3 3 5 4 4 1 1 2 3 1 3 2 1 2 4 1 4 2 3 1 3 4 2 2 3 1 3 1 1 5 4 2 4 1 5 5 5 5 3 1 2 4 3 1 4 3 4 2 2 3 1 5 2 3 4 4 2 4 2 4 3 5 4 3 1 1 4 4 1 5 3 2 1 5 1 5 4 4 4 5 1 5 3 2 5 4 4 2 3 3 3 3 ...

output:

416085601

result:

ok answer is '416085601'

Test #69:

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

input:

500 5
1 3 4 5 5 5 3 3 4 4 1 3 2 1 1 5 4 4 3 1 3 4 3 4 3 1 4 4 1 4 4 3 4 4 1 1 3 2 1 5 4 2 2 3 3 2 3 4 5 5 5 2 3 4 1 5 2 5 5 4 4 2 5 5 1 1 5 3 4 1 1 1 4 2 4 5 2 4 3 5 1 5 1 4 4 3 4 5 5 5 1 1 4 5 5 1 2 3 3 4 3 4 3 3 1 5 4 5 4 2 1 1 4 5 2 1 4 2 1 1 3 3 1 5 2 1 2 3 2 3 3 1 5 1 4 3 4 4 2 4 4 1 4 4 3 1 4 ...

output:

320473255

result:

ok answer is '320473255'

Test #70:

score: 0
Accepted
time: 1ms
memory: 11888kb

input:

500 10
7 7 7 5 5 7 7 7 7 7 7 5 7 5 5 7 7 7 6 5 7 7 7 7 5 6 7 7 7 7 7 7 5 7 7 7 9 7 7 7 5 5 7 7 7 7 7 5 7 5 7 7 7 5 5 5 7 5 5 6 5 7 5 5 5 7 7 5 5 7 9 7 5 7 6 7 7 5 7 7 7 7 7 7 7 7 6 7 5 7 7 5 5 7 7 7 7 7 7 7 7 7 7 5 7 7 5 7 7 7 7 7 5 7 7 7 5 7 7 7 7 7 7 6 7 7 9 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 5 7 4...

output:

239772932

result:

ok answer is '239772932'

Test #71:

score: 0
Accepted
time: 1ms
memory: 12152kb

input:

500 10
1 1 9 10 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 9 1 1 6 1 1 1 1 7 1 1 9 10 9 1 1 1 1 1 9 1 1 1 10 1 1 1 1 1 1 1 10 1 10 10 1 1 1 7 1 10 1 1 1 1 1 1 1 10 1 1 1 1 10 9 1 1 9 10 1 1 1 1 1 1 1 10 1 10 9 1 1 1 10 10 10 1 1 1 1 9 3 9 1 1 1 1 10 1 1 1 1 10 1 1 10 7 1 1 1 1 1 1 9 1 1 1 1 1 10 1 10 1 1 1 1...

output:

516842141

result:

ok answer is '516842141'

Test #72:

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

input:

500 10
7 4 8 5 5 1 7 10 2 1 1 4 2 5 3 10 8 7 1 9 2 1 2 1 3 3 5 3 4 3 10 1 1 5 7 1 10 1 6 6 4 8 7 5 5 3 8 10 7 3 6 2 10 5 9 2 9 8 6 2 4 5 8 10 2 1 9 5 8 8 3 1 8 3 5 3 2 2 8 4 5 9 6 6 10 9 6 7 10 8 6 4 5 9 10 1 5 3 7 10 9 8 6 1 8 9 10 4 7 8 1 4 1 10 8 5 7 5 2 5 10 2 7 7 1 2 6 8 2 3 5 4 2 6 1 4 10 8 9 ...

output:

180962819

result:

ok answer is '180962819'

Test #73:

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

input:

500 10
9 6 4 5 9 7 5 9 6 1 7 7 2 8 9 4 2 4 4 8 10 1 3 7 9 6 4 1 2 6 9 2 3 10 5 7 5 8 9 2 6 4 8 1 4 9 6 7 8 1 7 5 6 5 6 1 3 9 8 8 1 8 10 5 9 10 1 3 10 1 6 9 8 7 3 3 7 8 4 6 7 2 9 1 3 4 5 3 6 1 1 7 8 2 2 6 6 10 9 5 8 8 6 1 7 2 4 7 1 9 4 7 3 3 7 4 10 3 10 8 4 2 5 2 5 7 2 9 4 8 10 8 10 2 4 8 6 2 9 3 2 4...

output:

627406288

result:

ok answer is '627406288'

Test #74:

score: 0
Accepted
time: 0ms
memory: 12028kb

input:

500 10
9 6 3 4 6 5 7 9 9 3 6 6 6 6 7 8 10 10 6 4 4 8 8 10 3 1 5 8 4 9 10 5 5 4 1 8 1 7 4 6 2 4 7 5 2 1 4 5 9 10 1 4 1 1 1 8 5 8 1 4 7 10 7 8 9 9 4 3 4 5 9 4 2 9 10 9 9 6 3 10 7 10 5 8 10 1 6 10 6 2 5 9 8 3 3 9 9 3 5 4 6 8 1 8 3 6 2 4 3 3 7 6 1 9 9 6 5 5 2 3 10 8 6 6 5 10 6 5 1 9 5 10 3 8 10 2 1 9 8 ...

output:

561848920

result:

ok answer is '561848920'

Test #75:

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

input:

500 10
4 8 10 1 1 3 3 4 6 7 10 7 7 3 8 8 3 4 8 2 9 7 3 8 1 4 7 6 4 2 7 8 7 2 9 2 10 3 8 7 3 9 9 6 3 7 2 4 3 4 8 7 2 3 1 9 3 3 9 5 9 2 9 5 1 10 10 3 8 10 2 10 5 9 8 7 8 5 7 3 3 9 9 8 6 4 8 3 9 7 3 3 7 4 10 1 4 4 4 9 3 3 8 5 6 3 8 1 4 4 6 10 4 2 10 3 6 4 5 3 10 10 5 1 3 1 9 6 3 2 10 3 2 7 10 3 9 3 6 7...

output:

762179727

result:

ok answer is '762179727'

Test #76:

score: 0
Accepted
time: 0ms
memory: 12104kb

input:

500 20
18 18 18 2 18 6 2 18 12 6 12 18 18 12 12 6 12 6 6 2 18 12 18 18 18 12 6 18 12 12 6 18 12 18 18 18 6 6 18 18 18 18 6 18 18 18 7 2 12 18 12 18 6 2 18 2 20 12 6 10 18 18 18 18 7 13 18 18 18 12 18 18 18 12 12 18 18 6 12 6 6 7 12 12 18 18 6 8 7 18 18 18 18 12 6 12 7 1 7 18 18 18 18 6 6 18 18 18 18...

output:

537535822

result:

ok answer is '537535822'

Test #77:

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

input:

500 20
1 18 18 19 18 19 2 18 18 2 18 6 6 19 18 9 18 6 6 1 18 1 6 18 19 18 18 18 19 1 19 19 15 6 18 1 19 13 18 10 19 19 6 18 19 19 18 15 18 19 6 18 18 19 15 18 18 1 18 18 18 18 18 1 6 19 18 18 18 19 19 18 6 18 6 18 18 19 18 19 19 18 18 18 18 18 6 19 18 18 18 19 18 19 18 18 18 18 2 19 11 18 18 18 6 18...

output:

505939107

result:

ok answer is '505939107'

Test #78:

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

input:

500 20
11 19 17 1 5 20 20 3 8 16 9 17 13 20 11 8 17 9 13 15 10 10 18 3 4 11 9 2 1 8 5 6 20 20 14 5 3 5 16 17 8 17 2 17 7 11 12 4 12 10 1 20 7 18 4 16 5 6 11 2 11 14 16 15 5 18 1 10 4 11 11 4 8 15 15 8 4 15 1 11 14 20 1 7 8 7 1 20 12 13 6 4 16 18 14 1 15 11 18 2 18 11 17 3 10 10 1 11 11 17 17 7 2 6 6...

output:

299282126

result:

ok answer is '299282126'

Test #79:

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

input:

500 20
19 17 19 13 13 7 20 11 16 18 8 4 17 11 3 19 17 12 18 8 17 2 2 5 14 7 6 4 15 3 4 10 18 15 4 2 7 18 12 16 14 15 18 4 5 7 1 12 19 3 12 12 11 5 6 8 9 15 17 14 14 20 14 15 4 12 19 7 7 15 20 20 16 16 19 17 5 1 19 8 1 5 14 19 20 10 7 3 3 11 6 2 7 5 4 10 16 10 9 1 13 9 20 9 2 12 4 3 6 8 12 13 19 8 8 ...

output:

639893943

result:

ok answer is '639893943'

Test #80:

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

input:

500 20
12 5 4 10 10 19 8 1 18 16 16 17 16 13 3 11 14 1 1 2 14 6 7 20 13 9 4 5 9 20 11 19 1 15 8 12 11 16 1 15 19 1 2 8 9 18 9 19 2 8 1 7 11 7 5 15 15 9 18 3 20 17 7 2 16 10 11 8 19 6 14 10 5 20 4 3 6 14 19 9 9 8 19 7 15 11 13 4 15 20 17 7 16 5 16 1 2 17 6 18 14 18 1 17 19 15 7 10 16 10 19 5 17 18 17...

output:

900646697

result:

ok answer is '900646697'

Test #81:

score: 0
Accepted
time: 0ms
memory: 12036kb

input:

500 20
11 15 9 16 7 5 10 3 10 5 15 19 9 15 6 8 8 11 13 17 4 12 15 3 4 1 4 14 1 20 7 8 7 13 11 1 1 3 18 5 2 20 12 4 16 6 3 15 8 6 20 4 10 1 5 17 11 14 10 11 19 5 4 19 19 7 17 11 7 16 11 12 4 9 12 11 18 16 20 7 19 3 17 11 7 14 6 8 6 2 11 19 4 4 18 4 16 14 5 12 10 13 3 1 6 18 14 13 15 8 20 13 10 5 3 12...

output:

979272254

result:

ok answer is '979272254'

Test #82:

score: 0
Accepted
time: 0ms
memory: 10128kb

input:

500 40
33 12 12 40 12 12 33 27 37 38 8 12 12 2 38 12 33 32 8 37 12 12 7 2 38 4 30 12 12 3 22 16 8 12 33 16 38 26 2 16 12 40 16 12 12 18 18 16 32 30 2 8 12 2 16 16 37 12 16 2 12 40 38 32 12 18 2 12 8 37 33 16 38 38 12 18 12 16 2 16 12 12 33 2 21 8 18 16 12 2 38 8 12 16 2 12 33 16 8 8 16 37 40 12 12 3...

output:

704934301

result:

ok answer is '704934301'

Test #83:

score: 0
Accepted
time: 0ms
memory: 11968kb

input:

500 40
5 9 23 7 23 35 2 33 27 9 5 5 27 30 2 40 27 40 2 27 7 27 7 2 7 27 22 2 27 2 5 22 27 22 34 2 22 27 9 27 40 22 22 2 27 2 27 27 23 17 7 22 38 23 27 27 2 22 2 27 2 5 23 2 27 23 7 40 23 27 27 27 22 7 5 2 2 2 2 2 2 2 25 22 22 22 22 27 7 24 30 27 38 7 39 40 22 2 5 25 5 7 22 7 22 10 2 2 40 28 2 22 2 2...

output:

674540769

result:

ok answer is '674540769'

Test #84:

score: 0
Accepted
time: 5ms
memory: 12136kb

input:

500 40
31 24 31 11 1 32 13 2 15 32 5 23 22 6 27 31 30 1 30 28 22 28 26 40 39 11 7 4 16 1 6 8 1 19 9 24 7 22 8 13 8 2 2 1 21 17 29 13 24 14 32 23 36 10 32 3 34 14 6 13 12 17 25 12 7 4 11 26 38 16 5 3 38 19 9 25 24 9 3 39 33 10 7 20 5 32 29 15 4 17 22 4 40 39 3 33 12 2 35 17 15 23 30 28 39 7 10 38 21 ...

output:

329732263

result:

ok answer is '329732263'

Test #85:

score: 0
Accepted
time: 5ms
memory: 12160kb

input:

500 40
40 7 7 1 28 4 34 21 15 27 32 12 18 9 9 19 17 21 8 17 18 13 19 24 16 22 31 23 40 22 17 13 39 19 4 24 31 38 15 12 14 16 40 7 16 37 40 4 18 26 17 4 16 25 39 37 20 3 31 14 30 38 39 32 22 39 25 36 23 32 14 33 19 15 1 11 13 24 34 39 35 33 35 19 17 37 20 34 20 25 25 38 33 30 29 30 35 11 23 28 22 21 ...

output:

754219638

result:

ok answer is '754219638'

Test #86:

score: 0
Accepted
time: 5ms
memory: 12180kb

input:

500 40
33 32 25 8 23 8 34 25 16 8 5 25 16 35 9 5 6 1 10 16 17 38 22 25 23 5 5 36 34 7 24 32 1 38 14 2 3 15 4 35 16 36 3 13 22 20 29 27 40 36 24 8 26 21 39 15 1 23 36 22 31 10 12 29 32 6 1 15 40 7 37 14 31 32 40 39 1 19 7 1 1 21 35 6 16 4 38 6 13 4 35 12 12 11 28 6 3 38 15 40 17 10 32 24 18 15 7 17 2...

output:

843957197

result:

ok answer is '843957197'

Test #87:

score: 0
Accepted
time: 5ms
memory: 12144kb

input:

500 40
36 17 20 3 18 36 6 28 8 29 2 10 9 9 29 24 8 13 21 29 25 8 18 10 10 2 7 18 36 18 38 12 39 32 28 1 34 7 14 15 11 25 35 39 18 24 37 23 3 9 12 29 10 20 32 25 22 1 5 8 17 22 14 34 19 27 30 22 6 35 30 38 4 31 39 25 9 4 9 16 36 40 11 18 10 16 24 24 6 9 1 35 3 20 37 25 40 10 25 1 12 25 25 18 17 37 8 ...

output:

348483675

result:

ok answer is '348483675'

Test #88:

score: 0
Accepted
time: 5ms
memory: 11888kb

input:

500 50
5 2 46 7 2 5 7 3 20 30 5 28 2 33 7 35 2 35 14 5 46 7 35 35 7 7 20 20 7 5 36 28 35 4 8 34 30 35 25 5 2 36 36 7 2 2 20 27 7 43 35 5 2 45 20 7 7 5 2 2 7 20 46 23 14 33 20 5 5 7 7 20 20 13 25 2 7 7 34 7 7 20 36 5 7 35 7 10 23 2 7 34 20 14 35 46 20 5 5 5 5 7 25 5 2 5 5 2 7 7 35 2 34 5 36 2 36 25 7...

output:

609417022

result:

ok answer is '609417022'

Test #89:

score: 0
Accepted
time: 5ms
memory: 10132kb

input:

500 50
25 14 3 3 18 14 36 18 22 3 18 11 23 37 22 39 22 37 3 6 31 22 22 17 3 23 22 22 23 3 26 30 3 46 18 17 22 6 22 30 30 2 22 3 3 22 23 48 18 17 30 22 23 22 6 22 14 6 15 22 23 17 36 22 22 3 17 3 14 20 30 18 18 3 3 3 23 3 23 14 18 17 23 37 22 39 6 30 3 23 6 39 6 3 3 23 30 17 17 6 30 17 27 15 22 30 3 ...

output:

477945404

result:

ok answer is '477945404'

Test #90:

score: 0
Accepted
time: 7ms
memory: 12172kb

input:

500 50
18 15 28 10 24 7 16 36 49 2 25 14 17 6 40 4 30 20 26 29 30 40 24 42 21 50 7 37 43 18 48 8 4 27 29 30 26 32 11 31 43 15 10 17 14 28 48 31 38 14 37 49 33 19 5 1 32 12 46 24 9 9 47 15 29 8 13 13 46 11 9 1 12 21 37 1 36 30 22 25 45 37 1 43 16 29 11 16 2 17 41 46 43 30 34 42 18 42 23 45 15 10 13 2...

output:

777701638

result:

ok answer is '777701638'

Test #91:

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

input:

500 50
44 23 9 8 47 21 35 45 42 12 2 23 24 25 49 32 27 47 4 1 24 3 27 45 13 15 15 28 29 42 37 18 26 48 23 8 16 33 7 32 25 34 25 21 50 5 40 23 14 10 22 11 14 13 30 27 30 38 28 21 25 12 37 39 40 11 7 23 6 27 7 3 18 1 10 13 34 16 9 4 39 1 44 3 8 35 2 18 31 34 10 22 49 10 16 22 20 17 41 14 7 3 29 29 19 ...

output:

731977280

result:

ok answer is '731977280'

Test #92:

score: 0
Accepted
time: 6ms
memory: 12088kb

input:

500 50
17 29 35 42 26 47 10 38 50 18 14 3 17 20 50 45 18 3 4 13 15 26 36 15 3 48 13 4 40 41 36 33 35 17 25 24 24 26 14 23 31 22 17 13 7 26 22 7 35 26 50 2 13 41 28 6 24 43 43 38 11 29 38 12 5 44 28 26 45 22 7 27 9 36 19 35 17 2 28 39 28 2 36 3 6 34 36 48 9 16 36 26 30 19 35 30 38 35 41 14 50 38 21 3...

output:

794540368

result:

ok answer is '794540368'

Test #93:

score: 0
Accepted
time: 7ms
memory: 12080kb

input:

500 50
45 7 25 48 8 48 12 11 46 13 50 27 17 37 46 31 21 34 25 46 33 2 49 47 6 9 8 24 34 45 37 17 26 24 40 6 36 5 32 26 47 7 45 28 21 7 39 26 11 36 7 44 26 46 10 39 35 1 44 18 30 36 45 12 26 2 10 34 47 49 21 41 49 33 2 48 42 32 40 24 11 13 4 8 25 44 7 37 43 35 9 50 37 12 7 48 33 18 12 33 38 12 39 15 ...

output:

719351656

result:

ok answer is '719351656'

Test #94:

score: 0
Accepted
time: 4ms
memory: 14560kb

input:

5000 5
2 4 4 4 2 5 4 4 2 4 4 4 4 4 4 4 4 3 2 2 4 2 4 4 2 4 4 4 4 4 4 4 3 4 4 2 3 4 4 4 4 4 4 2 2 4 2 4 2 4 2 4 4 4 2 4 4 4 4 4 4 4 4 4 4 4 2 4 4 2 4 4 4 4 4 4 4 4 2 5 4 4 2 2 4 4 4 4 4 4 4 2 4 4 4 4 2 4 4 4 4 3 4 4 2 4 4 4 2 4 4 4 2 3 4 2 2 4 4 4 4 3 4 4 2 2 2 2 4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 4 4...

output:

572500849

result:

ok answer is '572500849'

Test #95:

score: 0
Accepted
time: 0ms
memory: 14780kb

input:

5000 5
4 4 4 4 4 4 4 4 4 4 4 4 1 4 4 2 5 4 4 4 4 4 4 1 4 4 4 5 4 4 4 4 4 1 4 5 4 4 4 4 4 4 4 4 1 4 4 4 5 4 4 4 4 4 5 4 4 4 4 4 4 4 4 1 4 4 4 5 4 5 4 4 4 4 5 4 4 4 4 4 5 1 5 5 4 5 4 4 4 4 5 4 5 4 4 4 4 4 4 4 4 2 5 5 4 4 5 4 4 4 4 4 4 4 4 4 4 1 5 4 4 4 1 4 4 4 4 4 4 4 4 5 4 4 5 5 4 4 4 4 4 4 4 4 4 4 5...

output:

308854905

result:

ok answer is '308854905'

Test #96:

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

input:

5000 5
2 5 3 2 4 5 1 5 2 2 1 5 3 5 5 2 2 4 5 3 2 1 2 2 2 2 5 1 4 3 4 1 1 4 4 5 5 3 4 1 1 1 2 4 2 1 2 4 5 2 5 1 3 5 2 2 4 3 4 2 2 4 3 4 4 1 1 1 4 5 5 4 4 5 5 3 5 2 2 5 3 1 2 2 2 1 4 1 2 5 4 1 3 3 3 2 3 4 5 2 1 5 1 5 2 4 1 1 2 4 3 3 4 2 3 3 3 5 3 4 2 3 3 3 2 2 5 5 2 5 5 5 3 4 1 5 2 4 4 3 3 5 4 5 3 4 1...

output:

196115104

result:

ok answer is '196115104'

Test #97:

score: 0
Accepted
time: 0ms
memory: 14260kb

input:

5000 5
4 4 2 4 1 5 2 3 4 1 5 4 3 4 1 5 5 5 4 2 3 5 5 3 2 1 1 1 5 5 3 5 1 2 4 4 1 3 1 1 3 4 1 1 2 1 1 5 2 3 1 4 3 5 1 2 2 3 1 3 2 2 4 5 4 5 3 3 3 2 4 5 5 4 5 2 5 1 3 3 2 5 1 2 5 5 1 5 2 2 2 5 5 3 1 1 2 5 1 4 4 3 3 3 2 5 5 5 1 2 5 3 2 1 2 4 4 4 2 5 5 1 4 5 4 2 2 5 2 4 1 1 2 1 2 3 4 4 5 1 5 3 3 3 5 2 4...

output:

716389422

result:

ok answer is '716389422'

Test #98:

score: 0
Accepted
time: 0ms
memory: 14156kb

input:

5000 5
5 3 1 4 3 4 4 5 3 1 3 4 5 5 3 3 5 1 3 4 2 2 4 1 3 1 5 1 5 2 4 1 5 3 1 4 5 5 4 2 1 4 3 3 4 1 5 3 3 2 3 4 3 5 1 2 5 1 5 1 4 2 4 3 5 4 2 2 2 5 2 2 1 2 2 4 5 5 1 3 2 4 1 4 2 4 1 4 4 5 4 1 2 4 1 3 5 4 3 4 1 1 5 4 1 3 5 5 2 3 5 5 2 3 3 4 5 1 2 1 4 3 1 3 5 3 4 2 3 3 2 5 4 2 5 1 1 4 3 2 3 4 1 3 2 4 3...

output:

333702253

result:

ok answer is '333702253'

Test #99:

score: 0
Accepted
time: 0ms
memory: 14688kb

input:

5000 5
4 4 1 2 5 4 2 5 4 1 1 5 2 1 4 2 5 3 2 3 2 1 3 3 4 3 2 4 1 2 2 4 2 2 2 5 4 5 4 5 1 3 3 5 4 4 1 3 5 1 3 1 4 1 1 4 3 1 1 5 4 1 2 1 5 1 5 3 4 4 4 4 3 2 3 1 5 2 3 2 1 5 5 1 2 2 1 5 5 4 5 3 4 4 2 3 1 3 2 1 3 3 4 1 4 4 3 3 2 4 3 1 3 2 5 5 3 2 2 1 1 1 3 4 3 1 4 3 4 2 1 3 5 3 5 3 3 1 2 4 2 3 2 2 1 1 4...

output:

939628711

result:

ok answer is '939628711'

Test #100:

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

input:

5000 10
1 1 4 5 5 1 1 4 4 4 4 1 1 1 1 1 4 1 1 4 4 1 1 1 1 1 1 1 4 1 4 1 1 4 1 6 1 1 1 4 1 6 1 1 1 1 1 1 1 4 1 4 1 1 5 1 4 1 1 1 1 1 1 1 1 1 1 4 1 4 1 1 4 1 1 1 1 1 1 4 1 1 4 1 1 1 1 7 1 1 1 1 4 1 1 1 1 5 1 1 1 4 1 1 4 1 4 1 1 4 4 1 4 5 4 1 1 1 1 1 4 1 1 1 1 1 1 1 5 1 1 1 1 4 5 1 4 4 1 1 4 1 5 1 5 1 ...

output:

509515507

result:

ok answer is '509515507'

Test #101:

score: 0
Accepted
time: 4ms
memory: 13968kb

input:

5000 10
3 3 3 2 3 8 2 3 3 3 3 3 8 3 3 3 8 3 3 8 3 8 8 3 3 8 3 6 3 8 3 3 3 3 8 3 3 3 8 8 3 3 3 8 3 3 3 8 3 3 3 6 6 3 3 3 3 3 6 3 8 3 3 3 3 3 8 3 3 8 3 3 3 3 3 5 3 8 8 6 8 8 6 8 3 8 3 3 3 8 6 3 3 8 8 8 6 8 3 3 3 8 3 3 3 3 2 3 8 3 3 8 3 3 3 8 3 3 3 3 8 3 8 3 6 6 8 3 3 8 3 8 3 8 3 8 3 8 3 3 3 3 3 3 3 3 ...

output:

355318262

result:

ok answer is '355318262'

Test #102:

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

input:

5000 10
4 5 4 8 4 3 5 10 8 7 4 1 6 7 3 2 2 4 10 5 8 1 3 4 7 1 10 9 5 3 7 6 8 3 8 3 2 4 2 4 4 8 2 9 10 6 6 4 10 2 5 10 9 4 4 6 5 7 9 5 3 4 2 9 3 5 1 5 5 5 10 5 8 2 8 10 8 6 10 5 1 3 6 7 9 4 2 2 2 5 10 2 8 3 9 1 4 2 9 10 10 2 9 4 1 6 5 5 6 9 5 2 1 9 8 2 3 4 3 9 7 10 7 8 1 8 4 4 8 7 2 7 5 3 5 8 2 7 7 4...

output:

645707964

result:

ok answer is '645707964'

Test #103:

score: 0
Accepted
time: 6ms
memory: 15648kb

input:

5000 10
4 5 5 3 4 5 6 2 3 7 9 1 10 4 4 2 2 4 8 6 8 3 4 6 10 3 10 10 9 10 4 7 1 4 6 3 5 4 2 2 7 10 1 7 6 8 6 10 4 3 6 2 2 2 7 9 9 9 7 2 9 6 2 1 10 4 6 10 4 7 9 6 1 2 2 2 10 8 5 5 10 8 5 1 1 7 3 6 1 5 5 8 2 7 5 10 5 6 4 1 3 1 6 10 10 10 7 1 3 9 6 3 3 5 2 2 5 6 9 4 1 1 9 7 7 6 2 2 7 3 2 1 5 4 7 3 7 5 3...

output:

479745590

result:

ok answer is '479745590'

Test #104:

score: 0
Accepted
time: 6ms
memory: 15104kb

input:

5000 10
8 3 8 10 6 5 5 1 9 2 1 9 4 4 4 6 8 1 1 3 4 3 6 3 7 8 5 1 8 3 4 8 5 1 9 5 10 1 10 10 10 9 5 4 7 5 6 1 9 5 9 9 7 8 9 4 7 6 3 8 3 4 6 8 3 3 5 3 7 1 9 1 4 1 8 3 1 5 2 6 2 6 2 2 2 8 5 4 5 1 3 1 9 1 7 10 2 6 1 4 1 8 5 7 9 8 3 1 3 5 5 6 4 5 2 7 3 2 9 9 7 8 2 2 1 1 8 8 7 4 2 5 7 2 2 7 9 1 2 1 5 3 9 ...

output:

566346851

result:

ok answer is '566346851'

Test #105:

score: 0
Accepted
time: 0ms
memory: 14284kb

input:

5000 10
3 1 3 9 10 9 8 5 2 7 6 7 7 10 9 3 7 4 6 3 2 6 3 4 3 3 10 1 8 5 3 2 3 1 10 1 3 1 4 2 8 10 7 2 9 2 5 6 5 1 7 6 9 8 6 4 9 5 10 10 10 6 9 10 2 7 6 4 1 9 7 6 2 1 6 3 2 3 5 4 1 8 8 3 1 8 7 9 3 3 10 5 3 9 9 5 7 2 5 4 4 8 9 10 9 6 1 2 2 2 6 8 7 1 10 3 3 3 6 7 3 9 8 1 2 2 8 7 10 10 1 4 1 2 10 7 7 6 2...

output:

660919340

result:

ok answer is '660919340'

Test #106:

score: 0
Accepted
time: 7ms
memory: 15740kb

input:

5000 20
10 19 3 10 16 10 19 10 18 18 10 3 10 10 10 10 3 10 10 10 15 10 18 10 10 3 19 16 10 3 10 10 12 10 10 18 10 10 15 3 18 5 10 10 15 3 3 10 3 10 3 10 10 3 10 3 10 10 10 15 16 10 18 3 3 3 16 10 3 10 10 3 16 18 10 19 10 10 14 3 10 10 10 3 18 10 10 3 10 19 10 10 10 16 3 15 10 10 10 15 10 3 10 3 10 1...

output:

496138525

result:

ok answer is '496138525'

Test #107:

score: 0
Accepted
time: 6ms
memory: 13340kb

input:

5000 20
2 4 4 6 2 4 20 2 4 3 4 2 3 2 2 5 3 6 2 4 5 6 2 3 4 4 6 20 4 2 6 2 2 6 2 3 5 20 2 5 3 2 2 2 3 3 6 5 2 2 4 4 2 4 4 2 6 2 4 6 3 6 2 4 3 6 4 20 2 4 6 3 6 5 4 2 3 4 2 2 4 5 2 6 4 3 4 4 2 2 4 6 2 6 2 4 13 2 4 2 4 2 4 4 5 4 10 13 6 4 4 4 2 2 20 6 6 2 2 2 2 4 9 2 6 4 2 5 2 4 2 2 2 13 4 4 2 2 4 4 2 2...

output:

540885700

result:

ok answer is '540885700'

Test #108:

score: 0
Accepted
time: 12ms
memory: 12256kb

input:

5000 20
5 18 10 16 10 19 11 16 14 17 10 4 19 8 2 7 4 10 19 6 17 6 13 18 4 2 20 11 5 10 19 5 1 18 19 20 12 12 1 19 18 19 13 1 15 20 15 7 13 12 18 19 20 9 10 14 16 13 10 19 19 10 19 14 18 8 15 9 19 13 11 1 20 11 12 10 16 7 15 2 14 1 16 16 15 9 20 16 17 18 10 6 8 8 17 6 14 2 9 16 6 6 15 6 2 3 18 19 20 ...

output:

917648821

result:

ok answer is '917648821'

Test #109:

score: 0
Accepted
time: 7ms
memory: 12260kb

input:

5000 20
13 8 1 10 3 16 20 9 19 16 6 14 13 18 12 3 13 10 18 12 8 17 16 3 16 9 9 4 3 4 3 7 16 3 6 8 15 14 7 18 10 11 19 12 20 3 1 8 9 4 15 15 4 12 20 5 1 13 2 8 9 5 11 2 13 19 15 19 6 17 3 5 13 6 9 7 17 20 14 14 7 13 12 20 19 10 19 18 16 13 10 18 9 16 3 11 13 4 16 15 16 17 5 20 4 16 17 5 9 11 1 13 9 1...

output:

508032089

result:

ok answer is '508032089'

Test #110:

score: 0
Accepted
time: 8ms
memory: 13228kb

input:

5000 20
18 7 17 11 14 12 13 1 16 2 15 2 18 1 18 15 16 3 15 15 16 20 18 9 15 12 11 17 2 16 12 2 4 4 9 11 19 18 6 18 7 1 4 6 17 10 17 12 17 9 7 13 18 18 11 2 13 7 14 17 7 20 2 13 11 15 13 8 10 6 9 9 16 2 14 11 7 5 6 15 1 11 12 3 8 16 2 19 15 7 17 11 18 13 5 15 3 10 2 12 11 6 19 16 6 4 20 10 2 5 10 19 ...

output:

863945411

result:

ok answer is '863945411'

Test #111:

score: 0
Accepted
time: 12ms
memory: 14796kb

input:

5000 20
19 5 4 2 8 3 6 10 4 4 19 10 3 20 13 9 12 9 18 10 19 6 15 7 4 2 8 8 19 19 4 10 11 13 13 11 16 13 6 6 14 1 5 15 6 20 1 12 19 16 10 8 16 4 19 8 2 8 8 12 2 3 8 2 2 4 8 14 12 17 14 14 4 11 20 2 19 13 10 11 20 19 18 10 16 1 6 5 7 8 12 12 5 20 20 3 9 9 18 10 6 1 13 2 3 14 3 16 10 11 14 8 20 7 12 17...

output:

530822024

result:

ok answer is '530822024'

Test #112:

score: 0
Accepted
time: 22ms
memory: 15056kb

input:

5000 40
9 27 34 32 27 40 34 25 27 32 27 9 34 6 30 29 27 40 6 9 9 29 27 9 16 32 27 27 9 9 12 32 12 6 27 6 6 9 40 12 12 27 32 6 34 40 9 12 1 12 27 6 40 40 27 29 6 27 32 9 29 27 40 6 27 27 27 9 9 27 27 34 6 9 34 27 34 12 12 34 9 32 27 27 16 12 32 25 9 29 9 12 6 27 12 34 9 12 27 6 32 9 27 12 27 27 27 9 ...

output:

382372668

result:

ok answer is '382372668'

Test #113:

score: 0
Accepted
time: 23ms
memory: 14664kb

input:

5000 40
33 17 36 33 38 7 33 30 11 33 33 30 30 7 11 19 38 30 7 33 30 36 30 33 36 36 7 30 33 33 18 30 33 11 16 7 36 33 36 30 11 38 11 7 30 33 7 7 16 11 36 36 33 18 20 36 18 33 38 18 30 36 33 7 36 36 38 30 33 33 5 17 36 33 38 33 30 36 30 36 38 33 33 33 30 30 33 36 7 36 38 30 9 19 19 33 16 36 33 36 30 1...

output:

676726804

result:

ok answer is '676726804'

Test #114:

score: 0
Accepted
time: 37ms
memory: 15644kb

input:

5000 40
13 9 31 24 4 33 30 36 6 23 29 14 11 10 8 30 2 31 30 20 39 4 24 13 36 13 14 14 33 38 15 26 25 2 39 2 22 8 19 18 34 25 2 24 21 5 2 20 8 21 28 20 37 22 33 27 38 39 34 18 16 35 32 28 38 11 19 28 8 33 21 8 16 5 14 40 29 37 24 14 31 13 31 34 25 19 11 16 8 6 39 28 18 17 9 23 29 17 19 34 4 38 1 37 2...

output:

534255931

result:

ok answer is '534255931'

Test #115:

score: 0
Accepted
time: 33ms
memory: 14432kb

input:

5000 40
34 38 40 18 34 35 27 19 17 22 7 17 16 24 39 4 25 25 10 13 7 34 33 20 21 23 15 37 35 39 25 3 37 4 3 6 15 34 5 17 23 2 37 24 11 10 10 8 20 20 25 31 8 12 17 6 18 39 11 14 3 10 30 12 19 34 22 24 5 40 37 12 1 36 37 21 9 16 5 3 13 26 15 29 1 39 11 1 15 6 21 18 19 26 18 37 33 4 17 6 40 5 34 26 36 2...

output:

140024597

result:

ok answer is '140024597'

Test #116:

score: 0
Accepted
time: 34ms
memory: 15120kb

input:

5000 40
5 21 17 26 18 40 14 35 15 26 19 25 38 38 39 19 14 11 34 39 20 25 14 4 25 5 14 36 1 34 18 14 5 9 18 32 2 12 8 32 19 6 38 35 32 34 31 1 21 18 40 8 29 39 7 4 29 6 21 9 32 24 31 23 33 9 9 14 27 32 14 30 28 17 36 36 17 32 6 21 34 29 39 18 20 7 13 16 36 37 40 13 12 22 26 33 31 34 1 17 2 15 40 19 1...

output:

238266717

result:

ok answer is '238266717'

Test #117:

score: 0
Accepted
time: 35ms
memory: 15628kb

input:

5000 40
3 40 6 4 36 22 33 30 34 31 6 19 29 24 4 39 18 37 35 19 28 22 30 31 29 25 23 38 25 16 5 10 37 17 6 33 34 21 39 6 23 4 12 32 37 27 11 1 18 31 34 40 22 12 33 24 5 36 35 36 4 31 17 30 19 15 30 26 28 30 10 25 3 26 27 14 26 28 30 19 12 40 11 20 1 24 33 4 35 22 21 14 27 28 1 2 20 40 13 3 28 40 39 3...

output:

143027165

result:

ok answer is '143027165'

Test #118:

score: 0
Accepted
time: 39ms
memory: 14964kb

input:

5000 50
12 49 1 47 49 3 1 3 49 3 26 26 26 49 39 13 38 13 7 31 3 3 3 39 3 3 3 26 33 12 33 49 13 49 49 47 13 3 26 39 33 31 31 31 13 13 12 33 3 47 39 33 13 33 13 49 12 3 31 39 13 3 12 26 3 33 3 33 3 49 3 49 26 3 33 3 26 26 39 13 39 47 33 50 33 3 26 35 3 3 1 13 49 1 33 33 39 33 23 3 15 1 26 13 22 13 13 ...

output:

343682503

result:

ok answer is '343682503'

Test #119:

score: 0
Accepted
time: 42ms
memory: 15936kb

input:

5000 50
32 37 44 44 32 23 37 3 11 32 32 24 23 11 32 23 32 4 37 37 11 37 24 5 7 23 24 11 28 21 3 24 44 23 28 11 23 35 3 32 23 44 11 3 23 23 7 3 32 32 11 32 3 3 23 23 3 23 21 3 32 32 3 38 32 3 32 7 38 24 32 37 24 26 21 23 23 23 32 24 32 49 11 44 23 3 3 3 35 3 3 37 32 11 34 6 38 24 23 3 32 32 28 3 32 2...

output:

879196229

result:

ok answer is '879196229'

Test #120:

score: 0
Accepted
time: 53ms
memory: 14696kb

input:

5000 50
22 28 14 22 5 37 15 32 40 38 43 23 17 26 44 46 18 26 1 2 20 32 27 28 3 5 9 41 40 30 35 10 4 14 26 8 41 9 49 26 17 12 39 46 15 21 8 10 4 48 3 11 13 14 36 31 10 6 28 39 4 37 33 34 30 32 25 20 22 23 15 10 11 7 40 42 46 18 48 30 6 31 14 43 31 41 16 36 41 20 10 35 43 36 44 19 17 7 4 9 36 9 5 28 4...

output:

965037649

result:

ok answer is '965037649'

Test #121:

score: 0
Accepted
time: 53ms
memory: 15040kb

input:

5000 50
37 43 16 34 45 32 30 29 25 25 36 21 15 35 11 48 40 16 3 27 40 10 1 29 36 40 9 25 19 2 5 32 32 11 1 17 14 33 4 2 34 9 28 21 10 40 43 31 22 38 48 34 3 10 24 3 12 18 18 22 41 14 20 35 31 45 29 25 35 29 11 26 11 1 34 31 19 4 43 38 32 2 10 47 14 45 18 28 45 23 31 30 35 18 3 13 30 9 33 29 2 6 49 4...

output:

906760828

result:

ok answer is '906760828'

Test #122:

score: 0
Accepted
time: 57ms
memory: 15600kb

input:

5000 50
1 28 47 4 4 5 33 17 29 22 40 1 35 13 36 15 7 46 33 33 4 36 38 12 43 21 12 38 49 21 15 44 7 9 38 38 25 7 26 10 16 43 18 2 48 3 7 5 5 17 14 12 44 29 2 22 31 33 24 48 32 6 50 26 37 21 24 33 41 8 7 5 6 5 32 31 39 44 38 37 32 48 31 7 28 31 44 8 48 37 17 35 20 10 28 46 37 19 20 2 8 8 21 14 7 29 30...

output:

167467589

result:

ok answer is '167467589'

Test #123:

score: 0
Accepted
time: 52ms
memory: 15208kb

input:

5000 50
40 21 3 21 8 50 20 8 27 26 44 13 2 41 2 38 27 33 27 24 42 5 32 24 15 36 9 4 20 32 19 36 18 29 36 15 43 42 43 42 2 1 46 46 11 22 39 38 48 8 49 19 50 30 28 9 22 2 5 2 7 22 24 23 8 20 18 45 48 21 33 48 21 47 38 29 20 25 34 39 25 3 29 29 10 6 22 49 27 26 5 16 24 32 13 40 33 13 13 26 16 43 27 46 ...

output:

316584235

result:

ok answer is '316584235'

Test #124:

score: 0
Accepted
time: 65ms
memory: 106772kb

input:

200000 5
3 3 3 3 3 3 4 4 3 4 3 4 4 3 3 4 4 3 2 4 3 4 3 4 3 4 4 3 5 3 3 4 3 4 3 3 3 4 3 3 3 3 3 3 3 4 4 4 3 3 3 4 3 3 3 3 3 3 3 3 3 3 3 4 3 4 3 3 3 3 3 3 3 3 4 3 4 4 3 3 3 4 4 3 4 3 3 3 3 3 3 4 3 3 4 3 3 4 4 3 3 3 3 3 3 4 4 3 3 3 3 5 3 4 3 3 4 4 3 3 5 3 3 3 3 4 3 3 3 3 3 3 3 4 3 4 3 4 3 3 3 3 3 3 3 3...

output:

846189442

result:

ok answer is '846189442'

Test #125:

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

input:

200000 5
2 2 2 2 1 2 2 2 1 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 1 1 5 5 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 1 2 2 2 2 5 5 2 2 2 2 2 2 5 1 5 2 1 2 2 2 2 5 1 2 1 2 2 5 2 1 2 2 2 1 2 2 2 1 1 2 2 2 2 2 1 2 2 2 5 2 2 2 1 2 2 2 2 5 2 2 1 2 2 2 2 5 2 2 2 2 1 2 5 5 2 1 2 2 1 2 2 2 1 1 2 2 2 2 1 2 5 2 2...

output:

829290301

result:

ok answer is '829290301'

Test #126:

score: 0
Accepted
time: 63ms
memory: 106796kb

input:

200000 5
5 1 4 4 1 2 5 1 4 1 5 4 2 1 1 3 2 4 2 5 1 3 5 5 1 2 1 1 5 3 1 1 4 4 4 2 4 2 1 4 2 4 1 4 1 3 1 5 2 2 1 1 1 3 1 3 5 4 4 5 4 2 4 4 1 3 5 4 5 4 3 3 1 2 5 2 3 3 5 1 3 4 5 5 1 4 1 2 2 5 1 4 2 5 4 2 3 3 5 4 5 1 4 3 5 1 2 3 3 2 3 4 5 1 5 5 4 2 1 1 2 4 2 3 4 1 1 1 4 1 2 1 1 1 3 2 3 4 5 5 4 1 3 1 1 4...

output:

154802722

result:

ok answer is '154802722'

Test #127:

score: 0
Accepted
time: 55ms
memory: 106704kb

input:

200000 5
4 2 4 5 2 2 3 5 2 1 3 1 4 3 3 2 4 5 2 4 5 5 2 5 4 1 4 4 4 2 1 5 3 1 2 1 3 5 2 1 1 1 2 3 2 1 2 4 1 2 5 5 2 3 1 2 2 4 3 4 3 5 5 3 3 4 5 5 2 3 3 3 2 2 5 2 3 5 3 1 5 2 5 1 3 5 2 2 4 4 2 3 1 5 3 2 4 1 4 1 5 5 5 4 2 4 5 1 2 2 4 3 4 4 1 3 4 5 5 2 1 2 2 3 4 4 3 3 5 3 2 4 4 4 3 4 3 5 5 1 5 5 2 2 5 5...

output:

974702886

result:

ok answer is '974702886'

Test #128:

score: 0
Accepted
time: 56ms
memory: 106700kb

input:

200000 5
4 5 2 5 2 3 2 2 2 4 5 1 5 3 5 4 1 1 2 4 4 1 5 2 5 3 3 1 1 1 1 5 2 1 1 3 4 5 5 2 1 4 4 3 1 5 5 2 3 1 3 3 4 5 2 4 1 2 2 2 1 5 2 4 5 4 3 2 2 2 3 5 3 5 5 4 4 4 1 5 1 1 1 3 1 5 5 5 2 1 1 5 2 1 5 3 5 5 3 3 1 2 3 3 3 2 2 5 5 4 3 4 2 2 1 2 2 3 4 2 4 2 5 2 3 2 2 3 3 3 5 5 3 3 1 1 5 1 5 5 4 3 3 3 2 1...

output:

731872682

result:

ok answer is '731872682'

Test #129:

score: 0
Accepted
time: 58ms
memory: 106832kb

input:

200000 5
3 5 5 3 1 2 5 1 4 4 1 2 5 4 2 3 1 1 1 2 1 5 2 2 1 5 3 1 3 4 1 5 2 5 3 5 4 4 3 2 2 5 5 3 5 4 1 2 2 1 1 1 4 5 2 5 2 3 4 2 1 3 2 5 4 5 2 3 1 3 1 1 4 2 1 3 2 2 2 4 4 2 5 1 2 5 5 3 4 1 4 3 3 1 1 5 3 3 1 5 3 5 5 2 4 2 2 4 2 5 5 5 2 2 1 5 5 5 5 1 5 1 4 4 4 3 4 2 4 2 3 2 2 5 4 1 4 1 1 2 3 1 3 1 5 1...

output:

123918488

result:

ok answer is '123918488'

Test #130:

score: 0
Accepted
time: 100ms
memory: 106768kb

input:

200000 10
4 4 1 1 10 4 4 10 4 4 6 1 4 4 1 1 4 1 1 4 6 4 1 4 4 4 4 4 4 1 4 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 1 10 4 4 4 4 4 4 4 4 6 4 4 10 4 4 1 10 4 4 1 4 1 4 1 4 4 10 6 4 4 4 10 4 10 4 4 4 4 4 4 4 4 1 4 4 4 1 1 4 4 4 4 1 4 1 1 1 4 1 1 4 6 1 4 1 4 9 1 4 10 4 4 4 4 4 4 1 4 10 4 1 4 4 4 4 1 1 4 4 4 ...

output:

305800020

result:

ok answer is '305800020'

Test #131:

score: 0
Accepted
time: 112ms
memory: 106836kb

input:

200000 10
10 1 1 10 10 10 10 10 10 1 10 10 9 10 10 10 1 10 10 6 1 1 10 1 9 10 1 10 10 10 10 10 1 1 10 10 10 1 1 1 10 10 10 1 1 1 10 10 1 10 10 10 10 10 9 10 1 10 9 10 1 10 10 1 10 9 1 1 9 10 10 1 10 10 10 1 10 10 10 10 10 10 10 10 10 10 10 1 10 10 1 10 1 10 10 10 1 10 1 1 1 10 1 10 10 10 10 10 10 10...

output:

429027287

result:

ok answer is '429027287'

Test #132:

score: 0
Accepted
time: 137ms
memory: 107284kb

input:

200000 10
10 10 5 4 1 1 5 7 1 8 1 2 4 8 10 5 8 8 10 2 8 6 7 5 3 4 6 6 9 6 1 10 3 9 9 10 8 1 9 5 5 10 2 6 2 8 1 6 9 2 1 2 9 2 10 7 4 9 8 3 3 3 5 7 4 2 8 7 1 1 7 9 9 10 8 7 5 4 9 4 4 2 6 7 4 9 1 7 3 5 7 7 7 9 3 10 2 8 8 1 10 4 5 1 1 1 8 2 9 7 10 5 10 3 9 7 4 2 1 2 5 1 6 4 4 10 3 8 2 2 2 3 5 10 1 5 5 5...

output:

318998086

result:

ok answer is '318998086'

Test #133:

score: 0
Accepted
time: 135ms
memory: 106744kb

input:

200000 10
2 9 5 8 3 8 4 6 9 6 3 2 6 5 3 2 5 2 10 8 2 2 1 5 4 7 6 10 5 10 1 1 9 7 10 10 1 10 3 1 5 4 3 10 4 8 2 9 1 6 9 9 10 4 5 6 3 5 3 8 7 4 5 1 9 4 4 3 2 3 7 10 9 4 1 6 5 9 4 6 6 4 7 1 10 1 6 8 1 6 6 8 9 7 5 2 3 8 9 9 2 8 7 8 8 8 6 6 10 10 6 9 2 2 8 2 5 10 10 6 7 10 8 4 3 3 1 9 1 7 3 5 7 7 5 7 7 9...

output:

934767984

result:

ok answer is '934767984'

Test #134:

score: 0
Accepted
time: 140ms
memory: 106784kb

input:

200000 10
1 8 5 10 10 10 5 2 8 1 4 4 6 6 6 1 5 2 10 1 9 2 4 2 4 8 4 8 2 8 4 3 9 3 10 8 2 3 9 1 9 9 3 5 2 5 2 7 9 5 4 8 10 10 2 7 9 10 5 1 5 4 2 9 5 3 1 9 4 9 4 6 8 6 5 3 7 5 5 10 10 8 7 6 5 7 8 7 8 1 7 7 1 6 8 6 6 2 2 7 4 7 8 1 3 8 10 1 4 5 5 9 8 10 5 7 8 2 1 4 6 9 10 2 8 4 2 2 7 9 7 8 1 7 6 5 9 4 8...

output:

417418643

result:

ok answer is '417418643'

Test #135:

score: 0
Accepted
time: 148ms
memory: 106896kb

input:

200000 10
7 2 8 4 8 4 10 10 8 6 9 8 8 2 5 4 9 1 9 3 3 8 7 8 6 4 6 3 6 4 5 10 10 3 3 1 7 3 3 5 4 5 7 5 9 9 8 9 1 1 3 3 4 3 9 1 5 10 10 8 1 8 1 5 4 4 3 6 6 7 1 4 6 9 8 10 1 3 2 3 3 6 9 7 9 5 5 8 3 2 2 5 5 6 4 7 5 6 1 1 9 4 1 6 6 7 2 10 5 7 3 9 7 10 6 6 5 7 8 5 6 9 1 2 6 3 9 6 8 3 3 1 1 6 1 5 4 5 2 2 2...

output:

836682971

result:

ok answer is '836682971'

Test #136:

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

input:

200000 20
7 7 15 16 4 15 7 7 16 7 7 15 7 15 11 7 1 15 15 7 15 16 15 16 15 15 7 7 13 15 15 15 15 16 16 15 4 1 15 16 7 4 16 16 7 5 7 7 7 7 16 1 16 16 16 4 5 15 7 7 16 4 7 15 11 7 15 15 16 15 16 7 15 4 15 7 15 7 7 7 7 5 7 7 7 7 7 1 15 15 15 7 16 4 7 15 7 7 15 4 7 7 16 7 7 15 7 15 16 16 15 7 15 7 7 1 15...

output:

189034125

result:

ok answer is '189034125'

Test #137:

score: 0
Accepted
time: 325ms
memory: 109012kb

input:

200000 20
4 20 15 20 15 4 20 4 20 4 4 6 15 15 15 20 20 4 15 15 12 15 15 20 15 15 20 15 15 12 6 20 6 20 4 20 20 4 15 20 15 20 20 15 20 15 4 15 15 15 20 20 15 11 20 16 20 4 15 15 15 15 20 15 15 20 6 20 6 15 15 15 14 15 15 20 14 20 20 15 20 20 14 6 20 20 15 15 12 15 20 15 15 15 20 11 20 15 14 15 11 15 ...

output:

174623981

result:

ok answer is '174623981'

Test #138:

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

input:

200000 20
2 5 15 10 18 12 20 15 13 10 11 8 2 9 4 5 2 8 7 13 8 15 3 12 5 2 9 4 9 10 9 15 11 4 15 4 12 2 8 1 17 2 6 6 10 3 6 19 5 8 10 9 1 10 8 8 12 5 15 11 18 9 8 12 2 17 13 4 9 10 14 9 19 13 13 3 1 1 20 2 12 13 2 3 1 1 20 15 20 14 8 7 11 5 14 16 7 8 19 20 4 16 2 9 1 3 19 13 7 12 16 12 3 14 1 10 9 7 ...

output:

665240555

result:

ok answer is '665240555'

Test #139:

score: 0
Accepted
time: 398ms
memory: 106828kb

input:

200000 20
16 14 5 14 12 9 10 4 17 17 1 5 8 10 2 3 5 3 19 1 17 17 3 10 19 10 5 13 2 3 14 4 4 2 14 19 14 15 12 16 12 8 1 13 12 19 6 18 8 17 6 7 12 1 2 13 19 20 4 3 3 6 11 16 5 13 8 8 19 1 18 16 11 15 5 1 5 14 2 15 8 16 14 7 12 19 14 8 9 12 10 18 18 20 18 2 13 14 20 16 11 12 4 18 1 15 18 10 10 10 7 2 1...

output:

377811639

result:

ok answer is '377811639'

Test #140:

score: 0
Accepted
time: 405ms
memory: 106712kb

input:

200000 20
18 12 20 8 13 14 10 11 5 5 18 9 6 11 4 1 20 13 9 14 19 8 17 7 8 2 5 16 8 7 9 5 20 19 20 5 13 12 3 16 16 8 13 18 19 13 6 13 8 7 3 18 1 15 14 13 11 6 14 5 15 19 13 12 18 13 7 2 19 18 3 9 18 7 17 15 13 5 10 9 9 10 6 7 14 19 4 14 17 3 9 6 3 16 10 15 12 4 3 17 9 9 20 6 13 19 7 7 4 10 7 12 16 11...

output:

635264935

result:

ok answer is '635264935'

Test #141:

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

input:

200000 20
9 15 20 16 8 5 20 1 2 18 19 14 12 7 10 7 1 9 2 11 8 2 18 17 11 20 16 4 19 4 13 1 20 12 16 9 7 10 6 19 1 9 6 12 20 11 6 6 4 4 9 3 11 16 3 7 8 6 4 13 14 15 13 14 15 1 1 10 14 20 18 20 16 5 17 14 4 7 2 12 14 9 6 7 3 19 19 15 20 13 7 7 13 9 6 4 11 3 6 2 5 19 9 6 20 4 11 6 16 7 2 13 18 13 2 3 1...

output:

977332342

result:

ok answer is '977332342'

Test #142:

score: 0
Accepted
time: 1108ms
memory: 106832kb

input:

200000 40
32 32 14 32 29 29 12 40 32 35 32 29 29 32 32 4 32 4 4 4 32 35 14 34 35 35 4 35 29 32 4 19 37 29 35 29 4 35 29 29 32 4 22 35 29 4 32 22 22 32 22 35 37 22 29 32 14 29 32 36 32 32 37 36 29 32 4 4 35 32 35 32 4 37 14 4 35 32 4 14 32 32 36 4 29 4 32 22 32 4 4 4 4 32 4 35 35 4 25 4 4 35 12 32 4 ...

output:

547132828

result:

ok answer is '547132828'

Test #143:

score: 0
Accepted
time: 1111ms
memory: 109132kb

input:

200000 40
1 40 16 14 14 14 16 1 7 21 23 6 1 7 14 6 1 1 7 1 23 23 5 7 1 23 23 14 5 6 23 14 1 14 23 7 1 6 1 23 23 7 1 23 7 23 21 25 5 7 7 16 1 5 14 7 1 1 7 7 7 1 14 1 7 6 23 7 23 23 14 1 23 6 16 1 1 14 14 14 20 7 7 6 23 16 7 7 23 5 16 6 23 1 16 5 40 23 40 7 14 14 1 1 1 16 7 1 37 16 23 1 1 1 7 40 14 19...

output:

132801450

result:

ok answer is '132801450'

Test #144:

score: 0
Accepted
time: 1414ms
memory: 108956kb

input:

200000 40
32 34 26 30 34 29 31 32 18 30 17 24 39 14 34 34 1 31 22 9 14 36 19 31 24 7 26 4 23 34 28 9 12 36 19 12 4 4 21 9 33 19 30 23 26 7 7 22 22 32 2 26 18 36 17 37 4 23 20 2 15 6 38 17 4 35 15 20 36 36 40 40 6 19 10 6 6 16 12 1 2 32 40 40 28 16 22 31 17 5 37 10 22 30 1 28 4 3 23 26 33 11 34 4 12 ...

output:

237417861

result:

ok answer is '237417861'

Test #145:

score: 0
Accepted
time: 1426ms
memory: 108956kb

input:

200000 40
3 36 4 14 29 39 4 38 21 25 30 22 34 17 18 33 4 11 8 25 15 9 21 12 34 12 39 29 16 17 14 9 23 7 11 40 31 36 33 9 3 7 28 7 2 2 37 7 22 9 31 12 26 11 32 19 40 25 9 14 2 6 37 34 17 39 24 14 17 19 7 31 23 28 23 11 32 33 2 5 16 36 28 19 28 34 18 30 30 27 3 7 6 10 7 15 23 8 21 36 40 37 38 23 22 8 ...

output:

13741130

result:

ok answer is '13741130'

Test #146:

score: 0
Accepted
time: 1419ms
memory: 108896kb

input:

200000 40
3 39 38 3 22 33 29 16 9 26 11 29 16 22 21 31 34 36 3 28 1 31 4 10 5 37 28 26 40 26 17 38 18 20 14 5 8 4 39 26 22 33 40 3 9 30 40 4 19 20 17 15 11 7 37 38 39 32 21 18 4 5 17 34 9 6 21 14 34 38 34 33 8 6 40 10 6 26 36 8 19 4 33 33 4 2 25 6 38 26 27 26 10 4 17 13 37 35 3 12 12 25 10 34 29 4 3...

output:

989405492

result:

ok answer is '989405492'

Test #147:

score: 0
Accepted
time: 1430ms
memory: 109048kb

input:

200000 40
39 2 4 16 40 11 20 39 33 28 33 21 22 36 37 16 36 19 24 2 5 30 35 13 29 18 24 7 40 21 4 21 14 33 15 6 2 3 6 39 34 21 27 37 1 10 27 9 14 29 20 21 7 4 31 35 17 20 12 26 39 40 36 36 16 11 12 15 24 14 6 31 22 18 31 33 7 33 32 21 40 26 36 19 4 9 31 12 21 34 14 17 3 29 25 14 36 26 8 1 12 29 35 2 ...

output:

484172290

result:

ok answer is '484172290'

Test #148:

score: 0
Accepted
time: 1778ms
memory: 106820kb

input:

200000 50
47 47 35 35 21 21 35 47 35 49 47 48 47 47 48 48 20 19 35 20 48 49 35 35 19 20 35 34 20 20 20 47 35 20 20 47 25 35 38 35 49 48 48 34 35 12 35 48 47 35 49 48 35 34 38 25 38 48 38 20 48 38 20 12 35 47 34 19 35 48 34 48 35 35 6 38 35 47 47 49 38 48 20 20 6 35 38 47 47 35 35 35 34 20 47 35 47 4...

output:

485138473

result:

ok answer is '485138473'

Test #149:

score: 0
Accepted
time: 1816ms
memory: 106848kb

input:

200000 50
23 15 24 24 8 23 9 8 20 9 41 24 17 20 8 35 17 23 15 23 21 24 23 41 20 23 24 35 17 2 21 24 15 2 41 24 2 23 41 15 9 41 20 15 8 15 15 8 15 24 13 17 23 41 15 10 15 41 15 24 23 15 24 23 19 8 24 9 24 41 24 15 24 2 2 9 15 8 2 8 41 15 15 15 41 23 8 15 41 2 41 8 24 30 10 20 15 8 20 8 15 9 24 41 24 ...

output:

873418732

result:

ok answer is '873418732'

Test #150:

score: -100
Time Limit Exceeded

input:

200000 50
31 7 24 22 46 38 14 10 14 29 20 14 41 40 8 30 50 50 22 18 43 14 29 19 10 35 21 16 34 45 3 21 43 11 44 6 11 5 41 18 15 6 39 26 45 15 24 25 1 5 15 45 29 28 44 34 25 42 22 14 32 37 36 9 1 24 26 15 1 16 41 21 13 43 49 44 39 18 30 42 7 36 40 1 33 19 14 14 21 28 46 43 35 6 12 49 10 6 13 26 23 43...

output:


result: