a few optimizations

1. static map to save time across multiple executions
2. for the same N with different start integers, just clone trees