1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>

using namespace std;

map<int,int>M,M1;
vector<pair<int,int>>v[2];

int main()
{
	int ans=0, a, b, c, n;
	scanf("%d", &n);

	for(int i=0;i<n;++i)
	{
		scanf("%d%d%d",&c, &a, &b);
		if(c&1)
		{
			++M[a-b];
			//v[1].push_back({a,b});
		}
		else
		{
			++M1[a-b];
			v[0].push_back({a,b});
		}
	}
	for(auto e: v[0])
	{
		if(M[e.first-e.second]<M1[e.first-e.second])
		{
			ans+=M[e.first-e.second];
			M[e.first-e.second]=0;
		}
		else
		{
			ans+=M1[e.first-e.second];
			M1[e.first-e.second]=0;
		}
			
	}
	/*for(auto e: v[1])
	{
		if(M1[e.first-e.second]>0)
			++ans2;
	}*/

	printf("%d", ans);
	return 0;
}