QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#460119#8840. Lalo's Lawyer Lostucup-team3215AC ✓131ms34868kbC++201.5kb2024-07-01 01:42:492024-07-01 01:42:50

Judging History

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

  • [2024-07-01 01:42:50]
  • 评测
  • 测评结果:AC
  • 用时:131ms
  • 内存:34868kb
  • [2024-07-01 01:42:49]
  • 提交

answer

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

constexpr int N = 2e5 + 1;

int d[N], st[N], sz[N], n;
int64_t ans;
vector<int> nei[N], tmp;

void build(int v, int p, int cd) {
  sz[v] = 1;
  d[v] = cd;
  for (auto u: nei[v]) if (u != p) if (!d[u]) {
    build(u, v, cd + 1);
    sz[v] += sz[u];
  }
}

int solve(int v) {
  st[d[v]] = v;
  int r = -1;
  for (auto u: nei[v]) if (d[u] == d[v] + 1) {
    int t = solve(u);
    if (!~t) ans += min(sz[u], n - sz[u]) * 2;
    else if (t != v) r = t;
  } else if (d[u] < d[v] - 1) {
    r = u;
    tmp.push_back(sz[v]);
    for (int i = d[v]; --i > d[u]; ) tmp.push_back(sz[st[i]] - sz[st[i + 1]]);
    tmp.push_back(n - sz[st[d[u] + 1]]);
    int s = 0;
    for (int i = 0; i < tmp.size() / 2; ++i) s += tmp[i];
    for (int i = 0; i < tmp.size() - tmp.size() / 2; ++i) ans += min(s, n - s), s += tmp[i + tmp.size() / 2] - tmp[i];
    for (int i = tmp.size() - tmp.size() / 2; i < tmp.size(); ++i) ans += min(s, n - s), s += tmp[i + tmp.size() / 2 - tmp.size()] - tmp[i];
    tmp.clear();
  }
  return r;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  for (int tc = (cin >> tc, tc); tc--; ) {
    int m; cin >> n >> m;
    for (int i = 0; i < m; ++i) {
      int a, b; cin >> a >> b; --a, --b;
      nei[a].push_back(b);
      nei[b].push_back(a);
    }
    build(0, 0, 1);
    solve(0);
    cout << ans / 2 << '\n';
    ans = 0;
    for (int i = 0; i < n; ++i) d[i] = 0, nei[i] = {};
  }
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

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

output:

4
7
11

result:

ok 3 number(s): "4 7 11"

Test #2:

score: 0
Accepted
time: 118ms
memory: 16436kb

input:

1
200000 237075
108858 94990
100551 10010
183651 18192
140340 165190
192857 129476
185234 114480
152373 152809
49111 63549
62291 177378
115652 89674
139745 156133
93833 185121
179667 97387
144207 40283
126581 168057
117092 89628
80414 137412
77365 35130
7266 156767
172205 147523
177935 11096
179072 ...

output:

2192727

result:

ok 1 number(s): "2192727"

Test #3:

score: 0
Accepted
time: 128ms
memory: 16408kb

input:

1
200000 236960
137548 162801
157074 51318
5638 31294
195423 141291
38208 53743
14753 176938
154886 11026
10978 42824
134124 48821
198767 88048
21713 73234
106220 106903
4642 111793
56308 31739
140241 91862
91319 172153
110572 170282
7228 35628
119604 38812
103528 159084
52200 21250
64015 63465
5400...

output:

2188621

result:

ok 1 number(s): "2188621"

Test #4:

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

input:

1
200000 199999
181735 63597
17160 185822
148438 135037
19174 117054
32004 188897
186883 196023
103743 76467
195268 3356
62111 41266
90340 135181
69351 116502
107385 166749
94727 45379
105812 33680
69562 113023
196695 30558
103650 60045
44690 101815
130993 12876
167184 90827
140741 142023
20019 1399...

output:

2209042

result:

ok 1 number(s): "2209042"

Test #5:

score: 0
Accepted
time: 131ms
memory: 16520kb

input:

1
200000 237008
134081 195228
90690 85741
166675 179587
8847 27406
71437 64397
106087 195509
131161 20860
78665 194188
165465 139899
22338 156510
158911 137606
151722 54373
173099 82669
137897 14846
67544 110755
101480 183407
49461 102696
110 165233
194 101068
181541 13799
183592 103899
52984 175057...

output:

2321957

result:

ok 1 number(s): "2321957"

Test #6:

score: 0
Accepted
time: 128ms
memory: 16364kb

input:

1
200000 237188
126326 138606
150990 187639
20449 10057
189759 130951
124119 81473
80656 159274
20123 150646
187702 20978
30204 115146
163495 35732
12474 37980
24433 126629
164122 189767
57597 120316
197352 180822
21170 138230
36523 83540
7452 159807
158891 79418
198288 1644
38735 22481
2392 57901
1...

output:

2184674

result:

ok 1 number(s): "2184674"

Test #7:

score: 0
Accepted
time: 119ms
memory: 16448kb

input:

1
200000 237147
196010 155770
99649 32034
171310 180249
93105 131415
180547 71179
103240 19335
9704 142974
147383 59397
70720 14589
129335 97920
54882 135096
43984 4957
139663 128612
52612 92101
173070 63958
170161 106384
49455 75289
54299 1459
197962 93274
87963 121012
174475 181429
114395 96517
18...

output:

2165249

result:

ok 1 number(s): "2165249"

Test #8:

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

input:

1
200000 199999
80800 180777
86937 26197
10621 111627
96277 132944
36346 198530
41454 167209
112886 67934
48603 45849
125859 43813
182767 157415
152280 184808
127634 48650
184652 37646
130631 192658
49960 192298
3790 68635
117116 90427
130040 167602
192668 49587
98509 73296
114020 158125
84242 53471...

output:

2231522

result:

ok 1 number(s): "2231522"

Test #9:

score: 0
Accepted
time: 122ms
memory: 34868kb

input:

1
200000 200000
179119 40844
136592 43631
150419 44319
55398 84744
77508 15349
3423 66152
61774 68612
130783 14903
144179 8413
10032 29256
67587 165617
1982 20288
153195 54086
172632 79849
32046 188142
56384 180181
163464 157186
67387 138974
101870 48681
119151 184690
49567 26297
113573 88399
34033 ...

output:

7083492420

result:

ok 1 number(s): "7083492420"

Test #10:

score: 0
Accepted
time: 117ms
memory: 16436kb

input:

1
200000 236955
94614 33051
64288 113909
130429 42114
107131 135964
156865 170243
178381 161160
79944 25577
33432 89761
33040 184472
176241 25492
83199 171844
44546 102673
63014 136646
164392 149125
72972 40123
86747 105274
41338 13512
178982 17490
168812 121893
99825 171949
54688 51988
36002 142119...

output:

2356757

result:

ok 1 number(s): "2356757"

Test #11:

score: 0
Accepted
time: 117ms
memory: 16516kb

input:

1
200000 237201
80971 92459
116301 52975
150701 161251
61336 73057
131097 70868
115462 154239
40086 170656
122444 111727
113462 121836
75441 64425
71564 119622
128610 27226
188547 195066
116242 59211
25514 67866
145420 107938
123526 184068
75520 198595
132903 166346
81002 124092
104781 51185
100748 ...

output:

2205778

result:

ok 1 number(s): "2205778"

Test #12:

score: 0
Accepted
time: 82ms
memory: 10336kb

input:

2
100000 118580
59636 9664
64836 33553
11627 79660
15810 48375
2728 82930
38948 1257
60789 74744
5817 19246
5570 62083
54454 73328
72576 99360
17450 61843
18563 52889
57381 68253
90642 43111
3802 55552
59749 21944
7740 68975
61620 83737
70715 97655
31068 36560
66168 61238
72975 12373
5973 35510
6715...

output:

1034755
1055009

result:

ok 2 number(s): "1034755 1055009"

Test #13:

score: 0
Accepted
time: 79ms
memory: 16516kb

input:

2
100000 100000
3860 58608
61659 12285
12151 66459
19653 32009
67068 86935
59595 69821
58087 30890
14739 29444
67924 7708
73655 84252
45381 74455
31200 67134
62928 42963
7343 30654
81514 60078
5928 47423
58787 29031
87096 16601
95564 53806
28471 56447
7555 73594
58830 72408
62930 4251
68519 35257
49...

output:

1212466758
1067679

result:

ok 2 number(s): "1212466758 1067679"

Test #14:

score: 0
Accepted
time: 60ms
memory: 16592kb

input:

2
100000 100000
37173 41260
59903 13378
72136 85897
28272 11331
18540 99411
63009 36440
80773 22348
79598 53789
16550 90817
52978 25046
99190 45797
25294 47295
70918 56805
56090 94636
6237 71221
74413 40791
78858 4780
79539 37072
49234 71751
69621 42984
83095 73557
31750 13482
32870 34164
19388 3115...

output:

624640809
1076069

result:

ok 2 number(s): "624640809 1076069"

Test #15:

score: 0
Accepted
time: 60ms
memory: 13400kb

input:

2
100000 100000
77107 19213
1687 31500
103 44136
79580 73354
51385 91075
39292 68388
63589 72023
7380 60400
72715 59057
27535 47301
1572 67655
60160 64105
58110 85636
56105 84585
47859 3399
31779 40672
93295 30041
33640 45838
77082 47802
11534 94702
56962 45516
70032 46668
71297 1669
15239 53569
207...

output:

595810022
1085180

result:

ok 2 number(s): "595810022 1085180"

Test #16:

score: 0
Accepted
time: 73ms
memory: 10396kb

input:

2
100000 118559
49137 35395
5543 40822
67074 34898
20188 19469
92114 34130
66366 14261
4497 53627
55141 61299
41802 27718
29949 31755
34515 83734
58636 641
21208 31723
34822 89326
4774 41526
53036 63780
9609 86253
8537 20091
53722 76689
45919 50915
49610 41123
87979 93905
33465 30078
12051 54678
455...

output:

1032993
987841

result:

ok 2 number(s): "1032993 987841"

Test #17:

score: 0
Accepted
time: 67ms
memory: 14812kb

input:

2
100000 100000
31954 10903
94488 31192
53792 79045
72791 67112
60798 83312
73884 42909
53835 10334
75620 45803
47283 50398
31634 67194
58997 12073
68301 30806
48301 20999
7114 99530
14550 75481
18329 55278
2302 87831
61458 80291
20980 24269
80357 34432
16616 13611
43136 96142
90645 48966
1102 49405...

output:

905609794
1080250

result:

ok 2 number(s): "905609794 1080250"

Test #18:

score: 0
Accepted
time: 68ms
memory: 10400kb

input:

2
100000 118510
85215 13981
27084 7859
91943 25174
19419 84560
73344 22383
73518 58848
83103 69075
5296 42740
39124 35902
90366 95072
11769 78839
95368 61568
66816 38078
35221 81258
59390 92519
48449 94060
83576 31574
70934 81283
88456 36641
23708 73196
77919 20488
42778 26077
14148 71642
1043 21479...

output:

1055521
1014167

result:

ok 2 number(s): "1055521 1014167"

Test #19:

score: 0
Accepted
time: 71ms
memory: 22084kb

input:

2
100000 100000
73654 60198
98390 82436
21270 54566
76332 23045
98203 40263
87599 42016
3998 51390
73905 10320
96362 45615
59461 76475
47725 59520
81706 64464
40528 24143
28912 9791
8703 28219
84705 89854
32604 15339
20087 8085
27693 60313
95592 60985
86197 16608
74953 84147
30581 12279
85324 65309
...

output:

2302681235
1074130

result:

ok 2 number(s): "2302681235 1074130"

Test #20:

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

input:

2
100000 99999
78427 29308
5512 50405
38289 54886
57379 99299
10259 45895
43117 31564
8006 6508
89707 17637
25470 18358
33253 16467
87303 29
43034 15600
31146 50864
27093 10535
96447 426
4352 87195
26981 54407
99093 90133
13642 60413
76304 33332
79010 68534
4730 49155
63928 4467
7041 5104
94552 8385...

output:

1050663
1078976

result:

ok 2 number(s): "1050663 1078976"

Test #21:

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

input:

2
100000 100000
38388 38997
95052 4214
43685 8712
31637 19581
17284 92564
30034 63168
34488 44835
23577 88216
52508 92483
29894 44830
72878 38750
6614 42193
16003 6168
4924 71821
89496 22297
99089 61947
18321 40657
72014 97468
80133 68380
5399 69779
56261 3391
83798 24964
97874 31692
91958 78104
379...

output:

5776819
748939278

result:

ok 2 number(s): "5776819 748939278"

Test #22:

score: 0
Accepted
time: 67ms
memory: 8364kb

input:

3
66666 79137
51106 64652
55671 53050
35032 28900
8617 15767
58346 7156
45162 49721
53056 44941
5237 36398
19089 33940
26264 33432
29615 17151
6935 22566
26514 51916
44813 24788
23503 17609
34122 17304
5750 49461
13051 36314
51666 27448
30144 3185
46732 41220
62517 65258
20955 9645
17020 55613
29421...

output:

689910
660143
654925

result:

ok 3 number(s): "689910 660143 654925"

Test #23:

score: 0
Accepted
time: 60ms
memory: 9952kb

input:

4
50000 50000
24938 32616
49479 14889
14845 28438
31969 1657
6128 47033
15857 32105
36064 861
45405 6513
19509 17301
28031 31252
32040 819
27473 14929
1967 26518
14367 49649
41275 41665
46563 29115
30953 24996
47547 16309
5094 33938
48827 43998
16621 18689
28635 14702
8267 10718
10225 14614
43280 27...

output:

500730
279572984
63849557
471901

result:

ok 4 number(s): "500730 279572984 63849557 471901"

Test #24:

score: 0
Accepted
time: 54ms
memory: 7760kb

input:

5
40000 47449
25423 7887
5985 28300
7269 39151
21561 10999
11987 19655
27786 27940
18745 26193
33275 834
27537 21426
22117 8477
3611 6321
1780 20353
22612 12891
29812 5507
10445 3426
36494 20810
34248 4426
6158 17386
10215 16962
23595 27570
23385 14613
16501 34447
32961 18822
10542 38517
5498 26815
...

output:

391884
97867949
362661
77566904
361105

result:

ok 5 number(s): "391884 97867949 362661 77566904 361105"

Test #25:

score: 0
Accepted
time: 51ms
memory: 7916kb

input:

6
33332 33332
31023 21590
17421 18649
9278 29627
4747 8575
1269 15734
25838 9984
23679 10547
24752 5908
32984 4310
9376 5124
10340 27518
29343 19735
20765 24498
4252 6533
12319 3298
27613 5196
21897 3548
4360 742
17526 2931
24559 686
26856 24479
13743 29641
15779 23099
15538 18929
2575 18855
17176 2...

output:

107455244
274831
311637
1612182
753217
313436

result:

ok 6 numbers

Test #26:

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

input:

7
28570 33828
18767 8608
25265 583
27813 2348
16793 10961
27758 20110
25886 9375
19264 13917
12885 19579
10290 25321
18623 9727
226 1346
16527 13435
15857 5486
7578 14304
27529 26127
23787 19927
1560 2372
7855 2434
13950 25840
17786 21917
22396 27371
22807 9921
24092 24437
8657 20956
1400 19224
6947...

output:

255860
246047
270882
269061
254714
298110
1151731

result:

ok 7 numbers

Test #27:

score: 0
Accepted
time: 47ms
memory: 7192kb

input:

8
25000 25000
18380 6664
3606 21755
24514 3014
11860 13355
19292 23043
16381 12070
3299 24085
18034 19070
14012 8915
8503 5327
4222 1524
5891 8070
24395 22908
11103 10090
10397 4922
5000 23712
11250 10643
9192 22451
21930 4369
23963 6186
1440 15606
18029 24807
11891 15372
8350 7664
8056 24530
17008 ...

output:

226171
230768
238528
73498075
230412
211475
218114
33285328

result:

ok 8 numbers

Test #28:

score: 0
Accepted
time: 38ms
memory: 5360kb

input:

9
22222 26298
3302 4051
11461 5733
15595 7572
4720 12609
3971 13451
395 2020
19022 8161
15873 11649
10866 3970
15265 18016
11857 7741
21005 966
222 14398
8451 10234
1924 2909
14149 22152
20259 8012
8771 1049
14569 14707
8438 22085
1280 1848
13921 587
6453 995
6334 4942
20360 19480
2178 5275
8414 139...

output:

183969
207647
217029
195338
202771
211840
186495
214236
192335

result:

ok 9 numbers

Test #29:

score: 0
Accepted
time: 66ms
memory: 5300kb

input:

10
20000 23603
2996 14509
4712 9730
785 8635
18991 1408
2381 8080
11672 14710
19976 1162
9509 19343
10421 11364
14869 5758
999 17086
1412 13964
4398 3472
9958 9494
17357 3737
11251 850
7441 7930
11673 5441
4836 19833
6020 14056
14650 6684
16237 7103
12672 553
17763 16163
17063 19018
19423 9275
2623 ...

output:

160569
169360
179495
172331
172800
177041
185949
176061
181295
163645

result:

ok 10 numbers

Test #30:

score: 0
Accepted
time: 25ms
memory: 3984kb

input:

100
2000 2369
662 555
906 954
304 1772
1380 1253
382 912
408 854
999 1824
1035 662
1176 962
1234 241
678 599
812 1543
346 497
268 1363
1334 1625
1451 249
1946 1635
1408 1987
721 1705
1928 1626
1341 319
1439 1844
765 1077
905 1595
302 758
976 316
1875 1231
662 1037
653 1506
464 899
556 1699
1232 125
...

output:

13223
14400
12432
12678
12807
12069
14310
12741
12912
13832
12739
527250
14425
12816
13405
15441
228386
838916
927885
12619
14396
11965
11724
14222
437624
336867
13568
12072
13994
13021
12753
12042
21655
13598
12552
312509
12706
12752
11531
965883
14192
13141
13731
428488
16045
13200
12382
14404
126...

result:

ok 100 numbers

Test #31:

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

input:

101
1980 2332
1427 100
1220 1132
477 1974
264 1670
381 1635
1116 944
357 1508
740 506
48 1187
217 1344
1260 455
295 1427
1747 53
1457 805
1442 1390
1710 720
1201 1333
1676 870
1947 29
533 363
305 27
1734 1648
581 1344
1035 1211
855 905
405 1692
518 1472
1466 695
357 1529
155 724
1852 894
407 287
108...

output:

12177
240829
11444
13021
12360
10922
12014
10521
12484
12890
158507
13224
135755
15360
12280
11940
15340
13945
12855
11922
13541
12845
14967
13239
13188
11120
14193
12514
12428
12775
12314
12354
12493
13259
12838
104557
12929
77341
11529
13034
778340
443227
13362
12371
11902
12789
13099
10748
13363
...

result:

ok 101 numbers

Test #32:

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

input:

102
1960 1960
1865 1612
602 107
351 882
713 535
1705 1135
826 272
1483 1944
991 699
1785 949
1245 1271
1729 1130
1335 549
361 1346
745 15
447 1260
1539 715
613 927
820 707
1758 1431
1299 954
1338 769
798 631
807 849
1544 1791
936 682
1492 988
781 1238
711 724
506 593
383 470
1228 319
116 788
842 347...

output:

14311
12594
11948
13944
12636
12773
14740
12210
11981
12913
938068
12453
13200
11097
13140
12444
12562
12186
12217
14123
11770
12158
12957
12546
15028
11684
12215
12585
13049
12814
12639
12205
13875
14274
14590
12338
12866
12084
13208
14209
13192
376847
210346
12250
11718
12890
663518
517487
13233
1...

result:

ok 102 numbers

Test #33:

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

input:

103
1940 1939
1142 1164
950 563
297 390
1724 302
1206 1460
751 425
330 27
177 1102
1863 109
1538 1150
721 1554
1149 485
283 1390
1784 1075
1422 751
888 940
231 1012
1190 1909
644 158
100 1292
533 1001
1640 787
395 282
1182 618
900 521
36 482
382 1638
582 1381
1007 1419
87 431
925 673
1336 1600
48 28...

output:

13498
15376
12252
254978
13165
11009
13606
11762
11623
675016
12009
11968
12079
11944
13031
11533
12208
11783
13128
15799
11502
12385
10900
13079
439534
12956
11591
143104
12184
12896
12373
13660
13735
13004
11761
11377
12695
13862
12344
893200
13678
14183
12816
12874
13935
12143
13657
13777
12643
1...

result:

ok 103 numbers

Test #34:

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

input:

104
1922 1922
1015 1718
211 742
1083 1800
1621 1725
478 364
810 338
1105 1251
23 886
1250 993
133 642
256 177
1713 1517
1287 1602
1012 98
1798 27
1280 1764
1003 1142
1656 648
550 189
1400 1069
553 74
1445 1200
873 1334
1579 495
432 1030
1393 180
553 50
928 767
1722 825
963 1007
1484 258
632 930
466 ...

output:

172848
177199
12680
13101
12438
13152
16533
12054
11934
13180
12650
12086
12556
10715
11276
13372
11889
12668
22007
11251
12164
15988
13736
11772
13751
485683
12720
11861
10434
12412
11748
14137
11206
567431
12015
11627
12380
11251
11945
13913
13378
567956
12802
334499
13716
12466
12003
12486
12786
...

result:

ok 104 numbers

Test #35:

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

input:

105
1904 2263
1247 1833
29 385
1572 445
1334 553
1005 1028
737 1838
1296 331
40 613
9 543
1165 1662
258 198
946 209
781 380
614 358
852 526
1715 181
160 388
1484 416
902 436
643 5
1657 645
1431 1068
30 533
8 47
138 1305
983 524
592 1419
359 1626
1620 91
147 90
16 1599
1047 1566
156 821
1744 1370
492...

output:

12523
11285
91108
12242
12321
12251
12932
14746
12396
787375
10616
11600
12120
13530
11827
11275
11162
11572
15390
13119
11301
11526
11405
12194
11544
12125
11225
13431
12806
11812
11866
12716
11780
12964
12407
11758
12301
12644
11681
50842
12128
11504
12718
12552
12136
11650
10367
11266
13703
11738...

result:

ok 105 numbers

Test #36:

score: 0
Accepted
time: 25ms
memory: 4116kb

input:

106
1886 2236
918 239
1831 1366
1232 1570
311 760
126 687
827 276
156 1330
1441 756
992 726
1228 774
496 120
1542 21
1692 1113
1528 1014
1183 130
822 1380
449 1016
1372 428
1092 342
1585 740
28 85
685 1270
1792 1613
887 1491
1390 1210
1422 257
1106 1627
1328 1304
748 159
1135 1019
630 1589
656 93
17...

output:

11494
12602
12466
719220
11763
12769
246794
12096
11994
508475
12883
12503
426758
138290
107196
12328
12494
11781
13246
11313
11472
13039
12263
18783
12667
12584
11959
51615
13174
12556
285896
11932
12041
12604
12708
11245
23356
13077
13175
12455
12323
11391
11359
12774
25424
11147
12581
12515
12143...

result:

ok 106 numbers

Test #37:

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

input:

107
1868 1867
1502 407
1666 772
1054 1024
1691 372
1420 750
1399 601
135 772
457 851
1661 1818
419 141
764 1665
175 1630
1096 116
1112 1565
1087 1826
678 368
484 684
455 938
188 725
773 769
1515 21
964 1057
1379 744
1834 730
50 677
1726 814
1719 698
469 27
90 133
1265 1527
1152 871
401 1376
1426 556...

output:

12445
11157
11009
162990
508159
12083
528152
12107
11696
12319
695729
12390
11414
13393
11637
11749
15991
12677
12678
87688
12388
100559
12771
11802
12063
13753
417990
12120
11719
11657
10817
11216
11639
11911
11692
11420
11851
20249
11546
10703
10891
410805
17185
12168
11032
11644
12997
361279
1198...

result:

ok 107 numbers

Test #38:

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

input:

108
1850 2198
1143 396
1218 26
1465 1045
1426 1268
1385 435
127 570
280 1551
428 1021
667 859
745 78
1580 1737
488 392
642 654
1606 1821
89 1506
1460 229
1320 1366
1749 610
240 1561
1824 765
540 982
1076 872
663 51
1409 1263
1073 745
1800 1292
1260 962
334 916
655 878
735 1762
1108 1082
513 1785
876...

output:

11871
662079
12305
11899
12974
162681
11566
129341
11733
12350
11132
12985
12831
11471
11111
11843
12439
12224
11897
11070
10808
11913
578855
12185
13330
13808
12044
11231
11860
547437
12357
10564
10202
514487
12069
10071
12585
12154
11667
12204
11334
10452
11499
11394
10919
10883
13188
11851
13771
...

result:

ok 108 numbers

Test #39:

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

input:

109
1834 2177
1204 1194
1101 384
708 1001
177 1599
1386 1614
566 846
162 8
676 818
825 1534
1031 1311
1080 1594
1196 1296
702 1601
1668 562
118 863
98 1085
1170 123
1289 868
455 64
859 270
10 1797
1681 468
800 834
1213 1300
1209 1331
942 1774
99 1712
1144 280
65 511
1582 995
1225 503
1141 1463
508 1...

output:

11304
11513
11340
12408
11956
11836
13400
12432
10543
12212
10575
11698
12410
10460
11810
100233
10958
499251
11460
13349
11063
10345
10383
425022
12650
12431
11620
10770
12902
11806
11339
10658
12803
333145
12957
13733
13628
12328
10869
12611
10915
11947
20116
11411
13845
11578
12364
11836
11615
10...

result:

ok 109 numbers

Test #40:

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

input:

110
1818 1818
652 302
682 6
671 239
434 1172
1694 1690
21 1030
531 748
297 286
1557 385
163 359
1537 783
1299 1382
1068 5
564 826
272 1217
1033 129
637 1259
1086 687
436 841
1773 381
1041 1705
1050 38
1479 244
672 537
762 865
1687 220
437 5
1549 928
793 876
8 265
767 470
39 1686
1406 1192
1435 299
5...

output:

411167
10897
12076
10819
11090
13696
12999
12176
11463
11182
242127
11481
14889
12026
14151
12908
12482
11526
12565
11862
11711
12605
11592
11508
661995
200978
11229
10328
12434
11253
93356
10385
12066
11702
721145
12060
331748
10732
13164
11577
11857
11904
12713
758086
10696
11456
15533
536304
1160...

result:

ok 110 numbers

Test #41:

score: 0
Accepted
time: 25ms
memory: 3568kb

input:

1000
200 242
169 124
134 75
142 80
130 15
113 156
112 69
156 19
48 138
179 108
172 45
64 104
127 45
188 147
146 10
160 20
1 90
162 24
169 57
133 158
80 176
20 174
72 161
72 135
1 30
89 151
145 163
70 49
62 157
165 158
175 200
148 156
4 66
170 142
44 172
83 18
65 89
78 195
16 181
191 87
163 50
38 155...

output:

724
907
758
804
8615
926
4182
2573
805
2583
903
810
900
867
804
912
852
835
745
4517
848
842
1734
820
891
878
941
855
740
963
839
798
700
6022
871
961
746
808
765
881
980
840
7907
895
1260
853
800
833
851
1079
858
974
881
879
893
840
780
798
3236
924
868
785
810
956
852
5455
930
906
746
1635
1651
20...

result:

ok 1000 numbers

Test #42:

score: 0
Accepted
time: 25ms
memory: 3576kb

input:

1001
198 197
57 77
66 144
170 6
40 61
170 10
162 158
147 170
142 193
196 55
148 164
167 109
49 70
131 150
166 50
93 125
5 54
162 196
25 15
92 163
88 187
58 38
118 127
25 6
185 166
101 80
103 132
63 75
162 135
106 97
108 166
34 146
72 113
129 188
1 162
197 73
37 56
24 30
36 32
60 119
74 30
51 81
125 ...

output:

744
1367
876
7412
883
866
843
727
956
908
776
5854
900
852
993
992
787
691
795
765
725
788
961
929
858
696
948
961
7898
844
835
4434
922
926
749
839
773
8549
822
828
5058
722
987
888
1137
805
792
752
782
778
1060
866
799
798
876
837
806
747
866
4734
911
855
886
874
855
843
1056
1085
856
839
886
735
...

result:

ok 1001 numbers

Test #43:

score: 0
Accepted
time: 22ms
memory: 3500kb

input:

1002
198 242
124 134
194 87
150 47
67 34
10 31
197 155
148 195
84 3
18 177
89 20
1 115
165 160
30 189
118 10
8 59
143 82
187 126
127 74
183 172
101 88
3 158
10 93
105 129
118 193
40 58
141 109
95 170
169 196
162 92
141 38
92 23
78 84
168 18
10 152
18 33
111 37
53 1
179 48
35 191
191 73
87 174
25 90
...

output:

808
822
927
961
816
827
877
749
924
846
786
846
4141
898
843
763
805
790
4268
916
896
862
980
894
808
903
999
1094
1050
737
980
6074
876
8800
4112
947
899
725
738
6267
844
724
799
896
807
841
911
733
828
895
787
2944
948
833
3555
824
961
746
844
899
840
684
805
814
714
921
853
791
734
727
769
809
77...

result:

ok 1002 numbers

Test #44:

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

input:

1003
198 231
136 81
17 148
135 198
97 105
40 2
181 92
57 95
4 178
114 190
120 198
12 128
147 171
171 162
97 71
62 100
105 28
62 159
191 55
89 148
155 146
63 167
194 182
79 71
198 39
46 166
103 136
38 22
165 58
151 148
2 65
181 86
27 89
135 130
168 76
135 122
179 188
166 114
18 107
136 110
130 18
180...

output:

887
842
884
828
830
818
840
783
747
729
1413
900
796
822
3837
802
883
770
1559
792
880
944
1999
5605
803
758
860
789
8803
753
760
843
876
850
893
884
855
762
829
808
809
983
886
725
950
714
892
840
864
931
826
881
866
920
728
4161
5721
850
882
754
4658
915
930
835
726
881
893
846
4289
890
831
910
25...

result:

ok 1003 numbers

Test #45:

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

input:

1004
198 228
29 17
159 2
187 77
47 179
21 5
19 27
5 45
28 131
103 3
103 41
57 71
77 72
26 126
193 103
37 173
131 39
139 52
63 172
104 119
46 153
135 88
94 141
180 58
113 160
14 83
103 93
74 129
127 87
52 6
68 95
165 101
52 59
169 50
34 57
188 40
89 156
166 44
85 96
108 11
158 106
38 7
20 70
15 185
8...

output:

697
877
858
729
966
7219
866
796
808
853
827
793
935
787
715
1028
889
736
726
911
848
4630
814
847
808
1099
9405
910
831
806
752
769
851
1098
6258
3532
789
714
785
935
661
950
4412
785
1258
3036
719
880
796
786
829
1008
1079
757
648
891
837
749
803
904
774
857
5343
799
875
1126
983
984
781
777
766
8...

result:

ok 1004 numbers

Test #46:

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

input:

1005
198 230
75 11
61 3
130 61
179 145
17 127
113 25
2 17
56 148
116 72
118 98
106 130
86 16
164 178
134 19
44 130
95 180
144 4
117 78
21 96
100 4
19 45
191 198
164 67
77 78
155 106
177 85
129 8
147 102
162 31
138 142
59 68
57 51
183 58
99 33
161 111
81 179
137 47
186 130
14 61
183 21
130 59
57 79
6...

output:

820
948
861
852
717
721
882
812
4241
727
5271
834
873
779
5098
765
751
8384
967
892
821
718
882
8633
880
787
888
913
973
1007
776
890
3408
8772
779
859
4829
826
683
845
902
4213
852
768
958
830
891
816
805
925
979
844
871
758
4851
842
765
891
764
743
7876
936
814
881
960
908
7656
932
2038
3739
709
8...

result:

ok 1005 numbers

Test #47:

score: 0
Accepted
time: 25ms
memory: 3556kb

input:

1006
198 230
169 2
186 85
102 189
146 191
44 49
90 96
189 169
78 118
80 101
41 132
81 44
189 62
53 107
56 160
174 77
64 76
171 35
185 168
187 161
34 145
109 44
37 180
180 143
90 183
136 44
31 38
186 84
189 13
171 74
77 131
3 137
55 134
159 98
20 184
61 102
100 159
49 65
67 15
52 151
166 84
166 18
80...

output:

731
835
820
929
840
826
908
727
975
786
882
838
818
867
805
814
904
715
863
7206
911
920
740
857
785
730
845
1021
707
790
844
829
840
789
933
802
850
725
804
1379
786
821
800
785
5961
883
976
686
867
922
881
982
822
915
1574
837
816
746
785
944
850
882
913
921
1192
875
772
1033
1019
842
920
822
802
...

result:

ok 1006 numbers

Test #48:

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

input:

1007
198 232
141 28
70 181
106 59
158 134
172 194
13 170
136 183
85 92
131 96
40 152
34 7
13 22
117 186
72 87
32 46
16 166
9 8
106 64
135 23
124 189
2 191
132 79
98 107
124 144
132 110
177 155
160 52
119 152
154 163
121 78
187 71
163 59
54 23
145 190
15 113
7 1
45 99
42 76
54 180
131 18
49 153
7 138...

output:

806
748
988
836
744
938
947
665
910
795
928
785
800
878
848
7995
818
820
736
955
789
842
855
830
877
771
830
810
723
7969
2224
1213
692
8299
796
851
814
718
929
5351
947
759
812
817
819
936
839
751
814
862
6751
788
722
791
869
810
768
827
904
927
836
874
751
1119
940
833
906
788
6577
791
861
842
753...

result:

ok 1007 numbers

Test #49:

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

input:

1008
198 240
129 148
166 122
45 86
11 94
143 21
59 27
52 143
27 48
69 37
49 177
160 163
196 152
119 14
187 138
108 58
90 157
58 98
142 84
161 42
47 73
129 191
81 11
176 145
104 17
145 180
25 11
152 178
88 125
9 122
170 87
100 162
145 183
127 143
129 120
15 13
113 37
133 99
45 153
9 10
73 125
90 168
...

output:

778
827
871
821
818
747
823
819
7663
866
685
7546
2604
786
799
758
737
756
4245
901
2417
1534
2866
856
762
1473
825
881
898
5318
819
2258
877
849
7855
5934
751
804
846
901
805
704
831
827
869
816
937
872
2689
935
932
908
3793
902
799
905
851
704
752
2900
695
747
768
825
967
891
756
812
806
871
813
8...

result:

ok 1008 numbers

Test #50:

score: 0
Accepted
time: 25ms
memory: 3568kb

input:

1009
198 198
23 88
150 193
86 185
42 64
167 168
108 140
170 88
97 35
100 180
195 93
141 23
56 100
47 24
88 31
9 184
17 176
58 184
2 69
191 5
171 174
194 60
185 158
28 169
131 145
126 109
157 124
9 112
49 91
181 74
106 110
81 4
108 154
125 52
93 109
177 16
99 33
145 61
51 62
151 61
153 93
110 77
153 ...

output:

917
1064
902
8882
961
825
875
918
991
838
7912
767
881
902
944
748
706
4812
759
808
844
901
750
800
876
796
797
773
816
716
726
862
674
843
839
760
1019
2505
725
930
770
728
732
873
8283
776
967
810
795
742
787
862
6389
861
855
789
902
3891
1011
819
901
741
805
948
3833
3691
853
842
805
793
972
838
...

result:

ok 1009 numbers

Test #51:

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

input:

1010
198 197
31 68
146 116
103 197
95 156
86 5
151 41
189 194
150 33
34 140
42 190
155 45
186 115
130 161
67 16
115 24
104 52
29 27
59 77
100 3
96 34
158 41
160 63
96 83
86 182
176 125
6 92
161 171
115 198
177 42
137 114
34 66
68 63
68 89
100 113
175 70
86 54
60 5
82 104
198 68
37 140
144 194
119 31...

output:

919
1029
769
925
6668
761
8405
8867
842
740
829
735
853
3197
843
789
1286
914
754
773
835
971
788
8057
960
941
876
883
723
5470
834
914
883
766
775
910
8402
854
734
833
4396
802
915
805
751
9237
1067
868
834
841
887
982
7042
837
1762
896
899
892
7717
836
3285
4029
922
917
957
875
835
769
802
947
985...

result:

ok 1010 numbers

Test #52:

score: 0
Accepted
time: 24ms
memory: 3524kb

input:

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

output:

36
39
49
39
40
42
44
37
34
42
54
37
35
84
41
50
42
35
46
47
42
45
45
41
78
50
39
44
54
42
44
31
47
100
38
34
40
49
52
60
51
37
44
44
41
55
49
42
40
74
33
30
37
45
42
52
36
56
35
39
42
49
88
35
40
36
34
38
41
38
34
34
46
47
36
38
36
51
39
43
36
42
36
43
34
36
35
91
36
36
40
49
35
38
38
67
32
38
41
44...

result:

ok 10000 numbers

Test #53:

score: 0
Accepted
time: 22ms
memory: 3556kb

input:

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

output:

34
44
36
45
37
40
37
37
38
43
30
41
37
26
67
36
32
43
42
37
32
33
46
43
45
41
33
28
44
36
43
32
37
32
38
34
37
36
29
36
33
66
34
37
34
46
31
28
37
35
43
39
35
29
50
46
33
29
29
33
33
35
36
48
34
34
33
43
33
32
61
29
30
55
34
34
36
38
51
42
37
35
32
31
36
34
35
45
36
40
38
64
45
31
35
39
27
73
33
34
...

result:

ok 10001 numbers

Test #54:

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

input:

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

output:

36
32
37
27
40
36
36
44
28
37
32
27
38
40
35
25
35
62
35
41
66
42
34
33
38
29
33
35
40
39
44
38
32
34
47
40
33
41
32
38
36
27
38
31
37
33
38
46
28
35
41
32
35
42
29
37
29
33
40
49
39
36
43
37
31
49
44
38
35
35
39
40
66
43
43
34
30
37
36
39
39
41
32
66
39
72
31
37
38
32
30
46
35
31
27
34
28
32
33
36
...

result:

ok 10002 numbers

Test #55:

score: 0
Accepted
time: 22ms
memory: 3508kb

input:

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

output:

34
31
51
37
47
41
33
35
52
37
32
46
41
32
40
42
42
40
35
46
32
53
32
63
71
37
36
39
36
37
42
57
32
37
35
36
42
28
30
29
39
33
35
81
33
35
39
31
34
36
28
32
37
43
37
28
38
33
61
34
65
39
46
31
38
38
30
65
43
41
41
29
62
65
31
47
37
47
32
63
39
32
73
34
31
30
34
29
36
34
39
61
55
41
28
28
41
35
35
37
...

result:

ok 10003 numbers

Test #56:

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

input:

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

output:

40
34
35
31
36
42
31
50
34
38
36
37
40
25
52
40
39
30
30
38
37
29
34
41
33
46
31
41
32
31
34
29
49
41
31
39
34
38
30
28
31
46
35
56
41
49
35
81
46
65
40
37
51
33
32
28
39
32
37
42
32
35
38
29
49
34
42
34
38
38
38
26
31
41
48
31
42
31
31
38
27
32
31
47
51
37
36
42
29
30
41
30
40
32
37
31
30
39
31
45
...

result:

ok 10004 numbers

Test #57:

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

input:

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

output:

34
39
38
37
46
41
29
40
37
33
36
42
41
60
51
34
35
51
33
36
36
31
41
31
29
33
41
35
38
57
31
73
33
35
41
44
33
42
29
35
33
53
37
34
31
41
30
34
35
37
56
31
34
41
34
32
35
30
34
32
30
36
34
27
40
32
49
44
40
38
31
29
41
47
35
32
32
38
50
32
29
38
37
36
38
43
35
36
34
37
36
35
38
32
36
36
37
43
31
50
...

result:

ok 10005 numbers

Test #58:

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

input:

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

output:

44
41
35
53
38
38
35
33
67
37
38
34
39
32
43
33
37
31
64
55
32
37
36
39
45
33
46
35
36
45
31
57
32
34
31
35
39
40
47
36
38
38
39
31
37
39
36
29
36
37
67
41
32
40
29
41
44
66
42
36
30
36
34
28
49
38
33
38
57
33
38
29
32
32
38
33
32
30
43
31
34
35
27
37
37
32
35
42
36
33
29
42
41
35
32
32
40
73
41
38
...

result:

ok 10006 numbers

Test #59:

score: 0
Accepted
time: 22ms
memory: 3516kb

input:

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

output:

39
34
45
39
41
57
33
48
33
42
35
34
35
41
28
40
47
31
34
31
52
51
31
44
32
42
42
29
35
37
31
53
37
34
39
47
38
34
45
32
31
28
28
30
54
32
65
41
36
41
36
45
30
28
42
42
40
48
36
40
29
41
28
33
41
56
39
33
34
30
53
47
37
32
47
27
35
30
42
48
43
81
30
35
37
37
42
37
31
54
32
34
81
40
63
31
44
37
38
38
...

result:

ok 10007 numbers

Test #60:

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

input:

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

output:

65
30
34
29
30
31
47
35
33
36
33
31
33
32
37
37
48
29
34
39
73
29
40
41
35
38
34
58
33
29
24
37
42
50
33
34
38
42
37
29
39
34
81
34
37
58
31
34
30
30
38
31
39
31
67
31
41
34
31
39
28
35
28
33
33
73
43
39
32
35
37
73
81
42
39
64
43
35
37
32
36
47
40
44
40
36
34
31
49
33
40
31
51
38
33
40
38
37
43
38
...

result:

ok 10008 numbers

Test #61:

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

input:

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

output:

33
34
38
30
34
32
64
37
36
42
35
65
37
43
31
41
48
34
44
53
35
46
32
28
33
38
33
36
67
33
27
39
60
37
73
42
35
39
30
32
31
37
32
47
44
29
35
81
39
37
51
32
34
41
53
42
34
40
40
28
30
34
34
42
32
31
41
33
30
42
41
31
37
81
38
39
37
32
41
34
33
42
38
33
53
59
34
41
33
54
34
29
39
37
31
39
45
43
37
34
...

result:

ok 10009 numbers

Test #62:

score: 0
Accepted
time: 22ms
memory: 3608kb

input:

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

output:

35
40
35
47
46
43
34
40
49
39
30
39
30
44
44
31
42
44
34
44
46
31
38
39
31
31
43
73
35
37
40
37
33
37
49
36
32
41
40
36
34
60
30
36
33
40
36
32
47
38
36
31
37
38
51
42
41
42
38
34
44
32
31
31
81
66
31
39
35
43
38
28
27
31
31
30
39
33
45
35
46
38
46
40
31
64
38
38
40
34
81
33
35
40
39
39
48
32
34
37
...

result:

ok 10010 numbers

Test #63:

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

input:

50000
4 4
2 3
4 3
1 2
1 4
4 4
3 1
4 2
3 2
4 3
4 4
2 3
3 1
2 4
4 1
4 3
2 4
2 1
2 3
4 3
2 4
2 3
4 1
4 3
1 3
4 2
2 3
4 4
4 2
4 3
3 1
2 1
4 4
4 2
4 3
1 4
1 2
4 4
3 1
2 4
3 4
2 1
4 3
2 4
2 1
4 3
4 4
4 3
2 1
1 3
2 4
4 3
3 4
2 3
1 3
4 3
2 3
2 4
1 2
4 3
3 1
1 2
1 4
4 3
4 3
4 1
4 2
4 4
1 2
3 2
1 4
1 3
4 3
2 ...

output:

4
3
4
3
4
4
4
3
4
4
4
3
3
3
3
3
4
4
4
3
3
3
4
3
3
4
3
3
3
3
3
3
3
3
4
3
4
3
4
4
3
3
3
4
4
3
3
3
4
4
4
4
4
3
4
3
4
3
4
4
3
3
4
4
4
4
4
3
3
3
3
4
4
4
3
4
3
3
4
3
3
3
3
3
4
4
3
3
4
3
3
3
3
3
3
3
3
4
3
3
4
4
4
3
3
4
3
4
3
3
4
3
4
3
3
3
3
3
3
4
3
3
3
3
3
3
3
3
3
4
3
3
3
4
3
3
3
3
4
4
3
3
4
3
4
3
3
3
4
4
...

result:

ok 50000 numbers

Extra Test:

score: 0
Extra Test Passed