Codeforces Beta Round 79 (Div. 1 Only)


A. Homework
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aaaaa
4
Output
1
aaaaa
Input
abacaba
4
Output
1
aaaa
Input
abcdefgh
10
Output
0
----------------------------------------------------------------------------------------------------
B. Buses
time limit per test: 2 seconds
memory limit per test: 265 megabytes
input: standard input
output: standard output

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

Examples
Input
0 0
1 1
0 1
Output
YES
Input
0 0
1 1
1 1
Output
YES
Input
0 0
1 1
2 2
Output
NO
----------------------------------------------------------------------------------------------------
D. Castle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2 1
Output
1.0
Input
4
1 3 2
4 2 1
3 2 3
Output
4.333333333333334
Input
5
1 2 1
1 3 1
1 4 1
1 5 1
Output
4.0
----------------------------------------------------------------------------------------------------
E. Candies and Stones
time limit per test: 7.5 seconds
memory limit per test: 45 megabytes
input: standard input
output: standard output

Examples
Input
2 2 10
0 0
0 1
Output
2
SC
Input
3 3 10
0 2 0
0 0 2
Output
10
CSSC
Input
3 3 2
0 1 1
1 1 0
Output
4
SCSC
----------------------------------------------------------------------------------------------------
