Codeforces Round 825 (Div. 2)


A. Make A Equal to B
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
1 0 1
0 0 1
4
1 1 0 0
0 1 1 1
2
1 1
1 1
4
1 0 0 1
0 1 1 0
1
0
1
Output
1
2
0
1
1
----------------------------------------------------------------------------------------------------
B. Playing with GCD
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
343
2
4 2
3
4 2 4
4
1 1 1 1
Output
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
C1. Good Subarrays (Easy Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 2 3
3
1 1 1
4
2 1 4 3
Output
6
3
7
----------------------------------------------------------------------------------------------------
C2. Good Subarrays (Hard Version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 4 1 4
3
2 4
3 3
2 1
Output
6
10
5
Input
5
1 1 3 2 1
3
1 3
2 5
4 5
Output
7
9
8
----------------------------------------------------------------------------------------------------
D. Equal Binary Subsequences
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1010
3
100010
2
1111
2
1110
Output
0
1 2
2 3 5
1 2 5
3 2 3 4
1 4
-1
----------------------------------------------------------------------------------------------------
E. Swap and Take
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
2
3 1
Output
6
Input
5
7 3 9 6 12
Output
52
----------------------------------------------------------------------------------------------------
