QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499941#8269. Minequakebachbeo2007100 ✓39ms17180kbC++231.1kb2024-07-31 20:21:522024-07-31 20:21:53

Judging History

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

  • [2024-07-31 20:21:53]
  • 评测
  • 测评结果:100
  • 用时:39ms
  • 内存:17180kb
  • [2024-07-31 20:21:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 1e5+5;
const int inf = 1e18;

int n;
struct node{
    int S=0,T=0;
    node(){}
    friend node operator+(node a,node b){
        a.T+=(2*a.S+1)*b.S+b.T;
        a.S+=b.S;
        return a;
    };
    friend node operator-(node a,node b){
        a.S-=b.S;
        a.T-=(2*a.S+1)*b.S+b.T;
        return a;
    }
}dp[maxn];
vector<int> edge[maxn];
int res=inf;

void dfs(int u,int p){
    for(int v:edge[u]){
        if(v==p) continue;
        dfs(v,u);
        dp[u]=dp[u]+dp[v];
    }
    dp[u].S++;
}
void dfs2(int u,int p,node d){
    dp[u].S--;
    dp[u]=dp[u]+d;
    res=min(res,dp[u].T);
    for(int v:edge[u]){
        if(v==p) continue;
        node cc=dp[u]-dp[v];cc.S++;
        dfs2(v,u,cc);
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin >> n;
    for(int i=1;i<n;i++){
        int u,v;cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(1,0);
    dfs2(1,0,node());
    cout << res << '\n';
}

详细

Subtask #1:

score: 18
Accepted

Test #1:

score: 18
Accepted
time: 1ms
memory: 5876kb

input:

2
1 2

output:

1

result:

ok single line: '1'

Test #2:

score: 18
Accepted
time: 1ms
memory: 6220kb

input:

100
11 38
22 77
15 96
32 98
44 72
40 80
36 38
24 34
54 84
22 62
4 8
4 27
88 95
43 83
23 87
48 85
20 76
28 95
66 74
37 40
1 71
66 67
52 54
28 60
7 32
12 47
6 83
73 85
45 94
26 35
18 35
52 81
9 74
1 14
61 70
49 55
16 63
59 67
68 81
13 51
31 63
82 92
73 82
42 91
25 100
57 59
53 58
23 33
14 69
72 98
6 7...

output:

4950

result:

ok single line: '4950'

Test #3:

score: 18
Accepted
time: 1ms
memory: 6332kb

input:

1000
456 460
231 501
167 987
355 458
513 745
648 839
405 771
544 908
550 780
247 462
490 968
340 832
354 593
149 984
219 329
139 419
187 353
611 997
21 52
265 700
656 907
648 801
631 754
306 999
79 788
50 372
228 719
383 824
810 860
744 882
271 597
381 469
71 538
590 715
165 536
275 426
736 923
460 ...

output:

499500

result:

ok single line: '499500'

Test #4:

score: 18
Accepted
time: 1ms
memory: 6052kb

input:

999
373 839
435 715
841 962
100 130
434 681
646 725
33 580
188 250
539 937
377 868
174 780
215 708
416 900
85 451
738 884
187 299
380 535
175 437
43 122
342 888
562 681
287 569
114 146
590 894
476 952
927 950
502 522
226 270
300 336
176 997
538 915
634 798
360 673
413 943
12 945
619 685
103 196
301 ...

output:

498501

result:

ok single line: '498501'

Test #5:

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

input:

10000
2478 7912
6084 6327
6138 7981
4307 7844
7336 7751
2033 5179
7681 9457
1937 9759
3179 8668
5807 9140
1393 5001
7092 7269
2949 6914
4827 8482
2076 4009
7719 8871
4555 8189
3200 4462
1027 9388
9 8506
654 8215
3785 7387
7876 9311
797 4946
519 9517
3063 7059
58 6852
217 5922
880 8300
55 2862
6263 7...

output:

49995000

result:

ok single line: '49995000'

Test #6:

score: 18
Accepted
time: 31ms
memory: 17180kb

input:

100000
63447 81769
10518 29951
51930 83828
12279 87657
8773 18966
46656 48966
62722 89892
69517 93765
58105 60105
982 94407
791 54257
53876 80692
66742 74816
23323 76655
67885 92952
8403 85783
52402 87875
15846 38499
10650 18431
30208 32962
37083 98919
87323 92004
26540 58217
7398 36425
26815 63605
...

output:

4999950000

result:

ok single line: '4999950000'

Test #7:

score: 18
Accepted
time: 33ms
memory: 15084kb

input:

99999
24661 76768
78932 88592
39439 94999
2718 50597
45435 50780
6109 65023
40701 71357
28528 92157
33870 37270
8624 83187
16605 87636
2186 63940
60672 84899
34548 74456
1862 69878
26044 35256
4755 78299
8458 87992
38587 56668
62601 88766
18622 73840
44594 67444
49486 80039
475 25256
18088 74155
220...

output:

4999850001

result:

ok single line: '4999850001'

Test #8:

score: 18
Accepted
time: 1ms
memory: 5200kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #9:

score: 18
Accepted
time: 1ms
memory: 5904kb

input:

1

output:

0

result:

ok single line: '0'

Subtask #2:

score: 19
Accepted

Dependency #1:

100%
Accepted

Test #10:

score: 19
Accepted
time: 1ms
memory: 6372kb

input:

2
1 2

output:

1

result:

ok single line: '1'

Test #11:

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

input:

100
11 38
22 77
15 96
32 98
44 72
40 80
36 38
24 34
54 84
22 62
4 8
4 27
88 95
43 83
23 87
48 85
20 76
28 95
66 74
37 40
1 71
66 67
52 54
28 60
7 32
12 47
6 83
73 85
45 94
26 35
18 35
52 81
9 74
1 14
61 70
49 55
16 63
59 67
68 81
13 51
31 63
82 92
73 82
42 91
25 100
57 59
53 58
23 33
14 69
72 98
6 7...

output:

4950

result:

ok single line: '4950'

Test #12:

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

input:

1000
456 460
231 501
167 987
355 458
513 745
648 839
405 771
544 908
550 780
247 462
490 968
340 832
354 593
149 984
219 329
139 419
187 353
611 997
21 52
265 700
656 907
648 801
631 754
306 999
79 788
50 372
228 719
383 824
810 860
744 882
271 597
381 469
71 538
590 715
165 536
275 426
736 923
460 ...

output:

499500

result:

ok single line: '499500'

Test #13:

score: 19
Accepted
time: 1ms
memory: 5248kb

input:

999
373 839
435 715
841 962
100 130
434 681
646 725
33 580
188 250
539 937
377 868
174 780
215 708
416 900
85 451
738 884
187 299
380 535
175 437
43 122
342 888
562 681
287 569
114 146
590 894
476 952
927 950
502 522
226 270
300 336
176 997
538 915
634 798
360 673
413 943
12 945
619 685
103 196
301 ...

output:

498501

result:

ok single line: '498501'

Test #14:

score: 19
Accepted
time: 4ms
memory: 6264kb

input:

10000
2478 7912
6084 6327
6138 7981
4307 7844
7336 7751
2033 5179
7681 9457
1937 9759
3179 8668
5807 9140
1393 5001
7092 7269
2949 6914
4827 8482
2076 4009
7719 8871
4555 8189
3200 4462
1027 9388
9 8506
654 8215
3785 7387
7876 9311
797 4946
519 9517
3063 7059
58 6852
217 5922
880 8300
55 2862
6263 7...

output:

49995000

result:

ok single line: '49995000'

Test #15:

score: 19
Accepted
time: 34ms
memory: 17176kb

input:

100000
63447 81769
10518 29951
51930 83828
12279 87657
8773 18966
46656 48966
62722 89892
69517 93765
58105 60105
982 94407
791 54257
53876 80692
66742 74816
23323 76655
67885 92952
8403 85783
52402 87875
15846 38499
10650 18431
30208 32962
37083 98919
87323 92004
26540 58217
7398 36425
26815 63605
...

output:

4999950000

result:

ok single line: '4999950000'

Test #16:

score: 19
Accepted
time: 34ms
memory: 15196kb

input:

99999
24661 76768
78932 88592
39439 94999
2718 50597
45435 50780
6109 65023
40701 71357
28528 92157
33870 37270
8624 83187
16605 87636
2186 63940
60672 84899
34548 74456
1862 69878
26044 35256
4755 78299
8458 87992
38587 56668
62601 88766
18622 73840
44594 67444
49486 80039
475 25256
18088 74155
220...

output:

4999850001

result:

ok single line: '4999850001'

Test #17:

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

input:

100
45 81
22 81
76 81
47 81
2 81
81 100
81 89
34 81
53 81
17 81
27 81
31 81
81 82
60 81
73 81
8 81
81 96
15 81
19 81
48 81
66 81
30 81
81 91
77 81
62 81
68 81
56 81
29 81
81 86
25 81
32 81
65 81
21 81
61 81
9 81
81 84
37 81
74 81
78 81
42 81
81 90
26 81
55 81
46 81
81 88
71 81
14 81
16 81
63 81
38 8...

output:

9703

result:

ok single line: '9703'

Test #18:

score: 19
Accepted
time: 1ms
memory: 6204kb

input:

1000
659 781
659 979
659 943
273 659
659 894
659 969
659 749
659 864
620 659
589 659
193 659
268 659
659 920
59 659
103 659
427 659
283 659
362 659
609 659
659 858
192 659
146 659
659 770
648 659
659 852
659 940
403 659
29 659
500 659
659 959
72 659
155 659
145 659
278 659
510 659
49 659
324 659
64 ...

output:

997003

result:

ok single line: '997003'

Test #19:

score: 19
Accepted
time: 20ms
memory: 11000kb

input:

100000
50511 59294
34909 59294
10993 59294
59294 97527
47908 59294
59294 81925
59216 59294
25837 59294
59294 92808
10453 59294
11141 59294
59294 73455
59294 81004
59294 61180
2029 59294
59294 75044
38324 59294
8583 59294
59294 94696
17989 59294
16068 59294
27599 59294
59294 97427
59294 64207
5929 59...

output:

9999700003

result:

ok single line: '9999700003'

Test #20:

score: 19
Accepted
time: 1ms
memory: 6340kb

input:

100
83 88
62 75
34 74
57 68
8 59
43 81
72 96
26 94
7 99
3 19
55 76
38 45
53 71
32 79
25 30
66 82
20 73
6 56
25 52
29 72
32 55
10 22
28 41
54 100
27 80
26 58
59 86
11 49
25 64
23 29
91 97
25 56
22 70
8 60
40 98
10 39
17 84
47 91
28 36
85 95
13 52
7 19
2 92
25 69
51 80
48 79
23 25
78 82
84 100
3 25
4 ...

output:

7425

result:

ok single line: '7425'

Test #21:

score: 19
Accepted
time: 1ms
memory: 6392kb

input:

1000
139 885
144 178
880 990
684 860
294 917
301 522
719 940
116 706
105 739
617 899
453 582
640 810
599 948
716 848
785 860
755 873
407 781
509 972
688 955
451 517
522 975
259 477
34 630
295 776
281 904
699 751
236 690
94 860
227 319
299 378
597 860
695 936
540 735
79 517
891 999
245 377
500 800
17...

output:

938096

result:

ok single line: '938096'

Test #22:

score: 19
Accepted
time: 4ms
memory: 7244kb

input:

10000
5894 6024
2637 5354
2296 9323
6870 8846
3495 9493
2597 6207
7385 8488
1295 1610
1448 3203
3373 4897
7264 8194
2875 7939
2716 4263
4079 9804
3836 3867
6053 7103
1404 2101
757 5842
3228 6319
3733 7088
3822 6661
4547 5705
6366 8888
2575 4417
5009 7135
4630 6048
124 5269
1503 8644
1132 9512
6651 6...

output:

56008002

result:

ok single line: '56008002'

Test #23:

score: 19
Accepted
time: 35ms
memory: 15228kb

input:

100000
5049 5620
25307 50592
10263 77237
43006 78969
19363 67437
74487 78314
24557 61768
57723 79750
8794 55926
30253 93198
51890 61698
26594 47499
1881 26315
54572 89951
21914 76196
60143 97880
65537 83036
51908 53108
26759 38062
43760 83508
8759 32204
3269 5133
53354 71688
55360 77652
21380 65670
...

output:

5786204822

result:

ok single line: '5786204822'

Test #24:

score: 19
Accepted
time: 30ms
memory: 11828kb

input:

100000
26837 34316
77469 87683
56641 59091
46249 95983
22792 23804
3453 32087
35514 71897
63555 94319
30315 82979
45786 50957
88312 98740
76865 84988
12786 97193
33579 59706
64570 75800
4799 51792
12941 64449
31299 45779
31236 62004
36937 59603
42220 72026
28311 40701
4612 99431
79645 80143
21369 68...

output:

8799333912

result:

ok single line: '8799333912'

Test #25:

score: 19
Accepted
time: 30ms
memory: 10792kb

input:

100000
52648 57089
27094 56193
44235 71656
3167 94996
30352 75606
52406 82870
45668 61852
32043 88645
14149 25705
5179 48377
32333 94734
35596 99356
21010 82075
84626 93457
9461 35246
44446 63587
28832 30653
81661 97135
43258 50604
2362 54573
22817 47971
2685 68290
8686 65683
2435 13122
70012 88220
...

output:

9746169600

result:

ok single line: '9746169600'

Test #26:

score: 19
Accepted
time: 31ms
memory: 10696kb

input:

100000
23092 58407
21164 41080
50766 51564
37960 44544
82514 90187
37611 57893
9736 74907
35281 69884
74762 78579
7774 58686
52913 71829
24130 95133
38324 97423
53829 85447
69238 85218
13928 80885
3105 85906
1102 40798
5473 99416
20417 33320
11465 89766
6711 63641
8482 45900
1799 31089
62779 93845
5...

output:

9957788731

result:

ok single line: '9957788731'

Test #27:

score: 19
Accepted
time: 24ms
memory: 10616kb

input:

100000
41901 86274
81845 81940
73161 81030
3555 66728
44565 87361
54222 89424
34317 63003
7740 19240
16319 17678
23828 28819
19240 23266
19240 86798
10055 72379
15052 84352
33776 77298
23476 36161
32020 67248
19240 94394
8803 18566
14326 28115
27838 28049
10127 19240
19240 33472
21335 38557
42291 96...

output:

9996468765

result:

ok single line: '9996468765'

Test #28:

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

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #29:

score: 19
Accepted
time: 1ms
memory: 5912kb

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #30:

score: 19
Accepted
time: 1ms
memory: 5248kb

input:

1

output:

0

result:

ok single line: '0'

Subtask #3:

score: 20
Accepted

Test #31:

score: 20
Accepted
time: 1ms
memory: 6788kb

input:

3
1 2
1 3

output:

3

result:

ok single line: '3'

Test #32:

score: 20
Accepted
time: 1ms
memory: 5264kb

input:

4
1 2
2 3
1 4

output:

6

result:

ok single line: '6'

Test #33:

score: 20
Accepted
time: 1ms
memory: 6164kb

input:

5
1 2
2 3
1 4
4 5

output:

10

result:

ok single line: '10'

Test #34:

score: 20
Accepted
time: 1ms
memory: 5716kb

input:

5
1 2
2 3
1 4
1 5

output:

11

result:

ok single line: '11'

Test #35:

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

input:

5
1 2
1 3
1 4
1 5

output:

13

result:

ok single line: '13'

Test #36:

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

input:

6
1 2
2 3
1 5
3 4
5 6

output:

15

result:

ok single line: '15'

Test #37:

score: 20
Accepted
time: 1ms
memory: 6624kb

input:

6
1 2
2 3
2 4
1 5
5 6

output:

16

result:

ok single line: '16'

Test #38:

score: 20
Accepted
time: 1ms
memory: 5748kb

input:

6
1 2
2 3
2 4
1 5
1 6

output:

19

result:

ok single line: '19'

Test #39:

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

input:

6
1 2
2 3
1 4
1 6
4 5

output:

17

result:

ok single line: '17'

Test #40:

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

input:

6
1 2
2 3
1 4
1 5
1 6

output:

18

result:

ok single line: '18'

Test #41:

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

input:

6
1 2
1 3
1 4
1 5
1 6

output:

21

result:

ok single line: '21'

Test #42:

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

input:

7
1 2
2 3
1 5
3 4
5 6
6 7

output:

21

result:

ok single line: '21'

Test #43:

score: 20
Accepted
time: 1ms
memory: 6148kb

input:

7
1 2
1 3
1 4
1 5
1 6
1 7

output:

31

result:

ok single line: '31'

Test #44:

score: 20
Accepted
time: 1ms
memory: 5876kb

input:

7
1 2
2 3
1 5
3 4
5 6
5 7

output:

22

result:

ok single line: '22'

Test #45:

score: 20
Accepted
time: 1ms
memory: 5196kb

input:

7
1 2
2 3
1 5
1 7
3 4
5 6

output:

23

result:

ok single line: '23'

Test #46:

score: 20
Accepted
time: 1ms
memory: 5804kb

input:

7
1 2
2 3
2 4
2 5
1 6
6 7

output:

24

result:

ok single line: '24'

Test #47:

score: 20
Accepted
time: 1ms
memory: 7048kb

input:

7
1 2
2 3
2 4
1 5
5 6
5 7

output:

26

result:

ok single line: '26'

Test #48:

score: 20
Accepted
time: 1ms
memory: 6268kb

input:

7
1 2
2 3
2 4
1 5
1 7
5 6

output:

25

result:

ok single line: '25'

Test #49:

score: 20
Accepted
time: 1ms
memory: 5268kb

input:

7
1 2
2 3
2 4
1 5
1 6
1 7

output:

28

result:

ok single line: '28'

Test #50:

score: 20
Accepted
time: 1ms
memory: 6504kb

input:

7
1 2
2 3
1 4
1 6
4 5
6 7

output:

25

result:

ok single line: '25'

Test #51:

score: 20
Accepted
time: 1ms
memory: 6060kb

input:

7
1 2
2 3
1 4
1 6
1 7
4 5

output:

26

result:

ok single line: '26'

Test #52:

score: 20
Accepted
time: 1ms
memory: 6152kb

input:

7
1 2
2 3
1 4
1 5
1 6
1 7

output:

27

result:

ok single line: '27'

Test #53:

score: 20
Accepted
time: 1ms
memory: 6272kb

input:

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

output:

28

result:

ok single line: '28'

Test #54:

score: 20
Accepted
time: 1ms
memory: 6404kb

input:

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

output:

33

result:

ok single line: '33'

Test #55:

score: 20
Accepted
time: 1ms
memory: 6552kb

input:

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

output:

34

result:

ok single line: '34'

Test #56:

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

input:

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

output:

36

result:

ok single line: '36'

Test #57:

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

input:

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

output:

35

result:

ok single line: '35'

Test #58:

score: 20
Accepted
time: 1ms
memory: 6436kb

input:

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

output:

40

result:

ok single line: '40'

Test #59:

score: 20
Accepted
time: 1ms
memory: 5776kb

input:

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

output:

37

result:

ok single line: '37'

Test #60:

score: 20
Accepted
time: 1ms
memory: 5172kb

input:

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

output:

35

result:

ok single line: '35'

Test #61:

score: 20
Accepted
time: 1ms
memory: 7036kb

input:

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

output:

36

result:

ok single line: '36'

Test #62:

score: 20
Accepted
time: 1ms
memory: 6640kb

input:

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

output:

39

result:

ok single line: '39'

Test #63:

score: 20
Accepted
time: 1ms
memory: 5180kb

input:

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

output:

36

result:

ok single line: '36'

Test #64:

score: 20
Accepted
time: 1ms
memory: 6816kb

input:

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

output:

29

result:

ok single line: '29'

Test #65:

score: 20
Accepted
time: 1ms
memory: 7164kb

input:

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

output:

37

result:

ok single line: '37'

Test #66:

score: 20
Accepted
time: 1ms
memory: 6720kb

input:

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

output:

38

result:

ok single line: '38'

Test #67:

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

input:

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

output:

43

result:

ok single line: '43'

Test #68:

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

input:

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

output:

34

result:

ok single line: '34'

Test #69:

score: 20
Accepted
time: 1ms
memory: 6180kb

input:

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

output:

30

result:

ok single line: '30'

Test #70:

score: 20
Accepted
time: 1ms
memory: 5208kb

input:

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

output:

33

result:

ok single line: '33'

Test #71:

score: 20
Accepted
time: 1ms
memory: 5224kb

input:

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

output:

34

result:

ok single line: '34'

Test #72:

score: 20
Accepted
time: 1ms
memory: 6040kb

input:

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

output:

31

result:

ok single line: '31'

Test #73:

score: 20
Accepted
time: 1ms
memory: 6624kb

input:

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

output:

31

result:

ok single line: '31'

Test #74:

score: 20
Accepted
time: 1ms
memory: 6988kb

input:

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

output:

32

result:

ok single line: '32'

Test #75:

score: 20
Accepted
time: 1ms
memory: 7136kb

input:

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

output:

32

result:

ok single line: '32'

Test #76:

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

input:

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

output:

36

result:

ok single line: '36'

Test #77:

score: 20
Accepted
time: 1ms
memory: 6148kb

input:

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

output:

46

result:

ok single line: '46'

Test #78:

score: 20
Accepted
time: 1ms
memory: 7136kb

input:

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

output:

45

result:

ok single line: '45'

Test #79:

score: 20
Accepted
time: 1ms
memory: 6448kb

input:

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

output:

46

result:

ok single line: '46'

Test #80:

score: 20
Accepted
time: 1ms
memory: 6656kb

input:

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

output:

40

result:

ok single line: '40'

Test #81:

score: 20
Accepted
time: 1ms
memory: 6100kb

input:

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

output:

41

result:

ok single line: '41'

Test #82:

score: 20
Accepted
time: 1ms
memory: 5748kb

input:

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

output:

43

result:

ok single line: '43'

Test #83:

score: 20
Accepted
time: 1ms
memory: 6088kb

input:

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

output:

42

result:

ok single line: '42'

Test #84:

score: 20
Accepted
time: 1ms
memory: 5860kb

input:

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

output:

44

result:

ok single line: '44'

Test #85:

score: 20
Accepted
time: 1ms
memory: 6356kb

input:

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

output:

45

result:

ok single line: '45'

Test #86:

score: 20
Accepted
time: 1ms
memory: 5176kb

input:

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

output:

45

result:

ok single line: '45'

Test #87:

score: 20
Accepted
time: 1ms
memory: 5940kb

input:

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

output:

37

result:

ok single line: '37'

Test #88:

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

input:

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

output:

46

result:

ok single line: '46'

Test #89:

score: 20
Accepted
time: 1ms
memory: 7080kb

input:

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

output:

42

result:

ok single line: '42'

Test #90:

score: 20
Accepted
time: 1ms
memory: 7224kb

input:

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

output:

43

result:

ok single line: '43'

Test #91:

score: 20
Accepted
time: 1ms
memory: 7132kb

input:

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

output:

42

result:

ok single line: '42'

Test #92:

score: 20
Accepted
time: 1ms
memory: 5208kb

input:

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

output:

43

result:

ok single line: '43'

Test #93:

score: 20
Accepted
time: 1ms
memory: 5196kb

input:

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

output:

43

result:

ok single line: '43'

Test #94:

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

input:

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

output:

44

result:

ok single line: '44'

Test #95:

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

input:

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

output:

44

result:

ok single line: '44'

Test #96:

score: 20
Accepted
time: 1ms
memory: 5192kb

input:

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

output:

45

result:

ok single line: '45'

Test #97:

score: 20
Accepted
time: 1ms
memory: 5748kb

input:

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

output:

46

result:

ok single line: '46'

Test #98:

score: 20
Accepted
time: 1ms
memory: 6092kb

input:

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

output:

38

result:

ok single line: '38'

Test #99:

score: 20
Accepted
time: 1ms
memory: 6832kb

input:

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

output:

48

result:

ok single line: '48'

Test #100:

score: 20
Accepted
time: 1ms
memory: 6732kb

input:

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

output:

47

result:

ok single line: '47'

Test #101:

score: 20
Accepted
time: 1ms
memory: 6960kb

input:

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

output:

50

result:

ok single line: '50'

Test #102:

score: 20
Accepted
time: 1ms
memory: 6592kb

input:

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

output:

49

result:

ok single line: '49'

Test #103:

score: 20
Accepted
time: 1ms
memory: 5912kb

input:

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

output:

47

result:

ok single line: '47'

Test #104:

score: 20
Accepted
time: 1ms
memory: 6976kb

input:

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

output:

48

result:

ok single line: '48'

Test #105:

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

input:

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

output:

53

result:

ok single line: '53'

Test #106:

score: 20
Accepted
time: 1ms
memory: 7064kb

input:

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

output:

47

result:

ok single line: '47'

Test #107:

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

input:

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

output:

50

result:

ok single line: '50'

Test #108:

score: 20
Accepted
time: 1ms
memory: 5144kb

input:

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

output:

48

result:

ok single line: '48'

Test #109:

score: 20
Accepted
time: 1ms
memory: 5244kb

input:

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

output:

39

result:

ok single line: '39'

Test #110:

score: 20
Accepted
time: 1ms
memory: 5120kb

input:

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

output:

49

result:

ok single line: '49'

Test #111:

score: 20
Accepted
time: 1ms
memory: 7004kb

input:

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

output:

52

result:

ok single line: '52'

Test #112:

score: 20
Accepted
time: 1ms
memory: 5244kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #113:

score: 20
Accepted
time: 1ms
memory: 6576kb

input:

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

output:

48

result:

ok single line: '48'

Test #114:

score: 20
Accepted
time: 1ms
memory: 5784kb

input:

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

output:

49

result:

ok single line: '49'

Test #115:

score: 20
Accepted
time: 1ms
memory: 5988kb

input:

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

output:

50

result:

ok single line: '50'

Test #116:

score: 20
Accepted
time: 1ms
memory: 5112kb

input:

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

output:

51

result:

ok single line: '51'

Test #117:

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

input:

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

output:

57

result:

ok single line: '57'

Test #118:

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

input:

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

output:

39

result:

ok single line: '39'

Test #119:

score: 20
Accepted
time: 1ms
memory: 5992kb

input:

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

output:

40

result:

ok single line: '40'

Test #120:

score: 20
Accepted
time: 1ms
memory: 6784kb

input:

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

output:

43

result:

ok single line: '43'

Test #121:

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

input:

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

output:

42

result:

ok single line: '42'

Test #122:

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

input:

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

output:

41

result:

ok single line: '41'

Test #123:

score: 20
Accepted
time: 1ms
memory: 5664kb

input:

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

output:

45

result:

ok single line: '45'

Test #124:

score: 20
Accepted
time: 1ms
memory: 6172kb

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #125:

score: 20
Accepted
time: 1ms
memory: 7028kb

input:

1

output:

0

result:

ok single line: '0'

Subtask #4:

score: 21
Accepted

Dependency #3:

100%
Accepted

Test #126:

score: 21
Accepted
time: 0ms
memory: 5212kb

input:

3
1 2
1 3

output:

3

result:

ok single line: '3'

Test #127:

score: 21
Accepted
time: 0ms
memory: 5108kb

input:

4
1 2
2 3
1 4

output:

6

result:

ok single line: '6'

Test #128:

score: 21
Accepted
time: 1ms
memory: 6156kb

input:

5
1 2
2 3
1 4
4 5

output:

10

result:

ok single line: '10'

Test #129:

score: 21
Accepted
time: 0ms
memory: 5136kb

input:

5
1 2
2 3
1 4
1 5

output:

11

result:

ok single line: '11'

Test #130:

score: 21
Accepted
time: 0ms
memory: 6680kb

input:

5
1 2
1 3
1 4
1 5

output:

13

result:

ok single line: '13'

Test #131:

score: 21
Accepted
time: 1ms
memory: 6472kb

input:

6
1 2
2 3
1 5
3 4
5 6

output:

15

result:

ok single line: '15'

Test #132:

score: 21
Accepted
time: 1ms
memory: 6468kb

input:

6
1 2
2 3
2 4
1 5
5 6

output:

16

result:

ok single line: '16'

Test #133:

score: 21
Accepted
time: 1ms
memory: 6392kb

input:

6
1 2
2 3
2 4
1 5
1 6

output:

19

result:

ok single line: '19'

Test #134:

score: 21
Accepted
time: 0ms
memory: 6724kb

input:

6
1 2
2 3
1 4
1 6
4 5

output:

17

result:

ok single line: '17'

Test #135:

score: 21
Accepted
time: 0ms
memory: 6276kb

input:

6
1 2
2 3
1 4
1 5
1 6

output:

18

result:

ok single line: '18'

Test #136:

score: 21
Accepted
time: 1ms
memory: 5996kb

input:

6
1 2
1 3
1 4
1 5
1 6

output:

21

result:

ok single line: '21'

Test #137:

score: 21
Accepted
time: 1ms
memory: 5204kb

input:

7
1 2
2 3
1 5
3 4
5 6
6 7

output:

21

result:

ok single line: '21'

Test #138:

score: 21
Accepted
time: 1ms
memory: 5172kb

input:

7
1 2
1 3
1 4
1 5
1 6
1 7

output:

31

result:

ok single line: '31'

Test #139:

score: 21
Accepted
time: 1ms
memory: 5188kb

input:

7
1 2
2 3
1 5
3 4
5 6
5 7

output:

22

result:

ok single line: '22'

Test #140:

score: 21
Accepted
time: 1ms
memory: 6480kb

input:

7
1 2
2 3
1 5
1 7
3 4
5 6

output:

23

result:

ok single line: '23'

Test #141:

score: 21
Accepted
time: 1ms
memory: 6360kb

input:

7
1 2
2 3
2 4
2 5
1 6
6 7

output:

24

result:

ok single line: '24'

Test #142:

score: 21
Accepted
time: 0ms
memory: 6360kb

input:

7
1 2
2 3
2 4
1 5
5 6
5 7

output:

26

result:

ok single line: '26'

Test #143:

score: 21
Accepted
time: 0ms
memory: 6612kb

input:

7
1 2
2 3
2 4
1 5
1 7
5 6

output:

25

result:

ok single line: '25'

Test #144:

score: 21
Accepted
time: 0ms
memory: 7216kb

input:

7
1 2
2 3
2 4
1 5
1 6
1 7

output:

28

result:

ok single line: '28'

Test #145:

score: 21
Accepted
time: 1ms
memory: 6368kb

input:

7
1 2
2 3
1 4
1 6
4 5
6 7

output:

25

result:

ok single line: '25'

Test #146:

score: 21
Accepted
time: 1ms
memory: 6652kb

input:

7
1 2
2 3
1 4
1 6
1 7
4 5

output:

26

result:

ok single line: '26'

Test #147:

score: 21
Accepted
time: 1ms
memory: 6328kb

input:

7
1 2
2 3
1 4
1 5
1 6
1 7

output:

27

result:

ok single line: '27'

Test #148:

score: 21
Accepted
time: 1ms
memory: 6752kb

input:

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

output:

28

result:

ok single line: '28'

Test #149:

score: 21
Accepted
time: 1ms
memory: 6108kb

input:

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

output:

33

result:

ok single line: '33'

Test #150:

score: 21
Accepted
time: 1ms
memory: 6540kb

input:

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

output:

34

result:

ok single line: '34'

Test #151:

score: 21
Accepted
time: 0ms
memory: 6832kb

input:

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

output:

36

result:

ok single line: '36'

Test #152:

score: 21
Accepted
time: 1ms
memory: 6532kb

input:

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

output:

35

result:

ok single line: '35'

Test #153:

score: 21
Accepted
time: 0ms
memory: 6404kb

input:

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

output:

40

result:

ok single line: '40'

Test #154:

score: 21
Accepted
time: 0ms
memory: 5928kb

input:

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

output:

37

result:

ok single line: '37'

Test #155:

score: 21
Accepted
time: 1ms
memory: 6184kb

input:

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

output:

35

result:

ok single line: '35'

Test #156:

score: 21
Accepted
time: 0ms
memory: 7180kb

input:

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

output:

36

result:

ok single line: '36'

Test #157:

score: 21
Accepted
time: 0ms
memory: 5244kb

input:

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

output:

39

result:

ok single line: '39'

Test #158:

score: 21
Accepted
time: 0ms
memory: 6196kb

input:

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

output:

36

result:

ok single line: '36'

Test #159:

score: 21
Accepted
time: 0ms
memory: 7044kb

input:

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

output:

29

result:

ok single line: '29'

Test #160:

score: 21
Accepted
time: 0ms
memory: 6672kb

input:

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

output:

37

result:

ok single line: '37'

Test #161:

score: 21
Accepted
time: 0ms
memory: 6320kb

input:

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

output:

38

result:

ok single line: '38'

Test #162:

score: 21
Accepted
time: 0ms
memory: 7120kb

input:

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

output:

43

result:

ok single line: '43'

Test #163:

score: 21
Accepted
time: 0ms
memory: 6048kb

input:

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

output:

34

result:

ok single line: '34'

Test #164:

score: 21
Accepted
time: 1ms
memory: 6148kb

input:

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

output:

30

result:

ok single line: '30'

Test #165:

score: 21
Accepted
time: 1ms
memory: 5272kb

input:

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

output:

33

result:

ok single line: '33'

Test #166:

score: 21
Accepted
time: 0ms
memory: 6212kb

input:

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

output:

34

result:

ok single line: '34'

Test #167:

score: 21
Accepted
time: 1ms
memory: 6436kb

input:

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

output:

31

result:

ok single line: '31'

Test #168:

score: 21
Accepted
time: 1ms
memory: 6884kb

input:

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

output:

31

result:

ok single line: '31'

Test #169:

score: 21
Accepted
time: 1ms
memory: 5192kb

input:

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

output:

32

result:

ok single line: '32'

Test #170:

score: 21
Accepted
time: 1ms
memory: 5144kb

input:

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

output:

32

result:

ok single line: '32'

Test #171:

score: 21
Accepted
time: 1ms
memory: 6852kb

input:

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

output:

36

result:

ok single line: '36'

Test #172:

score: 21
Accepted
time: 1ms
memory: 7112kb

input:

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

output:

46

result:

ok single line: '46'

Test #173:

score: 21
Accepted
time: 1ms
memory: 5244kb

input:

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

output:

45

result:

ok single line: '45'

Test #174:

score: 21
Accepted
time: 0ms
memory: 6328kb

input:

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

output:

46

result:

ok single line: '46'

Test #175:

score: 21
Accepted
time: 1ms
memory: 6988kb

input:

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

output:

40

result:

ok single line: '40'

Test #176:

score: 21
Accepted
time: 1ms
memory: 5264kb

input:

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

output:

41

result:

ok single line: '41'

Test #177:

score: 21
Accepted
time: 1ms
memory: 5192kb

input:

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

output:

43

result:

ok single line: '43'

Test #178:

score: 21
Accepted
time: 1ms
memory: 6016kb

input:

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

output:

42

result:

ok single line: '42'

Test #179:

score: 21
Accepted
time: 1ms
memory: 5144kb

input:

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

output:

44

result:

ok single line: '44'

Test #180:

score: 21
Accepted
time: 1ms
memory: 5120kb

input:

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

output:

45

result:

ok single line: '45'

Test #181:

score: 21
Accepted
time: 1ms
memory: 6456kb

input:

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

output:

45

result:

ok single line: '45'

Test #182:

score: 21
Accepted
time: 1ms
memory: 5920kb

input:

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

output:

37

result:

ok single line: '37'

Test #183:

score: 21
Accepted
time: 1ms
memory: 6492kb

input:

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

output:

46

result:

ok single line: '46'

Test #184:

score: 21
Accepted
time: 1ms
memory: 7060kb

input:

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

output:

42

result:

ok single line: '42'

Test #185:

score: 21
Accepted
time: 1ms
memory: 5264kb

input:

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

output:

43

result:

ok single line: '43'

Test #186:

score: 21
Accepted
time: 1ms
memory: 6256kb

input:

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

output:

42

result:

ok single line: '42'

Test #187:

score: 21
Accepted
time: 1ms
memory: 6912kb

input:

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

output:

43

result:

ok single line: '43'

Test #188:

score: 21
Accepted
time: 1ms
memory: 6932kb

input:

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

output:

43

result:

ok single line: '43'

Test #189:

score: 21
Accepted
time: 1ms
memory: 6104kb

input:

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

output:

44

result:

ok single line: '44'

Test #190:

score: 21
Accepted
time: 0ms
memory: 5124kb

input:

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

output:

44

result:

ok single line: '44'

Test #191:

score: 21
Accepted
time: 1ms
memory: 6620kb

input:

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

output:

45

result:

ok single line: '45'

Test #192:

score: 21
Accepted
time: 0ms
memory: 5264kb

input:

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

output:

46

result:

ok single line: '46'

Test #193:

score: 21
Accepted
time: 1ms
memory: 6800kb

input:

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

output:

38

result:

ok single line: '38'

Test #194:

score: 21
Accepted
time: 0ms
memory: 6852kb

input:

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

output:

48

result:

ok single line: '48'

Test #195:

score: 21
Accepted
time: 0ms
memory: 7048kb

input:

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

output:

47

result:

ok single line: '47'

Test #196:

score: 21
Accepted
time: 0ms
memory: 5200kb

input:

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

output:

50

result:

ok single line: '50'

Test #197:

score: 21
Accepted
time: 0ms
memory: 7084kb

input:

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

output:

49

result:

ok single line: '49'

Test #198:

score: 21
Accepted
time: 1ms
memory: 6376kb

input:

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

output:

47

result:

ok single line: '47'

Test #199:

score: 21
Accepted
time: 1ms
memory: 6320kb

input:

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

output:

48

result:

ok single line: '48'

Test #200:

score: 21
Accepted
time: 1ms
memory: 6400kb

input:

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

output:

53

result:

ok single line: '53'

Test #201:

score: 21
Accepted
time: 1ms
memory: 6272kb

input:

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

output:

47

result:

ok single line: '47'

Test #202:

score: 21
Accepted
time: 0ms
memory: 5176kb

input:

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

output:

50

result:

ok single line: '50'

Test #203:

score: 21
Accepted
time: 1ms
memory: 5120kb

input:

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

output:

48

result:

ok single line: '48'

Test #204:

score: 21
Accepted
time: 0ms
memory: 5264kb

input:

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

output:

39

result:

ok single line: '39'

Test #205:

score: 21
Accepted
time: 0ms
memory: 5916kb

input:

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

output:

49

result:

ok single line: '49'

Test #206:

score: 21
Accepted
time: 1ms
memory: 6164kb

input:

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

output:

52

result:

ok single line: '52'

Test #207:

score: 21
Accepted
time: 1ms
memory: 7140kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #208:

score: 21
Accepted
time: 1ms
memory: 5244kb

input:

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

output:

48

result:

ok single line: '48'

Test #209:

score: 21
Accepted
time: 0ms
memory: 7212kb

input:

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

output:

49

result:

ok single line: '49'

Test #210:

score: 21
Accepted
time: 1ms
memory: 6608kb

input:

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

output:

50

result:

ok single line: '50'

Test #211:

score: 21
Accepted
time: 1ms
memory: 5860kb

input:

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

output:

51

result:

ok single line: '51'

Test #212:

score: 21
Accepted
time: 1ms
memory: 6052kb

input:

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

output:

57

result:

ok single line: '57'

Test #213:

score: 21
Accepted
time: 1ms
memory: 5172kb

input:

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

output:

39

result:

ok single line: '39'

Test #214:

score: 21
Accepted
time: 0ms
memory: 5268kb

input:

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

output:

40

result:

ok single line: '40'

Test #215:

score: 21
Accepted
time: 1ms
memory: 6924kb

input:

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

output:

43

result:

ok single line: '43'

Test #216:

score: 21
Accepted
time: 1ms
memory: 6428kb

input:

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

output:

42

result:

ok single line: '42'

Test #217:

score: 21
Accepted
time: 1ms
memory: 5196kb

input:

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

output:

41

result:

ok single line: '41'

Test #218:

score: 21
Accepted
time: 1ms
memory: 5192kb

input:

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

output:

45

result:

ok single line: '45'

Test #219:

score: 21
Accepted
time: 2ms
memory: 7300kb

input:

1000
924 985
926 985
924 987
904 926
739 904
912 985
685 912
67 926
620 926
77 739
77 860
635 926
900 985
551 924
900 986
53 985
402 912
73 985
432 551
113 987
648 926
265 912
737 912
432 759
432 823
739 841
549 823
145 549
724 985
40 145
767 985
429 648
67 936
444 900
245 860
265 304
429 613
46 245...

output:

982402

result:

ok single line: '982402'

Test #220:

score: 21
Accepted
time: 0ms
memory: 7148kb

input:

1000
483 734
377 483
377 934
53 377
176 934
176 767
252 767
377 735
483 917
483 563
192 252
500 917
376 563
500 937
244 563
192 912
176 823
1 192
415 912
111 500
250 735
111 725
563 893
1 199
439 734
817 937
752 893
488 725
428 912
327 817
78 500
78 620
934 966
681 917
500 795
149 966
192 650
192 28...

output:

978624

result:

ok single line: '978624'

Test #221:

score: 21
Accepted
time: 0ms
memory: 6712kb

input:

1000
278 449
267 449
193 449
278 702
193 329
271 702
271 384
267 764
92 702
132 271
278 322
212 384
132 481
384 556
540 556
267 377
377 697
449 763
517 697
329 482
540 893
106 193
86 517
37 702
37 756
86 641
86 792
267 830
191 377
322 648
426 540
30 193
556 787
221 384
377 533
792 967
334 756
508 55...

output:

980907

result:

ok single line: '980907'

Test #222:

score: 21
Accepted
time: 1ms
memory: 5768kb

input:

1000
699 958
255 747
423 986
879 883
195 595
213 955
53 739
400 613
164 902
129 969
107 931
221 386
582 815
783 974
774 842
451 899
1 932
214 929
254 533
107 624
73 638
74 739
9 960
31 147
214 669
289 675
291 867
244 638
352 543
250 846
129 542
871 998
267 793
182 782
265 315
573 901
482 522
401 482...

output:

983819

result:

ok single line: '983819'

Test #223:

score: 21
Accepted
time: 1ms
memory: 7200kb

input:

999
4 606
471 679
109 662
37 337
428 467
55 507
153 749
290 582
507 546
85 186
173 669
110 277
465 469
216 796
711 877
70 943
69 415
72 150
33 62
222 570
148 776
455 569
304 982
451 625
275 531
371 737
441 479
290 715
258 356
967 981
61 848
191 837
205 251
805 896
757 797
131 262
323 623
760 861
60 ...

output:

981851

result:

ok single line: '981851'

Test #224:

score: 21
Accepted
time: 1ms
memory: 7004kb

input:

1000
224 950
197 1000
28 613
133 760
647 836
556 615
470 688
2 60
8 817
317 324
669 957
613 890
817 935
675 994
145 534
6 909
29 533
625 754
81 742
310 766
115 198
573 764
243 815
329 441
161 644
333 536
908 951
404 479
287 548
541 865
420 958
760 925
61 156
620 789
83 86
63 218
708 844
402 476
242 ...

output:

988389

result:

ok single line: '988389'

Test #225:

score: 21
Accepted
time: 1ms
memory: 6912kb

input:

999
267 668
388 633
175 743
98 622
125 660
409 839
235 936
316 617
862 901
732 878
409 817
59 760
574 947
374 620
88 838
97 901
243 946
73 160
95 803
50 109
198 303
479 635
163 737
266 821
124 529
919 957
176 289
264 388
148 906
454 713
719 843
291 434
151 254
951 952
835 849
146 931
686 967
469 571...

output:

986393

result:

ok single line: '986393'

Test #226:

score: 21
Accepted
time: 1ms
memory: 6388kb

input:

998
578 799
239 379
574 944
162 854
488 673
592 951
406 525
242 920
54 826
181 417
481 607
523 711
580 954
401 975
883 980
334 903
574 747
137 324
462 817
36 392
753 787
58 741
519 756
14 290
67 398
355 602
77 687
661 910
143 782
385 577
474 687
577 934
499 613
108 766
155 707
553 956
60 117
514 991...

output:

984399

result:

ok single line: '984399'

Test #227:

score: 21
Accepted
time: 1ms
memory: 6288kb

input:

1000
335 602
369 625
642 923
142 782
32 55
504 657
48 636
57 994
397 961
66 642
922 933
36 691
603 961
790 802
486 561
119 179
10 459
547 930
370 954
427 594
53 735
17 642
348 980
516 861
710 860
597 948
691 974
230 804
15 119
276 321
211 425
169 597
213 691
611 636
117 879
140 445
288 895
129 745
4...

output:

993345

result:

ok single line: '993345'

Test #228:

score: 21
Accepted
time: 1ms
memory: 6092kb

input:

1000
136 715
79 491
419 963
383 926
202 512
743 800
738 754
43 963
714 963
203 512
655 926
136 774
172 451
22 512
172 845
512 562
172 437
228 743
172 395
669 738
512 818
316 491
159 670
273 512
466 840
172 502
613 743
466 626
3 963
542 926
919 963
571 926
56 466
172 854
136 450
878 963
136 415
381 6...

output:

995304

result:

ok single line: '995304'

Test #229:

score: 21
Accepted
time: 1ms
memory: 6880kb

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #230:

score: 21
Accepted
time: 0ms
memory: 5752kb

input:

1

output:

0

result:

ok single line: '0'

Subtask #5:

score: 22
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #231:

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

input:

2
1 2

output:

1

result:

ok single line: '1'

Test #232:

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

input:

100
11 38
22 77
15 96
32 98
44 72
40 80
36 38
24 34
54 84
22 62
4 8
4 27
88 95
43 83
23 87
48 85
20 76
28 95
66 74
37 40
1 71
66 67
52 54
28 60
7 32
12 47
6 83
73 85
45 94
26 35
18 35
52 81
9 74
1 14
61 70
49 55
16 63
59 67
68 81
13 51
31 63
82 92
73 82
42 91
25 100
57 59
53 58
23 33
14 69
72 98
6 7...

output:

4950

result:

ok single line: '4950'

Test #233:

score: 22
Accepted
time: 1ms
memory: 7236kb

input:

1000
456 460
231 501
167 987
355 458
513 745
648 839
405 771
544 908
550 780
247 462
490 968
340 832
354 593
149 984
219 329
139 419
187 353
611 997
21 52
265 700
656 907
648 801
631 754
306 999
79 788
50 372
228 719
383 824
810 860
744 882
271 597
381 469
71 538
590 715
165 536
275 426
736 923
460 ...

output:

499500

result:

ok single line: '499500'

Test #234:

score: 22
Accepted
time: 1ms
memory: 6636kb

input:

999
373 839
435 715
841 962
100 130
434 681
646 725
33 580
188 250
539 937
377 868
174 780
215 708
416 900
85 451
738 884
187 299
380 535
175 437
43 122
342 888
562 681
287 569
114 146
590 894
476 952
927 950
502 522
226 270
300 336
176 997
538 915
634 798
360 673
413 943
12 945
619 685
103 196
301 ...

output:

498501

result:

ok single line: '498501'

Test #235:

score: 22
Accepted
time: 3ms
memory: 7024kb

input:

10000
2478 7912
6084 6327
6138 7981
4307 7844
7336 7751
2033 5179
7681 9457
1937 9759
3179 8668
5807 9140
1393 5001
7092 7269
2949 6914
4827 8482
2076 4009
7719 8871
4555 8189
3200 4462
1027 9388
9 8506
654 8215
3785 7387
7876 9311
797 4946
519 9517
3063 7059
58 6852
217 5922
880 8300
55 2862
6263 7...

output:

49995000

result:

ok single line: '49995000'

Test #236:

score: 22
Accepted
time: 30ms
memory: 17124kb

input:

100000
63447 81769
10518 29951
51930 83828
12279 87657
8773 18966
46656 48966
62722 89892
69517 93765
58105 60105
982 94407
791 54257
53876 80692
66742 74816
23323 76655
67885 92952
8403 85783
52402 87875
15846 38499
10650 18431
30208 32962
37083 98919
87323 92004
26540 58217
7398 36425
26815 63605
...

output:

4999950000

result:

ok single line: '4999950000'

Test #237:

score: 22
Accepted
time: 23ms
memory: 15068kb

input:

99999
24661 76768
78932 88592
39439 94999
2718 50597
45435 50780
6109 65023
40701 71357
28528 92157
33870 37270
8624 83187
16605 87636
2186 63940
60672 84899
34548 74456
1862 69878
26044 35256
4755 78299
8458 87992
38587 56668
62601 88766
18622 73840
44594 67444
49486 80039
475 25256
18088 74155
220...

output:

4999850001

result:

ok single line: '4999850001'

Test #238:

score: 22
Accepted
time: 1ms
memory: 6728kb

input:

100
45 81
22 81
76 81
47 81
2 81
81 100
81 89
34 81
53 81
17 81
27 81
31 81
81 82
60 81
73 81
8 81
81 96
15 81
19 81
48 81
66 81
30 81
81 91
77 81
62 81
68 81
56 81
29 81
81 86
25 81
32 81
65 81
21 81
61 81
9 81
81 84
37 81
74 81
78 81
42 81
81 90
26 81
55 81
46 81
81 88
71 81
14 81
16 81
63 81
38 8...

output:

9703

result:

ok single line: '9703'

Test #239:

score: 22
Accepted
time: 1ms
memory: 7044kb

input:

1000
659 781
659 979
659 943
273 659
659 894
659 969
659 749
659 864
620 659
589 659
193 659
268 659
659 920
59 659
103 659
427 659
283 659
362 659
609 659
659 858
192 659
146 659
659 770
648 659
659 852
659 940
403 659
29 659
500 659
659 959
72 659
155 659
145 659
278 659
510 659
49 659
324 659
64 ...

output:

997003

result:

ok single line: '997003'

Test #240:

score: 22
Accepted
time: 19ms
memory: 11052kb

input:

100000
50511 59294
34909 59294
10993 59294
59294 97527
47908 59294
59294 81925
59216 59294
25837 59294
59294 92808
10453 59294
11141 59294
59294 73455
59294 81004
59294 61180
2029 59294
59294 75044
38324 59294
8583 59294
59294 94696
17989 59294
16068 59294
27599 59294
59294 97427
59294 64207
5929 59...

output:

9999700003

result:

ok single line: '9999700003'

Test #241:

score: 22
Accepted
time: 1ms
memory: 5196kb

input:

100
83 88
62 75
34 74
57 68
8 59
43 81
72 96
26 94
7 99
3 19
55 76
38 45
53 71
32 79
25 30
66 82
20 73
6 56
25 52
29 72
32 55
10 22
28 41
54 100
27 80
26 58
59 86
11 49
25 64
23 29
91 97
25 56
22 70
8 60
40 98
10 39
17 84
47 91
28 36
85 95
13 52
7 19
2 92
25 69
51 80
48 79
23 25
78 82
84 100
3 25
4 ...

output:

7425

result:

ok single line: '7425'

Test #242:

score: 22
Accepted
time: 2ms
memory: 6964kb

input:

1000
139 885
144 178
880 990
684 860
294 917
301 522
719 940
116 706
105 739
617 899
453 582
640 810
599 948
716 848
785 860
755 873
407 781
509 972
688 955
451 517
522 975
259 477
34 630
295 776
281 904
699 751
236 690
94 860
227 319
299 378
597 860
695 936
540 735
79 517
891 999
245 377
500 800
17...

output:

938096

result:

ok single line: '938096'

Test #243:

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

input:

10000
5894 6024
2637 5354
2296 9323
6870 8846
3495 9493
2597 6207
7385 8488
1295 1610
1448 3203
3373 4897
7264 8194
2875 7939
2716 4263
4079 9804
3836 3867
6053 7103
1404 2101
757 5842
3228 6319
3733 7088
3822 6661
4547 5705
6366 8888
2575 4417
5009 7135
4630 6048
124 5269
1503 8644
1132 9512
6651 6...

output:

56008002

result:

ok single line: '56008002'

Test #244:

score: 22
Accepted
time: 39ms
memory: 15272kb

input:

100000
5049 5620
25307 50592
10263 77237
43006 78969
19363 67437
74487 78314
24557 61768
57723 79750
8794 55926
30253 93198
51890 61698
26594 47499
1881 26315
54572 89951
21914 76196
60143 97880
65537 83036
51908 53108
26759 38062
43760 83508
8759 32204
3269 5133
53354 71688
55360 77652
21380 65670
...

output:

5786204822

result:

ok single line: '5786204822'

Test #245:

score: 22
Accepted
time: 31ms
memory: 11736kb

input:

100000
26837 34316
77469 87683
56641 59091
46249 95983
22792 23804
3453 32087
35514 71897
63555 94319
30315 82979
45786 50957
88312 98740
76865 84988
12786 97193
33579 59706
64570 75800
4799 51792
12941 64449
31299 45779
31236 62004
36937 59603
42220 72026
28311 40701
4612 99431
79645 80143
21369 68...

output:

8799333912

result:

ok single line: '8799333912'

Test #246:

score: 22
Accepted
time: 27ms
memory: 10856kb

input:

100000
52648 57089
27094 56193
44235 71656
3167 94996
30352 75606
52406 82870
45668 61852
32043 88645
14149 25705
5179 48377
32333 94734
35596 99356
21010 82075
84626 93457
9461 35246
44446 63587
28832 30653
81661 97135
43258 50604
2362 54573
22817 47971
2685 68290
8686 65683
2435 13122
70012 88220
...

output:

9746169600

result:

ok single line: '9746169600'

Test #247:

score: 22
Accepted
time: 34ms
memory: 10724kb

input:

100000
23092 58407
21164 41080
50766 51564
37960 44544
82514 90187
37611 57893
9736 74907
35281 69884
74762 78579
7774 58686
52913 71829
24130 95133
38324 97423
53829 85447
69238 85218
13928 80885
3105 85906
1102 40798
5473 99416
20417 33320
11465 89766
6711 63641
8482 45900
1799 31089
62779 93845
5...

output:

9957788731

result:

ok single line: '9957788731'

Test #248:

score: 22
Accepted
time: 19ms
memory: 10612kb

input:

100000
41901 86274
81845 81940
73161 81030
3555 66728
44565 87361
54222 89424
34317 63003
7740 19240
16319 17678
23828 28819
19240 23266
19240 86798
10055 72379
15052 84352
33776 77298
23476 36161
32020 67248
19240 94394
8803 18566
14326 28115
27838 28049
10127 19240
19240 33472
21335 38557
42291 96...

output:

9996468765

result:

ok single line: '9996468765'

Test #249:

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

input:

3
1 2
1 3

output:

3

result:

ok single line: '3'

Test #250:

score: 22
Accepted
time: 1ms
memory: 5120kb

input:

4
1 2
2 3
1 4

output:

6

result:

ok single line: '6'

Test #251:

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

input:

5
1 2
2 3
1 4
4 5

output:

10

result:

ok single line: '10'

Test #252:

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

input:

5
1 2
2 3
1 4
1 5

output:

11

result:

ok single line: '11'

Test #253:

score: 22
Accepted
time: 1ms
memory: 5112kb

input:

5
1 2
1 3
1 4
1 5

output:

13

result:

ok single line: '13'

Test #254:

score: 22
Accepted
time: 1ms
memory: 7144kb

input:

6
1 2
2 3
1 5
3 4
5 6

output:

15

result:

ok single line: '15'

Test #255:

score: 22
Accepted
time: 1ms
memory: 7044kb

input:

6
1 2
2 3
2 4
1 5
5 6

output:

16

result:

ok single line: '16'

Test #256:

score: 22
Accepted
time: 1ms
memory: 6628kb

input:

6
1 2
2 3
2 4
1 5
1 6

output:

19

result:

ok single line: '19'

Test #257:

score: 22
Accepted
time: 1ms
memory: 5244kb

input:

6
1 2
2 3
1 4
1 6
4 5

output:

17

result:

ok single line: '17'

Test #258:

score: 22
Accepted
time: 1ms
memory: 6024kb

input:

6
1 2
2 3
1 4
1 5
1 6

output:

18

result:

ok single line: '18'

Test #259:

score: 22
Accepted
time: 1ms
memory: 6624kb

input:

6
1 2
1 3
1 4
1 5
1 6

output:

21

result:

ok single line: '21'

Test #260:

score: 22
Accepted
time: 1ms
memory: 7064kb

input:

7
1 2
2 3
1 5
3 4
5 6
6 7

output:

21

result:

ok single line: '21'

Test #261:

score: 22
Accepted
time: 1ms
memory: 6752kb

input:

7
1 2
1 3
1 4
1 5
1 6
1 7

output:

31

result:

ok single line: '31'

Test #262:

score: 22
Accepted
time: 1ms
memory: 5996kb

input:

7
1 2
2 3
1 5
3 4
5 6
5 7

output:

22

result:

ok single line: '22'

Test #263:

score: 22
Accepted
time: 1ms
memory: 7256kb

input:

7
1 2
2 3
1 5
1 7
3 4
5 6

output:

23

result:

ok single line: '23'

Test #264:

score: 22
Accepted
time: 1ms
memory: 5868kb

input:

7
1 2
2 3
2 4
2 5
1 6
6 7

output:

24

result:

ok single line: '24'

Test #265:

score: 22
Accepted
time: 1ms
memory: 6288kb

input:

7
1 2
2 3
2 4
1 5
5 6
5 7

output:

26

result:

ok single line: '26'

Test #266:

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

input:

7
1 2
2 3
2 4
1 5
1 7
5 6

output:

25

result:

ok single line: '25'

Test #267:

score: 22
Accepted
time: 1ms
memory: 7120kb

input:

7
1 2
2 3
2 4
1 5
1 6
1 7

output:

28

result:

ok single line: '28'

Test #268:

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

input:

7
1 2
2 3
1 4
1 6
4 5
6 7

output:

25

result:

ok single line: '25'

Test #269:

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

input:

7
1 2
2 3
1 4
1 6
1 7
4 5

output:

26

result:

ok single line: '26'

Test #270:

score: 22
Accepted
time: 1ms
memory: 5780kb

input:

7
1 2
2 3
1 4
1 5
1 6
1 7

output:

27

result:

ok single line: '27'

Test #271:

score: 22
Accepted
time: 1ms
memory: 6632kb

input:

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

output:

28

result:

ok single line: '28'

Test #272:

score: 22
Accepted
time: 1ms
memory: 7252kb

input:

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

output:

33

result:

ok single line: '33'

Test #273:

score: 22
Accepted
time: 1ms
memory: 6732kb

input:

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

output:

34

result:

ok single line: '34'

Test #274:

score: 22
Accepted
time: 1ms
memory: 6460kb

input:

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

output:

36

result:

ok single line: '36'

Test #275:

score: 22
Accepted
time: 1ms
memory: 5124kb

input:

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

output:

35

result:

ok single line: '35'

Test #276:

score: 22
Accepted
time: 1ms
memory: 6844kb

input:

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

output:

40

result:

ok single line: '40'

Test #277:

score: 22
Accepted
time: 1ms
memory: 6748kb

input:

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

output:

37

result:

ok single line: '37'

Test #278:

score: 22
Accepted
time: 1ms
memory: 6484kb

input:

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

output:

35

result:

ok single line: '35'

Test #279:

score: 22
Accepted
time: 1ms
memory: 5184kb

input:

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

output:

36

result:

ok single line: '36'

Test #280:

score: 22
Accepted
time: 1ms
memory: 6036kb

input:

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

output:

39

result:

ok single line: '39'

Test #281:

score: 22
Accepted
time: 1ms
memory: 6060kb

input:

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

output:

36

result:

ok single line: '36'

Test #282:

score: 22
Accepted
time: 1ms
memory: 7056kb

input:

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

output:

29

result:

ok single line: '29'

Test #283:

score: 22
Accepted
time: 1ms
memory: 6760kb

input:

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

output:

37

result:

ok single line: '37'

Test #284:

score: 22
Accepted
time: 1ms
memory: 5752kb

input:

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

output:

38

result:

ok single line: '38'

Test #285:

score: 22
Accepted
time: 1ms
memory: 6840kb

input:

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

output:

43

result:

ok single line: '43'

Test #286:

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

input:

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

output:

34

result:

ok single line: '34'

Test #287:

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

input:

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

output:

30

result:

ok single line: '30'

Test #288:

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

input:

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

output:

33

result:

ok single line: '33'

Test #289:

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

input:

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

output:

34

result:

ok single line: '34'

Test #290:

score: 22
Accepted
time: 1ms
memory: 7004kb

input:

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

output:

31

result:

ok single line: '31'

Test #291:

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

input:

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

output:

31

result:

ok single line: '31'

Test #292:

score: 22
Accepted
time: 1ms
memory: 6464kb

input:

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

output:

32

result:

ok single line: '32'

Test #293:

score: 22
Accepted
time: 1ms
memory: 5748kb

input:

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

output:

32

result:

ok single line: '32'

Test #294:

score: 22
Accepted
time: 1ms
memory: 6812kb

input:

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

output:

36

result:

ok single line: '36'

Test #295:

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

input:

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

output:

46

result:

ok single line: '46'

Test #296:

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

input:

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

output:

45

result:

ok single line: '45'

Test #297:

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

input:

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

output:

46

result:

ok single line: '46'

Test #298:

score: 22
Accepted
time: 1ms
memory: 6776kb

input:

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

output:

40

result:

ok single line: '40'

Test #299:

score: 22
Accepted
time: 1ms
memory: 5768kb

input:

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

output:

41

result:

ok single line: '41'

Test #300:

score: 22
Accepted
time: 1ms
memory: 7152kb

input:

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

output:

43

result:

ok single line: '43'

Test #301:

score: 22
Accepted
time: 1ms
memory: 5880kb

input:

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

output:

42

result:

ok single line: '42'

Test #302:

score: 22
Accepted
time: 1ms
memory: 6832kb

input:

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

output:

44

result:

ok single line: '44'

Test #303:

score: 22
Accepted
time: 1ms
memory: 5828kb

input:

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

output:

45

result:

ok single line: '45'

Test #304:

score: 22
Accepted
time: 1ms
memory: 6172kb

input:

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

output:

45

result:

ok single line: '45'

Test #305:

score: 22
Accepted
time: 1ms
memory: 6152kb

input:

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

output:

37

result:

ok single line: '37'

Test #306:

score: 22
Accepted
time: 1ms
memory: 5160kb

input:

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

output:

46

result:

ok single line: '46'

Test #307:

score: 22
Accepted
time: 1ms
memory: 6236kb

input:

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

output:

42

result:

ok single line: '42'

Test #308:

score: 22
Accepted
time: 1ms
memory: 6568kb

input:

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

output:

43

result:

ok single line: '43'

Test #309:

score: 22
Accepted
time: 1ms
memory: 7128kb

input:

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

output:

42

result:

ok single line: '42'

Test #310:

score: 22
Accepted
time: 1ms
memory: 5808kb

input:

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

output:

43

result:

ok single line: '43'

Test #311:

score: 22
Accepted
time: 1ms
memory: 6024kb

input:

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

output:

43

result:

ok single line: '43'

Test #312:

score: 22
Accepted
time: 1ms
memory: 6792kb

input:

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

output:

44

result:

ok single line: '44'

Test #313:

score: 22
Accepted
time: 1ms
memory: 5208kb

input:

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

output:

44

result:

ok single line: '44'

Test #314:

score: 22
Accepted
time: 1ms
memory: 5740kb

input:

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

output:

45

result:

ok single line: '45'

Test #315:

score: 22
Accepted
time: 1ms
memory: 5720kb

input:

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

output:

46

result:

ok single line: '46'

Test #316:

score: 22
Accepted
time: 1ms
memory: 5924kb

input:

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

output:

38

result:

ok single line: '38'

Test #317:

score: 22
Accepted
time: 1ms
memory: 7172kb

input:

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

output:

48

result:

ok single line: '48'

Test #318:

score: 22
Accepted
time: 1ms
memory: 7224kb

input:

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

output:

47

result:

ok single line: '47'

Test #319:

score: 22
Accepted
time: 1ms
memory: 7020kb

input:

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

output:

50

result:

ok single line: '50'

Test #320:

score: 22
Accepted
time: 1ms
memory: 5116kb

input:

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

output:

49

result:

ok single line: '49'

Test #321:

score: 22
Accepted
time: 1ms
memory: 5188kb

input:

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

output:

47

result:

ok single line: '47'

Test #322:

score: 22
Accepted
time: 1ms
memory: 5848kb

input:

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

output:

48

result:

ok single line: '48'

Test #323:

score: 22
Accepted
time: 1ms
memory: 7148kb

input:

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

output:

53

result:

ok single line: '53'

Test #324:

score: 22
Accepted
time: 1ms
memory: 6628kb

input:

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

output:

47

result:

ok single line: '47'

Test #325:

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

input:

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

output:

50

result:

ok single line: '50'

Test #326:

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

input:

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

output:

48

result:

ok single line: '48'

Test #327:

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

input:

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

output:

39

result:

ok single line: '39'

Test #328:

score: 22
Accepted
time: 1ms
memory: 6412kb

input:

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

output:

49

result:

ok single line: '49'

Test #329:

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

input:

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

output:

52

result:

ok single line: '52'

Test #330:

score: 22
Accepted
time: 1ms
memory: 6724kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #331:

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

input:

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

output:

48

result:

ok single line: '48'

Test #332:

score: 22
Accepted
time: 1ms
memory: 6296kb

input:

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

output:

49

result:

ok single line: '49'

Test #333:

score: 22
Accepted
time: 1ms
memory: 7060kb

input:

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

output:

50

result:

ok single line: '50'

Test #334:

score: 22
Accepted
time: 1ms
memory: 7184kb

input:

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

output:

51

result:

ok single line: '51'

Test #335:

score: 22
Accepted
time: 1ms
memory: 6808kb

input:

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

output:

57

result:

ok single line: '57'

Test #336:

score: 22
Accepted
time: 1ms
memory: 6392kb

input:

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

output:

39

result:

ok single line: '39'

Test #337:

score: 22
Accepted
time: 1ms
memory: 7040kb

input:

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

output:

40

result:

ok single line: '40'

Test #338:

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

input:

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

output:

43

result:

ok single line: '43'

Test #339:

score: 22
Accepted
time: 1ms
memory: 5120kb

input:

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

output:

42

result:

ok single line: '42'

Test #340:

score: 22
Accepted
time: 1ms
memory: 6720kb

input:

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

output:

41

result:

ok single line: '41'

Test #341:

score: 22
Accepted
time: 1ms
memory: 5184kb

input:

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

output:

45

result:

ok single line: '45'

Test #342:

score: 22
Accepted
time: 1ms
memory: 5960kb

input:

1000
924 985
926 985
924 987
904 926
739 904
912 985
685 912
67 926
620 926
77 739
77 860
635 926
900 985
551 924
900 986
53 985
402 912
73 985
432 551
113 987
648 926
265 912
737 912
432 759
432 823
739 841
549 823
145 549
724 985
40 145
767 985
429 648
67 936
444 900
245 860
265 304
429 613
46 245...

output:

982402

result:

ok single line: '982402'

Test #343:

score: 22
Accepted
time: 1ms
memory: 6420kb

input:

1000
483 734
377 483
377 934
53 377
176 934
176 767
252 767
377 735
483 917
483 563
192 252
500 917
376 563
500 937
244 563
192 912
176 823
1 192
415 912
111 500
250 735
111 725
563 893
1 199
439 734
817 937
752 893
488 725
428 912
327 817
78 500
78 620
934 966
681 917
500 795
149 966
192 650
192 28...

output:

978624

result:

ok single line: '978624'

Test #344:

score: 22
Accepted
time: 2ms
memory: 7276kb

input:

1000
278 449
267 449
193 449
278 702
193 329
271 702
271 384
267 764
92 702
132 271
278 322
212 384
132 481
384 556
540 556
267 377
377 697
449 763
517 697
329 482
540 893
106 193
86 517
37 702
37 756
86 641
86 792
267 830
191 377
322 648
426 540
30 193
556 787
221 384
377 533
792 967
334 756
508 55...

output:

980907

result:

ok single line: '980907'

Test #345:

score: 22
Accepted
time: 1ms
memory: 7096kb

input:

1000
699 958
255 747
423 986
879 883
195 595
213 955
53 739
400 613
164 902
129 969
107 931
221 386
582 815
783 974
774 842
451 899
1 932
214 929
254 533
107 624
73 638
74 739
9 960
31 147
214 669
289 675
291 867
244 638
352 543
250 846
129 542
871 998
267 793
182 782
265 315
573 901
482 522
401 482...

output:

983819

result:

ok single line: '983819'

Test #346:

score: 22
Accepted
time: 1ms
memory: 6348kb

input:

999
4 606
471 679
109 662
37 337
428 467
55 507
153 749
290 582
507 546
85 186
173 669
110 277
465 469
216 796
711 877
70 943
69 415
72 150
33 62
222 570
148 776
455 569
304 982
451 625
275 531
371 737
441 479
290 715
258 356
967 981
61 848
191 837
205 251
805 896
757 797
131 262
323 623
760 861
60 ...

output:

981851

result:

ok single line: '981851'

Test #347:

score: 22
Accepted
time: 1ms
memory: 6036kb

input:

1000
224 950
197 1000
28 613
133 760
647 836
556 615
470 688
2 60
8 817
317 324
669 957
613 890
817 935
675 994
145 534
6 909
29 533
625 754
81 742
310 766
115 198
573 764
243 815
329 441
161 644
333 536
908 951
404 479
287 548
541 865
420 958
760 925
61 156
620 789
83 86
63 218
708 844
402 476
242 ...

output:

988389

result:

ok single line: '988389'

Test #348:

score: 22
Accepted
time: 1ms
memory: 5952kb

input:

999
267 668
388 633
175 743
98 622
125 660
409 839
235 936
316 617
862 901
732 878
409 817
59 760
574 947
374 620
88 838
97 901
243 946
73 160
95 803
50 109
198 303
479 635
163 737
266 821
124 529
919 957
176 289
264 388
148 906
454 713
719 843
291 434
151 254
951 952
835 849
146 931
686 967
469 571...

output:

986393

result:

ok single line: '986393'

Test #349:

score: 22
Accepted
time: 1ms
memory: 5208kb

input:

998
578 799
239 379
574 944
162 854
488 673
592 951
406 525
242 920
54 826
181 417
481 607
523 711
580 954
401 975
883 980
334 903
574 747
137 324
462 817
36 392
753 787
58 741
519 756
14 290
67 398
355 602
77 687
661 910
143 782
385 577
474 687
577 934
499 613
108 766
155 707
553 956
60 117
514 991...

output:

984399

result:

ok single line: '984399'

Test #350:

score: 22
Accepted
time: 1ms
memory: 6472kb

input:

1000
335 602
369 625
642 923
142 782
32 55
504 657
48 636
57 994
397 961
66 642
922 933
36 691
603 961
790 802
486 561
119 179
10 459
547 930
370 954
427 594
53 735
17 642
348 980
516 861
710 860
597 948
691 974
230 804
15 119
276 321
211 425
169 597
213 691
611 636
117 879
140 445
288 895
129 745
4...

output:

993345

result:

ok single line: '993345'

Test #351:

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

input:

1000
136 715
79 491
419 963
383 926
202 512
743 800
738 754
43 963
714 963
203 512
655 926
136 774
172 451
22 512
172 845
512 562
172 437
228 743
172 395
669 738
512 818
316 491
159 670
273 512
466 840
172 502
613 743
466 626
3 963
542 926
919 963
571 926
56 466
172 854
136 450
878 963
136 415
381 6...

output:

995304

result:

ok single line: '995304'

Test #352:

score: 22
Accepted
time: 26ms
memory: 11220kb

input:

100000
22229 23376
5927 22229
22229 36206
23376 50592
23376 57975
27020 50592
1268 22229
994 36206
1268 55237
50592 77844
11312 77844
994 81655
27020 89957
13725 50592
23376 43461
22229 72203
1268 30647
52189 77844
1268 79746
30647 59958
72203 85117
52189 82280
57975 85716
43461 61231
79287 89957
22...

output:

9996758559

result:

ok single line: '9996758559'

Test #353:

score: 22
Accepted
time: 23ms
memory: 11220kb

input:

100000
51480 89111
20417 89111
7874 51480
51480 75552
51480 75335
44998 51480
43408 89111
75552 92662
37543 92662
63254 75552
92662 92992
37543 39590
43408 67081
7874 31848
49353 89111
67081 71510
3019 43408
44998 82460
82460 98766
3019 30205
20417 26810
26810 97524
92662 99611
35457 92662
3019 2928...

output:

9996518034

result:

ok single line: '9996518034'

Test #354:

score: 22
Accepted
time: 20ms
memory: 11344kb

input:

100000
84554 94103
84554 97113
54213 97113
33087 94103
13174 94103
10189 94103
10189 80469
33087 59517
10189 53352
44551 80469
8132 44551
32929 53352
53352 59389
43456 84554
59517 78665
43456 54219
10189 73351
8132 79544
52871 84554
49726 78665
7454 59517
53352 58866
73351 85539
52871 64913
33087 64...

output:

9996634546

result:

ok single line: '9996634546'

Test #355:

score: 22
Accepted
time: 30ms
memory: 11800kb

input:

100000
14961 28183
47992 61282
34307 39633
1127 69634
31244 82043
39264 88643
4250 58494
58802 80786
9526 89311
10349 63108
31395 45030
36178 58073
37692 62293
50816 61076
5079 64076
18792 46669
11746 84655
39800 84129
984 10813
10300 20959
33315 35222
20079 99454
37679 43854
2232 12045
4154 99692
6...

output:

9996981196

result:

ok single line: '9996981196'

Test #356:

score: 22
Accepted
time: 27ms
memory: 11996kb

input:

100000
8583 82902
61993 99109
8770 33557
15498 21568
27037 58934
68543 72045
36629 90264
89467 99933
67578 77879
43562 56596
20569 57475
16977 22347
24969 41921
23315 99473
62493 71399
48081 95489
8552 25448
70339 91140
92472 99061
46641 69627
26602 57324
22531 93144
76360 83364
40832 84653
29228 79...

output:

9998934567

result:

ok single line: '9998934567'

Test #357:

score: 22
Accepted
time: 20ms
memory: 11764kb

input:

100000
68958 85490
64427 80215
21106 82874
34116 54000
50812 74292
27262 41843
57037 68201
48052 64546
6854 17472
241 9212
46447 47505
6047 58502
26737 27051
35267 67632
24453 77017
31438 53565
30121 85742
49907 93013
7628 53586
8297 49303
22950 65266
25323 61375
5238 99044
43859 76813
19717 72859
1...

output:

9999330405

result:

ok single line: '9999330405'

Test #358:

score: 22
Accepted
time: 19ms
memory: 11424kb

input:

100000
14838 84900
2044 95951
13389 64216
28162 35675
1313 50577
64216 94465
4158 15322
42535 84900
20954 84900
46703 56295
62814 81900
57363 57598
50577 78036
21137 23092
77442 95063
57598 60825
25853 72245
25853 73627
93 83468
23761 71493
29423 34644
61035 66854
9003 83008
5940 20092
83634 85602
2...

output:

9999503004

result:

ok single line: '9999503004'

Test #359:

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

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #360:

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

input:

1

output:

0

result:

ok single line: '0'