Codeforces Round 334 (Div. 1)


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

Examples
Input
8
10000011
Output
5
Input
2
01
Output
2
----------------------------------------------------------------------------------------------------
B. Moodular Arithmetic
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
Output
3
Input
5 4
Output
25
----------------------------------------------------------------------------------------------------
C. Lieges of Legendre
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
3 4
Output
Kevin
Input
1 2
3
Output
Nicky
----------------------------------------------------------------------------------------------------
D. Ruminations on Ruminants
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 0 0
0 1 0
1 1 -1
1 -1 2
Output
2
Input
3
0 1 1
1 1 2
1 -1 -2
Output
1
----------------------------------------------------------------------------------------------------
E. Pastoral Oddities
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 3 4
2 4 8
1 2 2
3 4 3
Output
-1
8
8
3
Input
3 2
1 2 3
2 3 4
Output
-1
-1
Input
4 10
2 1 987
3 2 829
4 1 768
4 2 608
3 4 593
3 2 488
4 2 334
2 1 204
1 3 114
1 4 39
Output
-1
-1
829
829
768
768
768
488
334
204
----------------------------------------------------------------------------------------------------
