Codeforces Round 465 (Div. 2)


A. Fafa and his Company
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
1
Input
10
Output
3
----------------------------------------------------------------------------------------------------
B. Fafa and the Gates
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
U
Output
0
Input
6
RURUUR
Output
1
Input
7
URRRUUU
Output
2
----------------------------------------------------------------------------------------------------
C. Fifa and Fafa
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 3 1 1
Output
3.7677669529663684 3.7677669529663684 3.914213562373095
Input
10 5 5 5 15
Output
5.0 5.0 10.0
----------------------------------------------------------------------------------------------------
D. Fafa and Ancient Alphabet
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
0
1
Output
500000004
Input
1 2
1
0
Output
0
Input
7 26
0 15 12 9 13 0 14
11 1 0 13 15 12 0
Output
230769233
----------------------------------------------------------------------------------------------------
E. Fafa and Ancient Mathematics
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
(1?1)
1 0
Output
2
Input
(2?(1?2))
1 1
Output
1
Input
((1?(5?7))?((6?2)?7))
3 2
Output
18
Input
((1?(5?7))?((6?2)?7))
2 3
Output
16
----------------------------------------------------------------------------------------------------
F. Fafa and Array
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 1 1 1
5
1 2 4 1
2 2 3 1
2 4 4 2
2 3 4 1
1 3 3 2
Output
2
8
Input
5
1 2 3 4 5
4
1 2 4 2
2 2 4 1
2 3 4 1
1 2 4 2
Output
6
10
----------------------------------------------------------------------------------------------------
