QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#359281#1241. RaidbdzzjAC ✓383ms211208kbC++141.9kb2024-03-20 15:49:252024-03-20 15:49:25

Judging History

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

  • [2024-03-20 15:49:25]
  • 评测
  • 测评结果:AC
  • 用时:383ms
  • 内存:211208kb
  • [2024-03-20 15:49:25]
  • 提交

answer

#include<bits/stdc++.h>
#define N 45
#define NN 5000000
#define ll long long
using namespace std;
const int INF=1e9;
int n,a[N],p[N],bl[N][N],len[N][N],val[N][N],d[N],pc[N][NN];
struct node{
	int mn;
	ll val;
	inline void add(node b){
		if(mn==b.mn) val+=b.val;
		if(b.mn<mn) mn=b.mn,val=b.val;
		return;
	}
}f[NN],g[NN],ans[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) p[a[i]]=i;
	for(int i=0;i<=n;i++){
		int p=0,tot=0;
		for(int j=1;j<=n;j++){
			if(a[j]>i){
				bl[i][j]=p;
				continue;
			}
			if(j==1||a[j-1]>i){
				if(p) len[i][p]=tot;
				p++;
				tot=0;
			}
			bl[i][j]=p;
			tot++;
		}
		if(p) len[i][p]=tot;
		d[i]=p;
		val[i][0]=1;
		for(int j=1;j<=p;j++) val[i][j]=val[i][j-1]*(len[i][j]+1);
		for(int j=0,k=0;j<val[i][p];j++){
			if(j>=val[i][k]) k++;
			if(!k) pc[i][j]=0;
			else pc[i][j]=pc[i][j%val[i][k-1]]+j/val[i][k-1];
		}
	}
	f[0]=(node){0,1};
	for(int i=1;i<=n;i++){
		for(int j=0;j<val[i][d[i]];j++) g[j]=(node){INF,0};
		for(int j=0;j<val[i-1][d[i-1]];j++){
			int v=0,num=1;
			if(p[i]-1>=1&&a[p[i]-1]<=i-1){
				v+=j%val[i-1][bl[i-1][p[i]-1]-1];
				num+=(j/val[i-1][bl[i-1][p[i]-1]-1])%(len[i-1][bl[i-1][p[i]-1]]+1);
			}else v+=j%val[i-1][bl[i-1][p[i]]];
			if(p[i]+1<=n&&a[p[i]+1]<=i-1){
				v+=j/val[i-1][bl[i-1][p[i]+1]]*val[i][bl[i][p[i]+1]];
				num+=(j/val[i-1][bl[i-1][p[i]]])%(len[i-1][bl[i-1][p[i]+1]]+1);
			}else v+=j/val[i-1][bl[i-1][p[i]]]*val[i][bl[i][p[i]]];
			v+=num*val[i][bl[i][p[i]]-1];
			g[v].add((node){f[j].mn+pc[i-1][j-j%val[i-1][bl[i-1][p[i]]]],f[j].val});
			v-=val[i][bl[i][p[i]]-1];
			g[v].add(f[j]);
		}
		for(int j=0;j<val[i][d[i]];j++) f[j]=g[j];
	}
	for(int i=1;i<=n;i++) ans[i]=(node){INF,0};
	for(int i=0;i<val[n][d[n]];i++) ans[pc[n][i]].add(f[i]);
	for(int i=1;i<=n;i++) printf("%d %lld\n",ans[i].mn,ans[i].val);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
5 3 1 4 2

output:

0 5
0 3
1 2
3 1
7 1

result:

ok 10 numbers

Test #2:

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

input:

1
1

output:

0 1

result:

ok 2 number(s): "0 1"

Test #3:

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

input:

2
1 2

output:

0 2
0 1

result:

ok 4 number(s): "0 2 0 1"

Test #4:

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

input:

3
2 1 3

output:

0 3
0 2
1 1

result:

ok 6 numbers

Test #5:

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

input:

4
3 1 2 4

output:

0 4
0 4
0 1
2 1

result:

ok 8 numbers

Test #6:

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

input:

5
1 2 5 4 3

output:

0 5
0 7
0 3
1 3
3 1

result:

ok 10 numbers

Test #7:

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

input:

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

output:

0 18
0 78
0 132
0 104
0 38
0 5
1 2
3 6
5 1
9 8
12 1
17 1
25 4
33 5
41 2
50 1
61 1
75 1

result:

ok 36 numbers

Test #8:

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

input:

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

output:

0 18
0 76
0 141
0 139
0 78
0 24
0 3
1 2
3 3
5 1
10 3
15 1
22 1
30 1
40 1
52 3
64 2
77 1

result:

ok 36 numbers

Test #9:

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

input:

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

output:

0 18
0 86
0 190
0 223
0 154
0 60
0 10
1 12
2 2
4 4
6 1
9 1
15 3
21 1
29 1
39 1
50 1
67 1

result:

ok 36 numbers

Test #10:

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

input:

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

output:

0 18
0 153
0 816
0 3060
0 8568
0 18564
0 31824
0 43758
0 48620
0 43758
0 31824
0 18564
0 8568
0 3060
0 816
0 153
0 18
0 1

result:

ok 36 numbers

Test #11:

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

input:

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

output:

0 18
1 153
3 816
6 3060
10 8568
15 18564
21 31824
28 43758
36 48620
45 43758
55 31824
66 18564
78 8568
91 3060
105 816
120 153
136 18
153 1

result:

ok 36 numbers

Test #12:

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

input:

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

output:

0 18
0 85
0 150
0 115
0 42
0 6
1 9
2 3
4 1
7 1
11 2
16 2
22 2
29 2
37 2
46 2
56 1
68 1

result:

ok 36 numbers

Test #13:

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

input:

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

output:

0 18
0 64
0 89
0 55
0 16
0 2
1 1
3 1
6 1
10 2
15 5
20 1
27 1
35 1
45 1
57 1
72 1
89 1

result:

ok 36 numbers

Test #14:

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

input:

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

output:

0 18
0 88
0 163
0 127
0 43
0 4
1 4
2 1
4 1
7 1
11 2
15 1
20 1
27 1
35 3
43 1
53 1
65 1

result:

ok 36 numbers

Test #15:

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

input:

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

output:

0 18
0 67
0 83
0 36
0 4
1 2
3 2
6 5
9 2
13 3
18 3
24 3
31 3
39 3
48 2
58 1
70 1
86 1

result:

ok 36 numbers

Test #16:

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

input:

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

output:

0 18
0 147
0 720
0 2355
0 5418
0 8989
0 10836
0 9420
0 5760
0 2352
0 576
0 64
1 192
2 240
3 160
4 60
5 12
6 1

result:

ok 36 numbers

Test #17:

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

input:

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

output:

0 18
0 117
0 408
0 882
0 1260
0 1218
0 792
0 333
0 82
0 9
1 8
3 7
6 6
10 5
15 4
21 3
28 2
36 1

result:

ok 36 numbers

Test #18:

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

input:

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

output:

0 18
0 45
1 240
2 210
4 504
6 210
9 240
12 45
16 20
20 1
26 2
33 1
42 2
52 1
64 2
77 1
92 2
108 1

result:

ok 36 numbers

Test #19:

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

input:

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

output:

0 18
0 59
0 92
0 71
0 26
0 5
1 4
3 3
6 2
10 1
20 8
30 24
40 32
50 16
61 36
71 3
82 2
94 1

result:

ok 36 numbers

Test #20:

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

input:

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

output:

0 18
0 62
0 108
0 97
0 36
1 83
2 80
3 40
4 10
5 1
15 8
25 22
35 28
45 17
55 4
66 3
78 2
91 1

result:

ok 36 numbers

Test #21:

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

input:

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

output:

0 23
0 135
0 324
0 384
0 235
0 70
0 8
1 12
2 6
3 1
6 4
9 4
12 1
17 4
22 4
27 1
36 1
46 1
57 2
69 1
85 2
101 1
118 1

result:

ok 46 numbers

Test #22:

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

input:

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

output:

0 23
0 105
0 204
0 237
0 171
0 75
0 19
0 2
1 1
3 2
5 1
9 1
14 1
22 2
30 1
40 2
50 1
63 3
77 4
92 3
108 1
126 1
148 1

result:

ok 46 numbers

Test #23:

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

input:

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

output:

0 23
0 174
0 515
0 714
0 486
0 146
0 12
1 16
2 7
3 1
5 2
8 5
11 3
15 7
19 4
24 8
29 4
35 3
42 4
49 1
57 1
67 1
79 1

result:

ok 46 numbers

Test #24:

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

input:

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

output:

0 23
0 253
0 1771
0 8855
0 33649
0 100947
0 245157
0 490314
0 817190
0 1144066
0 1352078
0 1352078
0 1144066
0 817190
0 490314
0 245157
0 100947
0 33649
0 8855
0 1771
0 253
0 23
0 1

result:

ok 46 numbers

Test #25:

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

input:

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

output:

0 23
1 253
3 1771
6 8855
10 33649
15 100947
21 245157
28 490314
36 817190
45 1144066
55 1352078
66 1352078
78 1144066
91 817190
105 490314
120 245157
136 100947
153 33649
171 8855
190 1771
210 253
231 23
253 1

result:

ok 46 numbers

Test #26:

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

input:

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

output:

0 23
0 149
0 422
0 622
0 501
0 210
0 36
1 70
2 40
3 5
5 4
8 8
11 4
15 9
19 4
24 3
30 1
39 3
48 1
59 1
73 2
88 2
104 1

result:

ok 46 numbers

Test #27:

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

input:

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

output:

0 23
0 104
0 164
0 109
0 30
0 2
1 1
3 6
5 3
8 7
11 1
16 3
21 1
28 1
37 4
46 1
57 4
68 1
81 1
95 1
110 1
128 1
149 1

result:

ok 46 numbers

Test #28:

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

input:

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

output:

0 23
0 148
0 407
0 578
0 454
0 197
0 44
0 4
1 2
3 3
5 1
8 4
11 4
14 1
18 1
23 1
31 2
39 1
50 1
62 1
76 4
90 2
105 1

result:

ok 46 numbers

Test #29:

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

input:

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

output:

0 23
0 107
0 178
0 124
0 36
0 4
1 3
3 7
5 5
7 1
11 1
16 3
22 7
28 2
35 1
44 1
55 3
66 1
78 1
92 1
108 2
124 1
146 1

result:

ok 46 numbers

Test #30:

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

input:

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

output:

0 23
0 5
2 105
4 10
8 190
12 10
18 170
24 5
32 75
40 1
50 13
61 78
73 286
86 715
100 1287
115 1716
131 1716
148 1287
166 715
185 286
205 78
226 13
248 1

result:

ok 46 numbers

Test #31:

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

input:

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

output:

0 23
0 187
0 825
0 2310
0 4422
0 6006
0 5874
0 4125
0 2035
0 671
0 133
0 12
1 11
3 10
6 9
10 8
15 7
21 6
28 5
36 4
45 3
55 2
66 1

result:

ok 46 numbers

Test #32:

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

input:

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

output:

0 23
0 66
1 440
2 495
4 1584
6 924
9 1584
12 495
16 440
20 66
25 24
30 1
37 2
45 1
55 2
66 1
79 2
93 1
109 2
126 1
145 2
165 1
187 1

result:

ok 46 numbers

Test #33:

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

input:

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

output:

0 23
0 101
0 230
0 295
0 208
0 69
0 6
1 5
3 44
4 10
5 1
15 1
27 62
38 110
49 135
60 96
71 37
82 6
94 5
107 4
121 3
136 2
152 1

result:

ok 46 numbers

Test #34:

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

input:

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

output:

0 23
0 107
0 280
0 455
0 458
0 261
0 64
1 192
2 240
3 160
4 60
5 12
6 1
19 10
32 35
45 60
58 55
71 26
84 5
98 4
113 3
129 2
146 1

result:

ok 46 numbers

Test #35:

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

input:

26
7 2 16 21 23 4 1 5 12 24 13 14 8 18 10 3 11 6 22 17 19 20 9 15 25 26

output:

0 26
0 210
0 814
0 1800
0 2503
0 2326
0 1495
0 667
0 199
0 36
0 3
1 1
3 1
6 2
9 1
13 3
17 3
21 1
26 1
34 1
43 1
53 1
66 1
80 1
97 1
115 1

result:

ok 52 numbers

Test #36:

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

input:

26
23 19 21 18 2 4 7 8 5 9 16 12 11 25 20 17 10 26 24 6 15 3 14 1 22 13

output:

0 26
0 161
0 478
0 865
0 947
0 600
0 201
0 27
1 71
2 49
3 9
5 15
7 7
9 1
13 1
19 5
25 3
32 1
41 1
53 1
68 2
84 2
101 1
120 1
141 1
164 1

result:

ok 52 numbers

Test #37:

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

input:

26
5 10 2 17 19 7 8 6 20 11 1 3 22 4 23 14 24 16 9 12 15 25 26 18 21 13

output:

0 26
0 219
0 809
0 1570
0 1760
0 1185
0 477
0 112
0 15
0 1
2 2
4 1
7 1
10 2
13 1
18 3
23 1
29 2
35 1
42 1
50 2
58 1
68 2
79 1
92 1
106 1

result:

ok 52 numbers

Test #38:

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

input:

26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

output:

0 26
0 325
0 2600
0 14950
0 65780
0 230230
0 657800
0 1562275
0 3124550
0 5311735
0 7726160
0 9657700
0 10400600
0 9657700
0 7726160
0 5311735
0 3124550
0 1562275
0 657800
0 230230
0 65780
0 14950
0 2600
0 325
0 26
0 1

result:

ok 52 numbers

Test #39:

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

input:

26
26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

0 26
1 325
3 2600
6 14950
10 65780
15 230230
21 657800
28 1562275
36 3124550
45 5311735
55 7726160
66 9657700
78 10400600
91 9657700
105 7726160
120 5311735
136 3124550
153 1562275
171 657800
190 230230
210 65780
231 14950
253 2600
276 325
300 26
325 1

result:

ok 52 numbers

Test #40:

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

input:

26
7 2 9 11 4 14 16 26 24 18 21 1 5 12 19 22 25 8 15 3 10 17 23 6 20 13

output:

0 26
0 188
0 595
0 999
0 999
0 637
0 262
0 66
0 8
1 12
2 6
3 1
6 1
10 2
14 1
19 1
25 1
32 1
41 1
51 2
61 1
72 1
86 1
102 2
119 2
137 1

result:

ok 52 numbers

Test #41:

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

input:

26
14 7 20 11 23 3 17 25 5 9 21 18 16 1 13 24 19 26 22 15 10 4 12 8 2 6

output:

0 26
0 139
0 273
0 254
0 105
0 14
1 21
2 6
4 11
6 6
8 1
11 1
15 4
19 1
25 1
33 1
43 4
53 2
64 1
77 1
91 1
106 1
124 1
143 1
163 1
186 1

result:

ok 52 numbers

Test #42:

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

input:

26
2 13 21 1 19 6 25 12 3 23 7 17 4 26 11 14 20 5 15 24 8 16 22 9 18 10

output:

0 26
0 184
0 560
0 885
0 793
0 408
0 110
0 12
1 20
2 11
3 2
5 1
8 4
11 1
15 1
20 1
27 4
34 1
43 2
53 3
64 2
76 1
90 1
105 1
123 2
141 1

result:

ok 52 numbers

Test #43:

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

input:

26
14 26 7 22 15 3 24 10 25 5 12 23 1 19 8 21 6 18 13 2 20 11 4 17 9 16

output:

0 26
0 138
0 238
0 156
0 33
1 66
2 33
3 1
5 1
8 6
11 2
15 3
19 1
24 1
31 3
38 1
47 2
57 2
68 2
80 1
94 1
109 1
126 1
144 1
163 1
187 1

result:

ok 52 numbers

Test #44:

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

input:

26
1 25 13 19 7 16 10 4 22 23 2 14 8 11 17 26 5 20 3 15 18 21 12 9 24 6

output:

0 26
0 171
0 495
0 765
0 690
0 373
0 114
0 15
1 25
2 10
4 23
6 15
8 3
11 1
16 1
22 1
29 1
38 5
47 2
58 5
69 1
82 1
97 3
112 1
131 1
154 1

result:

ok 52 numbers

Test #45:

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

input:

26
20 24 2 12 16 14 8 22 26 10 6 18 4 13 7 25 5 21 19 3 11 15 17 9 1 23

output:

0 26
0 146
0 320
0 335
0 176
0 45
0 5
1 3
3 4
6 16
9 15
12 2
16 1
21 1
28 11
34 2
41 1
50 2
60 1
72 2
85 1
100 2
116 1
134 1
155 1
179 1

result:

ok 52 numbers

Test #46:

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

input:

26
2 1 3 4 5 6 8 7 9 10 12 11 13 14 16 15 17 18 19 20 22 21 24 23 26 25

output:

0 26
0 318
0 2432
0 13039
0 52074
0 160664
0 391912
0 767103
0 1215566
0 1566070
0 1640640
0 1392065
0 948430
0 511380
0 213272
0 66352
0 14496
0 1984
0 128
1 448
2 672
3 560
4 280
5 84
6 14
7 1

result:

ok 52 numbers

Test #47:

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

input:

26
1 4 7 10 13 16 19 22 25 2 5 8 11 14 17 20 23 26 3 6 9 12 15 18 21 24

output:

0 26
0 217
0 920
0 2338
0 3836
0 4186
0 3032
0 1405
0 378
0 45
1 72
2 28
4 42
6 15
9 20
12 6
16 6
20 1
26 2
33 1
42 2
52 1
64 2
77 1
92 2
108 1

result:

ok 52 numbers

Test #48:

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

input:

26
1 14 2 15 3 16 4 17 5 18 6 19 7 20 8 21 9 22 10 23 11 24 12 25 13 26

output:

0 26
0 247
0 1300
0 4433
0 10582
0 18447
0 24024
0 23595
0 17446
0 9581
0 3796
0 1027
0 170
0 13
1 12
3 11
6 10
10 9
15 8
21 7
28 6
36 5
45 4
55 3
66 2
78 1

result:

ok 52 numbers

Test #49:

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

input:

26
25 23 21 19 17 15 13 11 9 7 5 3 1 26 24 22 20 18 16 14 12 10 8 6 4 2

output:

0 26
0 91
1 728
2 1001
4 4004
6 3003
9 6864
12 3003
16 4004
20 1001
25 728
30 91
36 28
42 1
50 2
59 1
70 2
82 1
96 2
111 1
128 2
146 1
166 2
187 1
210 2
234 1

result:

ok 52 numbers

Test #50:

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

input:

26
13 20 14 21 15 22 16 23 17 24 18 25 19 26 2 1 4 3 6 5 8 7 10 9 12 11

output:

0 26
0 130
0 342
0 520
0 458
0 218
0 50
0 7
1 6
3 5
5 12
6 1
15 2
21 1
35 12
49 60
63 160
77 240
90 50
102 7
115 6
129 5
144 4
160 3
177 2
195 1

result:

ok 52 numbers

Test #51:

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

input:

26
15 21 16 22 17 23 18 24 19 25 20 26 2 1 4 3 6 5 8 7 10 9 12 11 14 13

output:

0 26
0 135
0 390
0 695
0 768
0 485
0 134
1 453
2 672
3 560
4 280
5 84
6 14
7 1
21 12
35 51
49 110
63 135
77 96
91 37
105 6
120 5
136 4
153 3
171 2
190 1

result:

ok 52 numbers

Test #52:

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

input:

30
2 27 28 16 5 9 24 23 4 13 25 11 30 18 21 19 15 26 29 10 7 22 14 17 12 8 20 3 1 6

output:

0 30
0 176
0 467
0 659
0 517
0 222
0 48
0 4
1 4
2 1
4 2
6 1
9 1
13 1
19 2
25 1
33 2
42 3
52 4
63 4
75 3
88 1
103 4
118 1
137 1
159 3
181 1
205 1
231 1
259 1

result:

ok 60 numbers

Test #53:

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

input:

30
13 11 28 12 29 5 7 19 3 30 25 20 16 2 24 21 23 26 22 1 17 10 9 15 8 27 4 14 6 18

output:

0 30
0 191
0 417
0 435
0 274
0 108
0 23
0 2
2 12
4 23
6 15
8 2
11 1
15 1
21 2
27 1
35 1
44 1
54 3
64 1
76 1
89 2
103 1
119 3
135 1
153 1
174 2
195 1
219 1
244 1

result:

ok 60 numbers

Test #54:

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

input:

30
18 29 23 5 20 21 4 2 26 22 25 19 30 14 3 15 9 13 11 17 28 27 12 24 8 1 7 10 16 6

output:

0 30
0 171
0 348
0 284
0 108
0 14
1 20
2 6
4 11
6 3
9 3
12 1
16 2
20 1
26 1
35 3
45 6
56 10
67 1
79 9
90 1
103 2
117 1
133 1
151 1
170 2
190 1
213 1
237 1
264 1

result:

ok 60 numbers

Test #55:

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

input:

30
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

output:

0 30
0 435
0 4060
0 27405
0 142506
0 593775
0 2035800
0 5852925
0 14307150
0 30045015
0 54627300
0 86493225
0 119759850
0 145422675
0 155117520
0 145422675
0 119759850
0 86493225
0 54627300
0 30045015
0 14307150
0 5852925
0 2035800
0 593775
0 142506
0 27405
0 4060
0 435
0 30
0 1

result:

ok 60 numbers

Test #56:

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

input:

30
30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

0 30
1 435
3 4060
6 27405
10 142506
15 593775
21 2035800
28 5852925
36 14307150
45 30045015
55 54627300
66 86493225
78 119759850
91 145422675
105 155117520
120 145422675
136 119759850
153 86493225
171 54627300
190 30045015
210 14307150
231 5852925
253 2035800
276 593775
300 142506
325 27405
351 4060...

result:

ok 60 numbers

Test #57:

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

input:

30
3 1 9 13 5 7 11 15 30 22 28 20 18 26 24 17 6 2 10 25 29 14 21 19 12 4 27 23 8 16

output:

0 30
0 255
0 979
0 2043
0 2490
0 1786
0 728
0 150
0 12
1 24
2 15
3 3
5 7
7 5
9 1
12 1
17 3
22 4
27 1
34 1
43 2
52 1
63 1
75 1
88 1
102 1
118 1
137 1
158 1
180 1

result:

ok 60 numbers

Test #58:

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

input:

30
16 8 24 20 4 12 28 26 14 2 18 22 10 6 29 30 27 25 23 19 13 7 21 17 9 11 15 1 3 5

output:

0 30
0 175
0 345
0 267
0 101
0 23
0 2
1 1
3 3
6 4
10 17
14 15
18 4
23 1
30 21
36 3
43 2
51 1
61 2
72 2
84 2
97 1
112 3
127 1
145 2
163 1
182 1
207 1
233 1
260 1

result:

ok 60 numbers

Test #59:

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

input:

30
5 18 2 26 1 19 7 29 3 17 10 25 6 20 12 30 8 21 4 27 9 22 11 28 13 23 14 24 15 16

output:

0 30
0 263
0 1040
0 2193
0 2665
0 1925
0 824
0 204
0 29
0 2
1 1
3 3
5 2
8 6
11 7
14 4
17 1
22 1
28 3
34 2
41 1
50 2
59 1
70 1
84 2
98 1
113 1
129 1
150 1
172 1

result:

ok 60 numbers

Test #60:

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

input:

30
15 29 7 26 14 23 3 28 12 27 6 25 13 24 1 30 11 22 5 20 9 18 2 19 10 17 4 16 8 21

output:

0 30
0 176
0 330
0 266
0 94
0 13
1 14
2 2
4 1
7 14
10 13
13 2
17 1
22 1
28 3
34 1
43 2
52 1
63 2
74 1
86 1
100 1
116 5
132 2
150 6
168 1
188 2
209 1
232 1
259 1

result:

ok 60 numbers

Test #61:

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

input:

30
15 27 6 9 24 3 30 21 18 12 4 25 22 13 10 7 19 16 28 1 17 11 29 5 20 8 23 26 2 14

output:

0 30
0 209
0 609
0 871
0 675
0 314
0 91
0 15
0 1
2 3
4 3
6 1
9 2
12 1
16 2
20 1
26 1
34 4
42 2
51 2
61 2
72 1
85 1
101 3
117 1
134 1
153 1
175 1
199 1
226 1

result:

ok 60 numbers

Test #62:

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

input:

30
1 7 25 21 13 19 17 23 3 5 11 29 27 9 15 4 16 24 30 18 20 2 22 10 28 12 14 26 6 8

output:

0 30
0 227
0 733
0 1315
0 1481
0 1115
0 575
0 199
0 42
0 4
1 4
2 1
4 1
7 1
11 1
16 1
22 2
29 1
38 4
47 2
57 2
68 2
80 1
94 1
109 3
124 1
143 2
163 1
185 1
208 1

result:

ok 60 numbers

Test #63:

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

input:

30
1 2 3 4 5 6 8 7 9 10 11 12 13 14 15 16 17 18 20 19 21 22 24 23 26 25 28 27 30 29

output:

0 30
0 429
0 3892
0 25152
0 123240
0 475780
0 1484640
0 3811230
0 8149460
0 14640774
0 22225800
0 28605356
0 31249128
0 28949028
0 22672832
0 14930505
0 8197758
0 3707509
0 1357284
0 392172
0 86080
0 13488
0 1344
0 64
1 192
2 240
3 160
4 60
5 12
6 1

result:

ok 60 numbers

Test #64:

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

input:

30
3 1 10 5 12 7 16 18 14 21 24 30 26 28 8 19 22 29 15 11 2 25 6 20 13 27 4 23 9 17

output:

0 30
0 255
0 1020
0 2316
0 3226
0 2822
0 1525
0 482
0 83
0 6
1 7
2 2
4 5
6 4
8 1
11 4
14 2
18 1
24 1
31 1
40 3
49 1
60 1
73 3
86 2
100 1
118 1
137 1
157 1
180 1

result:

ok 60 numbers

Test #65:

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

input:

30
17 8 25 12 21 4 28 14 23 6 2 10 19 30 27 15 26 29 24 18 20 16 9 22 7 3 13 11 1 5

output:

0 30
0 179
0 384
0 355
0 156
0 31
0 2
2 12
4 16
6 4
9 12
12 7
15 1
20 4
25 3
31 3
38 1
47 6
55 1
64 1
75 1
89 1
104 1
121 1
139 1
158 1
179 1
203 1
228 1
256 1

result:

ok 60 numbers

Test #66:

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

input:

30
5 21 1 25 3 18 2 28 4 15 24 16 7 30 10 23 6 17 27 8 20 9 29 13 22 11 26 12 19 14

output:

0 30
0 253
0 937
0 1840
0 2148
0 1555
0 679
0 162
0 16
1 18
2 7
3 1
5 1
8 2
11 1
15 2
19 1
25 2
31 1
38 1
47 2
56 1
66 1
77 1
91 1
106 1
122 1
141 1
161 1
182 1

result:

ok 60 numbers

Test #67:

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

input:

30
29 8 30 16 4 28 12 23 2 25 13 27 5 24 11 21 1 22 10 26 6 20 9 19 3 18 15 7 17 14

output:

0 30
0 176
0 343
0 231
0 64
0 6
1 3
3 10
5 7
8 15
11 7
15 11
19 2
24 2
30 4
36 2
43 1
51 1
60 1
70 1
82 1
95 1
110 1
126 1
143 1
161 1
180 1
204 1
231 1
259 1

result:

ok 60 numbers

Test #68:

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

input:

30
16 22 8 26 4 12 28 2 10 24 6 18 14 30 1 19 15 25 7 21 11 29 3 20 13 27 5 23 9 17

output:

0 30
0 223
0 638
0 847
0 553
0 157
1 535
2 672
3 377
4 92
5 8
7 4
10 16
13 20
16 8
19 1
26 1
34 4
42 6
50 4
58 1
70 1
83 2
96 1
113 3
130 1
149 2
169 2
190 2
212 1

result:

ok 60 numbers

Test #69:

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

input:

30
1 16 2 17 3 18 4 19 5 20 6 21 7 22 8 23 9 24 10 25 11 26 12 27 13 28 14 29 15 30

output:

0 30
0 330
0 2030
0 8190
0 23478
0 50050
0 81510
0 102960
0 101530
0 78078
0 46410
0 20930
0 6930
0 1590
0 226
0 15
1 14
3 13
6 12
10 11
15 10
21 9
28 8
36 7
45 6
55 5
66 4
78 3
91 2
105 1

result:

ok 60 numbers

Test #70:

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

input:

30
29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2

output:

0 30
0 120
1 1120
2 1820
4 8736
6 8008
9 22880
12 12870
16 22880
20 8008
25 8736
30 1820
36 1120
42 120
49 32
56 1
65 2
75 1
87 2
100 1
115 2
131 1
149 2
168 1
189 2
211 1
235 2
260 1
287 2
315 1

result:

ok 60 numbers

Test #71:

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

input:

30
13 22 14 23 15 24 16 25 17 26 18 27 19 28 20 29 21 30 2 1 4 3 6 5 8 7 10 9 12 11

output:

0 30
0 177
0 568
0 1122
0 1452
0 1282
0 792
0 333
0 82
0 9
1 8
3 7
6 6
10 5
15 4
21 3
28 2
36 1
54 12
72 60
90 160
108 240
126 192
144 64
163 192
182 240
201 164
219 3
238 2
258 1

result:

ok 60 numbers

Test #72:

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

input:

30
15 23 16 24 17 25 18 26 19 27 20 28 21 29 22 30 2 1 4 3 6 5 8 7 10 9 12 11 14 13

output:

0 30
0 176
0 560
0 1078
0 1288
0 924
0 360
0 65
0 8
1 7
3 6
5 84
6 14
7 1
21 18
28 1
44 14
60 84
76 280
91 476
105 232
119 65
133 8
148 7
164 6
181 5
199 4
218 3
238 2
259 1

result:

ok 60 numbers

Test #73:

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

input:

32
18 10 23 6 14 9 5 19 7 20 15 22 12 28 13 3 1 30 27 21 32 25 26 8 24 16 17 11 31 2 4 29

output:

0 32
0 278
0 1020
0 1890
0 1877
0 988
0 250
0 24
1 34
2 15
3 2
5 5
7 4
9 1
13 6
17 9
21 2
26 10
31 12
36 4
42 5
48 1
57 1
69 3
81 1
95 3
110 3
126 1
144 1
163 1
190 1
218 1

result:

ok 64 numbers

Test #74:

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

input:

32
26 30 21 10 18 31 20 15 6 22 13 1 24 12 28 9 27 25 5 7 16 14 8 3 29 2 23 4 19 32 11 17

output:

0 32
0 210
0 515
0 593
0 341
0 109
0 25
0 3
1 3
3 4
5 1
9 4
13 1
18 1
24 2
31 4
38 1
46 1
55 3
64 1
75 1
87 1
100 1
114 1
130 2
147 1
166 1
187 2
208 1
233 2
258 1
286 1

result:

ok 64 numbers

Test #75:

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

input:

32
6 19 15 10 30 27 20 7 14 1 2 8 16 18 17 11 21 5 24 9 23 13 22 28 3 32 29 26 12 31 4 25

output:

0 32
0 298
0 1336
0 3401
0 5290
0 5197
0 3237
0 1239
0 265
0 24
1 48
2 30
3 6
5 17
7 11
9 2
12 1
16 6
20 5
24 1
29 1
36 2
44 2
53 1
64 2
76 1
90 1
106 1
126 2
147 1
171 1
198 1

result:

ok 64 numbers

Test #76:

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

input:

32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

output:

0 32
0 496
0 4960
0 35960
0 201376
0 906192
0 3365856
0 10518300
0 28048800
0 64512240
0 129024480
0 225792840
0 347373600
0 471435600
0 565722720
0 601080390
0 565722720
0 471435600
0 347373600
0 225792840
0 129024480
0 64512240
0 28048800
0 10518300
0 3365856
0 906192
0 201376
0 35960
0 4960
0 496...

result:

ok 64 numbers

Test #77:

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

input:

32
32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

0 32
1 496
3 4960
6 35960
10 201376
15 906192
21 3365856
28 10518300
36 28048800
45 64512240
55 129024480
66 225792840
78 347373600
91 471435600
105 565722720
120 601080390
136 565722720
153 471435600
171 347373600
190 225792840
210 129024480
231 64512240
253 28048800
276 10518300
300 3365856
325 90...

result:

ok 64 numbers

Test #78:

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

input:

32
1 5 7 11 9 3 13 26 15 17 32 19 21 28 30 23 24 6 14 27 2 10 18 31 22 4 12 29 20 8 25 16

output:

0 32
0 300
0 1337
0 3528
0 6284
0 8125
0 7858
0 5704
0 3070
0 1192
0 317
0 52
0 4
1 4
2 1
5 2
9 5
13 3
18 3
24 3
31 3
39 2
48 1
59 1
72 3
85 1
100 3
115 1
133 2
152 1
174 2
196 1

result:

ok 64 numbers

Test #79:

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

input:

32
16 25 8 20 4 29 12 22 31 27 18 14 10 6 2 24 32 30 28 23 15 26 21 7 13 19 17 11 5 9 3 1

output:

0 32
0 188
0 359
0 270
0 69
1 180
2 137
3 30
5 43
7 11
10 10
13 1
17 1
22 3
27 1
34 1
42 1
51 1
61 3
71 2
82 2
94 1
108 1
124 1
141 3
158 1
178 1
199 1
222 1
248 1
277 1
308 1

result:

ok 64 numbers

Test #80:

score: 0
Accepted
time: 11ms
memory: 68544kb

input:

32
2 21 3 26 5 24 1 30 4 18 6 27 8 19 7 32 9 22 11 28 10 23 12 31 14 20 13 29 16 25 17 15

output:

0 32
0 307
0 1442
0 4066
0 7566
0 9642
0 8471
0 5056
0 1970
0 456
0 48
1 120
2 116
3 54
4 12
5 1
8 5
11 5
14 1
19 1
26 1
34 1
43 1
53 3
63 1
75 1
91 2
107 1
126 2
145 1
167 2
189 1

result:

ok 64 numbers

Test #81:

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

input:

32
30 14 31 7 32 15 29 3 27 13 24 5 25 11 28 1 23 12 22 4 26 8 21 16 2 20 9 19 6 17 10 18

output:

0 32
0 189
0 374
0 315
0 123
0 20
0 1
2 8
4 13
6 5
9 5
13 13
17 7
21 1
27 2
34 2
42 2
51 4
60 2
70 2
81 1
94 1
109 5
124 3
140 1
158 3
176 1
198 1
223 1
250 1
278 1
307 1

result:

ok 64 numbers

Test #82:

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

input:

32
2 26 11 23 32 20 29 8 17 14 5 3 9 30 15 24 12 18 27 6 21 1 28 16 4 31 22 7 19 10 25 13

output:

0 32
0 245
0 778
0 1313
0 1283
0 729
0 225
0 29
1 51
2 25
3 3
5 1
8 6
11 4
15 19
19 16
23 3
28 2
34 1
41 1
51 1
63 3
75 1
90 2
106 2
123 5
140 5
157 1
177 1
200 1
224 1
251 1

result:

ok 64 numbers

Test #83:

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

input:

32
5 19 25 9 31 21 13 17 7 23 27 1 29 15 3 11 8 4 10 18 22 28 2 26 20 30 32 24 12 16 6 14

output:

0 32
0 259
0 872
0 1581
0 1739
0 1196
0 502
0 118
0 12
1 10
2 2
5 20
7 1
10 1
14 5
18 5
22 1
28 2
35 2
43 2
52 1
63 4
74 1
87 1
101 1
115 1
131 2
147 1
166 1
187 1
211 1
237 1

result:

ok 64 numbers

Test #84:

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

input:

32
2 1 4 3 5 6 7 8 9 10 12 11 13 14 16 15 18 17 19 20 21 22 23 24 25 26 28 27 29 30 32 31

output:

0 32
0 489
0 4750
0 32936
0 173544
0 722260
0 2436200
0 6780510
0 15771920
0 30939694
0 51507348
0 73056956
0 88459840
0 91447284
0 80570888
0 60276169
0 38058768
0 20103025
0 8772302
0 3106740
0 870424
0 185648
0 28320
0 2752
0 128
1 448
2 672
3 560
4 280
5 84
6 14
7 1

result:

ok 64 numbers

Test #85:

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

input:

32
2 4 6 14 12 8 10 16 23 18 30 26 28 21 32 20 1 24 17 9 5 31 13 27 22 3 11 29 19 7 25 15

output:

0 32
0 290
0 1207
0 2884
0 4440
0 4529
0 3026
0 1283
0 323
0 42
0 2
1 1
3 6
5 9
7 2
10 1
14 7
18 5
23 4
29 3
36 2
44 1
54 1
66 1
79 1
93 1
109 1
126 3
143 4
160 1
183 2
206 1

result:

ok 64 numbers

Test #86:

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

input:

32
18 8 26 12 4 22 29 15 31 24 20 6 10 2 13 27 16 30 23 28 32 25 17 21 11 19 7 5 14 3 9 1

output:

0 32
0 205
0 527
0 669
0 446
0 153
0 24
0 1
2 7
4 8
6 2
9 5
12 2
16 3
20 1
26 5
32 1
40 3
48 2
58 7
68 6
78 1
93 3
108 1
124 1
142 1
161 1
184 2
207 1
232 1
260 1
291 1

result:

ok 64 numbers

Test #87:

score: 0
Accepted
time: 14ms
memory: 72960kb

input:

32
2 22 5 26 6 16 30 3 21 8 28 9 19 11 32 4 20 1 27 13 23 7 31 10 18 25 15 17 29 12 24 14

output:

0 32
0 283
0 1084
0 2248
0 2863
0 2359
0 1260
0 417
0 77
0 6
1 4
3 16
5 17
7 5
10 4
14 4
19 7
24 3
30 1
37 1
45 1
54 3
63 1
74 1
86 3
98 1
113 1
130 1
148 1
168 1
190 1
213 1

result:

ok 64 numbers

Test #88:

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

input:

32
32 13 26 5 31 10 29 3 16 30 7 25 9 28 1 27 14 21 4 24 15 8 18 17 2 23 12 22 6 20 11 19

output:

0 32
0 210
0 526
0 617
0 346
0 98
0 16
1 40
2 28
3 6
5 4
8 9
11 2
15 4
19 1
24 1
30 1
38 3
46 1
55 3
64 1
76 1
90 1
106 5
122 2
140 4
158 1
180 1
204 2
228 1
255 1
286 1

result:

ok 64 numbers

Test #89:

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

input:

32
1 4 7 10 13 16 19 22 25 28 31 2 5 8 11 14 17 20 23 26 29 32 3 6 9 12 15 18 21 24 27 30

output:

0 32
0 331
0 1770
0 5820
0 12792
0 19614
0 21372
0 16545
0 8920
0 3191
0 682
0 66
1 110
2 45
4 72
6 28
9 42
12 15
16 20
20 6
25 6
30 1
37 2
45 1
55 2
66 1
79 2
93 1
109 2
126 1
145 2
165 1

result:

ok 64 numbers

Test #90:

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

input:

32
16 18 14 20 12 22 10 24 8 26 6 28 4 30 2 32 1 31 3 29 5 27 7 25 9 23 11 21 13 19 15 17

output:

0 32
0 248
0 560
0 784
0 728
0 448
0 176
0 40
0 4
1 2
3 2
6 2
10 2
15 2
21 2
28 2
36 2
45 2
55 2
66 2
78 2
91 2
105 2
120 2
136 16
152 56
168 112
184 140
200 112
216 56
232 16
248 1

result:

ok 64 numbers

Test #91:

score: 0
Accepted
time: 17ms
memory: 68520kb

input:

32
16 24 8 28 4 20 12 30 2 22 10 26 6 18 14 32 1 19 15 27 7 23 11 31 3 21 13 29 5 25 9 17

output:

0 32
0 248
0 734
0 979
0 616
0 167
1 552
2 680
3 378
4 92
5 8
7 4
10 16
13 20
16 8
19 1
26 2
34 9
42 12
50 8
58 2
70 4
82 2
95 6
108 6
121 1
140 4
159 2
180 6
201 1
224 2
248 1

result:

ok 64 numbers

Test #92:

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

input:

32
1 17 2 18 3 19 4 20 5 21 6 22 7 23 8 24 9 25 10 26 11 27 12 28 13 29 14 30 15 31 16 32

output:

0 32
0 376
0 2480
0 10780
0 33488
0 77896
0 139568
0 195910
0 217360
0 191048
0 132496
0 71708
0 29680
0 9080
0 1936
0 257
0 16
1 15
3 14
6 13
10 12
15 11
21 10
28 9
36 8
45 7
55 6
66 5
78 4
91 3
105 2
120 1

result:

ok 64 numbers

Test #93:

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

input:

32
31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2

output:

0 32
0 136
1 1360
2 2380
4 12376
6 12376
9 38896
12 24310
16 48620
20 19448
25 24752
30 6188
36 4760
42 680
49 272
56 17
64 2
73 1
84 2
96 1
110 2
125 1
142 2
160 1
180 2
201 1
224 2
248 1
274 2
301 1
330 2
360 1

result:

ok 64 numbers

Test #94:

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

input:

32
15 24 16 25 17 26 18 27 19 28 20 29 21 30 22 31 23 32 2 1 4 3 6 5 8 7 10 9 12 11 14 13

output:

0 32
0 201
0 688
0 1442
0 1932
0 1666
0 920
0 333
0 82
0 9
1 8
3 7
6 20
7 1
15 4
21 3
28 2
36 1
54 14
72 84
90 280
108 560
126 672
144 448
162 136
178 7
195 6
213 5
232 4
252 3
273 2
295 1

result:

ok 64 numbers

Test #95:

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

input:

32
17 25 18 26 19 27 20 28 21 29 22 30 23 31 24 32 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15

output:

0 32
0 204
0 728
0 1638
0 2408
0 2268
0 1256
0 321
0 8
1 7
3 1798
4 1120
5 448
6 112
7 16
8 1
24 16
40 92
56 280
72 518
88 616
104 476
120 232
136 65
152 8
169 7
187 6
206 5
226 4
247 3
269 2
292 1

result:

ok 64 numbers

Test #96:

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

input:

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

output:

0 34
0 255
0 808
0 1339
0 1285
0 747
0 268
0 58
0 6
1 7
2 2
4 1
7 4
10 3
14 11
18 9
22 1
27 1
33 1
40 1
48 1
57 1
70 1
84 1
100 1
118 3
136 3
154 1
173 1
197 1
223 2
250 4
277 1
306 1

result:

ok 68 numbers

Test #97:

score: 0
Accepted
time: 10ms
memory: 71340kb

input:

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

output:

0 34
0 313
0 1129
0 2027
0 2097
0 1369
0 594
0 158
0 20
1 44
2 33
3 10
4 1
7 2
10 1
14 2
18 1
24 2
30 1
37 4
44 5
51 1
59 1
68 1
78 2
89 2
101 1
119 3
137 1
157 2
178 2
200 2
223 1
248 1

result:

ok 68 numbers

Test #98:

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

input:

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

output:

0 34
0 248
0 818
0 1480
0 1598
0 1065
0 434
0 100
0 10
1 15
2 3
4 4
6 1
9 3
12 1
17 2
23 1
31 4
39 15
46 4
54 3
63 1
74 1
86 1
102 1
119 1
137 1
157 1
178 3
199 1
224 1
250 1
280 1
313 1

result:

ok 68 numbers

Test #99:

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

input:

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

output:

0 34
0 561
0 5984
0 46376
0 278256
0 1344904
0 5379616
0 18156204
0 52451256
0 131128140
0 286097760
0 548354040
0 927983760
0 1391975640
0 1855967520
0 2203961430
0 2333606220
0 2203961430
0 1855967520
0 1391975640
0 927983760
0 548354040
0 286097760
0 131128140
0 52451256
0 18156204
0 5379616
0 13...

result:

ok 68 numbers

Test #100:

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

input:

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

output:

0 34
1 561
3 5984
6 46376
10 278256
15 1344904
21 5379616
28 18156204
36 52451256
45 131128140
55 286097760
66 548354040
78 927983760
91 1391975640
105 1855967520
120 2203961430
136 2333606220
153 2203961430
171 1855967520
190 1391975640
210 927983760
231 548354040
253 286097760
276 131128140
300 52...

result:

ok 68 numbers

Test #101:

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

input:

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

output:

0 34
0 320
0 1336
0 2977
0 3895
0 3171
0 1657
0 546
0 102
0 8
1 10
2 2
4 5
6 4
8 1
11 1
15 3
19 1
24 1
30 2
37 2
45 2
54 2
64 1
76 3
88 1
103 3
118 1
134 1
152 1
172 3
192 1
216 1
241 1

result:

ok 68 numbers

Test #102:

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

input:

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

output:

0 34
0 230
0 548
0 636
0 432
0 190
0 52
0 6
1 7
2 2
4 2
7 1
11 2
16 7
21 4
27 6
33 2
40 2
48 3
56 1
66 1
78 1
91 1
105 1
121 3
137 1
155 1
175 2
195 1
218 1
244 1
271 1
301 2
331 1

result:

ok 68 numbers

Test #103:

score: 0
Accepted
time: 28ms
memory: 92844kb

input:

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

output:

0 34
0 324
0 1351
0 3006
0 3933
0 3201
0 1671
0 551
0 103
0 8
1 9
2 2
4 6
6 4
9 6
12 2
16 2
21 5
26 2
32 2
39 5
46 1
55 3
64 1
75 1
88 3
101 4
114 1
130 1
149 2
168 1
188 1
212 1
237 1

result:

ok 68 numbers

Test #104:

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

input:

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

output:

0 34
0 233
0 578
0 661
0 386
0 119
0 18
0 1
2 6
4 8
6 2
9 7
12 3
16 6
20 1
26 3
32 3
38 1
46 1
56 4
66 1
78 2
91 2
105 2
120 2
136 1
154 2
173 2
193 1
215 1
239 1
267 1
296 1
328 1

result:

ok 68 numbers

Test #105:

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

input:

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

output:

0 34
0 306
0 1183
0 2390
0 2614
0 1504
0 422
0 56
0 3
1 3
3 14
5 15
7 4
10 12
13 11
16 3
20 4
24 1
29 2
34 1
42 1
52 2
62 1
73 3
84 3
95 1
108 1
125 2
142 1
162 2
183 2
205 2
228 1
255 1

result:

ok 68 numbers

Test #106:

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

input:

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

output:

0 34
0 280
0 907
0 1523
0 1499
0 904
0 327
0 64
0 5
1 4
2 1
4 2
6 1
10 1
15 2
21 6
27 2
34 1
43 2
52 2
61 1
71 1
82 3
93 4
104 1
117 1
133 1
150 1
169 2
189 2
210 2
232 2
255 1
281 1

result:

ok 68 numbers

Test #107:

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

input:

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

output:

0 34
0 5
2 160
4 10
8 300
12 10
18 280
24 5
32 130
40 1
50 24
61 276
73 2024
86 10626
100 42504
115 134596
131 346104
148 735471
166 1307504
185 1961256
205 2496144
226 2704156
248 2496144
271 1961256
295 1307504
320 735471
346 346104
373 134596
401 42504
430 10626
460 2024
491 276
523 24
556 1

result:

ok 68 numbers

Test #108:

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

input:

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

output:

0 34
0 331
0 1459
0 3426
0 4634
0 3849
0 2116
0 762
0 159
0 14
1 31
2 18
3 3
5 7
7 2
10 3
13 1
17 3
21 2
26 2
32 2
39 1
48 3
57 1
68 3
79 1
92 1
107 1
124 1
142 1
161 2
180 1
204 1
230 1

result:

ok 68 numbers

Test #109:

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

input:

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

output:

0 34
0 228
0 539
0 568
0 275
0 53
0 4
1 4
2 1
4 3
6 2
9 5
12 2
16 2
21 3
26 1
33 3
40 2
48 1
58 4
68 2
79 2
91 1
105 4
119 1
135 1
153 1
173 1
194 1
219 1
246 2
273 1
301 1
333 1

result:

ok 68 numbers

Test #110:

score: 0
Accepted
time: 31ms
memory: 93456kb

input:

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

output:

0 34
0 324
0 1473
0 3961
0 6986
0 8329
0 6609
0 3375
0 1047
0 176
0 12
1 20
2 11
3 2
5 6
7 4
10 12
13 6
16 1
21 1
27 1
35 1
44 1
55 2
67 2
80 1
95 3
110 1
128 1
147 2
166 1
187 1
212 2
237 1

result:

ok 68 numbers

Test #111:

score: 0
Accepted
time: 10ms
memory: 84160kb

input:

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

output:

0 34
0 230
0 609
0 713
0 407
0 115
0 14
1 27
2 13
4 42
6 36
8 8
11 8
14 2
18 1
23 2
29 3
35 1
43 3
51 1
60 1
71 1
84 1
98 1
113 1
130 2
148 1
168 1
189 1
213 1
239 1
267 1
298 1
331 1

result:

ok 68 numbers

Test #112:

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

input:

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

output:

0 34
0 363
0 1980
0 6600
0 14652
0 22638
0 24816
0 19305
0 10450
0 3751
0 804
0 78
1 143
2 55
4 90
6 36
9 56
12 21
16 30
20 10
25 12
30 3
36 2
43 1
52 2
62 1
74 2
87 1
102 2
118 1
136 2
155 1
176 2
198 1

result:

ok 68 numbers

Test #113:

score: 0
Accepted
time: 29ms
memory: 92364kb

input:

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

output:

0 34
0 278
0 840
0 1100
0 675
0 196
0 23
0 1
2 9
4 24
6 22
8 8
10 1
14 4
18 4
22 1
28 2
34 1
41 3
48 1
57 1
67 1
80 4
93 7
105 1
119 2
134 2
150 1
169 1
190 3
211 1
234 1
258 1
283 1

result:

ok 68 numbers

Test #114:

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

input:

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

output:

0 34
0 425
0 2992
0 13940
0 46648
0 117572
0 229840
0 354926
0 437580
0 432718
0 342992
0 216580
0 107576
0 41140
0 11696
0 2329
0 290
0 17
1 16
3 15
6 14
10 13
15 12
21 11
28 10
36 9
45 8
55 7
66 6
78 5
91 4
105 3
120 2
136 1

result:

ok 68 numbers

Test #115:

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

input:

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

output:

0 34
0 153
1 1632
2 3060
4 17136
6 18564
9 63648
12 43758
16 97240
20 43758
25 63648
30 18564
36 17136
42 3060
49 1632
56 153
64 36
72 1
82 2
93 1
106 2
120 1
136 2
153 1
172 2
192 1
214 2
237 1
262 2
288 1
316 2
345 1
376 2
408 1

result:

ok 68 numbers

Test #116:

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

input:

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

output:

0 34
0 229
0 850
0 1970
0 3024
0 3178
0 2348
0 1245
0 460
0 101
0 10
1 9
3 8
6 7
10 6
15 5
21 4
28 3
36 2
45 1
65 14
85 84
105 280
125 560
145 672
165 448
185 128
206 448
227 678
246 5
266 4
287 3
309 2
332 1

result:

ok 68 numbers

Test #117:

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

input:

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

output:

0 34
0 229
0 856
0 2002
0 3052
0 3010
0 1816
0 589
0 82
0 9
1 8
3 7
5 448
6 112
7 16
8 1
24 18
36 1
54 16
72 994
88 1260
104 1218
120 792
136 333
152 82
168 9
185 8
203 7
222 6
242 5
263 4
285 3
308 2
332 1

result:

ok 68 numbers

Test #118:

score: 0
Accepted
time: 11ms
memory: 84952kb

input:

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

output:

0 35
0 355
0 1491
0 3034
0 3208
0 1878
0 633
0 115
0 10
1 15
2 7
3 1
6 6
9 12
12 4
16 4
20 3
25 3
31 6
37 4
43 1
50 1
58 3
66 2
75 3
85 3
96 2
108 2
121 2
135 1
151 1
169 1
188 1
213 1
240 1

result:

ok 70 numbers

Test #119:

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

input:

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

output:

0 35
0 294
0 1005
0 1743
0 1696
0 948
0 290
0 38
1 59
2 24
4 74
6 70
8 25
10 3
13 1
19 3
25 3
31 1
38 1
46 1
55 1
65 3
75 1
88 1
102 4
116 6
130 6
144 1
161 2
178 1
196 1
217 1
240 1
270 2
301 1

result:

ok 70 numbers

Test #120:

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

input:

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

output:

0 35
0 289
0 1009
0 1810
0 1868
0 1189
0 494
0 128
0 16
1 32
2 20
3 4
5 3
8 2
12 3
16 1
21 2
27 1
35 6
43 8
51 2
60 1
71 2
83 1
97 3
111 3
126 6
141 1
158 2
176 1
198 2
221 1
247 1
275 1
306 1

result:

ok 70 numbers

Test #121:

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

input:

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

output:

0 35
0 595
0 6545
0 52360
0 324632
0 1623160
0 6724520
0 23535820
0 70607460
0 183579396
0 417225900
0 834451800
0 1476337800
0 2319959400
0 3247943160
0 4059928950
0 4537567650
0 4537567650
0 4059928950
0 3247943160
0 2319959400
0 1476337800
0 834451800
0 417225900
0 183579396
0 70607460
0 23535820...

result:

ok 70 numbers

Test #122:

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

input:

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

output:

0 35
0 348
0 1581
0 4003
0 6176
0 6012
0 3680
0 1361
0 277
0 24
1 40
2 19
3 2
5 4
7 2
10 10
13 12
16 4
20 4
24 1
30 1
37 1
45 1
55 1
66 3
77 4
88 1
105 4
122 6
139 4
156 1
175 1
197 1
222 2
247 1

result:

ok 70 numbers

Test #123:

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

input:

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

output:

0 35
0 239
0 613
0 739
0 464
0 148
0 18
1 25
2 8
4 31
6 27
8 9
10 1
14 1
19 1
25 1
32 2
39 1
48 9
56 2
65 1
75 1
87 2
100 1
115 1
131 1
148 1
167 1
188 1
211 1
236 3
261 1
291 1
322 1
356 1

result:

ok 70 numbers

Test #124:

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

input:

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

output:

0 35
0 356
0 1708
0 4779
0 8809
0 11374
0 10385
0 6589
0 2819
0 770
0 120
0 8
1 10
2 3
4 4
6 1
9 5
12 5
15 1
20 4
25 1
32 1
40 1
50 1
61 2
72 1
84 1
99 1
115 1
132 1
150 1
169 1
191 1
215 2
239 1

result:

ok 70 numbers

Test #125:

score: 0
Accepted
time: 15ms
memory: 81380kb

input:

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

output:

0 35
0 248
0 634
0 641
0 286
0 52
0 5
1 6
2 1
4 1
7 1
11 8
15 14
19 3
24 8
29 1
35 2
42 6
49 3
57 2
66 3
76 3
87 2
99 1
113 1
129 4
145 2
162 1
181 1
202 1
226 1
254 1
284 1
315 1
347 1

result:

ok 70 numbers

Test #126:

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

input:

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

output:

0 35
0 295
0 1087
0 2080
0 2237
0 1394
0 498
0 97
0 8
1 12
2 6
3 1
5 1
8 2
11 1
15 2
19 1
24 1
31 3
38 1
47 1
57 1
68 1
80 1
93 1
107 8
120 1
135 1
153 1
174 2
195 1
217 1
242 1
269 1
300 1

result:

ok 70 numbers

Test #127:

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

input:

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

output:

0 35
0 283
0 916
0 1487
0 1329
0 664
0 178
0 22
0 1
2 9
4 15
6 6
9 8
12 2
16 3
20 1
25 1
31 1
38 4
45 3
53 3
62 3
72 3
83 2
95 1
109 1
125 1
142 1
160 1
181 1
203 1
227 1
253 1
282 2
312 1

result:

ok 70 numbers

Test #128:

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

input:

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

output:

0 35
0 6
2 198
4 15
8 465
12 20
18 580
24 15
32 405
40 6
50 150
60 1
72 23
85 253
99 1771
114 8855
130 33649
147 100947
165 245157
184 490314
204 817190
225 1144066
247 1352078
270 1352078
294 1144066
319 817190
345 490314
372 245157
400 100947
429 33649
459 8855
490 1771
522 253
555 23
589 1

result:

ok 70 numbers

Test #129:

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

input:

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

output:

0 35
0 347
0 1651
0 4861
0 10162
0 16109
0 19755
0 18667
0 13396
0 7145
0 2739
0 712
0 112
0 8
1 12
2 6
3 1
6 3
9 1
16 2
23 1
31 1
41 1
53 2
65 1
79 2
93 1
108 3
123 2
139 3
155 1
175 1
197 1
222 1
248 1

result:

ok 70 numbers

Test #130:

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

input:

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

output:

0 35
0 241
0 661
0 865
0 592
0 225
0 43
0 3
1 1
3 4
5 1
8 11
11 8
14 1
18 1
23 4
28 1
35 5
42 3
50 2
59 1
70 2
82 1
96 2
111 1
128 1
146 1
166 3
186 1
209 1
233 1
260 1
289 1
321 1
354 1

result:

ok 70 numbers

Test #131:

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

input:

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

output:

0 35
0 353
0 1684
0 4699
0 8393
0 9912
0 7750
0 3920
0 1217
0 212
0 19
0 1
2 4
4 5
6 2
9 36
11 3
14 1
19 6
24 4
30 4
37 6
44 1
53 1
63 1
75 2
88 3
102 2
117 1
134 1
152 1
171 1
191 1
216 1
242 1

result:

ok 70 numbers

Test #132:

score: 0
Accepted
time: 11ms
memory: 87848kb

input:

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

output:

0 35
0 241
0 617
0 652
0 289
0 47
1 96
2 62
3 13
5 15
7 4
10 5
13 1
17 1
22 1
28 11
33 2
39 1
46 1
54 2
63 1
74 1
86 1
99 1
113 1
129 1
147 1
166 3
185 1
207 1
233 1
261 1
290 1
320 1
354 1

result:

ok 70 numbers

Test #133:

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

input:

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

output:

0 35
0 397
0 2343
0 8580
0 21252
0 37290
0 47454
0 44121
0 29755
0 14201
0 4555
0 882
0 78
1 132
2 55
4 90
6 36
9 56
12 21
16 30
20 10
25 12
30 3
36 2
43 1
52 2
62 1
74 2
87 1
102 2
118 1
136 2
155 1
176 2
198 1

result:

ok 70 numbers

Test #134:

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

input:

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

output:

0 35
0 295
0 937
0 1341
0 970
0 365
0 56
0 3
1 2
3 15
5 35
7 28
9 9
11 1
15 4
19 4
23 1
30 2
37 1
45 2
53 1
62 1
73 1
87 5
101 12
114 2
128 1
144 2
161 1
181 1
203 3
225 1
249 1
274 1
300 1

result:

ok 70 numbers

Test #135:

score: 0
Accepted
time: 19ms
memory: 92616kb

input:

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

output:

0 35
0 442
0 3128
0 14620
0 49028
0 123760
0 242216
0 374374
0 461890
0 457028
0 362440
0 228956
0 113764
0 43520
0 12376
0 2465
0 307
0 18
1 17
3 16
6 15
10 14
15 13
21 12
28 11
36 10
45 9
55 8
66 7
78 6
91 5
105 4
120 3
136 2
153 1

result:

ok 70 numbers

Test #136:

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

input:

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

output:

0 35
0 153
1 1632
2 3060
4 17136
6 18564
9 63648
12 43758
16 97240
20 43758
25 63648
30 18564
36 17136
42 3060
49 1632
56 153
64 36
72 1
82 2
93 1
106 2
120 1
136 2
153 1
172 2
192 1
214 2
237 1
262 2
288 1
316 2
345 1
376 2
408 1
442 1

result:

ok 70 numbers

Test #137:

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

input:

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

output:

0 35
0 243
0 934
0 2250
0 3584
0 3850
0 2796
0 1373
0 460
0 101
0 10
1 9
3 8
6 21
7 1
15 5
21 4
28 3
36 2
45 1
65 15
85 98
105 364
125 840
145 1232
165 1120
185 576
205 136
223 7
242 6
262 5
283 4
305 3
328 2
352 1

result:

ok 70 numbers

Test #138:

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

input:

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

output:

0 35
0 245
0 968
0 2450
0 4172
0 4802
0 3608
0 1613
0 338
0 9
1 8
3 1799
4 1120
5 448
6 112
7 16
8 1
25 18
42 117
59 408
76 882
93 1260
110 1218
127 792
144 333
161 82
178 9
196 8
215 7
235 6
256 5
278 4
301 3
325 2
350 1

result:

ok 70 numbers

Test #139:

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

input:

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

output:

0 37
0 337
0 1325
0 2988
0 4156
0 3639
0 1983
0 649
0 117
0 9
1 15
2 6
4 11
6 6
8 1
12 7
16 15
20 11
24 2
29 5
34 1
41 1
49 1
58 2
67 1
78 1
92 1
108 1
126 2
145 4
164 1
185 1
209 1
234 1
263 1
295 1
329 1

result:

ok 74 numbers

Test #140:

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

input:

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

output:

0 37
0 352
0 1360
0 2639
0 3017
0 2253
0 1156
0 393
0 77
0 6
1 7
2 2
4 5
6 2
9 3
13 5
17 2
22 1
29 3
36 1
44 5
52 8
60 4
69 4
78 1
89 1
103 1
118 1
135 4
152 1
171 1
192 1
214 3
236 1
260 1
286 1
314 1

result:

ok 74 numbers

Test #141:

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

input:

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

output:

0 37
0 354
0 1362
0 2535
0 2549
0 1502
0 522
0 100
0 8
1 12
2 6
3 1
5 3
7 1
10 1
14 1
19 4
24 2
30 3
36 1
44 6
52 8
60 2
69 1
80 4
91 5
102 1
116 1
131 1
148 2
166 1
186 1
207 1
230 3
253 1
280 1
312 1

result:

ok 74 numbers

Test #142:

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

input:

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

output:

0 37
1 666
3 7770
6 66045
10 435897
15 2324784
21 10295472
28 38608020
36 124403620
45 348330136
55 854992152
66 1852482996
78 3562467300
91 6107086800
105 9364199760
120 12875774670
136 15905368710
153 17672631900
171 17672631900
190 15905368710
210 12875774670
231 9364199760
253 6107086800
276 356...

result:

ok 74 numbers

Test #143:

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

input:

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

output:

0 37
0 393
0 1933
0 5297
0 8929
0 9854
0 7329
0 3636
0 1140
0 201
0 15
1 26
2 11
3 1
5 3
7 2
10 11
13 9
16 2
20 1
27 2
34 1
42 4
50 2
59 1
70 1
82 1
95 1
109 3
123 1
140 1
158 2
176 1
197 1
220 1
245 1
273 1

result:

ok 74 numbers

Test #144:

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

input:

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

output:

0 37
0 270
0 730
0 908
0 555
0 165
0 20
1 28
2 13
3 2
5 3
7 1
10 1
14 1
19 2
25 10
31 10
37 2
45 11
53 9
61 1
71 1
82 1
94 1
107 1
122 1
139 2
157 1
177 2
198 1
221 2
245 2
270 1
297 1
328 1
361 1
396 1

result:

ok 74 numbers

Test #145:

score: 0
Accepted
time: 81ms
memory: 129696kb

input:

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

output:

0 37
0 391
0 1933
0 5550
0 10496
0 14095
0 13988
0 10390
0 5734
0 2288
0 624
0 104
0 8
1 8
2 2
4 2
7 6
10 5
13 1
18 1
24 2
30 1
38 2
46 1
56 2
66 1
79 2
92 1
107 2
122 1
139 1
157 1
176 1
197 1
220 1
246 1
275 1

result:

ok 74 numbers

Test #146:

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

input:

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

output:

0 37
0 271
0 701
0 756
0 376
0 101
0 15
0 1
2 5
4 5
6 1
9 1
13 6
17 5
22 10
28 27
34 20
40 2
47 1
55 1
64 1
74 4
84 1
95 1
108 1
123 2
138 1
156 2
175 1
196 2
218 2
241 1
268 1
297 1
329 2
361 1
395 1

result:

ok 74 numbers

Test #147:

score: 0
Accepted
time: 11ms
memory: 92856kb

input:

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

output:

0 37
0 330
0 1169
0 1971
0 1785
0 930
0 280
0 45
0 3
1 3
3 13
5 19
7 11
9 2
12 3
15 1
19 1
24 1
30 2
36 1
44 2
53 4
62 1
73 2
85 3
98 3
112 2
127 1
143 1
160 1
178 1
198 1
221 2
244 1
272 1
302 1
336 1

result:

ok 74 numbers

Test #148:

score: 0
Accepted
time: 11ms
memory: 92716kb

input:

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

output:

0 37
0 319
0 1190
0 2339
0 2802
0 2291
0 1313
0 498
0 112
0 12
1 24
2 15
3 3
5 4
7 1
10 1
15 2
21 3
27 1
35 2
44 3
53 1
63 1
74 1
86 4
98 2
111 1
126 3
141 1
158 1
179 1
203 1
228 1
255 3
282 1
312 1
347 1

result:

ok 74 numbers

Test #149:

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

input:

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

output:

0 37
0 657
0 7455
0 60726
0 378180
0 1872468
0 7567596
0 25433766
0 72053110
0 173788174
0 359503218
0 641198928
0 989562180
0 1324231524
0 1537713852
0 1548548241
0 1349795853
0 1014889769
0 654862247
0 360027522
0 166994640
0 64480896
0 20346912
0 5111232
0 983040
0 135936
0 12032
0 512
1 2304
2 4...

result:

ok 74 numbers

Test #150:

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

input:

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

output:

0 37
0 391
0 1958
0 5690
0 10638
0 13445
0 11662
0 6872
0 2654
0 620
0 72
0 2
1 1
3 25
4 3
6 3
9 7
12 5
15 1
19 1
24 1
31 2
38 1
47 2
56 1
66 1
78 1
92 1
107 2
122 1
138 1
155 1
174 1
194 1
220 1
247 1
275 1

result:

ok 74 numbers

Test #151:

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

input:

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

output:

0 37
0 275
0 767
0 1152
0 1070
0 646
0 253
0 62
0 8
1 12
2 6
3 1
7 3
11 2
16 3
21 1
27 6
33 2
40 2
49 9
58 8
67 1
78 2
90 1
104 3
118 1
135 1
154 2
174 1
196 1
219 3
242 1
270 2
298 1
328 1
359 1
391 1

result:

ok 74 numbers

Test #152:

score: 0
Accepted
time: 86ms
memory: 114344kb

input:

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

output:

0 37
0 407
0 2197
0 7248
0 16536
0 27874
0 35703
0 34940
0 25934
0 14344
0 5728
0 1561
0 260
0 20
1 40
2 29
3 9
4 1
7 2
10 1
15 1
22 3
29 3
36 1
44 1
53 1
65 1
79 2
93 1
109 2
125 1
143 1
163 1
184 2
205 1
232 2
259 1

result:

ok 74 numbers

Test #153:

score: 0
Accepted
time: 30ms
memory: 103772kb

input:

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

output:

0 37
0 272
0 766
0 1026
0 701
0 213
0 16
1 28
2 13
3 1
5 2
8 26
10 2
13 2
17 3
21 1
26 1
32 2
39 2
47 1
56 2
66 3
77 3
89 3
102 2
116 1
132 1
151 1
172 2
194 1
218 3
242 1
268 1
297 1
327 1
358 1
394 1

result:

ok 74 numbers

Test #154:

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

input:

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

output:

0 37
0 432
0 2596
0 9625
0 24057
0 42504
0 54384
0 50787
0 34375
0 16456
0 5292
0 1027
0 91
1 168
2 66
4 110
6 45
9 72
12 28
16 42
20 15
25 20
30 6
36 6
42 1
50 2
59 1
70 2
82 1
96 2
111 1
128 2
146 1
166 2
187 1
210 2
234 1

result:

ok 74 numbers

Test #155:

score: 0
Accepted
time: 77ms
memory: 104892kb

input:

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

output:

0 37
0 322
0 1036
0 1484
0 1036
0 355
0 48
1 102
2 71
3 16
5 35
7 25
9 5
12 3
16 1
21 4
26 5
31 1
38 2
46 4
54 1
63 1
73 1
85 1
98 1
112 1
127 4
142 2
158 1
176 1
196 4
216 1
238 1
263 2
288 1
316 2
344 1

result:

ok 74 numbers

Test #156:

score: 0
Accepted
time: 26ms
memory: 102324kb

input:

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

output:

0 37
0 495
0 3723
0 18564
0 66708
0 181356
0 384540
0 648414
0 880022
0 967538
0 863226
0 623220
0 361284
0 165852
0 58956
0 15657
0 2925
0 343
0 19
1 18
3 17
6 16
10 15
15 14
21 13
28 12
36 11
45 10
55 9
66 8
78 7
91 6
105 5
120 4
136 3
153 2
171 1

result:

ok 74 numbers

Test #157:

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

input:

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

output:

0 37
0 171
1 1938
2 3876
4 23256
6 27132
9 100776
12 75582
16 184756
20 92378
25 151164
30 50388
36 54264
42 11628
49 7752
56 969
64 342
72 19
81 2
91 1
103 2
116 1
131 2
147 1
165 2
184 1
205 2
227 1
251 2
276 1
303 2
331 1
361 2
392 1
425 2
459 1
495 1

result:

ok 74 numbers

Test #158:

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

input:

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

output:

0 37
0 274
0 1134
0 2985
0 5324
0 6664
0 5988
0 3923
0 1870
0 616
0 122
0 11
1 10
3 9
6 8
10 7
15 6
21 5
28 4
36 3
45 2
55 1
77 15
99 98
121 364
143 840
165 1232
187 1120
209 576
231 128
254 448
277 678
298 5
320 4
343 3
367 2
392 1

result:

ok 74 numbers

Test #159:

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

input:

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

output:

0 37
0 273
0 1130
0 2978
0 5264
0 6314
0 5036
0 2525
0 716
0 101
0 10
1 9
3 8
5 448
6 112
7 16
8 1
25 20
36 2
45 1
65 17
85 128
105 560
125 1568
144 1245
161 460
178 101
195 10
213 9
232 8
252 7
273 6
295 5
318 4
342 3
367 2
393 1

result:

ok 74 numbers

Test #160:

score: 0
Accepted
time: 9ms
memory: 94276kb

input:

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

output:

0 39
0 401
0 1857
0 4720
0 7272
0 7088
0 4364
0 1612
0 316
0 24
1 48
2 30
3 6
5 25
7 18
9 3
12 10
15 9
18 2
22 3
26 1
33 2
40 1
48 1
57 1
68 3
80 6
92 1
106 8
119 1
134 1
151 2
169 1
190 1
214 1
240 1
270 1
304 1
340 1

result:

ok 78 numbers

Test #161:

score: 0
Accepted
time: 36ms
memory: 111796kb

input:

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

output:

0 39
0 388
0 1450
0 2645
0 2703
0 1690
0 660
0 152
0 16
1 20
2 8
3 1
6 7
9 11
12 2
16 1
21 1
27 1
34 7
41 14
48 7
56 12
64 3
73 1
83 1
94 3
105 2
117 5
129 4
141 1
155 1
172 1
191 1
212 1
235 2
259 1
285 1
318 1
353 1

result:

ok 78 numbers

Test #162:

score: 0
Accepted
time: 11ms
memory: 95004kb

input:

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

output:

0 39
0 373
0 1336
0 2453
0 2681
0 1888
0 880
0 269
0 52
0 4
1 4
2 1
4 3
7 11
10 11
13 2
17 1
22 2
28 1
35 4
42 3
50 5
58 2
67 1
77 1
89 1
102 1
118 1
136 1
155 2
175 4
195 2
216 2
238 2
261 2
285 1
311 3
337 1
368 1

result:

ok 78 numbers

Test #163:

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

input:

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

output:

0 39
0 741
0 9139
0 82251
0 575757
0 3262623
0 15380937
0 61523748
0 211915132
0 635745396
0 1676056044
0 3910797436
0 8122425444
0 15084504396
0 25140840660
0 37711260990
0 51021117810
0 62359143990
0 68923264410
0 68923264410
0 62359143990
0 51021117810
0 37711260990
0 25140840660
0 15084504396
0 ...

result:

ok 78 numbers

Test #164:

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

input:

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

output:

0 39
0 441
0 2321
0 6931
0 12929
0 15794
0 12902
0 7052
0 2502
0 522
0 48
1 144
2 168
3 96
4 27
5 3
7 1
10 2
13 1
17 1
22 1
29 2
37 8
44 2
52 2
61 2
71 2
82 2
94 2
107 2
121 1
137 1
155 2
174 1
195 1
217 1
242 1
269 1
300 1

result:

ok 78 numbers

Test #165:

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

input:

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

output:

0 39
0 301
0 798
0 901
0 488
0 119
0 9
1 6
3 48
5 47
7 12
10 18
13 5
17 5
22 15
27 5
33 4
40 14
47 5
55 6
63 1
73 2
84 6
95 2
107 1
121 1
136 1
153 3
170 1
189 2
209 1
232 1
256 1
282 1
310 1
340 1
371 1
405 1
440 1

result:

ok 78 numbers

Test #166:

score: 0
Accepted
time: 127ms
memory: 158268kb

input:

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

output:

0 39
0 449
0 2461
0 7883
0 16574
0 24446
0 26121
0 20411
0 11574
0 4658
0 1278
0 223
0 22
0 1
2 6
4 9
6 2
9 5
12 3
16 5
20 1
26 4
32 1
40 2
49 3
59 6
69 2
80 2
92 2
105 1
120 1
136 1
153 1
172 1
192 1
213 1
236 1
263 1
292 1

result:

ok 78 numbers

Test #167:

score: 0
Accepted
time: 95ms
memory: 141364kb

input:

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

output:

0 39
0 309
0 834
0 852
0 312
0 35
1 69
2 37
3 3
5 7
7 2
10 4
13 1
17 1
22 4
27 3
33 6
39 3
46 4
53 1
62 2
71 1
82 4
93 2
105 2
118 2
132 2
147 1
164 1
183 1
204 1
227 2
251 1
277 1
305 3
333 1
365 1
398 1
432 1

result:

ok 78 numbers

Test #168:

score: 0
Accepted
time: 32ms
memory: 109296kb

input:

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

output:

0 39
0 361
0 1354
0 2531
0 2552
0 1383
0 368
0 37
1 53
2 24
3 4
5 6
7 1
10 2
14 11
18 10
22 2
27 1
33 1
40 1
47 1
55 3
63 1
72 1
82 1
94 2
107 4
120 1
135 1
154 2
174 3
194 1
215 1
237 1
261 1
287 2
314 1
344 1
380 1

result:

ok 78 numbers

Test #169:

score: 0
Accepted
time: 20ms
memory: 97292kb

input:

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

output:

0 39
0 371
0 1581
0 3711
0 5194
0 4345
0 2060
0 488
0 44
0 2
1 1
3 12
5 52
6 1
9 5
12 5
15 1
20 14
24 3
29 2
35 1
42 1
50 1
59 3
68 1
79 1
91 1
107 2
124 2
142 1
162 1
183 3
204 1
227 1
252 1
278 1
307 1
338 1
370 1

result:

ok 78 numbers

Test #170:

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

input:

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

output:

0 39
0 10
2 370
4 45
8 1575
12 120
18 3960
24 210
32 6510
40 252
50 7308
60 210
72 5670
84 120
98 3000
112 45
128 1035
144 10
162 210
180 1
200 19
221 171
243 969
266 3876
290 11628
315 27132
341 50388
368 75582
396 92378
425 92378
455 75582
486 50388
518 27132
551 11628
585 3876
620 969
656 171
693...

result:

ok 78 numbers

Test #171:

score: 0
Accepted
time: 11ms
memory: 94144kb

input:

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

output:

0 39
0 417
0 2034
0 5439
0 8718
0 8730
0 5473
0 2052
0 409
0 32
1 80
2 80
3 40
4 10
5 1
7 1
10 2
13 1
18 3
23 1
29 3
35 1
43 8
50 1
59 1
71 2
84 4
97 4
110 2
124 2
139 2
155 2
172 1
192 1
215 1
239 1
266 2
294 1
324 1

result:

ok 78 numbers

Test #172:

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

input:

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

output:

0 39
0 307
0 944
0 1250
0 759
0 231
0 48
0 4
1 3
3 10
5 9
7 2
10 1
14 3
18 2
23 2
29 4
35 2
42 3
49 1
57 4
65 2
74 3
83 1
95 1
109 2
124 1
141 2
159 3
178 3
198 2
219 1
243 1
269 1
298 1
330 2
362 1
398 2
434 1

result:

ok 78 numbers

Test #173:

score: 0
Accepted
time: 187ms
memory: 168992kb

input:

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

output:

0 39
0 422
0 2064
0 5567
0 9292
0 10265
0 7691
0 3842
0 1210
0 214
0 16
1 32
2 24
3 8
4 1
7 4
10 4
13 1
17 2
21 1
27 2
33 1
41 1
50 1
60 2
71 3
82 1
95 2
108 1
123 1
139 1
156 1
174 1
193 1
214 2
236 1
261 1
290 2
319 1

result:

ok 78 numbers

Test #174:

score: 0
Accepted
time: 50ms
memory: 130068kb

input:

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

output:

0 39
0 297
0 845
0 1060
0 632
0 168
0 15
1 17
2 5
4 14
6 8
8 1
11 1
15 3
19 2
24 6
29 2
35 1
42 1
50 3
58 2
67 2
77 1
88 1
101 2
114 1
128 1
144 1
163 2
183 2
204 1
227 1
252 1
278 1
306 1
337 1
371 1
406 1
444 1

result:

ok 78 numbers

Test #175:

score: 0
Accepted
time: 154ms
memory: 145572kb

input:

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

output:

0 39
0 381
0 1460
0 2659
0 2566
0 1397
0 404
0 48
1 104
2 75
3 18
5 57
7 68
9 38
11 10
13 1
18 4
23 6
28 4
33 1
40 2
48 1
58 2
69 13
79 2
91 4
104 2
119 6
134 6
149 1
166 2
184 1
205 2
227 3
250 2
274 1
302 3
330 1
360 1

result:

ok 78 numbers

Test #176:

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

input:

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

output:

0 39
0 551
0 4389
0 23256
0 89148
0 259692
0 593028
0 1083342
0 1604018
0 1939938
0 1923142
0 1562028
0 1034892
0 554268
0 236436
0 78489
0 19551
0 3439
0 381
0 20
1 19
3 18
6 17
10 16
15 15
21 14
28 13
36 12
45 11
55 10
66 9
78 8
91 7
105 6
120 5
136 4
153 3
171 2
190 1

result:

ok 78 numbers

Test #177:

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

input:

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

output:

0 39
0 190
1 2280
2 4845
4 31008
6 38760
9 155040
12 125970
16 335920
20 184756
25 335920
30 125970
36 155040
42 38760
49 31008
56 4845
64 2280
72 190
81 40
90 1
101 2
113 1
127 2
142 1
159 2
177 1
197 2
218 1
241 2
265 1
291 2
318 1
347 2
377 1
409 2
442 1
477 2
513 1
551 1

result:

ok 78 numbers

Test #178:

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

input:

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

output:

0 39
0 308
0 1376
0 3975
0 7964
0 11548
0 12456
0 10127
0 6160
0 2706
0 804
0 145
0 12
1 11
3 10
6 9
10 8
15 7
21 6
28 5
36 4
45 3
55 2
66 1
90 15
114 98
138 364
162 840
186 1232
210 1120
234 576
258 128
283 448
308 672
333 560
358 284
382 3
407 2
433 1

result:

ok 78 numbers

Test #179:

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

input:

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

output:

0 39
0 304
0 1330
0 3713
0 7004
0 9128
0 8228
0 5075
0 2126
0 616
0 122
0 11
1 10
3 9
6 120
7 16
8 1
21 5
28 4
36 3
45 2
55 1
77 17
99 128
121 560
143 1568
165 2912
187 3584
209 2816
230 10
249 9
269 8
290 7
312 6
335 5
359 4
384 3
410 2
437 1

result:

ok 78 numbers

Test #180:

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

input:

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

output:

0 40
0 342
0 1024
0 1401
0 1017
0 418
0 91
0 8
1 7
2 2
4 5
6 4
8 1
12 1
17 3
22 1
28 2
34 1
42 4
50 4
58 1
68 2
79 3
90 1
102 1
115 1
130 3
145 1
161 1
178 1
196 1
216 1
240 4
264 4
288 1
314 3
340 2
367 1
400 1
438 1

result:

ok 80 numbers

Test #181:

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

input:

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

output:

0 40
0 369
0 1389
0 2607
0 2664
0 1517
0 458
0 57
1 121
2 88
3 25
4 2
6 1
9 27
11 3
14 1
19 1
26 4
33 4
40 1
49 1
59 4
69 4
79 1
91 1
104 1
119 2
135 5
151 4
167 1
186 3
205 3
224 1
244 1
265 1
290 1
317 1
346 3
375 1
411 1

result:

ok 80 numbers

Test #182:

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

input:

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

output:

0 40
0 389
0 1640
0 3656
0 4706
0 3738
0 1921
0 638
0 123
0 10
1 17
2 8
3 1
6 4
9 5
12 2
16 1
21 6
26 11
31 7
36 1
42 2
49 3
56 1
65 1
76 2
87 1
99 1
113 1
129 3
145 1
164 1
187 2
211 2
236 1
263 1
292 1
323 1
355 1
391 1

result:

ok 80 numbers

Test #183:

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

input:

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

output:

0 40
1 780
3 9880
6 91390
10 658008
15 3838380
21 18643560
28 76904685
36 273438880
45 847660528
55 2311801440
66 5586853480
78 12033222880
91 23206929840
105 40225345056
120 62852101650
136 88732378800
153 113380261800
171 131282408400
190 137846528820
210 131282408400
231 113380261800
253 88732378...

result:

ok 80 numbers

Test #184:

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

input:

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

output:

0 40
0 463
0 2553
0 8186
0 16719
0 22689
0 20733
0 12683
0 5048
0 1218
0 151
0 6
1 7
2 2
4 13
6 13
8 3
11 8
14 6
17 1
22 5
27 1
34 5
41 3
49 3
58 6
67 1
78 5
89 1
102 2
116 2
131 1
148 2
166 1
186 2
207 1
231 1
257 1
285 1
317 1

result:

ok 80 numbers

Test #185:

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

input:

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

output:

0 40
0 317
0 827
0 865
0 395
0 73
0 4
1 2
3 17
5 28
7 10
10 31
13 12
17 14
22 59
27 40
32 6
38 2
45 4
52 1
61 2
71 6
81 3
92 2
104 1
118 1
133 1
150 3
167 1
186 1
206 1
228 2
251 4
274 1
299 1
327 1
358 1
392 1
427 1
463 1

result:

ok 80 numbers

Test #186:

score: 0
Accepted
time: 220ms
memory: 205656kb

input:

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

output:

0 40
0 453
0 2358
0 7001
0 13401
0 17656
0 16452
0 10815
0 4900
0 1469
0 272
0 27
0 1
2 5
4 8
6 4
9 22
12 22
15 6
19 6
23 1
29 1
35 1
42 1
50 1
59 1
70 1
82 4
94 2
107 1
123 1
140 2
157 1
175 1
194 1
216 2
238 1
266 1
295 1
327 1

result:

ok 80 numbers

Test #187:

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

input:

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

output:

0 40
0 318
0 831
0 896
0 412
0 93
0 8
1 6
2 1
4 2
6 1
9 1
13 7
17 14
21 3
26 4
31 1
38 6
45 4
53 7
61 2
70 1
81 1
93 1
106 1
120 3
134 1
151 3
168 1
187 2
207 1
229 2
252 2
276 1
302 2
329 1
359 1
390 1
424 1
462 1

result:

ok 80 numbers

Test #188:

score: 0
Accepted
time: 10ms
memory: 104448kb

input:

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

output:

0 40
0 435
0 2064
0 5311
0 8338
0 8568
0 6012
0 2935
0 995
0 228
0 32
0 2
1 1
3 3
5 1
8 2
12 5
16 4
20 1
25 1
31 2
38 2
46 5
54 5
62 2
71 2
81 2
92 1
104 1
118 1
133 1
150 2
167 1
187 1
210 2
234 4
258 1
284 1
311 1
345 1

result:

ok 80 numbers

Test #189:

score: 0
Accepted
time: 36ms
memory: 112332kb

input:

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

output:

0 40
0 350
0 1171
0 1870
0 1568
0 742
0 213
0 33
0 2
2 15
4 31
6 15
8 2
11 3
14 1
18 2
23 2
29 3
35 1
43 2
52 2
61 1
70 1
80 1
92 2
105 5
118 1
133 1
149 1
166 1
185 2
205 1
227 1
251 1
278 1
307 7
335 1
365 1
397 2
430 1

result:

ok 80 numbers

Test #190:

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

input:

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

output:

0 40
0 770
0 9500
0 84405
0 575268
0 3128460
0 13941360
0 51881490
0 163489600
0 440815036
0 1024973960
0 2067284930
0 3632165400
0 5575315920
0 7489532784
0 8810152845
0 9070868280
0 8161373810
0 6399123260
0 4354393801
0 2556801700
0 1285519860
0 547778880
0 195113760
0 57010560
0 13307520
0 23859...

result:

ok 80 numbers

Test #191:

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

input:

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

output:

0 40
0 452
0 2434
0 7846
0 17153
0 26960
0 30933
0 25792
0 15403
0 6402
0 1752
0 282
0 20
1 32
2 17
3 3
5 2
8 8
11 6
14 1
19 1
26 2
33 1
41 1
50 1
60 2
70 1
81 1
94 1
109 1
126 2
143 1
161 2
179 1
199 2
219 1
243 1
268 1
297 1
328 1

result:

ok 80 numbers

Test #192:

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

input:

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

output:

0 40
0 328
0 991
0 1496
0 1186
0 453
0 62
1 131
2 92
3 24
4 2
6 1
9 4
12 4
15 1
19 4
23 3
28 6
33 1
39 1
47 1
57 2
68 4
79 1
92 1
106 1
122 3
138 1
155 1
173 1
192 1
213 1
237 2
262 2
288 1
316 1
346 1
379 1
415 1
452 1

result:

ok 80 numbers

Test #193:

score: 0
Accepted
time: 282ms
memory: 211208kb

input:

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

output:

0 40
0 437
0 2226
0 6606
0 12802
0 17143
0 16206
0 10778
0 4903
0 1432
0 236
0 16
1 24
2 12
3 2
5 8
7 8
9 2
12 1
18 11
22 1
28 1
36 3
44 2
53 2
63 1
76 2
89 1
103 1
119 3
135 2
152 5
169 2
187 1
208 1
231 1
256 1
284 1
313 1
343 1

result:

ok 80 numbers

Test #194:

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

input:

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

output:

0 40
0 329
0 1059
0 1677
0 1390
0 609
0 134
0 12
1 20
2 11
3 2
5 5
7 2
10 3
13 1
17 3
21 1
27 3
33 2
40 1
48 2
57 3
66 1
76 1
87 1
100 1
115 1
132 1
150 1
170 5
190 2
212 4
234 1
259 1
286 1
316 1
347 1
380 1
415 1
451 1

result:

ok 80 numbers

Test #195:

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

input:

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

output:

0 40
0 507
0 3328
0 13585
0 37752
0 75075
0 109824
0 119691
0 97240
0 58201
0 24960
0 7267
0 1288
0 105
1 195
2 78
4 132
6 55
9 90
12 36
16 56
20 21
25 30
30 10
36 12
42 3
49 2
57 1
67 2
78 1
91 2
105 1
121 2
138 1
157 2
177 1
199 2
222 1
247 2
273 1

result:

ok 80 numbers

Test #196:

score: 0
Accepted
time: 115ms
memory: 150356kb

input:

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

output:

0 40
0 390
0 1140
0 2160
0 2856
0 2688
0 1800
0 840
0 260
0 48
0 4
1 2
3 2
6 2
10 2
15 2
21 2
28 2
36 2
45 2
55 2
66 2
78 2
91 2
105 2
120 2
136 2
153 2
171 2
190 2
210 20
230 90
250 240
270 420
290 504
310 420
330 240
350 90
370 20
390 1

result:

ok 80 numbers

Test #197:

score: 0
Accepted
time: 383ms
memory: 191224kb

input:

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

output:

0 40
0 390
0 1482
0 2677
0 2570
0 1397
0 404
0 48
1 104
2 75
3 18
5 57
7 68
9 38
11 10
13 1
18 4
23 6
28 4
33 1
40 2
48 1
58 2
69 13
79 2
91 4
104 2
119 6
134 6
149 1
166 2
184 1
205 2
227 3
250 2
274 1
302 4
330 2
360 4
390 1

result:

ok 80 numbers

Test #198:

score: 0
Accepted
time: 77ms
memory: 140060kb

input:

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

output:

0 40
0 590
0 4940
0 27645
0 112404
0 348840
0 852720
0 1676370
0 2687360
0 3543956
0 3863080
0 3485170
0 2596920
0 1589160
0 790704
0 314925
0 98040
0 22990
0 3820
0 401
0 20
1 19
3 18
6 17
10 16
15 15
21 14
28 13
36 12
45 11
55 10
66 9
78 8
91 7
105 6
120 5
136 4
153 3
171 2
190 1

result:

ok 80 numbers

Test #199:

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

input:

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

output:

0 40
0 210
1 2660
2 5985
4 40698
6 54264
9 232560
12 203490
16 587860
20 352716
25 705432
30 293930
36 406980
42 116280
49 108528
56 20349
64 11970
72 1330
81 420
90 21
100 2
111 1
124 2
138 1
154 2
171 1
190 2
210 1
232 2
255 1
280 2
306 1
334 2
363 1
394 2
426 1
460 2
495 1
532 2
570 1

result:

ok 80 numbers

Test #200:

score: 0
Accepted
time: 11ms
memory: 94996kb

input:

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

output:

0 40
0 322
0 1460
0 4255
0 8524
0 12220
0 12904
0 10255
0 6160
0 2706
0 804
0 145
0 12
1 11
3 10
6 9
10 8
15 7
21 6
28 5
36 4
45 3
55 2
66 1
90 16
114 112
138 448
162 1120
186 1792
210 1792
234 1024
258 256
283 1024
308 1792
333 1798
356 5
380 4
405 3
431 2
458 1

result:

ok 80 numbers

Test #201:

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

input:

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

output:

0 40
0 320
0 1442
0 4161
0 8124
0 10920
0 10020
0 6099
0 2382
0 616
0 122
0 11
1 10
3 9
6 680
7 144
8 18
9 1
27 22
36 3
45 2
55 1
77 18
99 144
121 672
143 2016
165 4032
187 5376
207 122
225 11
244 10
264 9
285 8
307 7
330 6
354 5
379 4
405 3
432 2
460 1

result:

ok 80 numbers