We are given five integers c1..c5 (0 ≤ ci ≤ 100) representing the number of coins each player has at the end of the game. Initially, each player bets b coins, so initially each player has b coins? The problem statement: "Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player." So initially, each player contributed b coins, meaning they start with b coins? Typically, if you bet, you give away your coins? But reading: "Each person gives some non-zero number of coins b as an initial bet." Usually in such problems, the bet means they put coins into a pot, but here it says "gives" and then operations are passing coins from one player to another. So the initial distribution is each player has b coins. Because they each give b coins as a bet, and then they can pass coins among themselves. So at the start, total coins = 5b. The operations are passing coins from one player to another; that does not change total number of coins. So at the end, total coins = 5b. Thus we have sum(c_i) = 5b, so b = sum/5. Since b must be a positive integer (non-zero) and sum must be divisible by 5. Also, note that each player initially had b coins. Through passes, they end with ci. Since passes can move any number of coins arbitrarily? But there might be constraints? The operation is "a coin is passed from one player to some other player." It says repeated several times, each time one coin moves. So it is possible to transform any initial distribution of b each to any final distribution with the same total sum, provided we can move coins one by one? Actually, if we can pass coins arbitrarily, from any distribution to any other distribution with the same total sum, it's possible because we can think of net transfers: we can always move coins from players with excess to those with deficit one by one. Since there is no restriction on number of passes, any target distribution with same total sum is reachable. But is there any other constraint? For example, each operation moves exactly one coin from one player to another. So you can achieve any distribution of integer coins as long as the sum matches. Because the state space is connected (graph of integer vectors with sum constant, edges connecting by moving one coin from i to j). Yes, it's connected because you can always adjust one coin at a time. So the only condition is that sum(c_i) is divisible by 5 and the quotient b = sum/5 is positive (since b non-zero, sum > 0). Also, each ci between 0 and 100. So algorithm: read c1..c5, compute sum. If sum % 5 == 0 and sum != 0 (since b > 0) then output sum/5 else output -1. But note: b must be positive integer, and initial bet is "some non-zero number of coins b". So b > 0. So if sum == 0, then b=0 not allowed, output -1. Check examples: Input: 2 5 4 0 4 → sum = 2+5+4+0+4 = 15, 15/5=3, output 3. That matches. Input: 4 5 9 2 1 → sum = 21, 21/5 not integer, output -1. So our reasoning matches.
Thus solution straightforward.
But ensure that we consider constraints: ci ≤ 100, so sum ≤ 500, fine.
Edge case: sum=0 (all zeros). Then b=0 not allowed, so -1.
Edge: sum=5 but divisible, b=1 is allowed.
Thus answer.
We'll write Python code to read five ints, compute sum, if sum%5==0 and sum>0: print(sum//5) else print(-1). ```python
import sys
def main():
data = sys.stdin.read().strip().split()
if not data:
return
c = list(map(int, data))
total = sum(c)
if total % 5 == 0 and total > 0:
print(total // 5)
else:
print(-1)
if name == "main":
main()