Codeforces Round 586 (Div. 1 + Div. 2)


A. Cards
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
ezor
Output
0 
Input
10
nznooeeoer
Output
1 1 0 
----------------------------------------------------------------------------------------------------
B. Multiplication Table
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
0 4 6 2 4
4 0 6 2 4
6 6 0 3 6
2 2 3 0 2
4 4 6 2 0
Output
2 2 3 1 2 
Input
3
0 99990000 99970002
99990000 0 99980000
99970002 99980000 0
Output
9999 10000 9998 
----------------------------------------------------------------------------------------------------
C. Substring Game in the Lesson
time limit per test: 2 seconds
memory limit per test: 256 mebibytes
input: standard input
output: standard output

Examples
Input
abba
Output
Mike
Ann
Ann
Mike
Input
cba
Output
Mike
Mike
Mike
----------------------------------------------------------------------------------------------------
D. Alex and Julian
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
1
2 
Input
2
2 6
Output
0
----------------------------------------------------------------------------------------------------
E. Tourism
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 7
2 2 8 6 9
1 2
1 3
2 4
3 2
4 5
2 5
1 5
2
Output
27
Input
10 12
1 7 1 9 3 3 6 30 1 10
1 2
1 3
3 5
5 7
2 3
5 4
6 9
4 6
3 7
6 8
9 4
9 10
6
Output
61
----------------------------------------------------------------------------------------------------
F. Gardener Alex
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 3 4
Output
3 3
----------------------------------------------------------------------------------------------------
G. Geolocation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0
0 1
1 0
1
1 1 2
Output
1 1 1 
Input
4
0 0
0 1
1 0
1 1
2
0 1 1 2
2 5 5 8
Output
4 0 0 0 1 1 0 1 1 
4 -1 -1 -1 2 2 -1 2 2 
----------------------------------------------------------------------------------------------------
