Codeforces Round 311 (Div. 2)


A. Ilya and Diplomas
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 5
2 6
3 7
Output
1 2 3 
Input
10
1 2
1 3
1 5
Output
2 3 5 
Input
6
1 3
2 2
2 2
Output
2 2 2 
----------------------------------------------------------------------------------------------------
B. Pasha and Tea
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
1 1 1 1
Output
3
Input
3 18
4 4 4 2 2 2
Output
18
Input
1 5
2 3
Output
4.5
----------------------------------------------------------------------------------------------------
C. Arthur and Table
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 5
3 2
Output
2
Input
3
2 4 4
1 1 1
Output
0
Input
6
2 2 1 1 3 3
4 3 5 5 2 1
Output
8
----------------------------------------------------------------------------------------------------
D. Vitaly and Cycle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2
1 3
4 2
4 3
Output
1 2
Input
3 3
1 2
2 3
3 1
Output
0 1
Input
3 0
Output
3 1
----------------------------------------------------------------------------------------------------
E. Ann and Half-Palindrome
time limit per test: 1.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
abbabaab
7
Output
abaa
Input
aaaaa
10
Output
aaa
Input
bbaabb
13
Output
bbaabb
----------------------------------------------------------------------------------------------------
