Codeforces Round 443 (Div. 2)


A. Borya's Diagnosis
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 2
1 2
2 2
Output
4
Input
2
10 1
6 5
Output
11
----------------------------------------------------------------------------------------------------
B. Table Tennis
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
1 2
Output
2 
Input
4 2
3 1 2 4
Output
3 
Input
6 2
6 5 3 1 2 4
Output
6 
Input
2 10000000000
2 1
Output
2
----------------------------------------------------------------------------------------------------
C. Short Program
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
| 3
^ 2
| 1
Output
2
| 3
^ 2
Input
3
& 1
& 3
& 5
Output
1
& 1
Input
3
^ 1
^ 2
^ 3
Output
0
----------------------------------------------------------------------------------------------------
D. Teams Formation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 5
1 2 3 1
Output
12
Input
1 9 10
1
Output
1
Input
3 2 10
1 2 1
Output
0
----------------------------------------------------------------------------------------------------
E. Tournament
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 5
5 1
10 10
Output
1
2
1
Input
3 2
2 2
3 3
1 10
Output
1
1
3
Input
3 2
2 3
1 1
3 2
Output
1
1
2
----------------------------------------------------------------------------------------------------
