Count how many pairs of players can be formed when two groups arrive in equal sizes or with a one-item difference.
There are two groups of players standing in line for a game. In one move, you can take one player from each group and form a pair.
Given the sizes of the two groups, determine how many pairs can be formed before one of the groups becomes empty.
This is a simple counting problem: each pair consumes one player from both groups, so the answer is limited by the smaller group size.
Example 1
Input
4 7
Output
4
Explanation
You can form 4 pairs. After that, the first group is empty and 3 players remain in the second group.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.