Codeforces Round 121 (Div. 2)


A. Funky Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
256
Output
YES
Input
512
Output
NO
----------------------------------------------------------------------------------------------------
B. Walking in the Rain
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
10 3 5 10
Output
5
Input
5
10 2 8 3 5
Output
5
----------------------------------------------------------------------------------------------------
C. Dynasty Puzzles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
abc
ca
cba
Output
6
Input
4
vvp
vvp
dam
vvp
Output
0
Input
3
ab
c
def
Output
1
----------------------------------------------------------------------------------------------------
D. Demonstration
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
8
2 4 5 3 1
Output
2
Input
5 2
8
3 2 4 1 5
Output
5
Input
5 4
1000000000000000
5 4 3 2 1
Output
5
----------------------------------------------------------------------------------------------------
E. Fools and Roads
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2
1 3
2 4
2 5
2
1 4
3 5
Output
2 1 1 1 
Input
5
3 4
4 5
1 4
2 4
3
2 3
1 3
3 5
Output
3 1 1 1 
----------------------------------------------------------------------------------------------------
