Problem:
Score : 100 points

Problem Statement

There are N students in a school.

We will divide these students into some groups, and in each group they will discuss some themes.

You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.

Divide the students so that the number of groups consisting of three or more students is maximized.

Constraints

1 \leq N \leq 1000

All input values are integers.

Input

Input is given from Standard Input in the following format:

N

Output

If you can form at most x groups consisting of three or more students, print x.

Sample Input 1

8

Sample Output 1

2

For example, you can form a group of three students and another of five students.

Sample Input 2

2

Sample Output 2

0

Sometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.

Sample Input 3

9

Sample Output 3

3

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
using namespace std;

int solve(long long x[]){
  int ans = 0;
  ans += x[0] * x[1] * x[2];
  ans += x[0] * x[1] * x[3];
  ans += x[0] * x[1] * x[4];
  ans += x[0] * x[2] * x[3];
  ans += x[0] * x[2] * x[4];
  ans += x[0] * x[3] * x[4];
  ans += x[1] * x[2] * x[3];
  ans += x[1] * x[2] * x[4];
  ans += x[1] * x[3] * x[4];
  ans += x[2] * x[3] * x[4];
  return ans;
}

int main(){
  int n;
  long long march[5];
  for(int i=0; i<5; i++){
    march[i] = 0;
  }
  string s;
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> s;
    if(s[0] == 'M') {
      march[0]+=1;
    }
    else if(s[0] == 'A'){
      march[1] += 1;
    }
    else if(s[0] == 'R'){
      march[2] += 1;
    }
    else if(s[0] == 'C'){
      march[3] += 1;
    }
    else if(s[0] == 'H'){
      march[4] += 1;
    }
    else{
      continue;
    }
  }
  int ans = solve(march);
  cout << ans;
}