Codeforces Round 432 (Div. 1, based on IndiaHacks Final Round 2017)


A. Five Dimensional Points
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
0 0 0 0 0
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
Output
1
1
Input
3
0 0 1 2 0
0 0 9 2 0
0 0 5 9 0
Output
0
----------------------------------------------------------------------------------------------------
B. Arpa and a list of numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 23 17
1 17 17 16
Output
40
Input
10 6 2
100 49 71 73 66 96 8 60 41 63
Output
10
----------------------------------------------------------------------------------------------------
C. Arpa and a game with Mojtaba
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 1 1
Output
Arpa
Input
4
1 1 17 17
Output
Mojtaba
Input
4
1 1 17 289
Output
Arpa
Input
5
1 2 3 4 5
Output
Arpa
----------------------------------------------------------------------------------------------------
D. Tournament Construction
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
Output
4
0011
1001
0100
0010
Input
2
0 3
Output
6
000111
100011
110001
011001
001101
000000
----------------------------------------------------------------------------------------------------
E. Random Elections
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
01010101
Output
216
Input
3
01101001
Output
168
----------------------------------------------------------------------------------------------------
F. Rainbow Balls
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1
Output
1
Input
3
1 2 3
Output
750000026
----------------------------------------------------------------------------------------------------
