Codeforces Round 427 (Div. 2)


A. Key races
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 2 1 2
Output
First
Input
3 3 1 1 1
Output
Second
Input
4 5 3 1 5
Output
Friendship
----------------------------------------------------------------------------------------------------
B. The number on the board
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
11
Output
1
Input
3
99
Output
0
----------------------------------------------------------------------------------------------------
C. Star sky
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3 3
1 1 1
3 2 0
2 1 1 2 2
0 2 1 4 5
5 1 1 5 5
Output
3
0
3
Input
3 4 5
1 1 2
2 3 0
3 3 1
0 1 1 100 100
1 2 2 4 4
2 2 1 4 7
1 50 50 51 51
Output
3
3
5
0
----------------------------------------------------------------------------------------------------
D. Palindromic characteristics
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abba
Output
6 1 0 0 
Input
abacaba
Output
12 4 1 0 0 0 0 
----------------------------------------------------------------------------------------------------
E. The penguin's game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 1
2
1
1
Output
? 3 1 2 3
? 1 1
? 1 3
! 1 3
----------------------------------------------------------------------------------------------------
F. Roads in the Kingdom
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 4
2 3 5
1 3 1
Output
5
Input
5
2 3 7
3 1 9
4 1 8
3 5 4
4 5 5
Output
18
----------------------------------------------------------------------------------------------------
