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

int main ()
{
  std::unordered_map <int, int[2]> m;
  int n;
  scanf ("%i", &n);
  while (n--)
  {
    int r, w, t;
    scanf ("%i%i%i", &r, &w, &t);
    m[w-t][r-1]++;
  }
  int c = 0;
  for (auto [i, j]: m) c += std::min (j[0], j[1]);
  printf ("%i\n", c);
  return 0;
}