Codeforces Round 666 (Div. 2)


A. Juggling Letters
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
caa
cbb
3
cba
cba
cbb
4
ccab
cbac
bca
acbcc
4
acb
caf
c
cbafc
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
B. Power Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3 2
Output
1
Input
3
1000000000 1000000000 1000000000
Output
1999982505
----------------------------------------------------------------------------------------------------
C. Multiples of Length
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3 2 4
Output
1 1 
-1
3 4
4 2
2 4
-3 -6 -6
----------------------------------------------------------------------------------------------------
D. Stoned Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1
2
2
1 1
Output
T
HL
----------------------------------------------------------------------------------------------------
E. Monster Invaders
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 1 3 4 3
3 2 5 1
Output
34
Input
4 2 4 4 1
4 5 1 2
Output
31
----------------------------------------------------------------------------------------------------
