Codeforces Round 630 (Div. 2)


A. Exercising Walk
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
3 2 2 2
0 0 -2 -2 2 2
3 1 4 1
0 0 -1 -1 1 1
1 1 1 1
1 1 1 1 1 1
0 0 0 1
0 0 0 0 0 1
5 1 1 1
0 0 -100 -100 0 100
1 1 5 1
0 0 -100 -100 100 0
Output
Yes
No
No
Yes
Yes
Yes
----------------------------------------------------------------------------------------------------
B. Composite Coloring
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
3
6 10 15
2
4 9
23
437 519 865 808 909 391 194 291 237 395 323 365 511 497 781 737 871 559 731 697 779 841 961
Output
1
1 1 1
2
2 1
11
4 7 8 10 7 3 10 7 7 8 3 1 1 5 5 9 2 2 3 3 4 11 6
----------------------------------------------------------------------------------------------------
C. K-Complete Word
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
6 2
abaaba
6 3
abaaba
36 9
hippopotomonstrosesquippedaliophobia
21 7
wudixiaoxingxingheclp
Output
2
0
23
16
----------------------------------------------------------------------------------------------------
D. Walk on Matrix
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
0
Output
1 1
300000
Input
1
Output
3 4
7 3 3 1
4 8 3 6
7 7 7 3
----------------------------------------------------------------------------------------------------
E. Height All the Same
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 2 1 1
Output
1
Input
1 2 1 2
Output
2
----------------------------------------------------------------------------------------------------
F. Independent Set
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1
Output
3
Input
3
1 2
3 2
Output
11
----------------------------------------------------------------------------------------------------
G. No Monotone Triples
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6 2
3 1 4 1 5 9
1 3
4 6
Output
3
1 2 3 
0
----------------------------------------------------------------------------------------------------
