QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302894#5052. Rectangle Flip 2ucup-team1005#AC ✓578ms7156kbC++201.3kb2024-01-11 14:57:422024-01-11 14:57:42

详细

Test #1:

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

input:

2 2
1 1
2 1
1 2
2 2

output:

5
3
1
0

result:

ok 4 number(s): "5 3 1 0"

Test #2:

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

input:

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

output:

153
125
93
84
70
65
60
54
45
42
38
31
26
24
21
18
14
13
10
8
6
4
2
1
0

result:

ok 25 numbers

Test #3:

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

input:

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

output:

685
573
403
378
314
299
243
201
193
189
181
163
156
148
137
133
123
115
97
83
77
68
62
56
52
50
48
45
39
37
35
32
30
27
26
24
22
21
20
18
14
13
11
7
6
4
3
2
1
0

result:

ok 50 numbers

Test #4:

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

input:

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

output:

585
445
375
349
319
259
247
235
229
202
184
160
152
147
142
132
127
118
92
89
85
78
73
62
54
50
49
45
41
35
32
31
29
27
26
25
20
16
14
12
10
9
7
6
5
4
3
2
1
0

result:

ok 50 numbers

Test #5:

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

input:

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

output:

2593
2173
2050
1540
1432
1404
1355
1271
1264
1214
1034
926
856
835
755
642
621
615
585
575
555
546
466
445
439
423
404
378
364
350
334
311
302
277
240
227
217
213
210
208
199
195
178
176
172
164
156
154
146
134
125
119
116
113
109
103
99
98
95
92
89
87
75
72
71
70
66
64
58
56
53
52
49
47
45
44
40
39...

result:

ok 100 numbers

Test #6:

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

input:

100 100
43 16
47 31
27 79
87 19
43 50
97 58
45 17
99 82
98 16
74 55
62 50
5 4
94 57
56 68
33 19
82 56
43 72
78 36
83 75
82 28
15 27
98 48
89 17
47 68
91 59
54 87
48 32
64 2
60 29
28 68
85 3
99 98
48 79
66 78
53 43
74 58
13 23
64 56
39 4
1 14
47 52
45 99
86 11
68 26
49 18
48 28
87 66
64 58
32 41
84 9...

output:

22110660
19203840
16763688
15856768
13998730
13571914
13518088
13444938
13415162
11803888
11206816
11126216
10988540
10071534
9640344
9425930
9124064
8731358
8438278
8317477
7762957
7735682
7702672
7630852
7562624
7150786
7086362
6999944
6822971
6576482
6546644
6538760
6461388
6285324
6061916
601869...

result:

ok 10000 numbers

Test #7:

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

input:

1 100
1 60
1 76
1 89
1 77
1 41
1 81
1 42
1 49
1 39
1 37
1 48
1 56
1 26
1 38
1 85
1 50
1 40
1 13
1 20
1 24
1 79
1 21
1 22
1 9
1 92
1 11
1 45
1 58
1 55
1 62
1 69
1 82
1 97
1 67
1 18
1 32
1 88
1 84
1 19
1 96
1 7
1 36
1 83
1 95
1 52
1 98
1 44
1 53
1 12
1 75
1 90
1 87
1 28
1 3
1 1
1 6
1 15
1 65
1 68
1 94...

output:

2590
2190
2034
2022
1243
1211
1193
1116
1038
964
958
930
644
643
627
621
620
451
409
401
397
394
392
356
329
325
316
312
307
279
230
227
207
197
187
157
154
152
151
147
133
129
128
125
119
116
114
112
111
105
103
101
93
81
79
76
70
64
63
61
57
55
54
52
50
49
48
40
37
36
35
34
31
29
28
26
24
23
22
21...

result:

ok 100 numbers

Test #8:

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

input:

100 1
78 1
52 1
95 1
76 1
96 1
49 1
53 1
59 1
77 1
100 1
64 1
11 1
9 1
48 1
15 1
17 1
44 1
46 1
21 1
54 1
39 1
68 1
43 1
4 1
32 1
28 1
73 1
6 1
16 1
62 1
72 1
84 1
65 1
86 1
98 1
75 1
33 1
45 1
25 1
3 1
91 1
82 1
2 1
92 1
63 1
88 1
7 1
50 1
97 1
93 1
14 1
22 1
20 1
42 1
60 1
55 1
80 1
85 1
29 1
34 1...

output:

3256
1904
1802
1754
1749
1602
1579
1477
1476
1472
1412
994
976
939
807
745
637
633
541
536
446
414
410
390
313
285
270
264
263
257
253
187
184
166
162
160
154
153
141
138
118
110
108
105
104
98
96
94
93
91
88
85
82
79
77
73
69
68
65
60
57
54
53
49
47
46
44
42
41
39
38
36
33
31
29
28
26
25
24
23
21
2...

result:

ok 100 numbers

Test #9:

score: 0
Accepted
time: 556ms
memory: 6576kb

input:

500 500
251 452
436 482
88 232
251 447
493 58
197 280
75 489
37 67
63 158
185 93
330 492
262 159
407 19
137 101
352 459
97 149
295 18
309 129
256 445
440 46
486 151
13 147
7 266
22 144
76 408
348 484
118 170
72 355
447 300
343 369
366 293
115 273
424 248
476 384
393 29
457 28
236 252
351 453
385 4
2...

output:

14297775500
14178351000
12160290648
12045564398
11960926158
10104175454
10056515054
9835932857
9545442618
8827714550
8782080293
7791292387
7639588236
7492319340
7291917421
7219122837
7140060105
6723737433
6689484751
6567498563
6470487801
6443912057
6420377329
6405288631
6136560117
6128743839
6026404...

result:

ok 250000 numbers

Test #10:

score: 0
Accepted
time: 549ms
memory: 6900kb

input:

500 499
317 285
484 238
495 441
459 388
173 391
267 334
78 356
176 221
145 91
478 225
330 356
154 272
19 474
179 159
383 206
1 355
166 329
100 219
333 227
196 403
432 353
31 16
459 279
357 307
316 313
488 94
441 15
48 394
145 42
471 165
280 232
216 135
238 298
23 384
436 457
227 101
231 255
146 399
...

output:

12050889300
11813579262
11782355046
11453039396
10105287048
9473163834
8988103050
7787984871
7096875907
7031728083
6817627189
6608306372
6575652972
6251517302
5684171676
5680712217
5616151136
5412739667
5264326211
5124922594
4997152521
4964846601
4909818613
4808119441
4788359906
4739256433
468410854...

result:

ok 249500 numbers

Test #11:

score: 0
Accepted
time: 550ms
memory: 6956kb

input:

499 500
74 112
259 178
312 358
41 355
203 207
240 188
458 413
122 25
210 307
154 103
343 127
272 384
398 138
369 135
106 433
265 446
145 45
499 337
303 339
422 204
53 315
428 463
472 222
347 477
105 379
216 200
113 134
90 224
485 266
432 313
421 85
319 220
490 119
232 232
17 442
72 299
197 113
422 2...

output:

14251499868
11307944666
9544515570
9145041336
8372526432
8293115364
8006830596
7843679496
7278586968
6957611360
6365842014
6100760574
5811713904
5764586976
5466675508
5324360808
5245936268
5240325488
5132339737
4877696291
4760312803
4693915783
4603932265
4545771193
4427913755
4403790251
4289894772
4...

result:

ok 249500 numbers

Test #12:

score: 0
Accepted
time: 575ms
memory: 6972kb

input:

500 500
461 314
184 218
446 380
273 233
192 234
127 341
273 320
300 244
162 342
295 74
38 147
279 174
382 346
300 243
432 75
6 182
365 402
355 53
295 290
187 407
353 283
103 388
251 466
465 245
222 442
332 312
89 402
410 227
84 167
424 90
179 393
467 229
407 210
87 28
222 280
427 452
284 288
173 421...

output:

14604802580
11306352708
10929079548
9711723475
9597664291
8617153806
8164215589
7842868537
7718004445
7039277037
6716918743
6419003367
6047949647
6046568576
5857702949
5837588657
5581523573
5451823828
5351172262
5108763182
4964743840
4817887083
4649700113
4576923413
4480439458
4420643686
4367617958
...

result:

ok 250000 numbers

Test #13:

score: 0
Accepted
time: 578ms
memory: 6520kb

input:

500 500
181 43
434 212
498 149
132 191
213 145
258 268
498 2
118 140
483 426
407 342
382 485
12 278
41 228
134 407
245 324
76 109
396 8
69 275
470 110
38 106
239 376
330 457
247 423
358 74
323 439
220 311
371 494
278 319
107 287
354 470
57 246
107 203
68 171
325 336
105 119
219 322
73 452
63 119
29 ...

output:

14546886020
12916037345
12895216442
10953432026
9977034730
8431562506
8431239154
8271301482
8138886507
7480349871
7360983311
7242961439
7030800029
6408732977
6059515509
5908431915
5860588759
5709312497
5591237330
5566548498
5352549088
5139469184
5046044034
4694628172
4619469124
4502836106
4497714535...

result:

ok 250000 numbers

Test #14:

score: 0
Accepted
time: 575ms
memory: 6976kb

input:

500 500
184 432
164 136
338 333
358 28
475 442
291 257
228 175
420 133
434 239
146 111
15 297
171 335
120 132
320 277
491 197
257 364
159 90
454 94
257 153
164 374
322 137
97 200
324 489
267 122
434 148
388 257
167 463
41 361
390 81
416 469
89 443
242 85
432 383
440 19
102 117
202 257
77 335
214 228...

output:

13948921476
11693273348
9660140444
9338851476
9218248396
8085883668
7485524804
7019568040
6769691024
6536948628
6360558078
5931795228
5771962428
5634012692
5596215922
5317997306
5217950650
5145742952
5005761290
4912359037
4791391485
4495226962
4435227598
4372153510
4352115288
4204231416
4144164302
4...

result:

ok 250000 numbers

Test #15:

score: 0
Accepted
time: 89ms
memory: 6948kb

input:

500 100
480 91
400 40
127 50
318 49
141 32
220 22
208 70
57 82
106 42
179 98
157 48
150 20
280 86
261 20
315 99
158 77
319 7
275 92
182 4
150 64
22 34
267 74
298 90
201 9
289 12
31 18
215 12
89 85
308 89
182 21
159 22
276 15
127 71
145 90
209 10
426 62
477 43
54 6
70 51
444 18
96 57
406 78
447 99
49...

output:

623339700
528123700
433437580
384237877
355883125
326703293
281544302
268856558
261537828
257151201
252363789
247889409
230855589
223258689
222125325
215523252
208436676
205930770
203635666
197856148
194015520
187242288
185346746
182750655
179571215
177630067
177070117
174395301
173320221
172152491
...

result:

ok 50000 numbers

Test #16:

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

input:

100 500
89 235
89 293
23 399
69 63
27 414
9 139
77 85
60 170
99 135
81 195
23 347
29 398
45 490
99 500
69 19
24 96
92 458
40 60
75 460
43 414
90 295
15 238
55 97
25 268
25 203
56 308
93 189
22 291
88 343
43 330
51 14
85 348
35 158
92 500
7 250
73 202
73 237
36 355
14 90
78 333
36 466
11 474
64 102
9...

output:

565751820
552867468
488103792
444007824
432787434
407140638
393768894
336869505
335205205
323704005
304080609
298593453
293908333
293881917
292036029
275406243
270979149
260627649
252055653
238320785
237566310
222667911
216279531
205686167
200669192
179165210
177361718
175313020
170922007
163848453
...

result:

ok 50000 numbers

Test #17:

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

input:

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

output:

200
180
165
155
150
130
114
102
94
90
75
63
54
48
45
35
27
21
17
15
10
6
3
1
0

result:

ok 25 numbers

Test #18:

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

input:

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

output:

775
730
690
655
625
600
580
565
555
550
510
474
442
414
390
370
354
342
334
330
300
273
249
228
210
195
183
174
168
165
145
127
111
97
85
75
67
61
57
55
45
36
28
21
15
10
6
3
1
0

result:

ok 50 numbers

Test #19:

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

input:

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

output:

775
735
705
685
675
630
594
567
549
540
500
468
444
428
420
385
357
336
322
315
285
261
243
231
225
200
180
165
155
150
130
114
102
94
90
75
63
54
48
45
35
27
21
17
15
10
6
3
1
0

result:

ok 50 numbers

Test #20:

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

input:

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

output:

2925
2835
2755
2685
2625
2575
2535
2505
2485
2475
2385
2304
2232
2169
2115
2070
2034
2007
1989
1980
1900
1828
1764
1708
1660
1620
1588
1564
1548
1540
1470
1407
1351
1302
1260
1225
1197
1176
1162
1155
1095
1041
993
951
915
885
861
843
831
825
775
730
690
655
625
600
580
565
555
550
510
474
442
414
39...

result:

ok 100 numbers

Test #21:

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

input:

100 100
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1...

output:

25492500
25482600
25472800
25463100
25453500
25444000
25434600
25425300
25416100
25407000
25398000
25389100
25380300
25371600
25363000
25354500
25346100
25337800
25329600
25321500
25313500
25305600
25297800
25290100
25282500
25275000
25267600
25260300
25253100
25246000
25239000
25232100
25225300
252...

result:

ok 10000 numbers

Test #22:

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

input:

1 100
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 6...

output:

4950
4851
4753
4656
4560
4465
4371
4278
4186
4095
4005
3916
3828
3741
3655
3570
3486
3403
3321
3240
3160
3081
3003
2926
2850
2775
2701
2628
2556
2485
2415
2346
2278
2211
2145
2080
2016
1953
1891
1830
1770
1711
1653
1596
1540
1485
1431
1378
1326
1275
1225
1176
1128
1081
1035
990
946
903
861
820
780
7...

result:

ok 100 numbers

Test #23:

score: 0
Accepted
time: 280ms
memory: 6972kb

input:

500 500
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1...

output:

15687312500
15687063000
15686814000
15686565500
15686317500
15686070000
15685823000
15685576500
15685330500
15685085000
15684840000
15684595500
15684351500
15684108000
15683865000
15683622500
15683380500
15683139000
15682898000
15682657500
15682417500
15682178000
15681939000
15681700500
15681462500
...

result:

ok 250000 numbers

Test #24:

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

input:

500 100
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1...

output:

632462500
632413000
632364000
632315500
632267500
632220000
632173000
632126500
632080500
632035000
631990000
631945500
631901500
631858000
631815000
631772500
631730500
631689000
631648000
631607500
631567500
631528000
631489000
631450500
631412500
631375000
631338000
631301500
631265500
631230000
...

result:

ok 50000 numbers

Test #25:

score: 0
Accepted
time: 281ms
memory: 7156kb

input:

500 500
500 500
500 499
500 498
500 497
500 496
500 495
500 494
500 493
500 492
500 491
500 490
500 489
500 488
500 487
500 486
500 485
500 484
500 483
500 482
500 481
500 480
500 479
500 478
500 477
500 476
500 475
500 474
500 473
500 472
500 471
500 470
500 469
500 468
500 467
500 466
500 465
500 ...

output:

15687312500
15687063000
15686814000
15686565500
15686317500
15686070000
15685823000
15685576500
15685330500
15685085000
15684840000
15684595500
15684351500
15684108000
15683865000
15683622500
15683380500
15683139000
15682898000
15682657500
15682417500
15682178000
15681939000
15681700500
15681462500
...

result:

ok 250000 numbers

Test #26:

score: 0
Accepted
time: 59ms
memory: 5096kb

input:

500 100
500 100
500 99
500 98
500 97
500 96
500 95
500 94
500 93
500 92
500 91
500 90
500 89
500 88
500 87
500 86
500 85
500 84
500 83
500 82
500 81
500 80
500 79
500 78
500 77
500 76
500 75
500 74
500 73
500 72
500 71
500 70
500 69
500 68
500 67
500 66
500 65
500 64
500 63
500 62
500 61
500 60
500 ...

output:

632462500
632413000
632364000
632315500
632267500
632220000
632173000
632126500
632080500
632035000
631990000
631945500
631901500
631858000
631815000
631772500
631730500
631689000
631648000
631607500
631567500
631528000
631489000
631450500
631412500
631375000
631338000
631301500
631265500
631230000
...

result:

ok 50000 numbers

Test #27:

score: 0
Accepted
time: 319ms
memory: 6524kb

input:

500 500
1 2
1 3
1 1
1 5
1 4
1 7
1 8
1 6
1 9
1 11
1 10
1 13
1 12
1 14
1 15
1 17
1 18
1 19
1 16
1 20
1 22
1 23
1 21
1 24
1 26
1 25
1 28
1 27
1 30
1 29
1 32
1 31
1 34
1 33
1 36
1 37
1 35
1 38
1 40
1 41
1 42
1 39
1 44
1 43
1 46
1 47
1 48
1 49
1 50
1 45
1 52
1 53
1 54
1 55
1 56
1 51
1 58
1 59
1 57
1 61
1...

output:

15687063500
15686814500
15686814000
15686318000
15686317500
15685823500
15685577000
15685576500
15685330500
15684840500
15684840000
15684352000
15684351500
15684108000
15683865000
15683381000
15683139500
15682898500
15682898000
15682657500
15682178500
15681939500
15681939000
15681700500
15681225500
...

result:

ok 250000 numbers

Test #28:

score: 0
Accepted
time: 379ms
memory: 6592kb

input:

500 500
1 75
1 66
1 2
1 3
1 41
1 23
1 6
1 71
1 73
1 10
1 81
1 82
1 91
1 92
1 14
1 96
1 88
1 39
1 85
1 89
1 20
1 21
1 5
1 22
1 24
1 25
1 109
1 27
1 28
1 29
1 8
1 30
1 32
1 33
1 34
1 94
1 36
1 84
1 90
1 99
1 50
1 102
1 116
1 46
1 126
1 100
1 130
1 101
1 13
1 133
1 149
1 72
1 113
1 121
1 131
1 76
1 106...

output:

15671587500
15671290500
15671226500
15671195000
15670720000
15670540000
15670514500
15670504500
15670502500
15670476500
15669216500
15669007000
15667162000
15666957500
15666939500
15666129500
15666120500
15666104500
15666100000
15666099000
15666090000
15666089000
15666088000
15666087500
15666080000
...

result:

ok 250000 numbers

Test #29:

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

input:

500 500
1 472
1 1
1 419
1 469
1 95
1 5
1 235
1 47
1 309
1 9
1 10
1 402
1 14
1 4
1 391
1 252
1 437
2 14
1 18
1 19
1 132
1 483
1 51
1 288
1 24
1 102
1 26
1 27
1 28
1 488
1 229
1 329
1 386
1 484
1 34
1 35
1 36
1 420
2 1
1 341
1 496
2 38
1 240
1 43
1 293
1 63
1 206
2 35
1 343
1 448
1 459
1 486
1 473
1 5...

output:

15680718500
15680483000
15669406000
15669331000
15654103000
15653923000
15641043000
15640035000
15635965000
15635889000
15635870500
15635080000
15635014000
15635012500
15634561500
15634077000
15633789000
15630386818
15630328818
15630314818
15628409318
15628310318
15628222318
15627844318
15627786818
...

result:

ok 250000 numbers

Test #30:

score: 0
Accepted
time: 382ms
memory: 6896kb

input:

500 500
2 472
1 35
2 461
2 386
1 4
1 5
2 160
1 7
1 8
1 9
2 312
2 132
2 393
2 384
2 249
1 15
2 150
2 381
2 276
2 137
2 128
1 21
1 372
2 298
2 388
1 25
1 143
1 26
2 471
1 29
1 423
1 31
1 453
1 33
2 448
1 34
1 219
1 37
1 338
2 406
1 379
1 41
2 350
1 301
1 44
1 45
3 16
1 47
2 202
1 49
2 111
2 394
2 439
...

output:

15673901876
15666253361
15661384618
15633802393
15633740393
15633725393
15601584803
15601556803
15601543303
15601530303
15590304799
15587105211
15586630163
15586486451
15580890665
15580830665
15580651025
15580444439
15579474383
15579409513
15578968397
15578926397
15578613464
15578306080
15578296100
...

result:

ok 250000 numbers

Test #31:

score: 0
Accepted
time: 397ms
memory: 7020kb

input:

500 500
10 389
1 176
1 367
6 452
1 4
1 5
7 188
1 7
3 432
3 22
9 340
4 180
9 168
1 13
3 162
1 15
1 16
8 59
5 176
1 19
7 417
1 21
1 22
7 285
9 392
1 25
5 379
1 27
7 490
1 29
10 244
5 17
8 404
2 488
1 34
9 74
9 446
6 98
6 314
1 39
1 40
10 25
1 42
3 101
9 406
5 58
1 46
6 304
10 251
7 20
1 50
8 106
3 499...

output:

15473643620
15454722212
15452428684
15442874762
15442530762
15442445262
15329139690
15328970690
15327459847
15322629131
15282095043
15279713383
15243029863
15243001015
15241648615
15241640999
15241637691
15220124912
15219918128
15219912704
15216576257
15216574641
15216574333
15198031037
15197432387
...

result:

ok 250000 numbers

Test #32:

score: 0
Accepted
time: 399ms
memory: 6824kb

input:

500 500
20 474
1 1
12 126
1 3
9 215
2 21
16 323
19 289
19 401
2 390
14 324
1 11
7 486
1 13
1 14
1 15
7 33
4 498
1 18
1 19
1 20
13 487
1 22
12 51
1 24
6 242
8 330
11 82
19 334
1 29
1 30
2 462
5 223
2 109
6 341
15 4
1 36
1 37
1 38
12 465
10 177
1 41
4 407
13 279
13 480
18 206
17 395
11 295
9 48
1 49
8...

output:

15564445740
15564208727
15306752459
15306621209
15203343086
15201186893
14991792628
14876586161
14820808769
14819208303
14817953997
14817910157
14817025337
14817016377
14817012397
14817008917
14808143944
14808061900
14808055960
14808054480
14808053500
14807381000
14807372768
14793399593
14793386087
...

result:

ok 250000 numbers

Test #33:

score: 0
Accepted
time: 425ms
memory: 6972kb

input:

500 500
100 382
40 131
1 2
91 64
64 168
2 469
1 6
1 7
95 261
88 192
76 87
1 11
1 12
73 108
1 14
40 405
98 401
1 17
74 113
1 19
80 469
1 21
38 447
1 23
21 344
34 341
93 255
1 27
54 250
4 81
56 129
93 187
1 32
1 33
63 367
50 137
67 11
14 441
39 112
4 87
1 40
1 41
1 42
73 68
1 44
1 45
47 287
1 47
64 35...

output:

13864696700
13220957460
13220799600
12721475276
12318804348
12314220732
12314027756
12313980012
11701695657
11561226921
11504071849
11503891513
11503846929
11473426017
11473338987
11383855339
11336620699
11336494654
11329369553
11329287523
11254729315
11254649285
11234750945
11234673003
11173931983
...

result:

ok 250000 numbers

Test #34:

score: 0
Accepted
time: 453ms
memory: 6576kb

input:

500 500
200 156
41 284
1 2
18 324
1 4
152 3
106 196
105 406
91 164
194 174
84 474
171 56
1 12
1 13
1 14
191 261
1 16
108 274
98 30
1 19
1 20
1 21
1 22
37 402
1 24
16 388
1 26
200 79
187 334
1 29
1 30
159 43
130 153
188 305
1 34
165 435
1 36
20 56
1 38
77 253
1 40
1 41
1 42
95 263
41 127
1 45
114 468...

output:

12447598500
11703061952
11702839648
11620483318
11620271156
11589830206
10879362062
10211468742
10107224006
9913271590
9839299258
9508269708
9507823556
9507768287
9507713518
8738668068
8738560530
8631511560
8580088496
8579986775
8579953368
8579920461
8579888054
8549498384
8549435570
8539187554
85391...

result:

ok 250000 numbers

Test #35:

score: 0
Accepted
time: 554ms
memory: 6588kb

input:

500 500
500 499
199 260
120 283
427 486
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
403 150
98 142
497 419
1 16
1 17
333 13
1 19
417 195
410 497
296 43
1 23
1 24
1 25
1 26
1 27
1 28
471 499
483 77
463 403
330 316
366 228
1 34
51 282
1 36
1 37
1 38
490 381
1 40
1 41
285 457
1 43
173 452
328 35
1 46
1 47
1...

output:

15687063500
11921426300
11154865340
10985316964
10984682980
10984524984
10984367488
10984210492
10984053996
10983898000
10983742504
10983587508
10983433012
9643166572
9032878300
8998174836
8997783544
8997686221
8847132405
8846939759
8508322799
8499349099
8128025673
8127729561
8127656033
8127583005
8...

result:

ok 250000 numbers

Test #36:

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

input:

1 1
1 1

output:

0

result:

ok 1 number(s): "0"

Test #37:

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

input:

1 2
1 1
1 2

output:

1
0

result:

ok 2 number(s): "1 0"

Test #38:

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

input:

2 1
1 1
2 1

output:

1
0

result:

ok 2 number(s): "1 0"