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

using namespace std;

int n, t, a, b, result;

int tab[2000005][2];

int main ()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d%d%d", &t, &a, &b);
		tab[a - b + 1000000][t - 1]++;
	}
	for (int i = 1; i <= 2000000; ++i) result += min(tab[i][0], tab[i][1]);
	printf("%d\n", result);
	return 0;
}