enhanced template for quick input testing using freopen of stdin