QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#454824#8269. MinequakeAFewSuns100 ✓22ms18216kbC++142.1kb2024-06-25 14:49:182024-06-25 14:49:19

Judging History

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

  • [2024-06-25 14:49:19]
  • 评测
  • 测评结果:100
  • 用时:22ms
  • 内存:18216kb
  • [2024-06-25 14:49:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
ll n,head[100010],cnt=0,f[100010],siz[100010],ans=inf;
struct node{
	ll nxt,to;
}e[200020];
void add(ll u,ll v){
	e[++cnt].nxt=head[u];
	e[cnt].to=v;
	head[u]=cnt;
} 
void dfs1(ll fa,ll u){
	go(u){
		ll v=e[i].to;
		if(v==fa) continue;
		dfs1(u,v);
		f[u]+=f[v]+siz[v]+2*siz[u]*siz[v];
		siz[u]+=siz[v];
	}
	siz[u]++;
}
void dfs2(ll fa,ll u){
	ans=min(ans,f[u]);
	go(u){
		ll v=e[i].to;
		if(v==fa) continue;
		ll su=siz[u],sv=siz[v],fu=f[u],fv=f[v];
		siz[u]-=siz[v];
		f[u]-=f[v]+siz[v]+2*(siz[u]-1)*siz[v];
		f[v]+=f[u]+siz[u]+2*(siz[v]-1)*siz[u];
		siz[v]+=siz[u];
		dfs2(u,v);
		siz[u]=su;
		siz[v]=sv;
		f[u]=fu;
		f[v]=fv;
	}
}
int main(){
	n=read();
	fr(i,2,n){
		ll u=read(),v=read();
		add(u,v);
		add(v,u);
	}
	dfs1(0,1);
	dfs2(0,1);
	write(ans);
}

詳細信息

Subtask #1:

score: 18
Accepted

Test #1:

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

input:

2
1 2

output:

1

result:

ok single line: '1'

Test #2:

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

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: 0
Accepted
time: 0ms
memory: 5712kb

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: 0
Accepted
time: 1ms
memory: 5776kb

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: 0
Accepted
time: 2ms
memory: 6864kb

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: 0
Accepted
time: 13ms
memory: 18216kb

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: 0
Accepted
time: 14ms
memory: 15420kb

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: 0
Accepted
time: 1ms
memory: 5660kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #9:

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

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: 5664kb

input:

2
1 2

output:

1

result:

ok single line: '1'

Test #11:

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

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: 0
Accepted
time: 1ms
memory: 5676kb

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: 0
Accepted
time: 1ms
memory: 5688kb

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: 0
Accepted
time: 0ms
memory: 6868kb

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: 0
Accepted
time: 18ms
memory: 18216kb

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: 0
Accepted
time: 11ms
memory: 15420kb

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: 0
Accepted
time: 0ms
memory: 3528kb

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: 0
Accepted
time: 0ms
memory: 3664kb

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: 0
Accepted
time: 8ms
memory: 9056kb

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: 0
Accepted
time: 0ms
memory: 5548kb

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: 0
Accepted
time: 0ms
memory: 3604kb

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: 0
Accepted
time: 2ms
memory: 4984kb

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: 0
Accepted
time: 18ms
memory: 15448kb

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: 0
Accepted
time: 13ms
memory: 10696kb

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: 0
Accepted
time: 15ms
memory: 9308kb

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: 0
Accepted
time: 10ms
memory: 8996kb

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: 0
Accepted
time: 14ms
memory: 9064kb

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: 0
Accepted
time: 1ms
memory: 5592kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #29:

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

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #30:

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

input:

1

output:

0

result:

ok single line: '0'

Subtask #3:

score: 20
Accepted

Test #31:

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

input:

3
1 2
1 3

output:

3

result:

ok single line: '3'

Test #32:

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

input:

4
1 2
2 3
1 4

output:

6

result:

ok single line: '6'

Test #33:

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

input:

5
1 2
2 3
1 4
4 5

output:

10

result:

ok single line: '10'

Test #34:

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

input:

5
1 2
2 3
1 4
1 5

output:

11

result:

ok single line: '11'

Test #35:

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

input:

5
1 2
1 3
1 4
1 5

output:

13

result:

ok single line: '13'

Test #36:

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

input:

6
1 2
2 3
1 5
3 4
5 6

output:

15

result:

ok single line: '15'

Test #37:

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

input:

6
1 2
2 3
2 4
1 5
5 6

output:

16

result:

ok single line: '16'

Test #38:

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

input:

6
1 2
2 3
2 4
1 5
1 6

output:

19

result:

ok single line: '19'

Test #39:

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

input:

6
1 2
2 3
1 4
1 6
4 5

output:

17

result:

ok single line: '17'

Test #40:

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

input:

6
1 2
2 3
1 4
1 5
1 6

output:

18

result:

ok single line: '18'

Test #41:

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

input:

6
1 2
1 3
1 4
1 5
1 6

output:

21

result:

ok single line: '21'

Test #42:

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

input:

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

output:

21

result:

ok single line: '21'

Test #43:

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

input:

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

output:

31

result:

ok single line: '31'

Test #44:

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

input:

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

output:

22

result:

ok single line: '22'

Test #45:

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

input:

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

output:

23

result:

ok single line: '23'

Test #46:

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

input:

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

output:

24

result:

ok single line: '24'

Test #47:

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

input:

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

output:

26

result:

ok single line: '26'

Test #48:

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

input:

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

output:

25

result:

ok single line: '25'

Test #49:

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

input:

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

output:

28

result:

ok single line: '28'

Test #50:

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

input:

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

output:

25

result:

ok single line: '25'

Test #51:

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

input:

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

output:

26

result:

ok single line: '26'

Test #52:

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

input:

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

output:

27

result:

ok single line: '27'

Test #53:

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

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: 0
Accepted
time: 1ms
memory: 5548kb

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: 0
Accepted
time: 0ms
memory: 5552kb

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: 0
Accepted
time: 0ms
memory: 5584kb

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: 0
Accepted
time: 1ms
memory: 5660kb

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: 0
Accepted
time: 0ms
memory: 3620kb

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: 0
Accepted
time: 0ms
memory: 5652kb

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: 0
Accepted
time: 0ms
memory: 3644kb

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: 0
Accepted
time: 0ms
memory: 3616kb

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: 0
Accepted
time: 1ms
memory: 5584kb

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: 0
Accepted
time: 1ms
memory: 5664kb

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: 0
Accepted
time: 1ms
memory: 5656kb

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: 0
Accepted
time: 0ms
memory: 3636kb

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: 0
Accepted
time: 1ms
memory: 5744kb

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: 0
Accepted
time: 1ms
memory: 5668kb

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: 0
Accepted
time: 1ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 5612kb

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: 0
Accepted
time: 1ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 5688kb

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: 0
Accepted
time: 1ms
memory: 5660kb

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: 0
Accepted
time: 1ms
memory: 5588kb

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: 0
Accepted
time: 1ms
memory: 5596kb

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: 0
Accepted
time: 0ms
memory: 3612kb

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: 0
Accepted
time: 1ms
memory: 5648kb

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: 0
Accepted
time: 0ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 3544kb

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: 0
Accepted
time: 0ms
memory: 5664kb

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: 0
Accepted
time: 0ms
memory: 5588kb

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: 0
Accepted
time: 1ms
memory: 5668kb

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: 0
Accepted
time: 0ms
memory: 5744kb

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: 0
Accepted
time: 0ms
memory: 3604kb

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: 0
Accepted
time: 1ms
memory: 5552kb

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: 0
Accepted
time: 1ms
memory: 5628kb

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: 0
Accepted
time: 1ms
memory: 5588kb

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: 0
Accepted
time: 0ms
memory: 3608kb

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: 0
Accepted
time: 0ms
memory: 5584kb

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: 0
Accepted
time: 0ms
memory: 3544kb

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: 0
Accepted
time: 0ms
memory: 3548kb

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: 0
Accepted
time: 0ms
memory: 5652kb

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: 0
Accepted
time: 0ms
memory: 3700kb

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: 0
Accepted
time: 1ms
memory: 5668kb

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: 0
Accepted
time: 0ms
memory: 5736kb

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: 0
Accepted
time: 0ms
memory: 5580kb

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: 0
Accepted
time: 0ms
memory: 5672kb

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: 0
Accepted
time: 0ms
memory: 5744kb

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: 0
Accepted
time: 0ms
memory: 5720kb

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: 0
Accepted
time: 0ms
memory: 5736kb

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: 0
Accepted
time: 0ms
memory: 5648kb

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: 0
Accepted
time: 0ms
memory: 5596kb

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: 0
Accepted
time: 0ms
memory: 5680kb

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: 0
Accepted
time: 1ms
memory: 5660kb

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: 0
Accepted
time: 0ms
memory: 5644kb

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: 0
Accepted
time: 1ms
memory: 5660kb

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: 0
Accepted
time: 1ms
memory: 5700kb

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: 0
Accepted
time: 0ms
memory: 3644kb

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: 0
Accepted
time: 0ms
memory: 3544kb

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: 0
Accepted
time: 1ms
memory: 5656kb

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: 0
Accepted
time: 0ms
memory: 3512kb

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: 0
Accepted
time: 0ms
memory: 3696kb

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: 0
Accepted
time: 1ms
memory: 5676kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #113:

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

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: 0
Accepted
time: 0ms
memory: 3620kb

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: 0
Accepted
time: 0ms
memory: 3696kb

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: 0
Accepted
time: 0ms
memory: 3696kb

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: 0
Accepted
time: 1ms
memory: 5680kb

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: 0
Accepted
time: 1ms
memory: 5572kb

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: 0
Accepted
time: 0ms
memory: 5648kb

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: 0
Accepted
time: 1ms
memory: 5588kb

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: 0
Accepted
time: 0ms
memory: 5652kb

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: 0
Accepted
time: 0ms
memory: 5656kb

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: 0
Accepted
time: 0ms
memory: 3544kb

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: 0
Accepted
time: 0ms
memory: 5676kb

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #125:

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

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: 5656kb

input:

3
1 2
1 3

output:

3

result:

ok single line: '3'

Test #127:

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

input:

4
1 2
2 3
1 4

output:

6

result:

ok single line: '6'

Test #128:

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

input:

5
1 2
2 3
1 4
4 5

output:

10

result:

ok single line: '10'

Test #129:

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

input:

5
1 2
2 3
1 4
1 5

output:

11

result:

ok single line: '11'

Test #130:

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

input:

5
1 2
1 3
1 4
1 5

output:

13

result:

ok single line: '13'

Test #131:

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

input:

6
1 2
2 3
1 5
3 4
5 6

output:

15

result:

ok single line: '15'

Test #132:

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

input:

6
1 2
2 3
2 4
1 5
5 6

output:

16

result:

ok single line: '16'

Test #133:

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

input:

6
1 2
2 3
2 4
1 5
1 6

output:

19

result:

ok single line: '19'

Test #134:

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

input:

6
1 2
2 3
1 4
1 6
4 5

output:

17

result:

ok single line: '17'

Test #135:

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

input:

6
1 2
2 3
1 4
1 5
1 6

output:

18

result:

ok single line: '18'

Test #136:

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

input:

6
1 2
1 3
1 4
1 5
1 6

output:

21

result:

ok single line: '21'

Test #137:

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

input:

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

output:

21

result:

ok single line: '21'

Test #138:

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

input:

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

output:

31

result:

ok single line: '31'

Test #139:

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

input:

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

output:

22

result:

ok single line: '22'

Test #140:

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

input:

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

output:

23

result:

ok single line: '23'

Test #141:

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

input:

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

output:

24

result:

ok single line: '24'

Test #142:

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

input:

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

output:

26

result:

ok single line: '26'

Test #143:

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

input:

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

output:

25

result:

ok single line: '25'

Test #144:

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

input:

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

output:

28

result:

ok single line: '28'

Test #145:

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

input:

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

output:

25

result:

ok single line: '25'

Test #146:

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

input:

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

output:

26

result:

ok single line: '26'

Test #147:

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

input:

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

output:

27

result:

ok single line: '27'

Test #148:

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

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: 0
Accepted
time: 0ms
memory: 5652kb

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: 0
Accepted
time: 1ms
memory: 5548kb

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: 0
Accepted
time: 1ms
memory: 5664kb

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: 0
Accepted
time: 0ms
memory: 5552kb

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: 0
Accepted
time: 0ms
memory: 5684kb

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: 0
Accepted
time: 0ms
memory: 5676kb

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: 0
Accepted
time: 0ms
memory: 5668kb

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: 0
Accepted
time: 0ms
memory: 3704kb

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: 0
Accepted
time: 0ms
memory: 3544kb

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: 0
Accepted
time: 1ms
memory: 5660kb

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: 0
Accepted
time: 0ms
memory: 3624kb

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: 0
Accepted
time: 0ms
memory: 3680kb

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: 0
Accepted
time: 0ms
memory: 5556kb

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: 0
Accepted
time: 0ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 5736kb

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: 0
Accepted
time: 1ms
memory: 5600kb

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: 0
Accepted
time: 0ms
memory: 5548kb

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: 0
Accepted
time: 0ms
memory: 5592kb

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: 0
Accepted
time: 0ms
memory: 3616kb

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: 0
Accepted
time: 1ms
memory: 5716kb

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: 0
Accepted
time: 0ms
memory: 5740kb

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: 0
Accepted
time: 1ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 5548kb

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: 0
Accepted
time: 0ms
memory: 5652kb

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: 0
Accepted
time: 1ms
memory: 5744kb

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: 0
Accepted
time: 0ms
memory: 3616kb

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: 0
Accepted
time: 0ms
memory: 3676kb

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: 0
Accepted
time: 0ms
memory: 5660kb

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: 0
Accepted
time: 0ms
memory: 3620kb

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: 0
Accepted
time: 1ms
memory: 5744kb

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: 0
Accepted
time: 1ms
memory: 5664kb

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: 0
Accepted
time: 0ms
memory: 3684kb

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: 0
Accepted
time: 1ms
memory: 5668kb

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: 0
Accepted
time: 0ms
memory: 3620kb

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: 0
Accepted
time: 0ms
memory: 5544kb

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: 0
Accepted
time: 0ms
memory: 5592kb

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: 0
Accepted
time: 1ms
memory: 5668kb

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: 0
Accepted
time: 0ms
memory: 5556kb

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: 0
Accepted
time: 1ms
memory: 5600kb

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: 0
Accepted
time: 1ms
memory: 5680kb

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: 0
Accepted
time: 0ms
memory: 3624kb

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: 0
Accepted
time: 0ms
memory: 3508kb

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: 0
Accepted
time: 1ms
memory: 5676kb

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: 0
Accepted
time: 0ms
memory: 3548kb

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: 0
Accepted
time: 0ms
memory: 5584kb

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: 0
Accepted
time: 0ms
memory: 5552kb

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: 0
Accepted
time: 0ms
memory: 3608kb

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: 0
Accepted
time: 1ms
memory: 5556kb

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: 0
Accepted
time: 0ms
memory: 3508kb

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: 0
Accepted
time: 1ms
memory: 5584kb

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: 0
Accepted
time: 0ms
memory: 3512kb

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: 0
Accepted
time: 0ms
memory: 3544kb

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: 0
Accepted
time: 1ms
memory: 5548kb

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: 0
Accepted
time: 0ms
memory: 5596kb

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: 0
Accepted
time: 0ms
memory: 3548kb

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: 0
Accepted
time: 0ms
memory: 5644kb

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: 0
Accepted
time: 1ms
memory: 5724kb

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: 0
Accepted
time: 0ms
memory: 5664kb

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: 0
Accepted
time: 0ms
memory: 5660kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #208:

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

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: 0
Accepted
time: 0ms
memory: 5652kb

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: 0
Accepted
time: 0ms
memory: 5660kb

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: 0
Accepted
time: 0ms
memory: 5664kb

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: 0
Accepted
time: 0ms
memory: 5736kb

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: 0
Accepted
time: 0ms
memory: 5552kb

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: 0
Accepted
time: 0ms
memory: 5748kb

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: 0
Accepted
time: 0ms
memory: 5548kb

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: 0
Accepted
time: 0ms
memory: 3620kb

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: 0
Accepted
time: 0ms
memory: 5656kb

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: 0
Accepted
time: 0ms
memory: 5744kb

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: 0
Accepted
time: 1ms
memory: 5624kb

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: 0
Accepted
time: 1ms
memory: 5772kb

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: 0
Accepted
time: 0ms
memory: 3604kb

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: 0
Accepted
time: 0ms
memory: 5716kb

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: 0
Accepted
time: 1ms
memory: 5772kb

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: 0
Accepted
time: 1ms
memory: 5644kb

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: 0
Accepted
time: 1ms
memory: 5624kb

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: 0
Accepted
time: 1ms
memory: 5564kb

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: 0
Accepted
time: 0ms
memory: 3596kb

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: 0
Accepted
time: 1ms
memory: 5684kb

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: 0
Accepted
time: 0ms
memory: 5556kb

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #230:

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

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: 5596kb

input:

2
1 2

output:

1

result:

ok single line: '1'

Test #232:

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

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: 0
Accepted
time: 1ms
memory: 5856kb

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: 0
Accepted
time: 1ms
memory: 5852kb

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: 0
Accepted
time: 2ms
memory: 4960kb

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: 0
Accepted
time: 19ms
memory: 18132kb

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: 0
Accepted
time: 22ms
memory: 15344kb

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: 0
Accepted
time: 0ms
memory: 3700kb

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: 0
Accepted
time: 1ms
memory: 5592kb

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: 0
Accepted
time: 8ms
memory: 9004kb

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: 0
Accepted
time: 1ms
memory: 5720kb

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: 0
Accepted
time: 1ms
memory: 5592kb

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: 0
Accepted
time: 2ms
memory: 4800kb

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: 0
Accepted
time: 18ms
memory: 15524kb

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: 0
Accepted
time: 19ms
memory: 10692kb

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: 0
Accepted
time: 15ms
memory: 9212kb

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: 0
Accepted
time: 18ms
memory: 9188kb

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: 0
Accepted
time: 7ms
memory: 8960kb

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: 0
Accepted
time: 1ms
memory: 5548kb

input:

3
1 2
1 3

output:

3

result:

ok single line: '3'

Test #250:

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

input:

4
1 2
2 3
1 4

output:

6

result:

ok single line: '6'

Test #251:

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

input:

5
1 2
2 3
1 4
4 5

output:

10

result:

ok single line: '10'

Test #252:

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

input:

5
1 2
2 3
1 4
1 5

output:

11

result:

ok single line: '11'

Test #253:

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

input:

5
1 2
1 3
1 4
1 5

output:

13

result:

ok single line: '13'

Test #254:

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

input:

6
1 2
2 3
1 5
3 4
5 6

output:

15

result:

ok single line: '15'

Test #255:

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

input:

6
1 2
2 3
2 4
1 5
5 6

output:

16

result:

ok single line: '16'

Test #256:

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

input:

6
1 2
2 3
2 4
1 5
1 6

output:

19

result:

ok single line: '19'

Test #257:

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

input:

6
1 2
2 3
1 4
1 6
4 5

output:

17

result:

ok single line: '17'

Test #258:

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

input:

6
1 2
2 3
1 4
1 5
1 6

output:

18

result:

ok single line: '18'

Test #259:

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

input:

6
1 2
1 3
1 4
1 5
1 6

output:

21

result:

ok single line: '21'

Test #260:

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

input:

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

output:

21

result:

ok single line: '21'

Test #261:

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

input:

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

output:

31

result:

ok single line: '31'

Test #262:

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

input:

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

output:

22

result:

ok single line: '22'

Test #263:

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

input:

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

output:

23

result:

ok single line: '23'

Test #264:

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

input:

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

output:

24

result:

ok single line: '24'

Test #265:

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

input:

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

output:

26

result:

ok single line: '26'

Test #266:

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

input:

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

output:

25

result:

ok single line: '25'

Test #267:

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

input:

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

output:

28

result:

ok single line: '28'

Test #268:

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

input:

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

output:

25

result:

ok single line: '25'

Test #269:

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

input:

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

output:

26

result:

ok single line: '26'

Test #270:

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

input:

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

output:

27

result:

ok single line: '27'

Test #271:

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

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: 0
Accepted
time: 0ms
memory: 5552kb

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: 0
Accepted
time: 0ms
memory: 5676kb

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: 0
Accepted
time: 0ms
memory: 5660kb

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: 0
Accepted
time: 1ms
memory: 5748kb

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: 0
Accepted
time: 1ms
memory: 5672kb

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: 0
Accepted
time: 0ms
memory: 5716kb

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: 0
Accepted
time: 0ms
memory: 3680kb

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: 0
Accepted
time: 1ms
memory: 5556kb

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: 0
Accepted
time: 0ms
memory: 5736kb

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: 0
Accepted
time: 0ms
memory: 5744kb

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: 0
Accepted
time: 1ms
memory: 5664kb

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: 0
Accepted
time: 0ms
memory: 5584kb

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: 0
Accepted
time: 1ms
memory: 5744kb

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: 0
Accepted
time: 1ms
memory: 5540kb

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: 0
Accepted
time: 0ms
memory: 5660kb

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: 0
Accepted
time: 1ms
memory: 5664kb

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: 0
Accepted
time: 0ms
memory: 5728kb

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: 0
Accepted
time: 0ms
memory: 3700kb

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: 0
Accepted
time: 1ms
memory: 5660kb

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: 0
Accepted
time: 0ms
memory: 5652kb

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: 0
Accepted
time: 0ms
memory: 5552kb

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: 0
Accepted
time: 0ms
memory: 5668kb

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: 0
Accepted
time: 0ms
memory: 5584kb

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: 0
Accepted
time: 0ms
memory: 5652kb

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: 0
Accepted
time: 1ms
memory: 5684kb

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: 0
Accepted
time: 0ms
memory: 5548kb

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: 0
Accepted
time: 0ms
memory: 3616kb

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: 0
Accepted
time: 1ms
memory: 5744kb

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: 0
Accepted
time: 0ms
memory: 3508kb

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: 0
Accepted
time: 0ms
memory: 5736kb

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: 0
Accepted
time: 0ms
memory: 5656kb

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: 0
Accepted
time: 0ms
memory: 5528kb

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: 0
Accepted
time: 0ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 3512kb

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: 0
Accepted
time: 0ms
memory: 5656kb

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: 0
Accepted
time: 1ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 5548kb

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: 0
Accepted
time: 0ms
memory: 3504kb

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: 0
Accepted
time: 0ms
memory: 5660kb

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: 0
Accepted
time: 0ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 3508kb

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: 0
Accepted
time: 0ms
memory: 3620kb

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: 0
Accepted
time: 1ms
memory: 5744kb

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: 0
Accepted
time: 0ms
memory: 5652kb

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: 0
Accepted
time: 0ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 3616kb

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: 0
Accepted
time: 0ms
memory: 5656kb

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: 0
Accepted
time: 1ms
memory: 5592kb

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: 0
Accepted
time: 0ms
memory: 5664kb

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: 0
Accepted
time: 0ms
memory: 3696kb

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: 0
Accepted
time: 0ms
memory: 5740kb

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: 0
Accepted
time: 0ms
memory: 5548kb

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: 0
Accepted
time: 0ms
memory: 5664kb

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: 0
Accepted
time: 0ms
memory: 5668kb

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: 0
Accepted
time: 0ms
memory: 5744kb

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: 0
Accepted
time: 0ms
memory: 3696kb

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: 0
Accepted
time: 0ms
memory: 5736kb

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: 0
Accepted
time: 0ms
memory: 5736kb

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: 0
Accepted
time: 0ms
memory: 3680kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #331:

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

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: 0
Accepted
time: 1ms
memory: 5596kb

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: 0
Accepted
time: 0ms
memory: 3636kb

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: 0
Accepted
time: 0ms
memory: 3696kb

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: 0
Accepted
time: 0ms
memory: 5580kb

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: 0
Accepted
time: 1ms
memory: 5672kb

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: 0
Accepted
time: 0ms
memory: 3540kb

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: 0
Accepted
time: 1ms
memory: 5552kb

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: 0
Accepted
time: 0ms
memory: 5688kb

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: 0
Accepted
time: 1ms
memory: 5684kb

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: 0
Accepted
time: 0ms
memory: 5668kb

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: 0
Accepted
time: 1ms
memory: 5632kb

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: 0
Accepted
time: 1ms
memory: 5688kb

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: 0
Accepted
time: 1ms
memory: 5724kb

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: 0
Accepted
time: 0ms
memory: 3592kb

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: 0
Accepted
time: 1ms
memory: 5712kb

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: 0
Accepted
time: 1ms
memory: 5576kb

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: 0
Accepted
time: 0ms
memory: 3672kb

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: 0
Accepted
time: 1ms
memory: 5688kb

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: 0
Accepted
time: 1ms
memory: 5768kb

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: 0
Accepted
time: 1ms
memory: 5560kb

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: 0
Accepted
time: 8ms
memory: 8996kb

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: 0
Accepted
time: 11ms
memory: 9088kb

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: 0
Accepted
time: 9ms
memory: 9152kb

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: 0
Accepted
time: 12ms
memory: 9000kb

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: 0
Accepted
time: 10ms
memory: 9000kb

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: 0
Accepted
time: 7ms
memory: 9076kb

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: 0
Accepted
time: 7ms
memory: 9064kb

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: 0
Accepted
time: 1ms
memory: 5688kb

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #360:

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

input:

1

output:

0

result:

ok single line: '0'