Codeforces Round 541 (Div. 2)


A. Sea Battle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 2 1
Output
12
Input
2 2 1 2
Output
16
----------------------------------------------------------------------------------------------------
B. Draw!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 0
3 1
3 4
Output
2
Input
3
0 0
0 0
0 0
Output
1
Input
1
5 4
Output
5
----------------------------------------------------------------------------------------------------
C. Birthday
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 1 1 3 2
Output
1 2 3 2 1
Input
3
30 10 20
Output
10 20 30
----------------------------------------------------------------------------------------------------
D. Gourmet choice
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
>>>>
>>>>
>>>>
Output
Yes
2 2 2 
1 1 1 1 
Input
3 3
>>>
<<<
>>>
Output
Yes
3 1 3 
2 2 2 
Input
3 2
==
=<
==
Output
No
----------------------------------------------------------------------------------------------------
E. String Multiplication
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
a
b
a
Output
3
Input
2
bnn
a
Output
1
----------------------------------------------------------------------------------------------------
F. Asya And Kittens
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 4
2 5
3 1
4 5
Output
3 1 4 2 5
----------------------------------------------------------------------------------------------------
G. Most Dangerous Shark
time limit per test: 2 seconds
memory limit per test: 768 megabytes
input: standard input
output: standard output

Examples
Input
2 7
3
1 2 2
1 2 1
1
3
2
3
2 2
1 3
1 1
Output
5
Input
1 1
1
1
100000
1
1 100000
Output
10000000000
----------------------------------------------------------------------------------------------------
