QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#369508#1241. Raiducup-team1209#TL 2476ms741552kbC++201.4kb2024-03-28 13:05:542024-03-28 13:05:55

Judging History

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

  • [2024-03-28 13:05:55]
  • 评测
  • 测评结果:TL
  • 用时:2476ms
  • 内存:741552kb
  • [2024-03-28 13:05:54]
  • 提交

answer

#include<bits/stdc++.h>
using std::cin, std::cout;
using ll = long long;
using u64 = unsigned long long;
namespace rgs = std::ranges;
struct pr {
	int v; ll c;
	pr(int V = 1e9, ll C = 1) : v(V), c(C) {}
	pr& operator += (const pr & b) {
		if(b.v < v) *this = b;
		else if(b.v == v) c += b.c;
		return *this;
	}
	pr inc(int z) const {
		return {v + z, c};
	}
};

const int N = 45;
std::map<std::vector<int>, std::array<pr, N>> dp[N];
pr ans[N];

int n;
int p[N];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for(int i = 1;i <= n;++i) {
		cin >> p[i];
		p[i] = n + 1 - p[i];
	}

	dp[0][std::vector<int>(n)][0] = pr(0, 1);
	for(int i = 1;i <= n;++i) {
		int rank = 0;
		for(int j = i + 1;j <= n;++j) {
			rank += p[j] < p[i];
		}
		for(auto & [u, v] : dp[i - 1]) {
			auto z0 = u;
			auto z1 = u;
			int sum = 0;
			for(int i = 0;i <= rank;++i) sum += z0[i];
			if(rank + 1 < (int) z0.size()) {
				z0[rank + 1] += z0[rank];
				z1[rank + 1] += z1[rank] + 1;
			}
			z0.erase(z0.begin() + rank);
			z1.erase(z1.begin() + rank);

			auto & t0 = dp[i][z0];
			auto & t1 = dp[i][z1];
			for(int k = 0;k <= n;++k) {
				t0[k] += v[k];
				t1[k + 1] += v[k].inc(sum);
			}
		}
		dp[i - 1].clear();
	}
	for(auto & [u, v] : dp[n]) {
		for(int k = 0;k <= n;++k) ans[k] += v[k];
	}
	for(int k = 1;k <= n;++k) {
		cout << ans[k].v << ' ' << ans[k].c << '\n';
	}
}

詳細信息

Test #1:

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

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: 0ms
memory: 3592kb

input:

1
1

output:

0 1

result:

ok 2 number(s): "0 1"

Test #3:

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

input:

2
1 2

output:

0 2
0 1

result:

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

Test #4:

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

input:

3
2 1 3

output:

0 3
0 2
1 1

result:

ok 6 numbers

Test #5:

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

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: 0ms
memory: 3600kb

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: 4096kb

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: 4020kb

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: 1ms
memory: 3704kb

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: 3628kb

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: 1ms
memory: 3588kb

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: 2ms
memory: 3976kb

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: 2ms
memory: 4280kb

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: 1ms
memory: 3916kb

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: 1ms
memory: 3884kb

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: 1ms
memory: 3584kb

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: 3460kb

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: 1ms
memory: 4080kb

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: 1ms
memory: 3596kb

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: 1ms
memory: 3624kb

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: 5ms
memory: 6352kb

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: 3ms
memory: 4416kb

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: 1ms
memory: 3656kb

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: 3640kb

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: 1ms
memory: 3820kb

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: 6ms
memory: 6064kb

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: 10ms
memory: 7864kb

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: 6ms
memory: 6352kb

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: 4ms
memory: 5112kb

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: 1ms
memory: 3892kb

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: 1ms
memory: 3668kb

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: 7ms
memory: 6468kb

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: 1ms
memory: 3680kb

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: 1ms
memory: 3816kb

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: 2ms
memory: 5176kb

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: 9ms
memory: 9056kb

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: 1ms
memory: 4140kb

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: 3576kb

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: 1ms
memory: 3604kb

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: 19ms
memory: 11844kb

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: 7ms
memory: 10752kb

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: 3ms
memory: 4760kb

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: 6ms
memory: 7144kb

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: 12ms
memory: 12760kb

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: 33ms
memory: 17296kb

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: 1ms
memory: 3844kb

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: 12ms
memory: 12504kb

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: 1ms
memory: 3600kb

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: 10ms
memory: 12532kb

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: 3688kb

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: 1ms
memory: 3840kb

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: 86ms
memory: 32176kb

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: 29ms
memory: 15076kb

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: 24ms
memory: 14744kb

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: 3512kb

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: 1ms
memory: 3704kb

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: 122ms
memory: 44396kb

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: 142ms
memory: 51128kb

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: 4804kb

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: 3ms
memory: 8324kb

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: 193ms
memory: 68032kb

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: 113ms
memory: 39696kb

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: 3592kb

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: 148ms
memory: 49876kb

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: 157ms
memory: 59324kb

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: 4ms
memory: 4960kb

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: 9ms
memory: 8232kb

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: 132ms
memory: 34016kb

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: 3568kb

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: 81ms
memory: 40828kb

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: 1ms
memory: 3696kb

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: 0ms
memory: 3644kb

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: 64ms
memory: 33552kb

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: 62ms
memory: 25024kb

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: 7ms
memory: 5408kb

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: 3836kb

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: 1ms
memory: 3656kb

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: 323ms
memory: 88596kb

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: 343ms
memory: 116600kb

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: 0ms
memory: 4404kb

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: 10ms
memory: 6068kb

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: 355ms
memory: 166252kb

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: 180ms
memory: 58624kb

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: 3600kb

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: 347ms
memory: 73004kb

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: 290ms
memory: 97252kb

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: 26ms
memory: 18200kb

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: 19ms
memory: 8612kb

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: 148ms
memory: 83952kb

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: 194ms
memory: 86636kb

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: 345ms
memory: 86628kb

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: 0ms
memory: 3628kb

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: 221ms
memory: 79064kb

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: 1ms
memory: 3984kb

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: 1ms
memory: 3888kb

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: 69ms
memory: 21664kb

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: 148ms
memory: 49500kb

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: 138ms
memory: 44268kb

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: 3596kb

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: 1ms
memory: 3916kb

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: 680ms
memory: 190256kb

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: 597ms
memory: 174252kb

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: 21ms
memory: 16764kb

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: 43ms
memory: 14692kb

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: 675ms
memory: 248764kb

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: 1143ms
memory: 239464kb

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: 3692kb

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: 665ms
memory: 176996kb

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: 763ms
memory: 258888kb

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: 4ms
memory: 4996kb

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: 40ms
memory: 16100kb

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: 546ms
memory: 247660kb

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: 611ms
memory: 127532kb

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: 1ms
memory: 3616kb

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: 476ms
memory: 155672kb

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: 1ms
memory: 3760kb

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: 1ms
memory: 3940kb

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: 53ms
memory: 23780kb

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: 68ms
memory: 25332kb

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: 221ms
memory: 59364kb

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: 0ms
memory: 3508kb

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: 892ms
memory: 194088kb

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: 922ms
memory: 259708kb

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: 9ms
memory: 6504kb

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: 22ms
memory: 18232kb

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: 857ms
memory: 297536kb

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: 1133ms
memory: 233572kb

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: 3888kb

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: 1064ms
memory: 192676kb

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: 850ms
memory: 252116kb

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: 4ms
memory: 4352kb

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: 20ms
memory: 11308kb

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: 572ms
memory: 247496kb

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: 1010ms
memory: 170440kb

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: 1ms
memory: 3664kb

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: 715ms
memory: 224548kb

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: 1ms
memory: 3724kb

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: 1ms
memory: 3772kb

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: 81ms
memory: 28388kb

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: 437ms
memory: 115560kb

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: 51ms
memory: 25112kb

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: 1ms
memory: 3680kb

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: 1678ms
memory: 428296kb

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: 2364ms
memory: 580424kb

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: 9ms
memory: 7348kb

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: 78ms
memory: 34276kb

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: 2476ms
memory: 741552kb

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: 2194ms
memory: 453580kb

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: 3584kb

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: -100
Time Limit Exceeded

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:


result: