Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(void){
    int n;
    cin >>n;
    vector<int> red(2*n),blue(2*n);
    for(int i=0;i<n;i++)cin >> red[i][0] >> red[i][1];
    for(int i=0;i<n;i++)cin >> blue[i][1] >> blue[i][1];

    //queue<int> check(n*n);//redの具体的な候補
    vector<int> check_(n,0),blue_num(n,0);//redの候補のかずとblueの候補にされてる数
    int a=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++){
        if(red[i][0]<blue[j][0]&&red[i][1]<blue[j][1])
        {
            check_[i]++;
            blue_num[j]++;
            //check.push(j);
            a++;
        }
        }
    }
    sort(check_.begin(),check_.end());
    reverse(check_.begin(),check_.end());
    sort(blue_num.begin(),blue_num.end());
    reverse(blue_num.begin(),blue_num.end());
    a*=2;
    int ans=0;
    int i,j;
    i=j=0;
    while(a>0)
    {
        if(check_[i]==0)
        {
            i++;
            continue;
        }
        if(blue_num[j]==0)
        {
            j++;
            continue;
        }
        a=a-check_[i]-blue_num[j];
        i++;
        j++;
    }
    if(a<0)a=a+check[i]+blue_num[j];

    cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:8:38: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
    8 |     for(int i=0;i<n;i++)cin >> red[i][0] >> red[i][1];
      |                                      ^
a.cc:8:51: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
    8 |     for(int i=0;i<n;i++)cin >> red[i][0] >> red[i][1];
      |                                                   ^
a.cc:9:39: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
    9 |     for(int i=0;i<n;i++)cin >> blue[i][1] >> blue[i][1];
      |                                       ^
a.cc:9:53: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
    9 |     for(int i=0;i<n;i++)cin >> blue[i][1] >> blue[i][1];
      |                                                     ^
a.cc:17:18: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   17 |         if(red[i][0]<blue[j][0]&&red[i][1]<blue[j][1])
      |                  ^
a.cc:17:29: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   17 |         if(red[i][0]<blue[j][0]&&red[i][1]<blue[j][1])
      |                             ^
a.cc:17:40: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   17 |         if(red[i][0]<blue[j][0]&&red[i][1]<blue[j][1])
      |                                        ^
a.cc:17:51: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   17 |         if(red[i][0]<blue[j][0]&&red[i][1]<blue[j][1])
      |                                                   ^
a.cc:50:16: error: 'check' was not declared in this scope; did you mean 'check_'?
   50 |     if(a<0)a=a+check[i]+blue_num[j];
      |                ^~~~~
      |                check_