Codeforces Round 500 (Div. 2) [based on EJOI]


A. Piles With Stones
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
2 1 4 3 5
Output
Yes
Input
5
1 1 1 1 1
1 0 1 0 1
Output
Yes
Input
3
2 3 9
1 7 9
Output
No
----------------------------------------------------------------------------------------------------
B. And
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
1 2 3 7
Output
1
Input
2 228
1 1
Output
0
Input
3 7
1 2 3
Output
-1
----------------------------------------------------------------------------------------------------
C. Photo of The Sky
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 1 3 2 3 2 1 3
Output
1
Input
3
5 8 5 5 7 5
Output
0
----------------------------------------------------------------------------------------------------
D. Chemical table
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 2 3
1 2
2 2
2 1
Output
0
Input
1 5 3
1 3
1 1
1 5
Output
2
Input
4 3 6
1 2
1 3
2 2
2 3
3 1
3 3
Output
1
----------------------------------------------------------------------------------------------------
E. Hills
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 1 1 1
Output
1 2 2 
Input
3
1 2 3
Output
0 2 
Input
5
1 2 3 2 2
Output
0 1 3 
----------------------------------------------------------------------------------------------------
F. AB-Strings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
bab
bb
Output
2
1 0
1 3
Input
bbbb
aaa
Output
0
----------------------------------------------------------------------------------------------------
