using System.Collections.Generic;
static List<List<int>> CombinationSum(List<int> arr, int sum)
List<List<int>> ans = new List<List<int>>();
List<int> temp = new List<int>();
HashSet<int> hs = new HashSet<int>(arr);
FindNumbers(ans, arr, sum, 0, temp);
static void FindNumbers(List<List<int>> ans, List<int> arr, int sum, int index, List<int> temp)
ans.Add(new List<int>(temp));
for(int i = index; i < arr.Count; i++)
FindNumbers(ans, arr, sum - arr[i], i, temp);
public static void Main()
List<int> arr = new List<int>();
List<List<int>> ans = CombinationSum(arr, sum);
Console.WriteLine("Empty Result!");
for(int i = 0; i < ans.Count; i++)
for(int j = 0; j < ans[i].Count; j++)
Console.Write(ans[i][j]+ " " );