bowang0911/leetcode huggingface dataset:
Count Ways to Distribute Candies

There are `n` **unique** candies (labeled `1` through `n`) and `k` bags. You are asked to distribute **all** the candies into the bags such that every bag has **at least** one candy.

There can be multiple ways to distribute the candies. Two ways are considered **different** if the candies in one bag in the first way are not all in the same bag in the second way. The order of the bags and the order of the candies within each bag do not matter.

For example, `(1), (2,3)` and `(2), (1,3)` are considered different because candies `2` and `3` in the bag `(2,3)` in the first way are not in the same bag in the second way (they are split between the bags `(2)` and `(1,3)`). However, `(1), (2,3)` and `(3,2), (1)` are considered the same because the candies in each bag are all in the same bags in both ways.

Given two integers, `n` and `k`, return _the **number** of different ways to distribute the candies_. As the answer may be too large, return it **modulo** `109 + 7`.

**Example 1:**

**Input:** n = 3, k = 2
**Output:** 3
**Explanation:** You can distribute 3 candies into 2 bags in 3 ways:
(1), (2,3)
(1,2), (3)
(1,3), (2)

**Example 2:**

**Input:** n = 4, k = 2
**Output:** 7
**Explanation:** You can distribute 4 candies into 2 bags in 7 ways:
(1), (2,3,4)
(1,2), (3,4)
(1,3), (2,4)
(1,4), (2,3)
(1,2,3), (4)
(1,2,4), (3)
(1,3,4), (2)

**Example 3:**

**Input:** n = 20, k = 5
**Output:** 206085257
**Explanation:** You can distribute 20 candies into 5 bags in 1881780996 ways. 1881780996 modulo 109 + 7 = 206085257.

**Constraints:**

*   `1 <= k <= n <= 1000`
Reformat Phone Number

You are given a phone number as a string `number`. `number` consists of digits, spaces `' '`, and/or dashes `'-'`.

You would like to reformat the phone number in a certain manner. Firstly, **remove** all spaces and dashes. Then, **group** the digits from left to right into blocks of length 3 **until** there are 4 or fewer digits. The final digits are then grouped as follows:

*   2 digits: A single block of length 2.
*   3 digits: A single block of length 3.
*   4 digits: Two blocks of length 2 each.

The blocks are then joined by dashes. Notice that the reformatting process should **never** produce any blocks of length 1 and produce **at most** two blocks of length 2.

Return _the phone number after formatting._

**Example 1:**

**Input:** number =  "1-23-45 6 "
**Output:**  "123-456 "
**Explanation:** The digits are  "123456 ".
Step 1: There are more than 4 digits, so group the next 3 digits. The 1st block is  "123 ".
Step 2: There are 3 digits remaining, so put them in a single block of length 3. The 2nd block is  "456 ".
Joining the blocks gives  "123-456 ".

**Example 2:**

**Input:** number =  "123 4-567 "
**Output:**  "123-45-67 "
**Explanation:** The digits are  "1234567 ".
Step 1: There are more than 4 digits, so group the next 3 digits. The 1st block is  "123 ".
Step 2: There are 4 digits left, so split them into two blocks of length 2. The blocks are  "45 " and  "67 ".
Joining the blocks gives  "123-45-67 ".

**Example 3:**

**Input:** number =  "123 4-5678 "
**Output:**  "123-456-78 "
**Explanation:** The digits are  "12345678 ".
Step 1: The 1st block is  "123 ".
Step 2: The 2nd block is  "456 ".
Step 3: There are 2 digits left, so put them in a single block of length 2. The 3rd block is  "78 ".
Joining the blocks gives  "123-456-78 ".

**Constraints:**

*   `2 <= number.length <= 100`
*   `number` consists of digits and the characters `'-'` and `' '`.
*   There are at least **two** digits in `number`.
Maximum Erasure Value

You are given an array of positive integers `nums` and want to erase a subarray containing **unique elements**. The **score** you get by erasing the subarray is equal to the **sum** of its elements.

Return _the **maximum score** you can get by erasing **exactly one** subarray._

An array `b` is called to be a subarray of `a` if it forms a contiguous subsequence of `a`, that is, if it is equal to `a[l],a[l+1],...,a[r]` for some `(l,r)`.

**Example 1:**

**Input:** nums = \[4,2,4,5,6\]
**Output:** 17
**Explanation:** The optimal subarray here is \[2,4,5,6\].

**Example 2:**

**Input:** nums = \[5,2,1,2,5,2,1,2,5\]
**Output:** 8
**Explanation:** The optimal subarray here is \[5,2,1\] or \[1,2,5\].

**Constraints:**

*   `1 <= nums.length <= 105`
*   `1 <= nums[i] <= 104`
Jump Game VI

You are given a **0-indexed** integer array `nums` and an integer `k`.

You are initially standing at index `0`. In one move, you can jump at most `k` steps forward without going outside the boundaries of the array. That is, you can jump from index `i` to any index in the range `[i + 1, min(n - 1, i + k)]` **inclusive**.

You want to reach the last index of the array (index `n - 1`). Your **score** is the **sum** of all `nums[j]` for each index `j` you visited in the array.

Return _the **maximum score** you can get_.

**Example 1:**

**Input:** nums = \[1,\-1,-2,4,-7,3\], k = 2
**Output:** 7
**Explanation:** You can choose your jumps forming the subsequence \[1,-1,4,3\] (underlined above). The sum is 7.

**Example 2:**

**Input:** nums = \[10,-5,-2,4,0,3\], k = 3
**Output:** 17
**Explanation:** You can choose your jumps forming the subsequence \[10,4,3\] (underlined above). The sum is 17.

**Example 3:**

**Input:** nums = \[1,-5,-20,4,-1,3,-6,-3\], k = 2
**Output:** 0

**Constraints:**

*   `1 <= nums.length, k <= 105`
*   `-104 <= nums[i] <= 104`
Checking Existence of Edge Length Limited Paths

An undirected graph of `n` nodes is defined by `edgeList`, where `edgeList[i] = [ui, vi, disi]` denotes an edge between nodes `ui` and `vi` with distance `disi`. Note that there may be **multiple** edges between two nodes.

Given an array `queries`, where `queries[j] = [pj, qj, limitj]`, your task is to determine for each `queries[j]` whether there is a path between `pj` and `qj` such that each edge on the path has a distance **strictly less than** `limitj` .

Return _a **boolean array**_ `answer`_, where_ `answer.length == queries.length` _and the_ `jth` _value of_ `answer` _is_ `true` _if there is a path for_ `queries[j]` _is_ `true`_, and_ `false` _otherwise_.

**Example 1:**

**Input:** n = 3, edgeList = \[\[0,1,2\],\[1,2,4\],\[2,0,8\],\[1,0,16\]\], queries = \[\[0,1,2\],\[0,2,5\]\]
**Output:** \[false,true\]
**Explanation:** The above figure shows the given graph. Note that there are two overlapping edges between 0 and 1 with distances 2 and 16.
For the first query, between 0 and 1 there is no path where each distance is less than 2, thus we return false for this query.
For the second query, there is a path (0 -> 1 -> 2) of two edges with distances less than 5, thus we return true for this query.

**Example 2:**

**Input:** n = 5, edgeList = \[\[0,1,10\],\[1,2,5\],\[2,3,9\],\[3,4,13\]\], queries = \[\[0,4,14\],\[1,4,13\]\]
**Output:** \[true,false\]
**Exaplanation:** The above figure shows the given graph.

**Constraints:**

*   `2 <= n <= 105`
*   `1 <= edgeList.length, queries.length <= 105`
*   `edgeList[i].length == 3`
*   `queries[j].length == 3`
*   `0 <= ui, vi, pj, qj <= n - 1`
*   `ui != vi`
*   `pj != qj`
*   `1 <= disi, limitj <= 109`
*   There may be **multiple** edges between two nodes.
Number of Distinct Substrings in a String

Given a string `s`, return _the number of **distinct** substrings of_ `s`.

A **substring** of a string is obtained by deleting any number of characters (possibly zero) from the front of the string and any number (possibly zero) from the back of the string.

**Example 1:**

**Input:** s =  "aabbaba "
**Output:** 21
**Explanation:** The set of distinct strings is \[ "a ", "b ", "aa ", "bb ", "ab ", "ba ", "aab ", "abb ", "bab ", "bba ", "aba ", "aabb ", "abba ", "bbab ", "baba ", "aabba ", "abbab ", "bbaba ", "aabbab ", "abbaba ", "aabbaba "\]

**Example 2:**

**Input:** s =  "abcdefg "
**Output:** 28

**Constraints:**

*   `1 <= s.length <= 500`
*   `s` consists of lowercase English letters.

**Follow up:** Can you solve this problem in `O(n)` time complexity?
Number of Students Unable to Eat Lunch

The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers `0` and `1` respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.

The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a **stack**. At each step:

*   If the student at the front of the queue **prefers** the sandwich on the top of the stack, they will **take it** and leave the queue.
*   Otherwise, they will **leave it** and go to the queue's end.

This continues until none of the queue students want to take the top sandwich and are thus unable to eat.

You are given two integer arrays `students` and `sandwiches` where `sandwiches[i]` is the type of the `i​​​​​​th` sandwich in the stack (`i = 0` is the top of the stack) and `students[j]` is the preference of the `j​​​​​​th` student in the initial queue (`j = 0` is the front of the queue). Return _the number of students that are unable to eat._

**Example 1:**

**Input:** students = \[1,1,0,0\], sandwiches = \[0,1,0,1\]
**Output:** 0 
**Explanation:**
- Front student leaves the top sandwich and returns to the end of the line making students = \[1,0,0,1\].
- Front student leaves the top sandwich and returns to the end of the line making students = \[0,0,1,1\].
- Front student takes the top sandwich and leaves the line making students = \[0,1,1\] and sandwiches = \[1,0,1\].
- Front student leaves the top sandwich and returns to the end of the line making students = \[1,1,0\].
- Front student takes the top sandwich and leaves the line making students = \[1,0\] and sandwiches = \[0,1\].
- Front student leaves the top sandwich and returns to the end of the line making students = \[0,1\].
- Front student takes the top sandwich and leaves the line making students = \[1\] and sandwiches = \[1\].
- Front student takes the top sandwich and leaves the line making students = \[\] and sandwiches = \[\].
Hence all students are able to eat.

**Example 2:**

**Input:** students = \[1,1,1,0,0,1\], sandwiches = \[1,0,0,0,1,1\]
**Output:** 3

**Constraints:**

*   `1 <= students.length, sandwiches.length <= 100`
*   `students.length == sandwiches.length`
*   `sandwiches[i]` is `0` or `1`.
*   `students[i]` is `0` or `1`.
Average Waiting Time

There is a restaurant with a single chef. You are given an array `customers`, where `customers[i] = [arrivali, timei]:`

*   `arrivali` is the arrival time of the `ith` customer. The arrival times are sorted in **non-decreasing** order.
*   `timei` is the time needed to prepare the order of the `ith` customer.

When a customer arrives, he gives the chef his order, and the chef starts preparing it once he is idle. The customer waits till the chef finishes preparing his order. The chef does not prepare food for more than one customer at a time. The chef prepares food for customers **in the order they were given in the input**.

Return _the **average** waiting time of all customers_. Solutions within `10-5` from the actual answer are considered accepted.

**Example 1:**

**Input:** customers = \[\[1,2\],\[2,5\],\[4,3\]\]
**Output:** 5.00000
**Explanation:**
1) The first customer arrives at time 1, the chef takes his order and starts preparing it immediately at time 1, and finishes at time 3, so the waiting time of the first customer is 3 - 1 = 2.
2) The second customer arrives at time 2, the chef takes his order and starts preparing it at time 3, and finishes at time 8, so the waiting time of the second customer is 8 - 2 = 6.
3) The third customer arrives at time 4, the chef takes his order and starts preparing it at time 8, and finishes at time 11, so the waiting time of the third customer is 11 - 4 = 7.
So the average waiting time = (2 + 6 + 7) / 3 = 5.

**Example 2:**

**Input:** customers = \[\[5,2\],\[5,4\],\[10,3\],\[20,1\]\]
**Output:** 3.25000
**Explanation:**
1) The first customer arrives at time 5, the chef takes his order and starts preparing it immediately at time 5, and finishes at time 7, so the waiting time of the first customer is 7 - 5 = 2.
2) The second customer arrives at time 5, the chef takes his order and starts preparing it at time 7, and finishes at time 11, so the waiting time of the second customer is 11 - 5 = 6.
3) The third customer arrives at time 10, the chef takes his order and starts preparing it at time 11, and finishes at time 14, so the waiting time of the third customer is 14 - 10 = 4.
4) The fourth customer arrives at time 20, the chef takes his order and starts preparing it immediately at time 20, and finishes at time 21, so the waiting time of the fourth customer is 21 - 20 = 1.
So the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25.

**Constraints:**

*   `1 <= customers.length <= 105`
*   `1 <= arrivali, timei <= 104`
*   `arrivali <= arrivali+1`
Maximum Binary String After Change

You are given a binary string `binary` consisting of only `0`'s or `1`'s. You can apply each of the following operations any number of times:

*   Operation 1: If the number contains the substring `"00 "`, you can replace it with `"10 "`.
    *   For example, `"00010 " -> "10010` "
*   Operation 2: If the number contains the substring `"10 "`, you can replace it with `"01 "`.
    *   For example, `"00010 " -> "00001 "`

_Return the **maximum binary string** you can obtain after any number of operations. Binary string `x` is greater than binary string `y` if `x`'s decimal representation is greater than `y`'s decimal representation._

**Example 1:**

**Input:** binary =  "000110 "
**Output:**  "111011 "
**Explanation:** A valid transformation sequence can be:
 "000110 " ->  "000101 " 
 "000101 " ->  "100101 " 
 "100101 " ->  "110101 " 
 "110101 " ->  "110011 " 
 "110011 " ->  "111011 "

**Example 2:**

**Input:** binary =  "01 "
**Output:**  "01 "
**Explanation:**  "01 " cannot be transformed any further.

**Constraints:**

*   `1 <= binary.length <= 105`
*   `binary` consist of `'0'` and `'1'`.
Minimum Adjacent Swaps for K Consecutive Ones

You are given an integer array, `nums`, and an integer `k`. `nums` comprises of only `0`'s and `1`'s. In one move, you can choose two **adjacent** indices and swap their values.

Return _the **minimum** number of moves required so that_ `nums` _has_ `k` _**consecutive**_ `1`_'s_.

**Example 1:**

**Input:** nums = \[1,0,0,1,0,1\], k = 2
**Output:** 1
**Explanation:** In 1 move, nums could be \[1,0,0,0,1,1\] and have 2 consecutive 1's.

**Example 2:**

**Input:** nums = \[1,0,0,0,0,0,1,1\], k = 3
**Output:** 5
**Explanation:** In 5 moves, the leftmost 1 can be shifted right until nums = \[0,0,0,0,0,1,1,1\].

**Example 3:**

**Input:** nums = \[1,1,0,1\], k = 2
**Output:** 0
**Explanation:** nums already has 2 consecutive 1's.

**Constraints:**

*   `1 <= nums.length <= 105`
*   `nums[i]` is `0` or `1`.
*   `1 <= k <= sum(nums)`
Determine if String Halves Are Alike

You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half.

Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppercase and lowercase letters.

Return `true` _if_ `a` _and_ `b` _are **alike**_. Otherwise, return `false`.

**Example 1:**

**Input:** s =  "book "
**Output:** true
**Explanation:** a =  "bo " and b =  "ok ". a has 1 vowel and b has 1 vowel. Therefore, they are alike.

**Example 2:**

**Input:** s =  "textbook "
**Output:** false
**Explanation:** a =  "text " and b =  "book ". a has 1 vowel whereas b has 2. Therefore, they are not alike.
Notice that the vowel o is counted twice.

**Constraints:**

*   `2 <= s.length <= 1000`
*   `s.length` is even.
*   `s` consists of **uppercase and lowercase** letters.
Maximum Number of Eaten Apples

There is a special kind of apple tree that grows apples every day for `n` days. On the `ith` day, the tree grows `apples[i]` apples that will rot after `days[i]` days, that is on day `i + days[i]` the apples will be rotten and cannot be eaten. On some days, the apple tree does not grow any apples, which are denoted by `apples[i] == 0` and `days[i] == 0`.

You decided to eat **at most** one apple a day (to keep the doctors away). Note that you can keep eating after the first `n` days.

Given two integer arrays `days` and `apples` of length `n`, return _the maximum number of apples you can eat._

**Example 1:**

**Input:** apples = \[1,2,3,5,2\], days = \[3,2,1,4,2\]
**Output:** 7
**Explanation:** You can eat 7 apples:
- On the first day, you eat an apple that grew on the first day.
- On the second day, you eat an apple that grew on the second day.
- On the third day, you eat an apple that grew on the second day. After this day, the apples that grew on the third day rot.
- On the fourth to the seventh days, you eat apples that grew on the fourth day.

**Example 2:**

**Input:** apples = \[3,0,0,0,0,2\], days = \[3,0,0,0,0,2\]
**Output:** 5
**Explanation:** You can eat 5 apples:
- On the first to the third day you eat apples that grew on the first day.
- Do nothing on the fouth and fifth days.
- On the sixth and seventh days you eat apples that grew on the sixth day.

**Constraints:**

*   `n == apples.length == days.length`
*   `1 <= n <= 2 * 104`
*   `0 <= apples[i], days[i] <= 2 * 104`
*   `days[i] = 0` if and only if `apples[i] = 0`.
Where Will the Ball Fall

You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides.

Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.

*   A board that redirects the ball to the right spans the top-left corner to the bottom-right corner and is represented in the grid as `1`.
*   A board that redirects the ball to the left spans the top-right corner to the bottom-left corner and is represented in the grid as `-1`.

We drop one ball at the top of each column of the box. Each ball can get stuck in the box or fall out of the bottom. A ball gets stuck if it hits a "V " shaped pattern between two boards or if a board redirects the ball into either wall of the box.

Return _an array_ `answer` _of size_ `n` _where_ `answer[i]` _is the column that the ball falls out of at the bottom after dropping the ball from the_ `ith` _column at the top, or `-1` _if the ball gets stuck in the box_._

**Example 1:**

**Input:** grid = \[\[1,1,1,-1,-1\],\[1,1,1,-1,-1\],\[-1,-1,-1,1,1\],\[1,1,1,1,-1\],\[-1,-1,-1,-1,-1\]\]
**Output:** \[1,-1,-1,-1,-1\]
**Explanation:** This example is shown in the photo.
Ball b0 is dropped at column 0 and falls out of the box at column 1.
Ball b1 is dropped at column 1 and will get stuck in the box between column 2 and 3 and row 1.
Ball b2 is dropped at column 2 and will get stuck on the box between column 2 and 3 and row 0.
Ball b3 is dropped at column 3 and will get stuck on the box between column 2 and 3 and row 0.
Ball b4 is dropped at column 4 and will get stuck on the box between column 2 and 3 and row 1.

**Example 2:**

**Input:** grid = \[\[-1\]\]
**Output:** \[-1\]
**Explanation:** The ball gets stuck against the left wall.

**Example 3:**

**Input:** grid = \[\[1,1,1,1,1,1\],\[-1,-1,-1,-1,-1,-1\],\[1,1,1,1,1,1\],\[-1,-1,-1,-1,-1,-1\]\]
**Output:** \[0,1,2,3,4,-1\]

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m, n <= 100`
*   `grid[i][j]` is `1` or `-1`.
Maximum XOR With an Element From Array

You are given an array `nums` consisting of non-negative integers. You are also given a `queries` array, where `queries[i] = [xi, mi]`.

The answer to the `ith` query is the maximum bitwise `XOR` value of `xi` and any element of `nums` that does not exceed `mi`. In other words, the answer is `max(nums[j] XOR xi)` for all `j` such that `nums[j] <= mi`. If all elements in `nums` are larger than `mi`, then the answer is `-1`.

Return _an integer array_ `answer` _where_ `answer.length == queries.length` _and_ `answer[i]` _is the answer to the_ `ith` _query._

**Example 1:**

**Input:** nums = \[0,1,2,3,4\], queries = \[\[3,1\],\[1,3\],\[5,6\]\]
**Output:** \[3,3,7\]
**Explanation:**
1) 0 and 1 are the only two integers not greater than 1. 0 XOR 3 = 3 and 1 XOR 3 = 2. The larger of the two is 3.
2) 1 XOR 2 = 3.
3) 5 XOR 2 = 7.

**Example 2:**

**Input:** nums = \[5,2,4,6,6,3\], queries = \[\[12,4\],\[8,1\],\[6,3\]\]
**Output:** \[15,-1,5\]

**Constraints:**

*   `1 <= nums.length, queries.length <= 105`
*   `queries[i].length == 2`
*   `0 <= nums[j], xi, mi <= 109`
Largest Subarray Length K

An array `A` is larger than some array `B` if for the first index `i` where `A[i] != B[i]`, `A[i] > B[i]`.

For example, consider `0`\-indexing:

*   `[1,3,2,4] > [1,2,2,4]`, since at index `1`, `3 > 2`.
*   `[1,4,4,4] < [2,1,1,1]`, since at index `0`, `1 < 2`.

A subarray is a contiguous subsequence of the array.

Given an integer array `nums` of **distinct** integers, return the **largest** subarray of `nums` of length `k`.

**Example 1:**

**Input:** nums = \[1,4,5,2,3\], k = 3
**Output:** \[5,2,3\]
**Explanation:** The subarrays of size 3 are: \[1,4,5\], \[4,5,2\], and \[5,2,3\].
Of these, \[5,2,3\] is the largest.

**Example 2:**

**Input:** nums = \[1,4,5,2,3\], k = 4
**Output:** \[4,5,2,3\]
**Explanation:** The subarrays of size 4 are: \[1,4,5,2\], and \[4,5,2,3\].
Of these, \[4,5,2,3\] is the largest.

**Example 3:**

**Input:** nums = \[1,4,5,2,3\], k = 1
**Output:** \[5\]

**Constraints:**

*   `1 <= k <= nums.length <= 105`
*   `1 <= nums[i] <= 109`
*   All the integers of `nums` are **unique**.

**Follow up:** What if the integers in `nums` are not distinct?
Maximum Units on a Truck

You are assigned to put some amount of boxes onto **one truck**. You are given a 2D array `boxTypes`, where `boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]`:

*   `numberOfBoxesi` is the number of boxes of type `i`.
*   `numberOfUnitsPerBoxi` is the number of units in each box of the type `i`.

You are also given an integer `truckSize`, which is the **maximum** number of **boxes** that can be put on the truck. You can choose any boxes to put on the truck as long as the number of boxes does not exceed `truckSize`.

Return _the **maximum** total number of **units** that can be put on the truck._

**Example 1:**

**Input:** boxTypes = \[\[1,3\],\[2,2\],\[3,1\]\], truckSize = 4
**Output:** 8
**Explanation:** There are:
- 1 box of the first type that contains 3 units.
- 2 boxes of the second type that contain 2 units each.
- 3 boxes of the third type that contain 1 unit each.
You can take all the boxes of the first and second types, and one box of the third type.
The total number of units will be = (1 \* 3) + (2 \* 2) + (1 \* 1) = 8.

**Example 2:**

**Input:** boxTypes = \[\[5,10\],\[2,5\],\[4,7\],\[3,9\]\], truckSize = 10
**Output:** 91

**Constraints:**

*   `1 <= boxTypes.length <= 1000`
*   `1 <= numberOfBoxesi, numberOfUnitsPerBoxi <= 1000`
*   `1 <= truckSize <= 106`
Count Good Meals

A **good meal** is a meal that contains **exactly two different food items** with a sum of deliciousness equal to a power of two.

You can pick **any** two different foods to make a good meal.

Given an array of integers `deliciousness` where `deliciousness[i]` is the deliciousness of the `i​​​​​​th​​​​`​​​​ item of food, return _the number of different **good meals** you can make from this list modulo_ `109 + 7`.

Note that items with different indices are considered different even if they have the same deliciousness value.

**Example 1:**

**Input:** deliciousness = \[1,3,5,7,9\]
**Output:** 4
**Explanation:** The good meals are (1,3), (1,7), (3,5) and, (7,9).
Their respective sums are 4, 8, 8, and 16, all of which are powers of 2.

**Example 2:**

**Input:** deliciousness = \[1,1,1,3,3,3,7\]
**Output:** 15
**Explanation:** The good meals are (1,1) with 3 ways, (1,3) with 9 ways, and (1,7) with 3 ways.

**Constraints:**

*   `1 <= deliciousness.length <= 105`
*   `0 <= deliciousness[i] <= 220`