#C1082. Maximize Student Groups with Even Sum

    ID: 40067 Type: Default 1000ms 256MiB

Maximize Student Groups with Even Sum

Maximize Student Groups with Even Sum

You are given N students, where each student is assessed in one or more subjects. The skill levels for each student are provided as a list of integers. A student is considered even if the sum of their skill levels is even, and odd otherwise.

You can form a group by pairing two students. A valid group is one in which the sum of the skill levels of the two students is even. Note that:

  • The sum of two even numbers is even.
  • The sum of two odd numbers is even.

Your task is to determine the maximum number of groups that can be formed such that each group has exactly two students and each student can be in at most one group.

Hint: Count the number of students with even and odd total scores and then compute the number of pairs you can form from each group by using the floor division by 2.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer N representing the number of students.
  • Each of the next N lines contains space-separated integers representing the skill levels of a student in various subjects.

outputFormat

The output is written to stdout and should be a single integer representing the maximum number of groups that can be formed, where each group consists of exactly two students whose combined skill levels sum to an even number.## sample

4
1 2
3 4
5 6
7 8
2