QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#139718#6775. Cell AutomatonNOI_AK_ME#100 ✓3381ms703020kbC++209.6kb2023-08-14 12:08:242024-07-04 01:41:55

Judging History

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

  • [2024-07-04 01:41:55]
  • 评测
  • 测评结果:100
  • 用时:3381ms
  • 内存:703020kb
  • [2023-08-14 12:08:24]
  • 提交

answer

/*
	FULL-SCORE SOLUTION
	- Time Complexity: O((Q + N) log N)
*/

#include <set>
#include <tuple>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

class value {
public:
	long long x; int p1, p2; // value: x + p1 * eps + p2 * eps^2 (eps > 0 is an arbitrary value which is small enough)
	value() : x(0), p1(0), p2(0) {}
	value(long long x_, int p1_, int p2_) : x(x_), p1(p1_), p2(p2_) {}
	bool operator<(const value& v) const { return x != v.x ? x < v.x : (p1 != v.p1 ? p1 < v.p1 : p2 < v.p2); }
	bool operator>(const value& v) const { return x != v.x ? x > v.x : (p1 != v.p1 ? p1 > v.p1 : p2 > v.p2); }
	value operator+() const { return value(+x, +p1, +p2); }
	value operator-() const { return value(-x, -p1, -p2); }
	value& operator+=(const value& v) { x += v.x; p1 += v.p1; p2 += v.p2; return *this; }
	value& operator-=(const value& v) { x -= v.x; p1 -= v.p1; p2 -= v.p2; return *this; }
	value operator+(const value& v) const { return value(*this) += v; }
	value operator-(const value& v) const { return value(*this) -= v; }
};

class nearest_info {
public:
	int idx; value d1, d2;
	nearest_info() : idx(-1), d1(value()), d2(value()) {}
	nearest_info(int idx_, const value& d1_, const value& d2_) : idx(idx_), d1(d1_), d2(d2_) {}
};

class segment {
public:
	long long a, b, l, r; // y = ax + b (l <= x <= r)
	segment() : a(0), b(0), l(0), r(0) {}
	segment(long long a_, long long b_, long long l_, long long r_) : a(a_), b(b_), l(l_), r(r_) {}
};

// FUNCTION FOR SOLVING "CONTINUOUS VERSION" OF THE PROBLEM
// - Given N points (X[0], Y[0]), ..., (X[N-1], Y[N-1]) and Q queries with T[0], T[1], ..., T[Q-1]
// - For each query j, answer the following:
//   - Consider N squares that, for i = 0, 1, ..., N-1, the lower-left point is at (X[i], Y[i]) and the upper-right point is at (X[i]+T[j], Y[i]+T[j]).
//   - Calculate the area of union of these N squares.
vector<long long> area_union(int N, int Q, const vector<long long>& X, const vector<long long>& Y, const vector<long long>& T) {
	// step #1. compute nearest colliding square, for each square's corner
	vector<value> xp(N), yp(N);
	for (int i = 0; i < N; i++) {
		xp[i] = value(X[i], i, 0);
		yp[i] = value(Y[i], 0, i);
	}
	vector<vector<nearest_info> > nearest(8, vector<nearest_info>(N)); // d1: distance, d2: "orthogonal" distance
	for (int i = 0; i < 8; i++) {
		vector<value> xv(N), yv(N);
		for (int j = 0; j < N; j++) {
			switch (i) {
				case 0: xv[j] = +xp[j]; yv[j] = +yp[j]; break;
				case 1: xv[j] = +xp[j]; yv[j] = -yp[j]; break;
				case 2: xv[j] = -yp[j]; yv[j] = +xp[j]; break;
				case 3: xv[j] = -yp[j]; yv[j] = -xp[j]; break;
				case 4: xv[j] = -xp[j]; yv[j] = -yp[j]; break;
				case 5: xv[j] = -xp[j]; yv[j] = +yp[j]; break;
				case 6: xv[j] = +yp[j]; yv[j] = -xp[j]; break;
				case 7: xv[j] = +yp[j]; yv[j] = +xp[j]; break;
			}
		}
		vector<int> perm(N);
		for (int i = 0; i < N; i++) {
			perm[i] = i;
		}
		sort(perm.begin(), perm.end(), [&](int va, int vb) {
			return yv[va] < yv[vb];
		});
		set<value> s;
		for (int j : perm) {
			set<value>::iterator it = s.lower_bound(xv[j] - yv[j]);
			while (it != s.end() && xv[abs(it->p1)] < xv[j]) {
				it = s.erase(it);
			}
			if (it != s.begin()) {
				--it;
				nearest[i][j] = nearest_info(abs(it->p1), xv[j] - xv[abs(it->p1)], yv[j] - yv[abs(it->p1)]);
			}
			s.insert(xv[j] - yv[j]);
		}
	}
	for (int i = 0; i < 8; i += 2) {
		int p = vector<int>({ 7, 2, 1, 4, 3, 6, 5, 0 })[i];
		for (int j = 0; j < N; j++) {
			if (nearest[i][j].idx != -1 && nearest[p][j].idx != -1) {
				if (nearest[i][j].d1 > nearest[p][j].d1) {
					nearest[i][j] = nearest_info();
				}
				else {
					nearest[p][j] = nearest_info();
				}
			}
		}
	}

	// step #2. compute "time lapse" of each square's edge
	vector<vector<vector<nearest_info> > > timelapse(8, vector<vector<nearest_info> >(N)); // d1: time, d2: distance from another corner
	for (int i = 0; i < 8; i++) {
		int p1 = vector<int>({ 7, 2, 1, 4, 3, 6, 5, 0 })[i];
		int p2 = vector<int>({ 4, 5, 6, 7, 0, 1, 2, 3 })[i];
		for (int j = 0; j < N; j++) {
			if (nearest[p1][j].idx != -1) {
				timelapse[i][j].push_back(nearest_info(nearest[p1][j].idx, nearest[p1][j].d1, nearest[p1][j].d1));
			}
			if (nearest[p2][j].idx != -1) {
				timelapse[i][nearest[p2][j].idx].push_back(nearest_info(j, nearest[p2][j].d1, nearest[p2][j].d2));
			}
		}
		for (int j = 0; j < N; j++) {
			sort(timelapse[i][j].begin(), timelapse[i][j].end(), [&](const nearest_info& f1, const nearest_info& f2) {
				return f1.d1 < f2.d1;
			});
		}
	}

	// step #3. find all crashes & rectangular holes
	const long long INF = (3LL << 60);
	vector<vector<value> > eliminate(4, vector<value>(N, value(INF, 0, 0)));
	for (int i = 0; i < 8; i += 2) {
		for (int j = 0; j < N; j++) {
			if (!timelapse[i + 0][j].empty() && !timelapse[i + 1][j].empty()) {
				nearest_info f0 = timelapse[i + 0][j].back();
				nearest_info f1 = timelapse[i + 1][j].back();
				value t = f0.d2 + f1.d2;
				if ((timelapse[(i + 2) % 8][f0.idx].empty() || timelapse[(i + 2) % 8][f0.idx].back().d1 < t) && timelapse[(i + 3) % 8][f0.idx].back().d1 < t) {
					eliminate[((i + 2) % 8) / 2][f0.idx] = min(eliminate[((i + 2) % 8) / 2][f0.idx], t);
				}
				if ((timelapse[(i + 7) % 8][f1.idx].empty() || timelapse[(i + 7) % 8][f1.idx].back().d1 < t) && timelapse[(i + 6) % 8][f1.idx].back().d1 < t) {
					eliminate[((i + 6) % 8) / 2][f1.idx] = min(eliminate[((i + 6) % 8) / 2][f1.idx], t);
				}
				eliminate[i / 2][j] = min(eliminate[i / 2][j], t);
			}
		}
	}

	// step #4. final calculation
	vector<segment> seg;
	for (int i = 0; i < 8; i += 2) {
		for (int j = 0; j < N; j++) {
			seg.push_back(segment(1, 0, 0, eliminate[i / 2][j].x));
			for (int k = 0; k < 2; k++) {
				if (!timelapse[i + k][j].empty()) {
					seg.push_back(segment(-1, timelapse[i + k][j][0].d2.x, timelapse[i + k][j][0].d1.x, eliminate[i / 2][j].x));
					for (int l = 1; l < timelapse[i + k][j].size(); l++) {
						seg.push_back(segment(0, -(timelapse[i + k][j][l - 1].d2 - timelapse[i + k][j][l].d2).x, timelapse[i + k][j][l].d1.x, eliminate[i / 2][j].x));
					}
				}
			}
		}
	}
	vector<long long> tcomp({ 0, INF });
	for (segment s : seg) {
		if ((s.a != 0 || s.b != 0) && s.l != s.r) {
			tcomp.push_back(s.l);
			tcomp.push_back(s.r);
		}
	}
	sort(tcomp.begin(), tcomp.end());
	tcomp.erase(unique(tcomp.begin(), tcomp.end()), tcomp.end());
	vector<long long> polya(tcomp.size()), polyb(tcomp.size()); // y = ax + b
	for (segment s : seg) {
		if ((s.a != 0 || s.b != 0) && s.l != s.r) {
			int pl = lower_bound(tcomp.begin(), tcomp.end(), s.l) - tcomp.begin();
			int pr = lower_bound(tcomp.begin(), tcomp.end(), s.r) - tcomp.begin();
			polya[pl] += s.a;
			polya[pr] -= s.a;
			polyb[pl] += s.b;
			polyb[pr] -= s.b;
		}
	}
	for (int i = 1; i < tcomp.size(); i++) {
		polya[i] += polya[i - 1];
		polyb[i] += polyb[i - 1];
	}
	vector<long long> cum(tcomp.size());
	for (int i = 0; i < int(tcomp.size()) - 1; i++) {
		long long yl = polya[i] * tcomp[i] + polyb[i];
		long long yr = polya[i] * tcomp[i + 1] + polyb[i];
		cum[i + 1] = cum[i] + (yl + yr) * (tcomp[i + 1] - tcomp[i]) / 4;
	}
	vector<long long> answer(Q);
	for (int i = 0; i < Q; i++) {
		int pos = lower_bound(tcomp.begin(), tcomp.end(), T[i] + 1) - tcomp.begin() - 1;
		long long yl = polya[pos] * tcomp[pos] + polyb[pos];
		long long yt = polya[pos] * T[i] + polyb[pos];
		answer[i] = cum[pos] + (yl + yt) * (T[i] - tcomp[pos]) / 4;
	}
	return answer;
}

// FUNCTION FOR SOLVING THE MAIN PROBLEM
vector<long long> solve(int N, int Q, const vector<long long>& X, const vector<long long>& Y, const vector<long long>& T) {
	auto half = [&](long long x) {
		return (x >= 0 ? x / 2 : -((-x + 1) / 2));
	};
	vector<long long> xa, ya, xb, yb;
	for (int i = 0; i < N; i++) {
		if ((X[i] + Y[i]) % 2 == 0) {
			xa.push_back((X[i] + Y[i] + 0) / 2); ya.push_back((X[i] - Y[i] + 0) / 2);
			xa.push_back((X[i] + Y[i] + 0) / 2); ya.push_back((X[i] - Y[i] + 2) / 2);
			xa.push_back((X[i] + Y[i] + 2) / 2); ya.push_back((X[i] - Y[i] + 0) / 2);
			xa.push_back((X[i] + Y[i] + 2) / 2); ya.push_back((X[i] - Y[i] + 2) / 2);
			xb.push_back((X[i] + Y[i] + 2) / 2); yb.push_back((X[i] - Y[i] + 2) / 2);
		}
		else {
			xa.push_back((X[i] + Y[i] + 1) / 2); ya.push_back((X[i] - Y[i] + 1) / 2);
			xb.push_back((X[i] + Y[i] + 1) / 2); yb.push_back((X[i] - Y[i] + 1) / 2);
			xb.push_back((X[i] + Y[i] + 1) / 2); yb.push_back((X[i] - Y[i] + 3) / 2);
			xb.push_back((X[i] + Y[i] + 3) / 2); yb.push_back((X[i] - Y[i] + 1) / 2);
			xb.push_back((X[i] + Y[i] + 3) / 2); yb.push_back((X[i] - Y[i] + 3) / 2);
		}
	}
	vector<long long> T2(Q * 2);
	for (int i = 0; i < Q; i++) {
		T2[i * 2 + 0] = T[i];
		T2[i * 2 + 1] = (T[i] >= 1 ? T[i] - 1 : 0);
	}
	vector<long long> resa = area_union(xa.size(), Q * 2, xa, ya, T2);
	vector<long long> resb = area_union(xb.size(), Q * 2, xb, yb, T2);
	vector<long long> answer(Q, 0);
	for (int i = 0; i < Q; i++) {
		if (T[i] == 0) {
			answer[i] = N;
		}
		else {
			answer[i] += resa[2 * i + 0] - (T[i] >= 2 ? resa[2 * i + 1] : 0);
			answer[i] += resb[2 * i + 0] - (T[i] >= 2 ? resb[2 * i + 1] : 0);
			if (T[i] == 1) {
				answer[i] -= N;
			}
		}
	}
	return answer;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	vector<long long> X(N), Y(N), T(Q);
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
	}
	for (int i = 0; i < Q; i++) {
		cin >> T[i];
	}
	vector<long long> answer = solve(N, Q, X, Y, T);
	for (int i = 0; i < Q; i++) {
		cout << answer[i] << '\n';
	}
	return 0;
}

詳細信息

Subtask #1:

score: 4
Accepted

Test #1:

score: 4
Accepted
time: 1ms
memory: 3760kb

input:

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

output:

11
28
40
52
64
76
88
100
112
124
136
146
148
148
152
156
160
164
155
146
150
154
158
162
166
170
174
178
182
186
190
194
198
202
206
210
214
218
222
226
230
234
238
242
246
250
254
258
262
266

result:

ok 50 lines

Test #2:

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

input:

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

output:

21
48
60
72
84
96
108
120
132
144
156
168
180
192
204
216
228
240
252
264
276
286
288
288
288
288
290
294
298
302
306
310
314
292
271
275
279
283
287
291
295
299
303
307
311
315
319
323
327
331

result:

ok 50 lines

Test #3:

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

input:

50 50
0 4
21 -11
-9 3
17 23
1 -10
12 -10
13 29
6 -23
5 -9
47 -37
-17 -15
42 47
26 38
-5 -18
-8 17
-36 49
-15 -25
-23 38
3 12
-19 -24
14 45
-9 22
22 8
31 -2
-30 -18
8 -21
-9 -38
-50 -5
14 -3
-50 45
-16 2
4 -25
-13 28
-13 -9
-5 17
22 -6
1 0
5 2
3 19
-4 13
9 -9
-11 11
7 -11
-8 -15
12 43
-7 15
-13 0
20 ...

output:

50
199
371
486
569
611
613
616
625
619
558
543
520
484
487
499
511
491
495
503
503
494
502
510
518
519
480
470
465
465
464
464
462
461
461
463
467
471
475
479
483
487
491
495
499
503
507
511
515
519

result:

ok 50 lines

Test #4:

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

input:

50 50
-41 46
32 27
6 -33
-28 -33
41 10
27 -21
-32 12
24 -45
-7 11
22 33
48 28
-47 -31
25 38
-9 -38
-38 46
-3 18
16 2
43 -34
-48 33
-32 15
22 -41
45 9
26 46
36 -41
0 46
7 18
11 -43
46 37
-4 25
-39 50
-16 13
-15 -18
-15 4
49 0
-40 -8
47 39
16 5
3 20
37 -14
-18 26
-24 -20
-32 -9
-26 6
-47 -41
-34 -47
-...

output:

50
199
386
546
686
812
893
948
990
1000
991
949
897
795
747
677
610
540
491
470
445
435
436
440
444
448
452
456
460
464
468
472
476
480
484
488
492
496
500
504
508
512
516
520
524
528
532
536
540
544

result:

ok 50 lines

Test #5:

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

input:

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

output:

5
18
34
46
56
68
80
92
104
116
128
140
152
164
176
188
183
176
184
192
200
208
216
224
232
240
248
256
264
242
218
222
226
230
234
238
242
246
250
254
258
262
266
270
274
278
282
286
290
294

result:

ok 50 lines

Test #6:

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

input:

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

output:

10
38
62
78
98
118
131
142
158
174
190
194
196
208
220
232
244
238
230
238
246
254
262
270
278
286
267
246
250
254
258
262
266
270
274
278
282
286
290
294
298
302
306
310
314
318
322
326
330
334

result:

ok 50 lines

Test #7:

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

input:

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

output:

20
76
130
164
190
210
220
222
232
248
253
244
242
250
258
266
274
282
290
298
306
314
299
282
286
290
294
298
302
306
310
314
318
322
326
330
334
338
342
346
350
354
358
362
366
370
374
378
382
386

result:

ok 50 lines

Test #8:

score: 0
Accepted
time: 172ms
memory: 56368kb

input:

10000 50
-45 40
-30 -11
38 33
-12 5
-11 -42
-34 -28
-10 -29
-45 42
-24 -37
-43 -4
42 48
-5 5
-5 -31
-22 -3
19 -37
-11 -50
-5 -35
24 18
37 -9
47 -3
-7 49
-25 -2
-46 -14
-11 -37
32 2
13 -42
19 -29
-4 -49
-16 -1
44 -29
3 34
-38 37
-46 21
-21 -7
-13 14
6 33
-6 -23
43 -50
-4 -43
-11 -31
39 -37
48 -10
47 ...

output:

10000
400
404
408
412
416
420
424
428
432
436
440
444
448
452
456
460
464
468
472
476
480
484
488
492
496
500
504
508
512
516
520
524
528
532
536
540
544
548
552
556
560
564
568
572
576
580
584
588
592

result:

ok 50 lines

Test #9:

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

input:

50 50
24 -31
2 48
37 2
-32 14
27 -7
1 16
-40 28
-7 18
-18 -3
-9 20
16 42
-47 -40
-4 32
-18 -31
44 19
-16 6
-15 10
22 47
-48 13
-32 -7
-9 -32
14 -33
-3 25
7 27
27 -40
-16 19
48 46
22 -27
-18 32
46 -34
-28 -30
46 -12
-18 -48
30 -25
-47 -30
16 15
40 48
48 -43
7 44
-32 17
36 -25
-40 -7
31 0
-48 34
32 43...

output:

50
200
392
570
736
861
905
939
962
969
935
896
798
729
668
610
575
558
539
510
491
483
476
476
476
476
476
476
476
476
476
478
482
486
490
494
498
502
506
510
514
518
522
526
530
534
538
542
546
550

result:

ok 50 lines

Test #10:

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

input:

50 50
-24 -28
-39 7
-28 39
4 47
0 -37
36 46
-36 10
-17 -38
-41 27
4 34
26 -10
-43 -7
17 -15
-47 5
40 25
49 48
-34 -25
-38 32
-19 11
21 16
-15 -48
-4 -49
12 18
-17 -45
22 43
32 30
-14 18
-22 20
47 -28
39 -42
-40 -46
-44 0
-24 13
41 -24
35 -44
-49 -46
34 -48
14 30
-14 24
2 -43
32 28
2 29
30 -24
-12 -6...

output:

50
199
396
564
697
801
858
885
917
874
871
817
759
716
678
648
615
593
572
545
491
470
441
441
442
446
450
454
458
460
464
468
472
476
480
484
488
492
496
500
504
508
512
516
520
524
528
532
536
540

result:

ok 50 lines

Test #11:

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

input:

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

output:

50
196
378
540
675
794
887
923
936
874
807
774
754
704
663
594
573
507
483
457
448
440
419
414
418
422
426
430
434
438
442
446
450
454
458
462
466
470
474
478
482
486
490
494
498
502
506
510
514
518

result:

ok 50 lines

Test #12:

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

input:

1000 50
7 -33
-11 16
15 47
48 -24
-43 43
22 47
-13 -9
-41 27
-1 -14
29 -16
-33 -30
-6 -26
33 20
34 20
-43 45
-3 -43
13 7
20 -48
-25 22
-11 -17
-28 45
4 33
-45 -38
-45 1
-47 30
43 17
11 -49
-2 -47
37 25
-16 10
-6 -38
-41 -30
5 -6
38 4
-32 -15
49 -1
-29 -20
-46 29
-30 11
-17 21
-40 -1
49 6
9 -29
-27 -...

output:

1000
3196
3556
2046
858
477
409
410
414
418
422
426
430
434
438
442
446
450
454
458
462
466
470
474
478
482
486
490
494
498
502
506
510
514
518
522
526
530
534
538
542
546
550
554
558
562
566
570
574
578

result:

ok 50 lines

Test #13:

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

input:

1000 50
20 4
32 9
14 -9
25 47
-28 -24
-3 7
31 -16
17 18
18 40
15 7
-28 -46
0 -16
-17 -11
-39 -37
8 -28
22 -35
24 32
-31 -17
4 -38
-40 -5
-20 4
23 -46
34 19
-14 -33
-38 13
-23 38
38 -42
-30 -6
-39 25
-41 -14
-14 -49
-38 -23
0 -25
-40 7
-49 -38
24 43
-49 -42
-13 19
-40 -44
14 12
25 -21
-19 -28
-17 30
...

output:

1000
3163
3468
2067
923
493
423
420
424
428
432
436
440
444
448
452
456
460
464
468
472
476
480
484
488
492
496
500
504
508
512
516
520
524
528
532
536
540
544
548
552
556
560
564
568
572
576
580
584
588

result:

ok 50 lines

Test #14:

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

input:

1000 50
-1 45
46 -35
-31 -24
-10 -42
-48 -4
-24 -3
-21 -8
29 5
-39 25
24 -22
-8 44
2 33
25 3
-33 -49
-29 -14
21 -10
-38 -17
-36 -49
-9 -33
-10 -27
17 -11
-25 -9
41 -12
-42 31
-36 45
3 12
-12 40
26 -18
-23 40
24 -20
30 13
13 -5
5 47
19 29
47 5
-4 -38
25 5
-36 42
-33 23
2 -14
37 -30
-49 -5
44 -6
26 20...

output:

1000
3225
3579
2015
813
459
413
415
418
422
426
430
434
438
442
446
450
454
458
462
466
470
474
478
482
486
490
494
498
502
506
510
514
518
522
526
530
534
538
542
546
550
554
558
562
566
570
574
578
582

result:

ok 50 lines

Test #15:

score: 0
Accepted
time: 18ms
memory: 7548kb

input:

1000 50
39 23
10 46
26 -1
-32 45
-36 46
-47 36
8 -47
-44 39
-37 -32
10 14
-14 47
-19 -1
0 -7
-14 -50
-12 -18
-43 41
-18 3
29 -1
37 30
-8 -32
-33 -26
18 19
13 -31
-13 16
-44 27
39 39
43 -37
39 22
33 -29
-9 16
-2 9
29 40
20 -44
-19 -2
15 34
32 -27
9 -18
24 -7
11 -45
-37 45
-48 -49
-15 38
4 -44
10 5
46...

output:

1000
3180
3486
2042
899
477
415
414
416
420
424
428
432
436
440
444
448
452
456
460
464
468
472
476
480
484
488
492
496
500
504
508
512
516
520
524
528
532
536
540
544
548
552
556
560
564
568
572
576
580

result:

ok 50 lines

Test #16:

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

input:

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

output:

1
4
8
12
16
20
24
28
32
36
40
44
48
52
56
60
64
68
72
76
80
84
88
92
96
100
104
108
112
116
120
124
128
132
136
140
144
148
152
156
160
164
168
172
176
180
184
188
192
196

result:

ok 50 lines

Test #17:

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

input:

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

output:

2
6
10
14
18
22
26
30
34
38
42
46
50
54
58
62
66
70
74
78
82
86
90
94
98
102
106
110
114
118
122
126
130
134
138
142
146
150
154
158
162
166
170
174
178
182
186
190
194
198

result:

ok 50 lines

Test #18:

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

input:

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

output:

2
8
12
16
20
24
28
32
36
40
44
48
52
56
60
64
68
72
76
80
84
88
92
96
100
104
108
112
116
120
124
128
132
136
140
144
148
152
156
160
164
168
172
176
180
184
188
192
196
200

result:

ok 50 lines

Test #19:

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

input:

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

output:

3
8
12
16
20
24
28
32
36
40
44
48
52
56
60
64
68
72
76
80
84
88
92
96
100
104
108
112
116
120
124
128
132
136
140
144
148
152
156
160
164
168
172
176
180
184
188
192
196
200

result:

ok 50 lines

Test #20:

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

input:

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

output:

3
10
15
18
22
26
30
34
38
42
46
50
54
58
62
66
70
74
78
82
86
90
94
98
102
106
110
114
118
122
126
130
134
138
142
146
150
154
158
162
166
170
174
178
182
186
190
194
198
202

result:

ok 50 lines

Test #21:

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

input:

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

output:

3
10
18
19
23
27
31
35
39
43
47
51
55
59
63
67
71
75
79
83
87
91
95
99
103
107
111
115
119
123
127
131
135
139
143
147
151
155
159
163
167
171
175
179
183
187
191
195
199
203

result:

ok 50 lines

Test #22:

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

input:

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

output:

4
12
17
20
24
28
32
36
40
44
48
52
56
60
64
68
72
76
80
84
88
92
96
100
104
108
112
116
120
124
128
132
136
140
144
148
152
156
160
164
168
172
176
180
184
188
192
196
200
204

result:

ok 50 lines

Test #23:

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

input:

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

output:

4
12
17
19
23
27
31
35
39
43
47
51
55
59
63
67
71
75
79
83
87
91
95
99
103
107
111
115
119
123
127
131
135
139
143
147
151
155
159
163
167
171
175
179
183
187
191
195
199
203

result:

ok 50 lines

Test #24:

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

input:

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

output:

4
12
17
20
24
28
32
36
40
44
48
52
56
60
64
68
72
76
80
84
88
92
96
100
104
108
112
116
120
124
128
132
136
140
144
148
152
156
160
164
168
172
176
180
184
188
192
196
200
204

result:

ok 50 lines

Test #25:

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

input:

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

output:

4
13
15
19
23
27
31
35
39
43
47
51
55
59
63
67
71
75
79
83
87
91
95
99
103
107
111
115
119
123
127
131
135
139
143
147
151
155
159
163
167
171
175
179
183
187
191
195
199
203

result:

ok 50 lines

Test #26:

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

input:

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

output:

9
17
19
23
27
31
35
39
43
47
51
55
59
63
67
71
75
79
83
87
91
95
99
103
107
111
115
119
123
127
131
135
139
143
147
151
155
159
163
167
171
175
179
183
187
191
195
199
203
207

result:

ok 50 lines

Test #27:

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

input:

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

output:

9
16
18
22
26
30
34
38
42
46
50
54
58
62
66
70
74
78
82
86
90
94
98
102
106
110
114
118
122
126
130
134
138
142
146
150
154
158
162
166
170
174
178
182
186
190
194
198
202
206

result:

ok 50 lines

Test #28:

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

input:

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

output:

9
16
17
21
25
29
33
37
41
45
49
53
57
61
65
69
73
77
81
85
89
93
97
101
105
109
113
117
121
125
129
133
137
141
145
149
153
157
161
165
169
173
177
181
185
189
193
197
201
205

result:

ok 50 lines

Subtask #2:

score: 12
Accepted

Dependency #1:

100%
Accepted

Test #29:

score: 12
Accepted
time: 1ms
memory: 3772kb

input:

11 1000
4 22
22 3
0 0
0 22
1 22
3 22
22 4
22 2
22 0
22 1
2 22
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82...

output:

11
28
40
52
64
76
88
100
112
124
136
146
148
148
152
156
160
164
155
146
150
154
158
162
166
170
174
178
182
186
190
194
198
202
206
210
214
218
222
226
230
234
238
242
246
250
254
258
262
266
270
274
278
282
286
290
294
298
302
306
310
314
318
322
326
330
334
338
342
346
350
354
358
362
366
370
374...

result:

ok 1000 lines

Test #30:

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

input:

101 1000
9 410
0 0
410 40
47 410
410 8
12 410
38 410
28 410
410 6
13 410
410 49
410 36
22 410
39 410
34 410
410 24
410 13
44 410
14 410
41 410
410 9
410 12
410 32
410 11
410 10
410 5
410 27
410 48
20 410
410 33
32 410
410 21
26 410
410 35
410 41
410 20
29 410
0 410
410 0
410 47
410 7
410 23
410 42
2...

output:

101
208
220
232
244
256
268
280
292
304
316
328
340
352
364
376
388
400
412
424
436
448
460
472
484
496
508
520
532
544
556
568
580
592
604
616
628
640
652
664
676
688
700
712
724
736
748
760
772
784
796
808
820
832
844
856
868
880
892
904
916
928
940
952
964
976
988
1000
1012
1024
1036
1048
1060
10...

result:

ok 1000 lines

Test #31:

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

input:

451 1000
900 51
45 900
11 900
900 145
128 900
900 107
117 900
190 900
93 900
900 126
120 900
900 133
900 98
210 900
900 157
88 900
900 208
132 900
900 197
900 143
222 900
900 71
900 80
197 900
175 900
103 900
900 189
58 900
68 900
8 900
98 900
900 105
71 900
27 900
56 900
900 221
28 900
900 147
900 ...

output:

451
908
920
932
944
956
968
980
992
1004
1016
1028
1040
1052
1064
1076
1088
1100
1112
1124
1136
1148
1160
1172
1184
1196
1208
1220
1232
1244
1256
1268
1280
1292
1304
1316
1328
1340
1352
1364
1376
1388
1400
1412
1424
1436
1448
1460
1472
1484
1496
1508
1520
1532
1544
1556
1568
1580
1592
1604
1616
1628...

result:

ok 1000 lines

Test #32:

score: 0
Accepted
time: 2576ms
memory: 422896kb

input:

100000 1000
-221 283
306 176
-31 295
-40 67
148 110
-13 83
-96 -103
-56 -21
291 156
201 -206
-162 -91
-300 50
114 -59
279 -48
-11 4
64 -177
-189 -477
-95 352
-362 -191
84 315
-352 -164
196 338
287 -204
-334 -191
264 289
19 -120
66 -221
241 -241
-70 8
-114 -264
-175 336
-207 -216
-345 -212
-191 17
-3...

output:

100000
293055
282990
154753
82591
49526
28558
15338
8300
5402
4434
4139
4047
4037
4041
4045
4049
4053
4057
4061
4065
4069
4073
4077
4081
4085
4089
4093
4097
4101
4105
4109
4113
4117
4121
4125
4129
4133
4137
4141
4145
4149
4153
4157
4161
4165
4169
4173
4177
4181
4185
4189
4193
4197
4201
4205
4209
421...

result:

ok 1000 lines

Test #33:

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

input:

10 1000
-455 -455
-489 -489
-208 -208
-129 -129
-408 -408
-284 -284
-493 -493
180 180
-91 -91
-126 -126
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68...

output:

10
40
80
116
145
174
206
238
270
302
334
366
398
430
462
494
526
558
590
622
654
686
718
750
782
814
846
878
910
942
974
1006
1038
1070
1067
1026
1016
1040
1064
1088
1112
1136
1160
1184
1208
1232
1256
1232
1206
1226
1246
1266
1286
1306
1326
1346
1366
1386
1406
1426
1446
1466
1486
1506
1526
1546
1566...

result:

ok 1000 lines

Test #34:

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

input:

100 1000
-443 -443
-341 -341
-209 -209
-166 -166
109 109
-203 -203
-131 -131
-438 -438
235 235
304 304
-328 -328
-22 -22
78 78
-174 -174
487 487
169 169
-185 -185
-76 -76
-382 -382
358 358
-163 -163
302 302
-332 -332
-159 -159
93 93
85 85
-257 -257
15 15
-116 -116
152 152
397 397
492 492
-312 -312
4...

output:

100
392
734
992
1211
1394
1539
1678
1789
1884
1986
2072
2105
2130
2161
2210
2264
2296
2337
2332
2275
2244
2222
2192
2152
2130
2127
2122
2142
2162
2182
2202
2222
2242
2262
2282
2302
2322
2342
2362
2341
2318
2334
2350
2321
2290
2302
2314
2326
2288
2248
2256
2264
2272
2280
2232
2182
2186
2190
2194
2198...

result:

ok 1000 lines

Test #35:

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

input:

1000 1000
-333 -333
-156 -156
202 202
377 377
2 2
-228 -228
-413 -413
219 219
-489 -489
-478 -478
-448 -448
-497 -497
157 157
28 28
142 142
437 437
-192 -192
-431 -431
-202 -202
-466 -466
209 209
-277 -277
-248 -248
-329 -329
-287 -287
29 29
227 227
400 400
-167 -167
326 326
-32 -32
305 305
-355 -35...

output:

1000
2002
2006
2010
2014
2018
2022
2026
2030
2034
2038
2042
2046
2050
2054
2058
2062
2066
2070
2074
2078
2082
2086
2090
2094
2098
2102
2106
2110
2114
2118
2122
2126
2130
2134
2138
2142
2146
2150
2154
2158
2162
2166
2170
2174
2178
2182
2186
2190
2194
2198
2202
2206
2210
2214
2218
2222
2226
2230
2234
...

result:

ok 1000 lines

Test #36:

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

input:

1 500
-2 0
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99...

output:

1
4
8
12
16
20
24
28
32
36
40
44
48
52
56
60
64
68
72
76
80
84
88
92
96
100
104
108
112
116
120
124
128
132
136
140
144
148
152
156
160
164
168
172
176
180
184
188
192
196
200
204
208
212
216
220
224
228
232
236
240
244
248
252
256
260
264
268
272
276
280
284
288
292
296
300
304
308
312
316
320
324
...

result:

ok 500 lines

Test #37:

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

input:

2 500
0 0
0 1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98...

output:

2
6
10
14
18
22
26
30
34
38
42
46
50
54
58
62
66
70
74
78
82
86
90
94
98
102
106
110
114
118
122
126
130
134
138
142
146
150
154
158
162
166
170
174
178
182
186
190
194
198
202
206
210
214
218
222
226
230
234
238
242
246
250
254
258
262
266
270
274
278
282
286
290
294
298
302
306
310
314
318
322
326...

result:

ok 500 lines

Test #38:

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

input:

1000 1000
-500 -213
46 -115
496 85
-438 -7
123 -279
465 80
-61 -492
-56 -162
486 17
311 373
-406 -35
100 -433
-171 -482
-483 488
-98 -497
95 -181
-42 110
95 -94
-256 336
312 -176
-79 -162
282 114
-160 57
-131 -23
102 -7
243 -256
-303 240
179 92
-171 -30
-356 -49
459 -363
387 -44
327 -358
-22 153
-34...

output:

1000
3994
7947
11807
15505
19010
22322
25369
28064
30387
32397
33989
35442
36638
37528
37873
37959
37692
37452
36911
36276
34942
33676
32323
31037
29689
28109
26735
25349
23835
22349
20861
19372
18119
16788
15595
14535
13431
12672
11632
10724
9728
8987
8323
7764
7189
6835
6438
6119
5920
5668
5447
52...

result:

ok 1000 lines

Test #39:

score: 0
Accepted
time: 193ms
memory: 55488kb

input:

10000 1000
-314 -330
341 210
167 -86
302 -381
-288 447
-490 -110
40 219
-248 -60
-420 -263
395 45
-493 418
180 -498
375 -69
-234 8
-364 -451
-159 -415
-187 -89
379 315
59 204
213 70
222 -475
-251 135
-31 293
-238 154
399 -321
-325 -332
-475 469
-123 273
-62 -500
-160 369
-282 217
254 413
-353 -289
-...

output:

10000
39083
73626
99866
115631
120727
116579
105554
90088
72869
56284
41761
30065
21254
14658
10323
7743
5955
5007
4477
4256
4180
4120
4110
4100
4091
4091
4085
4071
4075
4079
4083
4087
4091
4095
4099
4103
4107
4111
4115
4119
4123
4127
4131
4135
4139
4143
4147
4151
4155
4159
4163
4167
4171
4175
4179
...

result:

ok 1000 lines

Test #40:

score: 0
Accepted
time: 2585ms
memory: 422060kb

input:

100000 1000
1 299
475 -36
169 -311
486 33
230 459
328 252
473 76
-453 -175
114 -191
-125 -283
-165 -15
114 -132
-211 402
-123 306
-259 -223
-357 253
-369 -256
70 -349
345 100
-314 278
341 495
368 328
439 398
-267 -459
-20 238
-353 163
228 -211
-108 328
-123 -455
184 19
-147 431
93 135
-243 -476
-316...

output:

100000
316346
341662
180413
57639
14079
5192
4133
4023
4020
4024
4028
4032
4036
4040
4044
4048
4052
4056
4060
4064
4068
4072
4076
4080
4084
4088
4092
4096
4100
4104
4108
4112
4116
4120
4124
4128
4132
4136
4140
4144
4148
4152
4156
4160
4164
4168
4172
4176
4180
4184
4188
4192
4196
4200
4204
4208
4212
...

result:

ok 1000 lines

Subtask #3:

score: 8
Accepted

Test #41:

score: 8
Accepted
time: 2811ms
memory: 690796kb

input:

100000 1
-985257637 -985257637
250450772 250450772
-543941233 -543941233
-420211066 -420211066
-451295860 -451295860
-64287093 -64287093
-162021978 -162021978
-107854341 -107854341
-897471581 -897471581
-237154896 -237154896
177689343 177689343
210408814 210408814
532550488 532550488
-649837500 -649...

output:

983477794

result:

ok single line: '983477794'

Test #42:

score: 0
Accepted
time: 2858ms
memory: 690480kb

input:

100000 1
540127374 540127374
-460127033 -460127033
647168037 647168037
-850573762 -850573762
983611113 983611113
452354365 452354365
-687026276 -687026276
881509891 881509891
-948950382 -948950382
358745459 358745459
-672684782 -672684782
-466435349 -466435349
559530363 559530363
-768397316 -7683973...

output:

817536751

result:

ok single line: '817536751'

Test #43:

score: 0
Accepted
time: 2908ms
memory: 690924kb

input:

100000 1
1135816 1135816
-63822172 -63822172
-116739767 -116739767
417929951 417929951
117796579 117796579
934311782 934311782
578434172 578434172
362124243 362124243
-744012855 -744012855
343158136 343158136
-788436402 -788436402
-226925652 -226925652
-5753826 -5753826
523629632 523629632
-88357255...

output:

2697435596

result:

ok single line: '2697435596'

Test #44:

score: 0
Accepted
time: 2890ms
memory: 689388kb

input:

100000 1
781752624 781752624
-154186918 -154186918
295878677 295878677
-571299897 -571299897
-577140323 -577140323
115226843 115226843
-895470427 -895470427
-615635383 -615635383
88501696 88501696
-818891968 -818891968
-672871643 -672871643
532896176 532896176
482820258 482820258
-628632591 -6286325...

output:

4506437926

result:

ok single line: '4506437926'

Test #45:

score: 0
Accepted
time: 2967ms
memory: 690796kb

input:

100000 1
-303593636 -303593636
-608115879 -608115879
-307900177 -307900177
-68679671 -68679671
809519659 809519659
582824766 582824766
-916467225 -916467225
-581052741 -581052741
-135610196 -135610196
-75067680 -75067680
885968673 885968673
-606830844 -606830844
-209434173 -209434173
-797583600 -797...

output:

3346435555

result:

ok single line: '3346435555'

Test #46:

score: 0
Accepted
time: 3002ms
memory: 691232kb

input:

100000 1
-169895779 -169895779
-45855071 -45855071
-435953902 -435953902
564510600 564510600
804648498 804648498
364826048 364826048
581144182 581144182
-489224332 -489224332
-35320030 -35320030
-699270775 -699270775
418356827 418356827
-542108334 -542108334
368787388 368787388
-396708127 -396708127...

output:

4024482078

result:

ok single line: '4024482078'

Test #47:

score: 0
Accepted
time: 2869ms
memory: 691408kb

input:

100000 1
614282014 614282014
184147499 184147499
766282057 766282057
799098933 799098933
119967303 119967303
950196990 950196990
924689529 924689529
-65493033 -65493033
-2514002 -2514002
92605485 92605485
-79345735 -79345735
517701077 517701077
337866429 337866429
366630013 366630013
92354783 923547...

output:

1819938610

result:

ok single line: '1819938610'

Test #48:

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

input:

1 1
0 0
0

output:

1

result:

ok single line: '1'

Test #49:

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

input:

2 1
0 0
1 1
0

output:

2

result:

ok single line: '2'

Test #50:

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

input:

1000 1
587696818 587696818
-270061954 -270061954
49213442 49213442
-101306304 -101306304
-272356521 -272356521
979453098 979453098
-465521327 -465521327
327236253 327236253
-444251960 -444251960
-183163578 -183163578
-993635493 -993635493
-915438528 -915438528
-903654735 -903654735
-975079427 -97507...

output:

4383685522

result:

ok single line: '4383685522'

Test #51:

score: 0
Accepted
time: 2777ms
memory: 689008kb

input:

100000 1
456288537 456288537
87023566 87023566
86662961 86662961
357710020 357710020
664907723 664907723
-132014351 -132014351
871430047 871430047
-838530865 -838530865
812562155 812562155
-811800697 -811800697
-2388954 -2388954
681791054 681791054
-589099932 -589099932
855077689 855077689
743905460...

output:

6402331592

result:

ok single line: '6402331592'

Subtask #4:

score: 8
Accepted

Dependency #3:

100%
Accepted

Test #52:

score: 8
Accepted
time: 2911ms
memory: 702160kb

input:

100000 500000
-296928757 -296928757
137304676 137304676
-704561834 -704561834
122323264 122323264
-608117668 -608117668
293347830 293347830
399961656 399961656
796881101 796881101
-857588453 -857588453
-936808333 -936808333
-158746539 -158746539
292296512 292296512
-751340241 -751340241
366428744 36...

output:

100000
399996
799973
1199932
1599867
1999760
2399621
2799464
3199279
3599058
3998829
4398610
4798349
5198000
5597572
5997116
6396633
6796094
7195551
7594950
7994376
8393744
8793017
9192388
9591783
9991134
10390465
10789718
11188889
11588026
11987162
12386234
12785111
13184112
13583108
13981936
14380...

result:

ok 500000 lines

Test #53:

score: 0
Accepted
time: 2910ms
memory: 702360kb

input:

100000 500000
-577562445 -577562445
432221186 432221186
-18051978 -18051978
860945592 860945592
-421673809 -421673809
-855530900 -855530900
-581209877 -581209877
-191021169 -191021169
634526654 634526654
755988288 755988288
-448560453 -448560453
946031778 946031778
-29393810 -29393810
-772308031 -77...

output:

100000
399996
799967
1199912
1599833
1999714
2399563
2799362
3199116
3598846
3998529
4398174
4797831
5197486
5597121
5996766
6396344
6795848
7195337
7594856
7994309
8393696
8793162
9192680
9592038
9991246
10390437
10789674
11188935
11588144
11987294
12386416
12785539
13184568
13583530
13982456
14381...

result:

ok 500000 lines

Test #54:

score: 0
Accepted
time: 2912ms
memory: 703020kb

input:

100000 500000
-818419396 -818419396
395381559 395381559
-118999836 -118999836
-339741650 -339741650
-320368360 -320368360
1823784 1823784
930423461 930423461
-908154905 -908154905
-121798369 -121798369
-370651741 -370651741
-653571100 -653571100
705966169 705966169
678597681 678597681
541325963 5413...

output:

100000
399998
799982
1199922
1599823
1999720
2399600
2799424
3199236
3599036
3998763
4398468
4798202
5197888
5597524
5997112
6396619
6796138
7195640
7595054
7994388
8393744
8793152
9192440
9591771
9991120
10390291
10789480
11188546
11587576
11986713
12385696
12784610
13183548
13582485
13981532
14380...

result:

ok 500000 lines

Test #55:

score: 0
Accepted
time: 2958ms
memory: 701888kb

input:

100000 500000
329556408 329556408
691436671 691436671
141404272 141404272
517594412 517594412
57391284 57391284
842671193 842671193
521900076 521900076
-918869143 -918869143
741684555 741684555
744805342 744805342
919015085 919015085
111338952 111338952
-978103921 -978103921
515699418 515699418
5142...

output:

100000
399994
799976
1199934
1599844
1999724
2399543
2799316
3199071
3598802
3998541
4398246
4797929
5197586
5597191
5996734
6396294
6795822
7195195
7594542
7993841
8393098
8792399
9191714
9591051
9990210
10389202
10788334
11187660
11586824
11985941
12385088
12783988
13182780
13581664
13980688
14379...

result:

ok 500000 lines

Test #56:

score: 0
Accepted
time: 45ms
memory: 34520kb

input:

1 500000
-1 -1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
9...

output:

1
4
8
12
16
20
24
28
32
36
40
44
48
52
56
60
64
68
72
76
80
84
88
92
96
100
104
108
112
116
120
124
128
132
136
140
144
148
152
156
160
164
168
172
176
180
184
188
192
196
200
204
208
212
216
220
224
228
232
236
240
244
248
252
256
260
264
268
272
276
280
284
288
292
296
300
304
308
312
316
320
324
...

result:

ok 500000 lines

Test #57:

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

input:

2 500000
-2 -2
-1 -1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
9...

output:

2
6
10
14
18
22
26
30
34
38
42
46
50
54
58
62
66
70
74
78
82
86
90
94
98
102
106
110
114
118
122
126
130
134
138
142
146
150
154
158
162
166
170
174
178
182
186
190
194
198
202
206
210
214
218
222
226
230
234
238
242
246
250
254
258
262
266
270
274
278
282
286
290
294
298
302
306
310
314
318
322
326...

result:

ok 500000 lines

Test #58:

score: 0
Accepted
time: 74ms
memory: 35176kb

input:

100 500000
-416336896 -416336896
-820953094 -820953094
326507542 326507542
-752483073 -752483073
952616161 952616161
-761379382 -761379382
-125266836 -125266836
-734529253 -734529253
933570662 933570662
-142448271 -142448271
238795253 238795253
-530744105 -530744105
-57671877 -57671877
943013248 943...

output:

819600
821200
969600
1076800
1855200
2368800
2433200
5532400
6472400
7352400
7958000
8394800
8955600
10444000
11244800
11548400
12115200
12993200
13968400
14439200
15151200
15813600
15833200
17932000
18956400
19315600
20352000
20866400
21162000
21524800
21568800
23595200
25314400
25903200
26522400
2...

result:

ok 500000 lines

Test #59:

score: 0
Accepted
time: 2964ms
memory: 702628kb

input:

100000 500000
-810801604 -810801604
491840632 491840632
660057216 660057216
119399125 119399125
859952980 859952980
785329307 785329307
685200099 685200099
106460319 106460319
-451654766 -451654766
-715428846 -715428846
-188051431 -188051431
-357753813 -357753813
193681291 193681291
983262276 983262...

output:

368252172
1003192202
1298171618
1331661464
2259290668
2781889162
3157476926
3253645466
3293708664
3497913194
3599829927
3690529462
4082930968
4321962358
4368149240
4407031032
4435521222
4485220662
4545770814
4536272488
4531227462
4515760710
4515954920
4508184158
4403329480
4403200096
4402462720
4393...

result:

ok 500000 lines

Subtask #5:

score: 17
Accepted

Test #60:

score: 17
Accepted
time: 30ms
memory: 11860kb

input:

1999 1
947 3000
3000 409
3000 133
3000 700
479 3000
3000 794
3000 177
888 3000
484 3000
224 3000
619 3000
983 3000
3000 536
56 3000
3000 609
3000 873
26 3000
3000 582
3000 668
3000 826
3000 827
3000 817
3000 398
3000 202
3000 216
939 3000
594 3000
3000 269
3000 276
866 3000
862 3000
794 3000
3000 64...

output:

2988965670

result:

ok single line: '2988965670'

Test #61:

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

input:

1999 1
8010 751
566 8010
8010 629
974 8010
576 8010
4 8010
8010 642
370 8010
517 8010
447 8010
8010 303
8010 711
8010 589
713 8010
59 8010
758 8010
224 8010
378 8010
983 8010
432 8010
8010 275
46 8010
475 8010
375 8010
635 8010
8010 624
560 8010
8010 984
8010 206
714 8010
135 8010
8010 504
230 8010
...

output:

2290225892

result:

ok single line: '2290225892'

Test #62:

score: 0
Accepted
time: 43ms
memory: 12672kb

input:

2000 1
-970402683 -925617533
56203728 -874876348
-989595969 -787319656
-808848552 68537404
-915872908 290863298
995910854 954899695
-143839356 377316732
398835901 -73865775
-609453191 -607781006
-800118864 236088763
644337253 668405024
-404162908 19296303
-360464457 918907552
59228688 -678690164
-42...

output:

8869990280

result:

ok single line: '8869990280'

Test #63:

score: 0
Accepted
time: 44ms
memory: 12284kb

input:

2000 1
729728810 -912297277
903300903 8269508
5051280 -706654804
-869642040 -808982040
22667879 -545758175
-840335114 268559027
37806441 -466917575
-866305134 126166096
-414003449 405394761
414614320 375869564
-972791638 884792620
-965965530 -934866153
955363997 -348593145
-388907837 -335673673
-707...

output:

10716300192

result:

ok single line: '10716300192'

Subtask #6:

score: 25
Accepted

Dependency #5:

100%
Accepted

Test #64:

score: 25
Accepted
time: 101ms
memory: 39784kb

input:

1999 500000
879 3000
901 3000
3000 143
3000 590
706 3000
795 3000
696 3000
802 3000
168 3000
299 3000
3000 877
55 3000
37 3000
315 3000
285 3000
3000 125
3000 466
3000 814
3000 334
3000 840
868 3000
3000 606
3000 354
3000 955
136 3000
409 3000
543 3000
3000 214
3000 808
3000 500
974 3000
232 3000
30...

output:

1999
4004
4016
4028
4040
4052
4064
4076
4088
4100
4112
4124
4136
4148
4160
4172
4184
4196
4208
4220
4232
4244
4256
4268
4280
4292
4304
4316
4328
4340
4352
4364
4376
4388
4400
4412
4424
4436
4448
4460
4472
4484
4496
4508
4520
4532
4544
4556
4568
4580
4592
4604
4616
4628
4640
4652
4664
4676
4688
4700
...

result:

ok 500000 lines

Test #65:

score: 0
Accepted
time: 99ms
memory: 39668kb

input:

1999 500000
8010 288
979 8010
8010 903
8010 13
8010 270
8010 967
8010 51
216 8010
236 8010
8010 428
8010 119
8010 871
8010 901
8010 756
8010 522
8010 785
936 8010
8010 358
8010 53
362 8010
8010 513
8010 315
165 8010
8010 512
583 8010
8010 581
8010 866
8010 696
8010 492
966 8010
359 8010
8010 931
801...

output:

1999
4004
4016
4028
4040
4052
4064
4076
4088
4100
4112
4124
4136
4148
4160
4172
4184
4196
4208
4220
4232
4244
4256
4268
4280
4292
4304
4316
4328
4340
4352
4364
4376
4388
4400
4412
4424
4436
4448
4460
4472
4484
4496
4508
4520
4532
4544
4556
4568
4580
4592
4604
4616
4628
4640
4652
4664
4676
4688
4700
...

result:

ok 500000 lines

Test #66:

score: 0
Accepted
time: 99ms
memory: 39772kb

input:

2000 500000
-9 2
39 -20
-901123908 -439261380
-49 -1
-20 19
-29 41
26 -45
-398614111 174786844
257813350 46942931
-941195084 679568710
9 14
989402333 -373917361
18 19
-366224660 -827532852
-266752 -709720333
4 44
7 32
582160253 -142758533
-24 14
25584214 -422275183
527589987 298583192
20 -1
-7117186...

output:

2000
6442
8533
9359
11222
13765
16430
19106
21782
24458
27134
29810
32486
35162
37838
40514
43190
45866
48542
51218
53894
56570
59246
61922
64598
67274
69950
72626
75302
77978
80654
83330
86006
88682
91358
94034
96710
99386
102062
104738
107414
110090
112766
115442
118118
120794
123470
126146
128822...

result:

ok 500000 lines

Test #67:

score: 0
Accepted
time: 106ms
memory: 39628kb

input:

2000 500000
-866293418 53069574
-36 -93
-2 36
61 -55
-43834836 -687931743
-164479421 621350691
-89 48
995576571 784482404
-377769007 -78774129
-88 -10
-296174379 -721607085
-27 -54
-384911586 279820574
11 96
70 -36
398553534 -981617391
-5 87
182199308 777650142
-54 -81
-25 94
-126926143 775442978
25...

output:

2000
7619
13591
16862
18057
18419
19135
20596
22634
25022
27594
30226
32884
35555
38231
40907
43583
46259
48935
51611
54287
56963
59639
62315
64991
67667
70343
73019
75695
78371
81047
83723
86399
89075
91751
94427
97103
99779
102455
105131
107807
110483
113159
115835
118511
121187
123863
126539
1292...

result:

ok 500000 lines

Test #68:

score: 0
Accepted
time: 110ms
memory: 39744kb

input:

2000 500000
560421428 43270570
-209 -4
458506910 -994607668
883177763 -482286916
-66351534 -501600714
130 -295
-61 164
105 105
159 -154
-776138695 -503527301
299402280 -325189478
227 226
288 -61
-164077303 679327737
84859674 -390283420
21 207
-55 149
97 -185
972097475 155415741
-126 -61
150 -223
-51...

output:

2000
7933
15603
22856
29516
35428
40545
44894
48277
50771
52706
54205
55243
55739
56193
56553
57052
57584
58304
59525
60781
62357
64018
65914
68009
70266
72634
75134
77605
80131
82767
85399
88011
90670
93327
95997
98673
101349
104025
106701
109377
112051
114726
117402
120078
122754
125430
128106
130...

result:

ok 500000 lines

Test #69:

score: 0
Accepted
time: 106ms
memory: 39780kb

input:

2000 500000
750 -485
849199419 -819785484
-623 -222
998 -323
-497 996
-451417087 -991201650
-27 -882
357 390
741089883 348625091
-546247122 712339967
-359 -746
852680942 94471832
763226775 -419103066
525 -456
-975 505
-185708153 406988538
845 306
80596637 661675735
-812596213 -704325543
-840 -766
-8...

output:

2000
7992
15952
23873
31750
39490
47174
54748
62209
69491
76675
83559
90302
96872
103281
109457
115201
120716
125811
130891
135453
139885
144273
148251
152163
155673
158842
161626
164386
166686
168686
170538
172434
173842
175941
176905
177906
179032
180389
181360
182005
182794
183861
184309
184628
1...

result:

ok 500000 lines

Test #70:

score: 0
Accepted
time: 125ms
memory: 39988kb

input:

2000 500000
-939248571 352377512
-269799670 -446139385
-522107019 -931100
865047130 -307047213
-395078532 153280335
98863801 355223785
-417476170 -168194704
-5030325 -369713336
343386217 856161755
-518029418 -573110595
694816589 547068006
431692727 -496281731
-353706570 -323665138
624822537 76795680...

output:

12504000
27624000
42576000
49704000
52128000
61872000
67928000
72064000
87736000
92552000
114992000
124856000
131872000
134064000
149010044
165137976
169016036
243722664
250951048
268550244
279704664
297471776
316918048
319260876
340202400
356290352
357897548
367740624
381293844
404338316
413373796
...

result:

ok 500000 lines

Test #71:

score: 0
Accepted
time: 114ms
memory: 39732kb

input:

2000 500000
-334147022 306740615
-237418960 -908210803
56954118 -161785665
586996718 249039545
-938996472 217224782
230967598 -814413263
599983806 532667358
-923087251 376713586
448459743 925554759
-782498160 -868532962
-894504684 905646041
723710705 -876830278
-220900129 942962193
-871202770 138999...

output:

3512000
9184000
33096000
72608000
97872000
105760000
135464000
145752000
161728000
234832000
259424000
275112000
280480000
293784000
311360000
311496000
338104000
341288000
349664000
377504000
391464000
423280000
424352000
437536000
457784000
458488000
494744000
515096000
522952000
537632000
5527520...

result:

ok 500000 lines

Subtask #7:

score: 26
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Test #72:

score: 26
Accepted
time: 2289ms
memory: 433420kb

input:

99999 500000
100000 30283
44713 100000
4375 100000
100000 48812
100000 1611
100000 38573
100000 4033
40902 100000
100000 18271
40422 100000
19540 100000
29707 100000
100000 27096
100000 16933
100000 34521
31704 100000
100000 16480
100000 19681
100000 14061
100000 2280
100000 24075
4295 100000
20818 ...

output:

99999
200004
200016
200028
200040
200052
200064
200076
200088
200100
200112
200124
200136
200148
200160
200172
200184
200196
200208
200220
200232
200244
200256
200268
200280
200292
200304
200316
200328
200340
200352
200364
200376
200388
200400
200412
200424
200436
200448
200460
200472
200484
200496
...

result:

ok 500000 lines

Test #73:

score: 0
Accepted
time: 2272ms
memory: 432424kb

input:

99999 500000
21158 200000
40519 200000
7695 200000
23785 200000
6205 200000
200000 25457
200000 23757
200000 392
28207 200000
200000 11866
200000 34885
200000 28218
8870 200000
200000 34104
2812 200000
9753 200000
200000 6724
200000 3495
14762 200000
48611 200000
9733 200000
200000 19632
200000 3403...

output:

99999
200004
200016
200028
200040
200052
200064
200076
200088
200100
200112
200124
200136
200148
200160
200172
200184
200196
200208
200220
200232
200244
200256
200268
200280
200292
200304
200316
200328
200340
200352
200364
200376
200388
200400
200412
200424
200436
200448
200460
200472
200484
200496
...

result:

ok 500000 lines

Test #74:

score: 0
Accepted
time: 2279ms
memory: 433120kb

input:

99999 500000
12808 300000
33139 300000
300000 2571
300000 1373
300000 9525
22344 300000
5044 300000
34787 300000
300000 7594
300000 42320
43434 300000
300000 40602
300000 25710
14667 300000
4946 300000
300000 12726
300000 48822
300000 42850
37822 300000
300000 26991
31420 300000
27861 300000
300000 ...

output:

99999
200004
200016
200028
200040
200052
200064
200076
200088
200100
200112
200124
200136
200148
200160
200172
200184
200196
200208
200220
200232
200244
200256
200268
200280
200292
200304
200316
200328
200340
200352
200364
200376
200388
200400
200412
200424
200436
200448
200460
200472
200484
200496
...

result:

ok 500000 lines

Test #75:

score: 0
Accepted
time: 2186ms
memory: 431456kb

input:

99999 500000
400100 41639
400100 22398
400100 6529
6329 400100
400100 44064
47903 400100
400100 45664
400100 45354
400100 19031
33481 400100
400100 39189
45448 400100
21362 400100
400100 40868
400100 30641
400100 17578
14018 400100
21574 400100
400100 23003
6955 400100
400100 9701
400100 46505
19381...

output:

99999
200004
200016
200028
200040
200052
200064
200076
200088
200100
200112
200124
200136
200148
200160
200172
200184
200196
200208
200220
200232
200244
200256
200268
200280
200292
200304
200316
200328
200340
200352
200364
200376
200388
200400
200412
200424
200436
200448
200460
200472
200484
200496
...

result:

ok 500000 lines

Test #76:

score: 0
Accepted
time: 2855ms
memory: 442160kb

input:

100000 500000
-47 -271
-93 -140
-523473742 -665908524
196 -89
565668511 425273987
248066304 -441103887
202011936 375288059
-757887511 141179039
200 55
-136 -292
-10 287
623681052 -122607059
207 212
-212 -112
67 -186
-296 39
16 -198
169 -132
161 15
-754177999 -181504608
268602903 110869993
-125 -110
...

output:

100000
295127
353320
414870
536282
668987
802321
935661
1069001
1202341
1335681
1469021
1602361
1735701
1869041
2002381
2135721
2269061
2402401
2535741
2669081
2802421
2935761
3069101
3202441
3335781
3469121
3602461
3735801
3869141
4002481
4135821
4269161
4402501
4535841
4669181
4802521
4935861
5069...

result:

ok 500000 lines

Test #77:

score: 0
Accepted
time: 2888ms
memory: 470596kb

input:

100000 500000
-220536316 340096658
-421 -322
-216 348
-643408121 692041006
231 -70
-131635637 -519273646
-996316191 132243926
24 -262
340 125
320 434
-254 238
915068034 -142484657
-428 312
-332 -236
-272 -36
451 -453
490970492 -510152256
-708552978 962491264
377 277
336 -192
298 -148
366 -58
-417 16...

output:

100000
360836
566118
621262
643072
706704
812929
938930
1070820
1203989
1337318
1470657
1603997
1737337
1870677
2004017
2137357
2270697
2404037
2537377
2670717
2804057
2937397
3070737
3204077
3337417
3470757
3604097
3737437
3870777
4004117
4137457
4270797
4404137
4537477
4670817
4804157
4937497
5070...

result:

ok 500000 lines

Test #78:

score: 0
Accepted
time: 2839ms
memory: 471352kb

input:

100000 500000
623945776 91968063
-323 -802
742 129
817 -242
864 -698
-220 -96
-571 846
85827529 804119228
-843 -710
-772 616
-83 -100
335 472
479 -316
810 -481
-643 -226
143810258 -141249117
885 967
-166239314 -650643305
504 -838
15 -487
-948607839 -40880394
614 -678
-305 -788
511027572 462315443
82...

output:

100000
389980
731139
988774
1152222
1237370
1273231
1290963
1315358
1360397
1430437
1522739
1632034
1752697
1879619
2010012
2142078
2274896
2408073
2541383
2674713
2808051
2941391
3074731
3208071
3341411
3474751
3608091
3741431
3874771
4008111
4141451
4274791
4408131
4541471
4674811
4808151
4941491
...

result:

ok 500000 lines

Test #79:

score: 0
Accepted
time: 2859ms
memory: 471356kb

input:

100000 500000
537218416 144360490
2566 1878
1379 -47
-4128828 -761551298
-598803466 -424439163
-1140 -1063
219 332
-2366 1519
-1626 -906
-1531 -170
1853 -295
-2470 1728
466030020 669929891
959264839 -70955657
1914 2509
393773996 785115553
2585 -1177
249852595 -944191369
699 1000
2864 2915
-415 301
7...

output:

100000
398920
792098
1173631
1538663
1882093
2199966
2490382
2751652
2980061
3178388
3345222
3482804
3593667
3680333
3744895
3792775
3825761
3851005
3868595
3884481
3901581
3918523
3941281
3968062
4002355
4045290
4097025
4156192
4224331
4300258
4385518
4476647
4574611
4678593
4787569
4900625
5017633...

result:

ok 500000 lines

Test #80:

score: 0
Accepted
time: 3370ms
memory: 472304kb

input:

100000 500000
717734231 606424044
652187227 337394018
23548638 -245182013
-578822750 -44750905
-949802888 -207670127
-13774251 223896160
-518438777 -783504463
44946448 -576822777
-828741315 -94566691
-604793166 569797235
-963840867 502051661
-663794647 836926768
477012841 17038450
-818303956 -591177...

output:

1718400000
1944400000
3136800000
3190800000
3924000000
5587200000
7881518234
8395502814
9067482654
9755020024
11234911836
11672885556
11709683348
11978415734
12055610330
12563921104
15178008056
15432382616
15543571496
15694756376
16244275646
17317357594
18118683802
18249864122
18642544800
1957437704...

result:

ok 500000 lines

Test #81:

score: 0
Accepted
time: 3381ms
memory: 474412kb

input:

100000 500000
-209533926 52979168
733394994 -511018313
282134223 212981136
579277022 14887319
520929802 794993321
-713226988 833846075
-388643658 -849591732
-977696606 -360287344
18647268 -522006122
129729889 215514048
-98438754 -318826492
-26458348 -101966278
185570344 432054190
-984743162 -6090039...

output:

77200000
1314000000
1737600000
1959992172
4406342538
5041529834
5149127682
5343523794
6073466618
6202661450
6393053834
6538248026
6591845882
7943343228
10945295162
11099275142
11545617110
11694366230
11933932686
12680553720
14800033744
15340241154
15597387142
16899745320
17439452116
18593014366
1903...

result:

ok 500000 lines

Extra Test:

score: 0
Extra Test Passed