Skip to main content
Back to problems
Codeforces
Medium
Combinatorics
Bit Manipulation
Math
Team

Count how many teams of 3 students can be formed such that the total skill level is even.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

You are given the skill levels of nn students. Count the number of different teams of exactly 3 students whose combined skill is even.

A team is identified only by the chosen 3 students, so the order does not matter.

The task is to determine how many such teams can be formed.

Input Format

  • The first line contains an integer nn.
  • The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n representing the skill values.

Output Format

Print a single integer — the number of 3-person teams with even total skill.

Constraints

  • 3n3 \le n
  • Skill values fit in standard 32-bit signed integers.
  • The answer may be large; use 64-bit integer arithmetic.
Examples
Sample cases returned by the problem API.

Example 1

Input

5
1 2 3 4 5

Output

3

Explanation

The valid teams are {1,2,3}, {1,4,5}, and {2,3,5}. Each has an even sum.

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.