Codeforces Round 282 (Div. 1)


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

Examples
Input
(((#)((#)
Output
1
2
Input
()((#((#(#()
Output
2
2
1
Input
#
Output
-1
Input
(#)
Output
-1
----------------------------------------------------------------------------------------------------
B. Obsessive String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
ababa
aba
Output
5
Input
welcometoroundtwohundredandeightytwo
d
Output
274201
Input
ddd
d
Output
12
----------------------------------------------------------------------------------------------------
C. Helping People
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1 7 2 4 3
1 3 0.500
2 2 0.500
Output
8.000000000
Input
5 2
281 280 279 278 282
1 4 1.000
1 4 0.000
Output
282.000000000
Input
3 5
1 2 3
1 3 0.500
2 2 0.250
1 2 0.800
1 1 0.120
2 2 0.900
Output
4.465000000
----------------------------------------------------------------------------------------------------
D. Birthday
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 1
4 3 1
3 5 1
1 3 1
5
1 1
1 5
2 4
2 1
3 5
Output
10
1000000005
1000000002
23
1000000002
Input
8
1 2 100
1 3 20
2 4 2
2 5 1
3 6 1
3 7 2
6 8 5
6
1 8
2 3
5 8
2 6
4 7
6 1
Output
999968753
49796
999961271
999991235
999958569
45130
----------------------------------------------------------------------------------------------------
E. Sharti
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2 1
1 1 3 3
2 2 4 4
Output
Malek
Input
12 5 7
3 4 5 6
1 2 1 2
4 5 9 9
8 6 12 10
12 4 12 4
Output
Hamed
----------------------------------------------------------------------------------------------------
