Codeforces Beta Round 8


A. Train and Peter
time limit per test: 1 second
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
atob
a
b
Output
forward
Input
aaacaaa
aca
aa
Output
both
----------------------------------------------------------------------------------------------------
B. Obsession with Robots
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
LLUUUR
Output
OK
Input
RRUULLDD
Output
BUG
----------------------------------------------------------------------------------------------------
C. Looking for Order
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
0 0
2
1 1
-1 1
Output
8
0 1 2 0 
Input
1 1
3
4 3
3 4
0 0
Output
32
0 1 2 0 3 0 
----------------------------------------------------------------------------------------------------
D. Two Friends
time limit per test: 1 second
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
0 2
0 0
4 0
-3 0
Output
1.0000000000
Input
0 0
0 0
2 0
1 0
Output
2.0000000000
----------------------------------------------------------------------------------------------------
E. Beads
time limit per test: 5 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
4 4
Output
0101
----------------------------------------------------------------------------------------------------
