Russian Code Cup 2017 - Finals [Unofficial Mirror, Div. 1 Only Recommended, Teams Allowed]


A. Set Theory
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 10 100
1
1
2
2 4
Output
YES
1 2 3 
YES
1 
YES
1 2 
----------------------------------------------------------------------------------------------------
B. Similar Words
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
3
aba
baba
aaab
2
aa
a
Output
6
1
----------------------------------------------------------------------------------------------------
C. Eleventh Birthday
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1 1
3
1 31 12
3
12345 67 84
9
1 2 3 4 5 6 7 8 9
Output
2
2
2
31680
----------------------------------------------------------------------------------------------------
D. Masha and Cactus
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 3
1 1 2 2 3 3
4 5 1
6 7 1
2 3 1
Output
2
----------------------------------------------------------------------------------------------------
E. Satellites
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 8
1 -5 8
1 -4 8
1 -3 8
1 2 7
3 1 3
2 2
3 1 3
3 3 4
Output
NO
YES
YES
----------------------------------------------------------------------------------------------------
F. To Play or not to Play
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 5
1 7
10 20
10 20
Output
25
Input
1 2 5
0 100
20 60
85 90
Output
125
----------------------------------------------------------------------------------------------------
