1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstdio>
#include <algorithm>
using namespace std;

int n;

int a[2000005][2];

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		int r, w, t;
		scanf("%d%d%d", &r, &w, &t);
		a[1000000 + t - w][r - 1]++;
	}
	int res = 0;
	for (int i = 0; i <= 2000000; i++){
		res += min(a[i][0], a[i][1]);
	}
	//printf("aa %d %d\n", a[1000003][0], a[1000003][1]);
	printf("%d\n", res);
}