Codeforces Round 245 (Div. 2)


A. Points and Segments (easy)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1 
----------------------------------------------------------------------------------------------------
B. Balls Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2 2
1 1 2 2 1 1
Output
6
Input
1 1 1
1
Output
0
----------------------------------------------------------------------------------------------------
C. Xor-tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
2 1
3 1
4 2
5 1
6 2
7 5
8 6
9 8
10 5
1 0 1 1 0 1 0 1 0 1
1 0 1 0 0 1 1 1 0 1
Output
2
4
7
----------------------------------------------------------------------------------------------------
D. Working out
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
100 100 100
100 1 100
100 100 100
Output
800
----------------------------------------------------------------------------------------------------
E. Guess the Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 1 4
Output
YES
Input
5
1 1 5 2 1
Output
NO
----------------------------------------------------------------------------------------------------
