Codeforces Round 626 (Div. 2, based on Moscow Open Olympiad in Informatics)


A. Even Subset Sum Problem
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 4 3
1
15
2
3 5
Output
1
2
-1
2
1 2
----------------------------------------------------------------------------------------------------
B. Count Subrectangles
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2
1 0 1
1 1 1
Output
4
Input
3 5 4
1 1 1
1 1 1 1 1
Output
14
----------------------------------------------------------------------------------------------------
C. Unusual Competitions
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
8
))((())(
Output
6
Input
3
(()
Output
-1
----------------------------------------------------------------------------------------------------
D. Present
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
Output
3
Input
3
1 2 3
Output
2
----------------------------------------------------------------------------------------------------
E. Instant Noodles
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
2 4
1 1
1 1
1 2
2 1
2 2
3 4
1 1 1
1 1
1 2
2 2
2 3
4 7
36 31 96 29
1 2
1 3
1 4
2 2
2 4
3 1
4 3
Output
2
1
12
----------------------------------------------------------------------------------------------------
F. Reality Show
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 4
4 3 1 2 1
1 2 1 2 1
1 2 3 4 5 6 7 8 9
Output
6
Input
2 2
1 2
0 0
2 1 -100 -100
Output
2
Input
5 4
4 3 2 1 1
0 2 6 7 4
12 12 12 6 -3 -5 3 10 -4
Output
62
----------------------------------------------------------------------------------------------------
