Counting D-sets

CodeChef - CNTDSETS