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 (GCC 5.4.1) (judge verdict: Wrong Answer)

/*
 AtCoder XXX 000
 */
 
#include <stdio.h>
#include <math.h>

int main(void){
	
	int width,height,dist;
	int a[300][300];
	int q;
	int l,r;
	int i,j,k;
	int from_x,from_y;
	int goto_x,goto_y;
	int maryoku;
	
	scanf("%d",&height);
	scanf("%d",&width);
	scanf("%d",&dist);
	
	for(i=0; i<width; i++) for(j=0; j<height; j++){
		scanf("%d",&a[i][j]);
	}
	
	scanf("%d",&q);
	
	for(k=0,maryoku=0; k<q; k++){
		scanf("%d",&l);
		scanf("%d",&r);
		
		for(i=0; i<width; i++) for(j=0; j<height; j++){
			if(a[i][j] == l){
				from_x = i;
				from_y = j;
				goto OUT;
			}
		}
		
		OUT:
		while(l != r){
			l += dist;
			for(i=0; i<width; i++) for(j=0; j<height; j++){
				if(a[i][j] == l){
					goto_x = i;
					goto_y = j;
					maryoku += (int)fabs(from_x - goto_x);
					maryoku += (int)fabs(from_y - goto_y);
					from_x = goto_x;
					from_y = goto_y;
					break;
				}
			}
		}
		printf("%d\n",maryoku);
	}
	
	return 0;
}