QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#858309#9676. Ancestorsc#41 383ms86628kbC++236.0kb2025-01-16 15:57:172025-01-16 15:57:18

Judging History

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

  • [2025-01-16 15:57:18]
  • 评测
  • 测评结果:41
  • 用时:383ms
  • 内存:86628kb
  • [2025-01-16 15:57:17]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "\33[32m[" << __LINE__ << "]\33[m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T& x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T& x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = - f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x *= f;
}
const int N = 1e5 + 10, M = 1e6 + 10, K = N * 100;
int n, m, fa[N], rt, ans[N], s[N], sz[N], son[N];
vector <int> v[N];
struct Q {
	int l, r, x, id;
} q[M], tmpq[M];
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(pair <int, int> x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(((uint64_t) x.first << 32 | x.second) + FIXED_RANDOM);
    }
};
void dfs(int x) {
	sz[x] = 1;
	for (int i: v[x]) {
		dfs(i);
		sz[x] += sz[i];
		if (sz[i] > sz[son[x]]) son[x] = i;
	}
}
vector <set <int>> vw[N];
vector <pair <pair <int, int>, int>> tt[N];
int k;
struct O {
	int l, r, x, v;
} o[K], tmpo[K];
void ins(int x, int l, int r, int v) {
	if (l <= r) tt[x].emplace_back(make_pair(l, r), v);
}
void dfs2(int x) {
	if (son[x]) {
		dfs2(son[x]);
		swap(vw[x], vw[son[x]]);
		for (int i: v[x]) if (i != son[x]) {
			dfs2(i);
			while (vw[x].size() < vw[i].size()) vw[x].insert(vw[x].begin(), set <int> {});
			F(j, 0, SZ(vw[i])) {
				int jj = SZ(vw[x]) - (SZ(vw[i]) - j), pos = vw[i].size() - j;
					// if (x == 5) {
					// 	debug << i << ' ' << vw[i][j].size() << endl;
					// }
				int lst = 0;
				for (int k: vw[i][j]) {
					auto it = vw[x][jj].insert(k).first, iit = next(it);
					int l = it == vw[x][jj].begin() ? 1 : * prev(it) + 1, r = iit == vw[x][jj].end() ? n : * iit - 1;
					// if () l = * prev(it) + 1;
					// else l = 1;
					// if (iit == vw[x][jj].end()) r = n;
					// else r = * iit - 1;
					if (l != 1 || r != n) ins(pos, l, r, - 1);
					ins(pos, l, k - 1, 1);
					ins(pos, k + 1, r, 1);
					ins(pos, lst + 1, k - 1, - 1);
					lst = k;
				}
				ins(pos, lst + 1, n, - 1);
			}
			vector <set <int>> ().swap(vw[i]);
		}
	}
	s[vw[x].size()]++;
	vw[x].push_back(set <int> {x});
	ins(1, 1, x - 1, 1);
	ins(1, x + 1, n, 1);
}
int info[N], tim[N], cur;
void mdf(int x, int y) {
	for (; x <= n; x += x & - x)
		if (tim[x] != cur) tim[x] = cur, info[x] = y;
		else info[x] += y;
}
int qry(int x) {
	int s = 0;
	for (; x; x ^= x & - x)
		(tim[x] == cur) && (s += info[x]);
	return s;
}
void cdq(int l1, int r1, int l2, int r2, int l3, int r3) {
	if (l1 > r1 || l2 > r2 || l3 == r3) {
		if (l1 <= r1) {
			sort(q + l1, q + r1 + 1, [&] (Q x, Q y) {
				return x.r < y.r;
			});
		}
		if (l2 <= r2) {
			sort(o + l2, o + r2 + 1, [&] (O x, O y) {
				return x.r < y.r;
			});
		}
		return;
	}
	int mid = (l3 + r3) >> 1;
	F(i, l1, r1) tmpq[i] = q[i];
	// F(i, l2, r2) tmpo[i] = o[i];
	int s1 = l1 - 1;
	F(i, l1, r1)
		if (tmpq[i].x <= mid) q[++s1] = tmpq[i];
	int mid1 = s1;
	F(i, l1, r1)
		if (tmpq[i].x > mid) q[++s1] = tmpq[i];
	// int s2 = l2 - 1;
	int mid2 = l2 - 1;
	F(i, l2, r2)
		if (o[i].x <= mid) mid2++;
	// int mid2 = s2;
	// F(i, l2, r2)
	// 	if (tmpo[i].x > mid) o[++s2] = tmpo[i];
	cdq(l1, mid1, l2, mid2, l3, mid);
	cdq(mid1 + 1, r1, mid2 + 1, r2, mid + 1, r3);
	cur++;
	int pos = mid2;
	DF(i, r1, mid1 + 1) {
		while (pos >= l2 && q[i].r <= o[pos].r) mdf(o[pos].l, o[pos].v), pos--;
		// debug << qry(q[i].l) << " " << q[i].id << " " << pos << " " << mid2 << " " << l2 << endl;
		// if (q[i].id == 2) {
		// 	F(j, pos + 1, mid2) {
		// 		debug << o[j].l << " " << o[j].v << endl;
		// 	}
		// 	debug << q[i].x << " " << mid + 1 << " " << r3 << " " << q[i].l << " " << qry(q[i].l) << endl;
		// }
		ans[q[i].id] -= qry(q[i].l);
	}
	{
		F(i, l1, r1) tmpq[i] = q[i];
		int p1 = l1, p2 = mid1 + 1, pp = l1;
		while (p1 <= mid1 || p2 <= r1) {
			if (p1 <= mid1 && (p2 > r1 || tmpq[p1].r < tmpq[p2].r)) q[pp++] = tmpq[p1++];
			else q[pp++] = tmpq[p2++];
		}
	}
	{
		F(i, l2, r2) tmpo[i] = o[i];
		int p1 = l2, p2 = mid2 + 1, pp = l2;
		while (p1 <= mid2 || p2 <= r2) {
			if (p1 <= mid2 && (p2 > r2 || tmpo[p1].r < tmpo[p2].r)) o[pp++] = tmpo[p1++];
			else o[pp++] = tmpo[p2++];
		}
	}
}
signed main() {
	read(n), read(m);
	F(i, 1, n)
		if (read(fa[i])) v[fa[i]].push_back(i);
		else rt = i;
	dfs(rt), dfs2(rt);
	F(j, 0, SZ(vw[rt])) {
		int pos = vw[rt].size() - j;
			// if (x == 5) {
			// 	debug << i << ' ' << vw[i][j].size() << endl;
			// }
		int lst = 0;
		for (int k: vw[rt][j]) {
			ins(pos, lst + 1, k - 1, - 1);
			lst = k;
		}
		ins(pos, lst + 1, n, - 1);
	}
	F(i, 1, n) {
		unordered_map <pair <int, int>, int, custom_hash> id;
		for (auto [a, b]: tt[i]) id[a] += b;
		// tt[i].clear();
		vector <pair <pair <int, int>, int>> ().swap(tt[i]);
		for (auto [a, b]: id)
			if (b) o[++k] = {a.first, a.second, i - 1, b};//, debug << i << " " << a.first << ' ' << a.second << ' ' << b << endl;
	}
	DF(i, n, 1) s[i] += s[i + 1];
	F(i, 1, m) read(q[i].l), read(q[i].r), ans[i] = s[read(q[i].x)], q[i].id = i;
	// F(i, 1, m) debug << ans[i] << '\n';
	cdq(1, m, 1, k, 0, n);
	F(i, 1, m) cout << ans[i] << '\n';
	return 0;
}
/* why?
*/

詳細信息

Subtask #1:

score: 11
Accepted

Test #1:

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

input:

7 5
3 1 0 5 3 5 1
1 3 1
5 7 2
1 5 1
4 7 1
4 7 2

output:

2
1
3
3
1

result:

ok 5 number(s): "2 1 3 3 1"

Test #2:

score: 11
Accepted
time: 3ms
memory: 12364kb

input:

1000 1000
686 337 192 336 405 0 108 485 350 762 258 780 179 939 25 657 571 662 119 786 604 224 935 494 685 575 369 178 249 740 954 204 598 592 68 771 498 86 55 38 298 704 239 292 993 286 16 813 719 187 14 476 792 49 944 52 227 720 310 470 900 243 663 950 627 300 728 189 45 610 673 548 873 95 48 841 ...

output:

452
67
611
126
329
486
354
25
559
585
184
265
576
116
489
289
147
287
13
282
151
192
146
141
148
131
43
72
69
29
5
15
57
10
9
16
87
162
19
217
232
24
178
334
103
139
293
400
299
351
529
632
592
296
640
678
715
708
52
465
322
731
2
69
110
286
172
0
40
31
16
105
75
45
8
94
540
115
357
7
11
431
581
37
...

result:

ok 1000 numbers

Test #3:

score: 11
Accepted
time: 2ms
memory: 14472kb

input:

1000 1000
594 766 788 546 408 364 152 525 963 359 339 746 747 58 628 60 144 646 222 863 418 1000 494 84 225 21 202 146 81 879 239 526 662 816 483 140 7 834 978 26 370 619 12 112 824 319 855 852 877 32 708 236 296 791 40 102 238 930 734 609 740 309 982 837 272 451 825 977 717 597 761 90 305 224 216 8...

output:

441
362
300
535
197
383
360
29
428
31
473
9
310
242
232
37
96
227
50
146
180
93
108
83
58
106
61
26
61
32
7
25
54
25
59
17
48
42
68
237
83
95
206
339
161
47
377
250
335
136
436
98
6
515
216
132
263
270
137
463
117
292
61
468
237
326
149
0
126
228
353
168
76
332
169
98
75
418
49
133
284
281
282
134
1...

result:

ok 1000 numbers

Test #4:

score: 11
Accepted
time: 1ms
memory: 12364kb

input:

1000 1000
330 124 926 768 265 445 803 501 173 371 897 686 88 668 787 5 440 818 604 119 918 821 30 400 391 262 299 334 279 58 45 101 814 582 467 182 538 549 455 761 121 769 480 639 605 906 883 341 138 862 684 42 855 535 778 154 407 439 967 780 128 565 622 739 910 69 647 612 345 407 929 352 296 869 31...

output:

347
340
86
105
386
17
172
27
104
146
341
160
298
321
97
112
232
110
222
37
40
42
84
173
114
25
82
81
56
14
1
2
41
62
12
126
122
50
125
152
100
123
26
0
106
34
173
52
184
89
268
270
152
77
39
322
154
50
0
284
146
199
54
149
27
18
101
84
140
232
73
199
334
195
35
1
107
138
1
25
158
78
4
10
178
202
315...

result:

ok 1000 numbers

Test #5:

score: 11
Accepted
time: 2ms
memory: 10356kb

input:

1000 1000
461 631 908 871 9 818 589 859 917 846 415 498 899 405 954 857 192 327 912 204 453 253 923 705 211 775 882 41 956 634 761 588 676 694 428 729 575 747 216 979 10 472 471 422 580 944 295 121 62 603 376 520 720 864 792 22 891 773 77 520 801 680 590 70 617 807 784 136 566 699 167 726 75 701 780...

output:

95
177
33
70
54
125
39
35
0
263
17
65
55
46
144
73
55
152
58
145
194
103
68
101
34
32
83
60
43
24
0
1
23
46
51
114
57
27
116
38
86
70
53
52
147
129
136
46
41
14
137
154
161
159
205
6
149
157
21
24
7
50
81
9
15
53
13
134
225
36
32
3
104
44
73
139
35
24
191
94
61
128
399
29
103
2
31
34
23
116
9
91
158...

result:

ok 1000 numbers

Test #6:

score: 11
Accepted
time: 2ms
memory: 12344kb

input:

1000 1000
287 431 325 595 467 406 982 985 603 656 520 452 564 548 370 451 331 407 538 749 304 421 813 467 941 545 807 796 484 617 276 908 461 162 323 903 455 796 466 897 972 859 359 684 644 348 245 579 149 18 702 537 415 64 906 382 210 478 145 369 128 336 574 86 847 475 671 849 135 238 920 421 512 9...

output:

117
162
29
84
31
73
55
52
148
119
26
88
88
186
44
96
41
39
276
8
27
81
60
38
58
13
5
17
17
32
8
14
26
24
23
10
58
52
140
6
63
14
66
99
185
207
51
163
61
13
1
183
252
70
87
42
45
127
108
23
92
70
4
35
136
143
7
34
7
53
31
57
39
11
24
132
13
0
23
39
37
13
16
60
25
5
10
130
0
47
5
1
103
54
45
24
31
176...

result:

ok 1000 numbers

Test #7:

score: 11
Accepted
time: 3ms
memory: 14448kb

input:

1000 1000
744 630 563 578 427 227 792 774 559 165 201 450 227 905 966 321 29 908 183 636 603 275 148 739 196 551 884 685 487 276 139 646 352 52 96 246 212 295 502 968 1000 938 121 100 326 309 567 582 744 290 170 312 464 262 768 179 921 741 4 431 107 465 240 973 526 369 172 744 580 420 134 566 875 85...

output:

65
71
39
51
42
31
29
29
3
25
170
6
3
38
58
97
9
11
65
3
27
29
136
24
108
67
83
54
38
13
0
11
58
22
33
17
6
5
50
96
75
13
60
32
239
165
20
49
16
69
73
280
98
29
341
67
25
21
46
69
101
65
12
134
81
3
61
10
5
4
42
46
23
88
39
153
96
55
14
31
1
0
48
57
42
4
24
95
41
68
13
24
20
0
9
28
190
53
35
79
68
10...

result:

ok 1000 numbers

Test #8:

score: 11
Accepted
time: 4ms
memory: 14460kb

input:

1000 1000
566 649 769 706 200 912 838 31 319 791 685 53 463 151 803 239 656 355 5 739 729 295 655 349 403 776 187 277 256 792 488 796 953 925 702 255 740 794 33 801 137 591 875 101 842 815 969 713 701 295 202 360 44 959 494 684 80 425 270 272 155 700 287 994 921 12 214 831 963 307 167 946 980 782 81...

output:

23
429
186
23
122
29
32
75
247
7
60
82
114
17
113
19
17
47
151
25
45
16
162
28
74
17
114
2
17
12
8
0
24
50
102
19
83
10
18
145
1
23
228
277
54
0
124
9
59
114
11
61
5
93
105
29
160
47
97
3
17
23
26
15
27
51
9
6
40
46
97
14
29
20
91
62
19
26
6
46
26
0
10
91
33
37
104
218
61
53
2
172
8
167
50
32
17
2
2...

result:

ok 1000 numbers

Test #9:

score: 11
Accepted
time: 4ms
memory: 14436kb

input:

1000 1000
764 506 989 348 872 809 829 365 739 924 383 727 511 53 628 31 786 95 836 751 621 947 398 814 190 398 382 895 663 98 296 28 960 509 354 106 523 62 630 423 270 16 764 118 607 33 336 459 185 812 315 1 998 174 943 523 277 734 72 202 905 542 173 138 493 585 793 61 427 94 283 295 278 142 748 604...

output:

61
87
61
0
1
290
103
370
361
83
345
38
215
6
54
12
0
45
218
0
49
224
151
10
12
160
96
13
42
1
8
3
44
70
12
35
3
9
51
64
55
31
249
21
352
289
12
16
422
35
21
4
79
504
376
69
69
58
403
240
105
24
74
11
18
157
2
15
10
17
55
39
30
36
20
74
127
64
0
7
41
0
2
41
0
27
47
25
54
4
27
1
65
0
87
1
144
4
36
178...

result:

ok 1000 numbers

Test #10:

score: 11
Accepted
time: 4ms
memory: 12476kb

input:

1000 1000
522 493 442 21 785 730 493 508 750 600 670 661 422 716 820 417 819 974 83 859 382 748 63 262 960 384 999 579 653 955 870 496 136 473 764 117 523 224 160 254 868 45 200 609 442 512 449 7 826 534 765 36 65 834 740 543 138 245 230 722 287 791 649 497 960 953 194 362 124 759 719 347 443 126 31...

output:

8
40
22
207
39
15
508
147
21
19
454
25
318
68
171
21
157
0
80
18
8
209
29
13
73
12
73
91
0
3
9
6
6
0
0
0
27
0
2
4
130
79
182
59
9
205
26
4
4
307
73
106
147
110
4
39
4
7
113
1
0
57
331
4
69
67
4
181
83
23
32
20
246
14
37
28
6
356
4
213
10
7
50
21
56
2
4
1
4
6
7
7
13
59
176
11
2
20
13
6
24
66
67
117
1...

result:

ok 1000 numbers

Test #11:

score: 11
Accepted
time: 2ms
memory: 14432kb

input:

1000 1000
395 337 905 274 702 42 864 411 818 384 745 901 328 380 321 822 953 182 278 962 907 207 8 131 424 928 456 567 119 305 423 443 531 408 532 882 722 488 365 554 811 619 280 184 183 964 802 719 293 637 234 177 6 684 454 375 105 561 879 880 805 196 609 255 8 768 772 757 359 184 294 623 125 44 21...

output:

127
17
79
12
1
190
477
12
282
7
11
11
7
5
239
104
1
148
5
44
43
14
26
0
36
23
21
36
11
17
8
12
3
2
17
10
1
0
32
13
0
6
0
0
41
0
42
69
6
2
416
32
447
457
10
186
48
123
7
81
126
17
2
52
27
0
1
3
32
1
307
2
14
3
13
0
4
69
0
0
1
0
13
267
6
119
0
2
27
1
5
0
46
17
0
34
17
310
34
17
34
24
0
71
3
56
1
1
5
2...

result:

ok 1000 numbers

Test #12:

score: 11
Accepted
time: 1ms
memory: 14296kb

input:

1000 1000
797 184 557 796 605 213 135 636 713 129 518 178 641 192 850 415 492 26 472 129 586 505 121 348 631 948 725 403 988 937 277 20 738 69 441 207 523 337 809 550 433 66 389 9 380 86 774 525 238 687 277 28 914 538 695 188 588 736 536 135 491 143 568 448 960 209 152 569 707 586 129 25 389 425 93 ...

output:

68
11
0
171
458
11
161
62
62
6
0
0
6
92
0
0
16
81
0
0
12
5
3
61
91
15
120
61
68
1
1
1
23
1
1
14
121
45
147
0
19
259
273
127
198
2
3
24
60
0
5
40
413
158
435
161
66
11
68
68
28
109
76
1
6
19
2
9
8
266
89
0
1
10
5
0
1
6
59
31
268
13
61
205
0
0
157
97
0
0
72
10
9
0
17
52
1
46
44
0
172
24
56
55
383
2
44...

result:

ok 1000 numbers

Test #13:

score: 11
Accepted
time: 3ms
memory: 12412kb

input:

1000 1000
518 308 645 387 69 663 532 44 924 655 952 521 239 811 208 909 531 329 376 778 885 471 42 815 506 155 344 704 90 99 133 29 881 491 528 869 791 352 703 261 13 695 902 19 276 449 950 727 52 55 253 50 708 487 497 967 310 234 570 953 530 120 158 94 687 269 993 945 331 79 897 471 488 655 252 632...

output:

7
62
62
31
124
0
3
3
62
124
249
91
3
0
7
3
7
0
302
7
90
102
31
62
190
7
500
0
15
265
15
100
245
15
31
0
1
62
15
31
7
15
240
1
31
62
83
15
1
62
147
15
62
50
133
438
8
64
124
1
1
15
62
0
1
62
0
0
0
331
31
3
3
3
15
3
7
240
3
3
0
0
1
11
124
7
124
339
225
84
31
249
186
7
1
125
0
248
0
62
1
1
15
0
3
3
1
5...

result:

ok 1000 numbers

Subtask #2:

score: 13
Accepted

Dependency #1:

100%
Accepted

Test #14:

score: 13
Accepted
time: 19ms
memory: 20152kb

input:

10000 10000
9604 441 474 6593 7295 7622 5538 3949 131 5596 7590 2194 8222 6170 5424 6009 9447 9516 3302 3375 2030 4876 99 2757 3207 7323 7979 255 9612 1485 5970 2268 2899 6083 7319 7491 2335 1878 5123 5338 3470 80 895 6483 9950 4840 3548 8394 5702 8400 8010 1 3760 4207 8587 1193 1562 8196 9645 824 1...

output:

576
3056
2286
1145
1535
99
619
5349
8135
8913
3560
7476
6513
8575
5129
7417
6309
7237
556
38
5242
7158
1208
6373
1600
2033
573
6740
3365
4141
2173
2663
986
2790
1374
3157
2241
1482
3538
254
1995
1747
5688
5555
2437
4087
621
852
2311
2464
682
3720
1862
1876
1590
3220
3809
2029
3531
918
1040
1585
2647...

result:

ok 10000 numbers

Test #15:

score: 13
Accepted
time: 20ms
memory: 18468kb

input:

10000 10000
1692 7955 6503 5384 1267 9294 679 7789 9455 6927 9650 8926 132 6924 2657 3236 6893 4435 8659 3600 3737 7703 2013 4434 7110 4972 904 4639 3978 3792 2865 1724 3902 3633 9193 7862 1261 3995 5269 7169 9365 3754 8944 9575 9110 4836 9624 2535 5904 1477 7608 457 4961 5327 3077 4309 1969 5922 81...

output:

5524
3048
1164
4202
493
2033
764
1010
2303
5633
2880
2958
5456
4651
1068
5195
3330
1740
2697
1358
1135
2945
5326
2049
2847
5522
884
3495
1824
1745
2922
829
3577
2567
133
801
193
2896
899
2957
2494
3109
2252
661
3066
1820
874
3276
1917
1892
4007
1392
163
1931
446
906
3652
1060
3347
1902
1360
1634
281...

result:

ok 10000 numbers

Test #16:

score: 13
Accepted
time: 24ms
memory: 18456kb

input:

10000 10000
4296 8019 1840 1961 3650 197 9749 6116 1830 1624 8010 2446 3277 473 2642 5336 1296 9702 5712 747 5005 2270 994 2146 5670 5530 2074 6862 6913 9172 3829 1563 8271 6419 2391 7930 501 1373 724 6305 3031 8158 4570 1700 6560 4073 7490 7234 7544 5864 7574 9757 6561 9775 2801 8410 203 6548 2361 ...

output:

1595
568
3717
1964
1607
1652
3402
1650
1274
2729
3276
2801
3826
1238
274
3556
200
1580
3568
2601
1190
170
1413
751
134
2222
2057
2449
2779
2832
812
2108
2645
2524
1722
3017
1812
239
231
2418
2617
3064
2781
2244
419
1882
3185
2181
1886
1895
2740
1943
525
1134
627
1305
611
2692
1003
1207
634
1198
826
...

result:

ok 10000 numbers

Test #17:

score: 13
Accepted
time: 22ms
memory: 20304kb

input:

10000 10000
2267 217 3797 6825 1492 4817 4941 614 6694 1713 6972 857 7354 7818 2463 7262 910 1000 5383 1837 3570 7028 3892 8557 8399 9350 5060 7885 1560 8998 2367 7723 7908 9259 7141 5042 2345 3570 189 2677 8830 7904 6838 9362 9285 4327 5705 8190 895 826 2248 5403 6102 9604 1422 5885 758 8491 728 70...

output:

846
1438
2003
1593
2130
317
1728
1131
1368
1439
1958
1900
1929
817
1416
2734
825
124
84
2148
786
843
60
692
2551
576
842
1616
1827
1295
2082
1595
1515
791
1001
1010
265
833
408
1787
950
1211
722
1054
2000
1683
219
638
1826
1130
602
219
301
577
771
1210
1197
888
1421
138
676
1617
452
1020
292
587
132...

result:

ok 10000 numbers

Test #18:

score: 13
Accepted
time: 27ms
memory: 18620kb

input:

10000 10000
9592 1159 2441 4724 9625 8832 8271 7344 7061 5255 7134 5790 6818 2659 9691 6351 9207 7863 4180 1561 7473 9548 6845 153 1818 9986 3707 810 679 4984 8658 7223 1636 3022 3187 4296 8543 594 1411 8373 9198 2527 4737 7014 7917 3021 8591 6679 438 327 3210 9920 4788 3036 2934 2838 4931 6840 8994...

output:

467
724
1511
722
730
1103
198
959
173
1144
922
25
405
417
1070
320
500
1128
320
217
309
640
1025
1336
1005
165
361
37
21
61
331
36
335
594
155
330
926
791
37
472
58
630
229
65
1004
543
414
833
627
376
368
5
517
875
429
1026
805
905
1079
318
674
421
66
58
529
729
932
188
885
638
597
294
125
144
713
7...

result:

ok 10000 numbers

Test #19:

score: 13
Accepted
time: 28ms
memory: 18072kb

input:

10000 10000
2012 4393 5745 1329 8411 3722 715 2809 2164 9024 7518 6244 7942 4517 9764 1076 5689 9463 5501 508 4793 4015 6605 2721 722 9300 9755 5319 1330 4124 515 6027 8625 3986 8131 3045 3201 6207 5869 8475 4571 6616 1501 4038 1202 7411 3890 2475 3121 9233 5689 5506 3944 9421 5187 5690 5294 5669 42...

output:

36
293
144
511
624
127
160
170
319
143
387
358
382
395
437
111
534
238
1
419
308
146
298
476
26
76
465
548
31
463
872
54
415
247
442
133
24
64
116
344
445
135
428
547
353
1944
7
332
86
446
961
214
425
244
104
267
339
422
95
878
527
388
433
4
7
68
24
119
441
419
113
92
122
169
204
45
214
1449
199
283...

result:

ok 10000 numbers

Test #20:

score: 13
Accepted
time: 29ms
memory: 18980kb

input:

10000 10000
737 3616 8236 1748 9746 1025 8320 7694 9618 5460 8569 2054 6012 1482 3594 4616 3404 8968 1596 9324 5765 6690 7168 4005 6211 9929 5701 7180 146 9198 3281 4427 2957 7385 5027 5085 7331 5273 2325 3592 3308 231 2585 246 3426 6552 7548 4894 7876 2163 3705 2716 564 1243 694 828 9358 2759 6950 ...

output:

127
282
221
177
71
49
161
178
109
132
1301
28
121
460
147
207
187
3068
116
12
488
168
140
71
140
13
188
78
1074
485
41
188
198
275
398
122
73
271
626
18
381
123
87
48
256
732
74
422
250
68
173
76
18
186
226
21
238
151
89
95
120
245
184
661
328
21
131
16
44
93
84
130
748
78
159
260
1476
192
256
45
89...

result:

ok 10000 numbers

Test #21:

score: 13
Accepted
time: 33ms
memory: 18436kb

input:

10000 10000
5784 6727 2539 4195 5929 822 6989 8755 2424 6452 3930 8206 134 3402 1651 2968 2027 1351 6615 7042 9909 3799 6033 6631 8993 2122 2290 6231 6826 3752 5606 3942 9999 932 1406 8374 6996 3516 2800 7997 3159 8159 6413 386 9402 3151 2900 9501 4996 8640 4023 2414 1752 7388 6026 3891 5964 7522 29...

output:

12
52
13
60
1076
9
4
166
219
491
598
59
680
204
54
52
104
1204
23
175
2182
1
59
63
116
98
3285
70
1040
147
76
747
207
64
51
199
242
219
364
5
13
43
120
221
53
997
227
743
23
532
46
32
25
28
42
13
39
359
29
99
62
81
101
133
63
84
55
1
161
19
69
506
54
46
15
26
1029
39
117
190
76
0
470
28
16
788
1
63
...

result:

ok 10000 numbers

Test #22:

score: 13
Accepted
time: 32ms
memory: 18116kb

input:

10000 10000
3200 7860 2449 7493 5913 3622 4301 8336 4880 5581 5443 3937 1098 9371 6433 5186 5734 4116 7021 2886 6015 1503 1382 553 3640 2545 2550 69 3637 2068 4089 4270 5953 3564 6640 207 4331 209 3711 360 1115 1658 6289 2254 5282 7423 5418 8274 2944 1632 9410 4372 4658 5870 3091 847 5240 2168 4729 ...

output:

6
372
267
179
575
53
23
69
95
145
179
218
236
1683
2
2849
447
101
57
44
95
6
176
83
23
182
88
231
5
250
14
154
33
17
630
140
153
58
802
42
256
25
71
5
14
1
3
192
255
120
16
1317
285
49
56
1565
10
10
440
99
978
62
164
164
289
939
508
9
385
1040
23
426
304
16
222
144
598
174
522
608
145
94
30
762
82
7...

result:

ok 10000 numbers

Test #23:

score: 13
Accepted
time: 37ms
memory: 18360kb

input:

10000 10000
4501 9267 7490 8458 7296 461 8299 2141 7551 905 2607 7307 9655 5695 9397 1268 4576 1741 3628 9247 3254 64 6569 2748 7210 9490 5288 9499 4042 4431 3803 3519 1869 8755 994 7602 8961 8914 1921 1023 1550 8449 755 5949 5167 7465 2515 5387 2901 2234 5466 3488 6443 9850 850 3699 2078 216 8780 9...

output:

294
109
94
1
109
67
216
33
5
568
93
67
2448
343
618
120
804
435
613
10
105
57
312
3
137
282
22
18
721
663
2264
118
5
714
935
1293
116
4
45
1435
1
3
5
21
1819
30
96
632
4016
0
44
175
3
1320
6
173
468
50
137
67
2340
390
66
9
15
41
198
72
1021
406
82
649
0
425
675
62
0
0
146
1360
157
20
1324
1158
17
23...

result:

ok 10000 numbers

Test #24:

score: 13
Accepted
time: 34ms
memory: 19040kb

input:

10000 10000
8659 3242 1316 5197 1986 3871 6477 355 4171 544 8684 1077 4863 9404 5142 533 8429 7698 9363 3188 8823 575 1980 7915 5259 2658 2454 8594 4553 1642 4302 9289 365 9586 5153 832 6183 2087 8821 967 9767 3295 6211 3591 1638 8283 7538 8717 3923 6460 4884 952 4572 8812 5769 3769 6827 3301 9051 8...

output:

352
0
38
2650
16
5
50
287
145
579
1
19
5668
791
283
1271
2
110
2
1072
227
0
2058
141
15
474
19
1
1441
1041
470
135
26
463
3
1019
10
14
4471
858
14
376
991
4196
1148
2181
1323
368
44
10
44
597
0
0
498
123
1442
294
6
1043
2191
767
660
0
1134
70
544
9
13
29
83
0
28
1293
414
839
14
1
26
1405
185
361
24
...

result:

ok 10000 numbers

Test #25:

score: 13
Accepted
time: 33ms
memory: 17552kb

input:

10000 10000
2562 8869 7831 1233 6909 8608 5685 5550 9245 8287 1515 445 6353 823 6167 6017 7135 2963 3401 3801 1190 7126 7624 1497 566 1580 2101 9802 2736 8835 4186 5868 4076 5237 9502 5905 9777 191 4969 7820 6985 1981 9765 5351 8969 9707 7089 5423 2263 1411 9237 5064 7278 1115 7568 3332 4830 5608 73...

output:

1004
9
13
535
2
188
265
11
93
186
11
31
21
522
1637
3
1
1625
2797
2785
2117
2751
61
4
503
1
694
3
913
8
10
243
672
59
14
238
1
8
3
8
1
1439
1
82
828
162
227
2
1
2876
80
4
1708
113
1
7
36
1275
54
53
75
1937
22
195
270
0
185
0
2577
0
0
67
345
12
4
1744
12
88
29
6
0
84
0
19
4
8
11
1
126
0
153
40
230
0
...

result:

ok 10000 numbers

Test #26:

score: 13
Accepted
time: 33ms
memory: 18184kb

input:

10000 10000
8176 2411 3176 6326 8941 749 5715 4947 1231 2064 3372 8557 4257 7944 9617 898 1985 5805 4311 1725 6850 7742 1737 7869 4330 4550 2212 8047 1131 6867 8253 7062 2386 4052 1953 7309 3703 2595 4718 5447 2661 5903 2883 3102 7425 8326 8343 941 8409 2778 7600 9490 4294 1479 2164 9820 7778 9146 9...

output:

5629
1
10
17
2
17
130
43
63
2
5296
2
947
61
28
7
40
2
1
925
1
4909
609
177
9
1
38
86
37
2043
15
2991
384
118
0
3
379
82
373
3
36
4043
14
52
821
5
0
243
8
0
22
34
766
234
77
498
2319
3210
33
224
75
3
3
3
46
1
308
102
0
3
2381
288
12
1
12
823
175
125
62
11
1009
0
9
1427
0
7
792
747
0
805
329
216
610
0...

result:

ok 10000 numbers

Test #27:

score: 13
Accepted
time: 34ms
memory: 21380kb

input:

10000 10000
2561 7464 7906 1883 1520 8020 764 8445 8525 4129 8134 941 7003 4576 2118 5702 8183 5262 6500 1822 2097 1481 4374 7243 4116 9531 9232 9533 2907 4216 7033 4200 8824 9750 884 911 296 9071 1762 1291 8719 1328 574 5258 9913 35 9664 8185 2430 5464 607 2017 6410 6970 4514 6175 7101 7944 2023 13...

output:

11
684
7
11
11
31
184
184
4
4
670
1039
5
29
278
3
0
413
1622
2677
7
0
1
638
1
110
1561
2
401
0
0
1514
3
2
3
103
68
23
4
3823
22
907
1
2261
572
885
237
4
358
3
20
2089
0
12
3
0
340
2984
2
56
0
7
4
1778
323
35
203
202
7
1603
192
0
1004
646
4
419
10
7
1733
873
10
28
10
239
41
7
453
3
601
391
74
346
97
...

result:

ok 10000 numbers

Test #28:

score: 13
Accepted
time: 34ms
memory: 19692kb

input:

10000 10000
1706 7043 7104 4628 3359 1337 9962 9789 6176 3053 7246 8083 4183 1940 3130 5434 8243 4779 8751 4943 1503 9587 6028 3456 6440 391 7261 2844 6710 9279 845 4257 3280 3638 2188 3855 4754 1090 5926 1846 4560 4745 3975 6960 7008 5952 3581 50 6519 4102 2125 8904 3192 9629 609 3277 1427 5463 454...

output:

1646
0
6
100
6
1
0
979
24
1
242
15
0
4585
2
240
61
61
3
1
15
938
1524
4274
23
147
60
95
354
1469
4048
1
221
551
1432
1
15
0
2278
9
525
521
1
1
209
20
2123
7
11
200
126
0
199
125
3073
6
2977
11
17
190
4
1
1748
0
0
3
4
1051
415
71
26
404
11
254
596
11
1855
11
11
1660
0
792
145
89
205
678
20
613
263
71...

result:

ok 10000 numbers

Test #29:

score: 13
Accepted
time: 45ms
memory: 19256kb

input:

10000 10000
9143 2740 807 1817 5064 4038 8672 808 9701 57 8544 5787 2777 4663 3308 1515 2527 2862 4368 8794 2611 7401 684 565 6521 3932 6124 1548 8316 2936 8184 2019 5974 3147 5976 218 2131 1551 2814 4397 6000 5132 4007 7622 9229 7016 3321 3181 5973 9819 8360 3623 7341 3868 2712 3635 8272 9098 4113 ...

output:

78
39
0
2
4794
312
0
2215
312
1
0
625
1250
4490
78
4396
604
156
0
0
1
9
1250
0
9
156
1
312
19
19
622
9
9
2
4872
9
78
78
0
625
78
2
9
4
625
4
312
156
39
625
19
1117
1
4
312
9
156
625
2
1250
0
1933
1
156
39
1471
1
156
2
78
170
1014
4508
39
156
1
9
9
2
625
0
2
625
2479
1
2
39
4
1
137
2
302
1653
9
625
1...

result:

ok 10000 numbers

Subtask #3:

score: 17
Accepted

Test #30:

score: 17
Accepted
time: 207ms
memory: 53364kb

input:

50000 200000
42574 43129 47328 17982 40521 6668 12729 32377 201 11940 8599 11734 18349 41045 26854 22540 9897 33419 7463 1243 47272 27135 49050 49111 22435 42539 39924 20272 5843 9308 45963 3283 31185 13692 38952 20583 15885 24802 4773 953 49907 28689 36942 23550 19449 8970 33340 31665 5407 46023 18...

output:

12045
1321
12292
2444
32443
36534
38575
30505
16464
16648
47153
41144
23401
1762
18567
6831
26486
29716
8905
16295
38569
29990
22061
7638
3820
34754
17582
6466
12632
23384
11657
16493
24434
11503
3945
2205
37806
13036
29052
24114
39158
34702
37326
20815
11766
41253
44355
17807
23452
26717
43107
4133...

result:

ok 200000 numbers

Test #31:

score: 17
Accepted
time: 201ms
memory: 50356kb

input:

50000 200000
13611 7267 47234 19765 39458 30493 19935 34465 46369 11995 35207 5752 13718 47418 12913 13725 27694 47726 25253 30406 27587 25790 21091 12008 13534 8804 26484 34270 33810 49102 25288 37607 11863 23340 22747 40502 4461 24803 31317 25617 46077 6504 46299 34533 6829 17841 2812 35413 16394 ...

output:

14606
766
20003
9866
13393
15046
12175
16064
14351
32598
8598
4328
20759
18242
14279
16634
19676
27649
22510
18209
10566
6103
7184
10324
11352
25597
17392
26556
19067
28802
18806
8556
16176
19224
25066
21928
3542
3540
2793
21786
15621
831
18062
6304
5590
24262
14451
14273
10795
9579
10524
6779
16154...

result:

ok 200000 numbers

Test #32:

score: 17
Accepted
time: 213ms
memory: 45588kb

input:

50000 200000
7808 37218 25681 42081 13175 20056 26651 36373 24916 22399 6718 4909 8913 8722 43481 17050 49628 37628 9367 22930 27058 40654 5776 8531 26430 24332 39623 5383 17932 44070 29404 47256 19162 25499 2140 3864 43779 46852 10360 40725 38332 16051 16623 9761 9775 35907 31158 36636 39585 10652 ...

output:

14838
16217
8834
7129
15203
340
4210
7269
18579
323
16773
4298
7069
8897
4908
12477
10072
17823
16194
12297
16355
18783
14541
11142
1182
19042
3025
18213
7450
16225
9323
9982
5313
7448
8667
17101
18811
6096
1270
16782
16588
5960
2743
18056
9152
15598
18523
11798
9945
19292
6793
8049
19527
15405
4257...

result:

ok 200000 numbers

Test #33:

score: 17
Accepted
time: 224ms
memory: 47684kb

input:

50000 200000
17019 6516 42836 34960 31966 21120 26093 38510 34959 34501 21687 46943 11848 11123 34078 42163 21906 42658 23287 22671 42591 37793 45773 27274 14076 16061 45524 9550 9150 26134 9851 43143 39161 47054 15529 29755 36170 10171 15826 11608 30165 25465 24654 24623 40231 43600 20883 2956 3879...

output:

6036
8975
2529
1459
3742
6840
1646
6933
7256
6524
7820
9180
11057
6427
6812
5492
251
3080
3376
6343
4160
887
50
2182
9828
8028
20
1535
2744
3413
9684
9288
4357
6221
9904
8728
1709
9303
9290
2920
2763
1763
6381
5524
1462
5744
9625
5959
9253
10551
1389
4468
8868
7844
5050
10410
7696
7342
10626
7321
89...

result:

ok 200000 numbers

Test #34:

score: 17
Accepted
time: 233ms
memory: 49184kb

input:

50000 200000
28543 14178 18801 353 43041 45128 27928 39644 22071 30277 18193 41913 14812 43930 47029 28664 25683 13155 30716 14229 33495 5690 11537 40210 29588 33940 1326 40684 12721 10254 30431 38869 15718 48272 49256 40277 5650 36524 5542 35389 49417 36528 26315 38124 16450 46095 23406 4713 9031 1...

output:

5609
3746
2300
4896
5137
3267
4667
865
2540
4697
1513
2303
1512
3202
979
1600
1440
1633
2278
2781
1674
5766
2712
2684
2302
3273
2798
2575
5571
4974
960
3483
2456
2977
1107
4747
1586
2513
4536
4717
115
2147
3169
2298
5094
530
4341
894
636
4065
5581
2829
4294
207
3076
3767
2038
417
4411
6070
869
525
1...

result:

ok 200000 numbers

Test #35:

score: 17
Accepted
time: 238ms
memory: 42580kb

input:

50000 200000
42265 30997 16742 19473 6990 7490 28098 1438 29608 39635 1443 1545 2057 31374 14189 14949 10785 20287 4530 36698 37061 22642 27247 32244 49598 24351 26840 18362 2238 20195 25009 41897 21015 41709 7534 19999 47530 40977 41426 2119 41946 4046 35492 30475 32060 9232 25575 237 18694 26502 2...

output:

825
941
1345
699
1008
783
839
2876
1641
225
2832
47
1631
1483
1503
2813
814
2970
2244
2857
2096
2882
2722
2868
2692
1441
1064
680
927
973
888
1583
1691
56
1328
2856
943
319
523
1670
715
1073
2124
1415
647
1103
160
882
1060
501
1599
655
2923
2722
151
1180
1410
1216
830
2263
1951
745
3818
773
1852
223...

result:

ok 200000 numbers

Test #36:

score: 17
Accepted
time: 250ms
memory: 46144kb

input:

50000 200000
35275 48137 32517 36923 17090 33719 22003 25282 16638 31131 40542 25036 38173 41767 5573 46953 35455 27461 46247 32004 43935 22667 40180 34839 47048 22937 25880 21912 25022 6824 15242 3447 32153 33149 861 3742 38611 13195 49884 34265 23790 14796 44706 33843 26639 32729 14181 41978 831 1...

output:

400
624
6616
1887
1852
136
1450
302
730
750
1148
877
1111
1492
1768
999
193
1983
629
2541
859
208
852
760
911
196
1317
1137
1
504
580
753
1226
914
448
1326
895
748
473
1226
1216
1676
173
1331
756
629
845
493
1128
456
317
2006
503
356
589
647
2282
721
605
1128
351
527
810
646
683
781
886
732
233
167
...

result:

ok 200000 numbers

Test #37:

score: 17
Accepted
time: 265ms
memory: 48544kb

input:

50000 200000
916 9192 892 22349 11058 24972 6584 25500 21081 3605 19000 22398 40009 16140 11330 16866 33042 19197 38993 21879 38803 46494 19048 29135 21786 36419 9522 48044 17884 44413 8440 27879 32411 32078 44270 44595 33184 24636 18550 22681 39133 17034 32607 41246 44755 40937 327 1332 43951 40283...

output:

6092
55
642
360
4136
650
433
96
650
214
56
139
284
454
94
897
212
198
468
43
3
561
80
1187
1159
128
311
519
1575
11804
432
559
5
121
374
301
219
404
583
235
662
329
412
382
302
71
53
10459
1263
42
556
266
382
62
147
664
423
150
394
1170
2015
171
210
5
1025
223
272
715
456
394
347
48
0
487
491
712
14...

result:

ok 200000 numbers

Test #38:

score: 17
Accepted
time: 275ms
memory: 48180kb

input:

50000 200000
46139 14805 31812 39098 21964 6703 17708 15873 43255 9279 9629 47667 32951 5775 36158 46562 17562 14586 38543 27081 43386 47250 46728 39174 33842 26177 37728 45321 10787 20625 28043 30088 32039 28316 22089 42733 26509 42530 35295 23932 6176 3610 23867 45568 22695 42079 28544 39179 40973...

output:

2604
146
31
549
159
141
368
347
257
3942
428
23
123
291
197
233
39
5072
327
525
2303
305
106
58
2513
156
793
175
757
37
69
41
235
4
1694
267
62
4521
547
61
499
341
243
309
675
1975
529
857
4293
5677
134
80
160
359
73
134
4505
241
177
829
233
955
91
219
98
185
595
6481
398
521
2149
1729
999
561
51
44...

result:

ok 200000 numbers

Test #39:

score: 17
Accepted
time: 282ms
memory: 48724kb

input:

50000 200000
4608 1857 41886 13649 44549 33326 36750 43707 8331 26700 5235 35802 11906 9220 38528 14357 43330 37226 38582 9388 23049 33174 7458 25829 3782 8713 23697 13110 42538 13424 16280 43853 6716 33776 15003 45671 16386 18842 33781 16370 10410 31454 4983 7137 48164 21352 48341 48309 27556 14074...

output:

471
2815
630
8327
15457
1328
9172
383
878
160
136
15392
504
11492
69
1087
24
5
359
0
1235
798
84
642
812
60
1783
617
593
470
90
569
2
430
273
536
11
1154
1918
3519
10
102
249
3010
1041
345
69
1232
1388
105
450
9
63
303
183
391
117
45
231
677
1778
2018
1591
3116
3114
859
1662
3823
420
450
60
84
4398
...

result:

ok 200000 numbers

Test #40:

score: 17
Accepted
time: 284ms
memory: 47096kb

input:

50000 200000
13954 28374 11800 26848 889 38500 12745 39721 6813 38466 23046 26952 6390 29768 45230 9461 32608 14347 29175 46979 7780 19166 24339 23746 48724 46976 20028 31303 1743 17910 7347 45475 19884 3526 40689 39989 3596 27241 46338 6943 7001 7369 16028 27265 7197 45164 35044 47212 37722 21872 3...

output:

583
5030
1276
4132
103
79
1649
31
190
2928
397
951
365
397
520
397
8
1648
11246
1391
7346
1120
30470
5007
1390
21
3
698
951
55
672
349
168
464
3435
3247
500
179
1119
306
482
429
280
71
3428
14771
12
1271
0
989
2157
381
811
36
811
3235
319
5
16
21
582
840
4072
603
9751
31
2896
1638
499
671
1163
79
46...

result:

ok 200000 numbers

Test #41:

score: 17
Accepted
time: 287ms
memory: 53392kb

input:

50000 200000
36996 3181 11620 3429 35358 34168 48667 28333 29506 32941 5744 32970 31756 19808 43639 13481 43713 44725 33528 29411 29294 10158 13551 3334 45351 24198 35139 44657 31114 12893 47647 17501 38554 32297 14098 17787 9099 20091 12328 45062 7443 2592 9020 49321 41993 17708 12530 12379 31102 2...

output:

655
12269
769
76
117
2371
1293
95
768
2370
5328
1043
13
450
33
1043
3467
3
2207
1
75
1798
3459
1797
2205
7215
766
893
14343
4063
2363
162
449
16
3
402
1681
29561
322
3440
8031
3730
13
6
14195
2939
29162
21695
2718
1115
1468
5788
359
213
2190
43
184
3712
3163
4
1368
882
4376
4376
1899
6
2038
132
43
2...

result:

ok 200000 numbers

Test #42:

score: 17
Accepted
time: 281ms
memory: 51084kb

input:

50000 200000
27519 38386 26996 34745 17417 13335 4891 17383 12096 10265 20670 16540 42879 39540 2284 9544 31976 47486 41852 39195 3560 48292 45924 13120 21604 2486 23658 32577 19024 9373 28258 7457 6082 19165 22479 4973 36551 35193 8885 11355 1475 47728 42128 31369 3108 26923 12815 42785 9040 24006 ...

output:

8204
4074
30810
589
1640
2
26
9578
720
2
238
387
4
10
13749
238
719
18
100
0
479
8
5253
100
183
8
6
12
8095
384
5233
713
2435
6014
6013
1204
179
5218
5
4020
8048
1860
9
179
25
4009
35
4549
379
4544
5
1
1
1018
2
2749
135
9312
470
0
50
28320
9272
13255
35
575
295
4510
2
27948
292
2728
7906
847
16126
2...

result:

ok 200000 numbers

Test #43:

score: 17
Accepted
time: 280ms
memory: 48756kb

input:

50000 200000
41928 38140 20927 32889 13587 7566 19308 15849 11660 36495 23766 3147 21244 25794 16293 42941 14708 39580 25737 42685 44736 21610 18716 19662 6604 48837 18272 28457 44686 35314 130 11010 10544 27630 26644 13089 42472 7823 10021 17141 16188 47740 10388 21663 48509 43801 48863 39461 12867...

output:

39
998
5
248
175
12177
175
248
1
3925
24
4941
57
1361
2393
84
4
720
1358
505
358
2385
24
504
5
29236
3
122
3885
6
8
1349
57
5
502
20404
20388
24
501
1346
3
6
82
3859
1
708
7517
9384
1791
23
11
3027
23
976
495
0
1
169
4809
3015
1780
5987
4793
19785
239
2
81
27502
55
23
1318
23
54
79
492
7365
4
167
36...

result:

ok 200000 numbers

Test #44:

score: 17
Accepted
time: 299ms
memory: 52824kb

input:

50000 200000
46590 44034 18071 33305 18068 9254 6913 27880 33800 5672 30923 31456 31265 358 39743 4802 9888 36059 4577 37459 22303 43877 21241 35228 45183 12569 20426 45673 43256 30859 44123 44640 14376 11771 30601 31363 32308 25025 24158 5423 36221 22089 49584 16078 43252 39077 46970 39450 2158 339...

output:

43
567
252
110
43
169
169
6144
372
27
563
27
69
1909
2
6106
28394
12784
1907
27
6
1905
4
851
1
2803
4
2
18474
4
13
4126
18389
69
3
69
10
556
2
4101
27
19
2
43
1871
12494
2758
362
19
69
13
8638
5946
241
162
2730
27
13
106
2722
12320
3
7
42
355
239
820
3
26
2
9
1225
1225
2
18
26
8483
3984
2690
1822
12...

result:

ok 200000 numbers

Test #45:

score: 17
Accepted
time: 280ms
memory: 47964kb

input:

50000 200000
15898 42657 4986 19863 30665 24370 12689 13374 2396 17019 32397 24489 12511 45501 13973 8012 47309 38241 10547 36426 26338 10644 5480 33395 42563 36582 33104 1862 2454 46370 28242 30791 14418 2113 38629 2113 2242 42577 18482 445 3076 297 38402 14798 45114 1189 47937 20443 25826 39208 47...

output:

9228
1485
4
3598
132
958
9184
290
1483
42
289
88
88
6
10
954
5643
10
1
25788
425
18
0
1
27
952
6
5599
130
286
27
638
0
42
286
2
190
8948
285
189
1
86
86
5529
1449
5518
27
285
6
41
2
0
41
41
128
627
24540
283
2
9
5
1
85
3453
3
5
5
14276
2200
9
128
128
187
1
1
187
85
3
3420
1
5366
85
5
186
17
3
40
2
2...

result:

ok 200000 numbers

Test #46:

score: 17
Accepted
time: 291ms
memory: 46068kb

input:

50000 200000
3084 33641 21921 49781 44713 38 28280 45178 32711 39076 37318 5988 7315 17566 25555 23321 5539 16120 27388 30215 31797 36272 6498 17030 38250 40406 22470 3705 29595 38807 48067 17106 3482 17503 21695 17541 47842 14170 21099 762 26631 43803 5189 35139 43921 16104 8069 40554 17808 21791 4...

output:

6
3224
212
6
2027
41
27
24744
511
510
210
41
4
2
2012
92
136
19
8236
3177
2
10
3
813
5
92
92
2
5
506
1
0
24018
41
207
4
8
41
23830
4970
8
1
4
4957
8071
6
13
23538
13
12
3
2
317
59
7
9
9
0
23203
796
9
24
17
1
1
0
316
13196
1250
4870
17
203
3068
7
13108
7
0
37
1932
4830
3
3
3038
312
129
87
87
2
202
12...

result:

ok 200000 numbers

Test #47:

score: 17
Accepted
time: 383ms
memory: 55536kb

input:

50000 200000
13552 21185 5378 25377 29874 26867 35463 14778 22033 47123 12009 19003 34019 34345 21611 37505 43925 15335 38300 45047 42159 31896 26577 25336 47272 24868 31102 12178 19424 10487 18884 49849 34294 46914 49522 46158 44733 19394 27501 11056 35541 37165 30604 48855 44987 14659 31259 10584 ...

output:

48
24
6
1
3
1562
8097
48
781
97
12
390
1
1213
3125
1
24
6
390
195
6250
195
6250
781
97
0
532
3
8438
0
24
195
12
6250
97
97
6243
6
48
6
11412
3
3
195
195
12485
97
12
97
3
390
1
6
1562
781
195
6242
2830
8507
781
6
3
6
12
1562
781
48
24
195
6250
19710
12363
97
1
12
12
20651
8298
6
5510
3121
12145
390
3...

result:

ok 200000 numbers

Subtask #4:

score: 0
Wrong Answer

Dependency #3:

100%
Accepted

Test #48:

score: 0
Wrong Answer
time: 242ms
memory: 83732kb

input:

100000 400000
6457 23693 90928 23592 90440 75018 16865 3342 83718 16731 95103 31510 38719 27886 29093 41955 6596 46409 51839 10527 91993 61074 14405 34833 53674 42363 11490 43757 46191 6058 59164 96938 57858 40178 97523 84164 21582 72243 11267 47368 97058 6637 95208 60092 53943 16441 28363 64965 522...

output:

68052
31330
65326
18011
17342
2987
78524
96863
67336
53285
90349
20608
8839
44819
3102
10125
60331
57270
93175
79057
26210
66364
5752
11765
64609
11194
56656
47540
62126
86871
41715
19191
26931
83164
77764
77112
39977
72679
78228
8229
15479
24512
12434
57901
25601
5118
7890
60091
45553
89895
18704
7...

result:

wrong answer 6th numbers differ - expected: '3039', found: '2987'

Subtask #5:

score: 0
Wrong Answer

Test #67:

score: 0
Wrong Answer
time: 228ms
memory: 86628kb

input:

100000 1000000
6457 23693 90928 23592 90440 75018 16865 3342 83718 16731 95103 31510 38719 27886 29093 41955 6596 46409 51839 10527 91993 61074 14405 34833 53674 42363 11490 43757 46191 6058 59164 96938 57858 40178 97523 84164 21582 72243 11267 47368 97058 6637 95208 60092 53943 16441 28363 64965 52...

output:

52956
18767
1319
13405
11021
-4982
50595
81481
6813
3640
58937
10991
-380
4713
-6051
9517
39731
1166
67346
74637
2667
45182
4298
6774
1625
4198
52270
30435
60137
48654
29768
2815
6846
73091
21944
49693
9923
46795
29787
6725
2435
20773
2959
34666
4377
322
4166
7527
38292
7253
3586
63817
28075
43828
2...

result:

wrong answer 6th numbers differ - expected: '455', found: '-4982'

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%