Codeforces Round 780 (Div. 3)


A. Vasya and Coins
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1
4 0
0 2
0 0
2314 2374
Output
4
5
1
1
7063
----------------------------------------------------------------------------------------------------
B. Vlad and Candies
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2
2 3
1
2
5
1 6 2 4 3
4
2 2 2 1
3
1 1000000000 999999999
1
1
Output
YES
NO
NO
YES
YES
YES
----------------------------------------------------------------------------------------------------
C. Get an Even String
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
aabbdabdccc
zyx
aaababbb
aabbcc
oaoaaaoo
bmefbmuyw
Output
3
3
2
0
2
7
----------------------------------------------------------------------------------------------------
D. Maximum Product Strikes Back
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
1 2 -1 2
3
1 1 -2
5
2 0 -2 2 -1
3
-2 -1 -1
3
-1 -2 -2
Output
0 2
3 0
2 0
0 1
1 0
----------------------------------------------------------------------------------------------------
E. Matrix and Shifts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
010
011
100
5
00010
00001
10000
01000
00100
2
10
10
4
1111
1011
1111
1111
Output
1
0
2
11
----------------------------------------------------------------------------------------------------
F1. Promising String (easy version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
+-+
5
-+---
4
----
7
--+---+
6
+++---
Output
2
4
2
7
4
----------------------------------------------------------------------------------------------------
F2. Promising String (hard version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
+-+
5
-+---
4
----
7
--+---+
6
+++---
Output
2
4
2
7
4
----------------------------------------------------------------------------------------------------
