Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up, break up or cut these fruits into pieces. These fruits — lemons, apples and pears — should be put in the compote as whole fruits.
Your task is to determine the maximum total number of lemons, apples and pears from which Nikolay can cook the compote. It is possible that Nikolay can't use any fruits, in this case print 0.
Input
The first line contains the positive integer a (1 ≤ a ≤ 1000) — the number of lemons Nikolay has.
The second line contains the positive integer b (1 ≤ b ≤ 1000) — the number of apples Nikolay has.
The third line contains the positive integer c (1 ≤ c ≤ 1000) — the number of pears Nikolay has.
Output
Print the maximum total number of lemons, apples and pears from which Nikolay can cook the compote.
Examples
Input
2
5
7
Output
7
Input
4
7
13
Output
21
Input
2
3
2
Output
0
Note
In the first example Nikolay can use 1 lemon, 2 apples and 4 pears, so the answer is 1 + 2 + 4 = 7.
In the second example Nikolay can use 3 lemons, 6 apples and 12 pears, so the answer is 3 + 6 + 12 = 21.
In the third example Nikolay don't have enough pears to cook any compote, so the answer is 0.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
We need to find maximum total number of fruits used such that they are in ratio lemon:apple:pear = 1:2:4. So we can use x lemons, 2x apples, 4x pears for some integer x >= 0. The constraints: x <= a, 2x <= b, 4x <= c. The total fruits = x + 2x + 4x = 7x. So we need to maximize x such that x <= a, 2x <= b, 4x <= c. The maximum possible x is floor(min(a, b/2, c/4)). Then answer = 7 * floor(min(a, b/2, c/4)). But careful: a, b, c are positive integers. Compute x = min(a, b//2, c//4). Then total = 7 * x. This matches examples.
But wait: Could there be a scenario where we can't use all fruits because we have to follow exactly ratio, but we could also consider using multiple sets? That's exactly x sets. So answer is 7x. That's straightforward.
But is there any twist? The problem statement: "determine the maximum total number of lemons, apples and pears from which Nikolay can cook the compote." That is exactly the sum of used fruits. So indeed answer = 7 * min(a, b//2, c//4). It seems too easy for Codeforces problem? But I've seen similar problems: maybe it's from some contest. But given constraints up to 1000, it's trivial. However, maybe we need to consider that we can choose any ratio? No, it's fixed 1:2:4.
Double-check: In example 2: a=4, b=7, c=13. Compute: a=4, b//2=3, c//4=3 => min=3, total=21. Yes.
Example 1: 2,5,7 => a=2, b//2=2, c//4=1 => min=1, total=7.
Example 3: 2,3,2 => a=2, b//2=1, c//4=0 => min=0, total=0.
Thus solution is straightforward.
But maybe we should be careful with integer division. Since b and c are integers, b//2 gives floor division. But what if b or c are odd? That's fine.
Thus solution is just: read a,b,c; compute x = min(a, b//2, c//4); print(7*x).
That's it.
But wait, why is the problem named "Nikolay and the compote"? Actually I recall a Codeforces problem: "Nikolay and the compote" (or maybe "Nikolay and the fruit"?), but I think it's exactly that. So it's trivial.
I'll code accordingly.
But the conversation says: "You are ChatGPT, a large language model ... Provide the final answer inside a code block. No other text." So I need to output just code? The instruction: "You are ChatGPT, a large language model trained ... Provide the final answer inside a code block. No other text." That implies that I should output the solution code only. However, it might be that they want the solution description as well? But "Provide the final answer inside a code block." So I'll output the code block containing the solution.
But sometimes the user expects a response: the code. So I'll output:
python
def solve():
import sys
data = sys.stdin.read().strip().split()
if not data:
return
a = int(data[0])
b = int(data[1])
c = int(data[2])
x = min(a, b//2, c//4)
print(7 * x)
if __name__ == "__main__":
solve()
Yes.
Alternatively, could also use input() three times.
But note: the input lines are separate: first line a, second b, third c. So we can read with input().
But to be safe, I'll use input(). Because constraints small.
So final answer code.
But hold on: In the problem, input numbers are positive integers (>=1). So reading is fine.
Thus final answer. ```python
import sys
def solve() -> None:
data = sys.stdin.read().strip().split()
if not data:
return
a = int(data[0])
b = int(data[1])
c = int(data[2])
x = min(a, b // 2, c // 4)
print(7 * x)