Skip to main content
Back to problems
Codeforces
Easy
Game Theory
Math
Games

Count how many pairs of players can be formed when two groups arrive in equal sizes or with a one-item difference.

Acceptance 0%
Problem Statement

Problem

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.

Input Format

  • The input contains two integers aa and bb — the sizes of the two groups.
  • 1≤a,b1 \le a, b.

Output Format

  • Print a single integer: the maximum number of pairs that can be formed.

Constraints

  • 1≤a,b≤1091 \le a, b \le 10^9
  • The answer fits in a 64-bit signed integer.
Examples
Sample cases returned by the problem API.

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

Unlock deeper context for this problem

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.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.