Codeforces Round 387 (Div. 2)


A. Display Size
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
Output
2 4
Input
64
Output
8 8
Input
5
Output
1 5
Input
999999
Output
999 1001
----------------------------------------------------------------------------------------------------
B. Mammoth's Genome Decoding
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
AG?C??CT
Output
AGACGTCT
Input
4
AGCT
Output
AGCT
Input
6
????G?
Output
===
Input
4
AA??
Output
===
----------------------------------------------------------------------------------------------------
C. Servers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
1 3 2
2 2 1
3 4 3
Output
6
-1
10
Input
3 2
3 2 3
5 1 2
Output
3
3
Input
8 6
1 3 20
4 2 1
6 5 5
10 1 1
15 3 6
21 8 8
Output
6
9
30
-1
15
36
----------------------------------------------------------------------------------------------------
D. Winter Is Coming
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
-5 20 -3 0
Output
2
Input
4 2
-5 20 -3 0
Output
4
Input
10 6
2 -5 1 3 0 0 -4 -3 1 0
Output
3
----------------------------------------------------------------------------------------------------
E. Comments
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
hello,2,ok,0,bye,0,test,0,one,1,two,2,a,0,b,0
Output
3
hello test one 
ok bye two 
a b 
Input
a,5,A,0,a,0,A,0,a,0,A,0
Output
2
a 
A a A a A 
Input
A,3,B,2,C,0,D,1,E,0,F,1,G,0,H,1,I,1,J,0,K,1,L,0,M,2,N,0,O,1,P,0
Output
4
A K M 
B F H L N O 
C D G I P 
E J 
----------------------------------------------------------------------------------------------------
F. Igor and Interesting Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
17 1
Output
12
Input
1000000 2
Output
fca2c
----------------------------------------------------------------------------------------------------
