Codeforces Round 833 (Div. 2)


A. The Ultimate Square
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
5
197654321
Output
1
3
98827161
----------------------------------------------------------------------------------------------------
B. Diverse Substrings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1
7
2
77
4
1010
5
01100
6
399996
5
23456
18
789987887987998798
Output
1
2
10
12
10
15
106
----------------------------------------------------------------------------------------------------
C. Zero-Sum Prefixes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5
2 0 1 -1 0
3
1000000000 1000000000 0
4
0 0 0 0
8
3 0 2 -10 10 -30 30 0
9
1 0 0 1 -1 0 1 0 -1
Output
3
1
4
4
5
----------------------------------------------------------------------------------------------------
D. ConstructOR
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
12 39 5
6 8 14
100 200 200
3 4 6
2 2 2
18 27 3
420 666 69
987654321 123456789 999999999
Output
18
14
-1
-1
0
11
25599
184470016815529983
----------------------------------------------------------------------------------------------------
E. Yet Another Array Counting Problem
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3 3
1 3 2
4 2
2 2 2 2
6 9
6 9 6 9 6 9
9 100
10 40 20 20 100 60 80 60 60
Output
8
5
11880
351025663
----------------------------------------------------------------------------------------------------
F. Circular Xor Reversal
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
3
1 0 1
Input
3
Output
9
1 0 1 0 2 1 0 1 0 
----------------------------------------------------------------------------------------------------
