Language: C++


import queue

class Dinic:
    """Implementation of Dinic's Alogorithm"""

    def __init__(self, v, inf = 1000000007):
        self.V = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [0 for _ in range(v)]
        self.iter = [0 for _ in range(v)]

    def add_edge(self, from_, to, cap):
        self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
        self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})

    def bfs(self, s):
        self.level = [-1 for _ in range(self.V)]
        self.level[s] = 0;
        que = queue.Queue()
        que.put(s)
        while not que.empty():
            v = que.get()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e['cap'] > 0 and self.level[e['to']] < 0:
                    self.level[e['to']] = self.level[v] + 1
                    que.put(e['to'])

    def dfs(self, v, t, f):
        if v == t: return f
        for i in range(self.iter[v], len(self.G[v])):
            self.iter[v] = i
            e = self.G[v][i]
            if e['cap'] > 0 and self.level[v] < self.level[e['to']]:
                d = self.dfs(e['to'], t, min(f, e['cap']))
                if d > 0:
                    e['cap'] -= d
                    self.G[e['to']][e['rev']]['cap'] += d
                    return d

        return 0

    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t] < 0 : return flow
            self.iter = [0 for _ in range(self.V)]
            f = self.dfs(s, t, self.inf)
            while f > 0:
                flow += f
                f = self.dfs(s,t, self.inf)


N, = [int(x) for x in input().strip().split(" ")]
dinic = Dinic(2 * N + 2)

import sys
rs = []
bs = []
for i in range(N):
    rs.append([int(x) for x in input().strip().split(" ")])
for i in range(N):
    bs.append([int(x) for x in input().strip().split(" ")])

for i in range(N):
    rx, ry = rs[i]
    for j, b in enumerate(bs):
        bx, by = b
        if rx < bx and ry < by:
            dinic.add_edge(i, N+j, 1)
for i in range(N):
    dinic.add_edge(2*N, i, 1)
    dinic.add_edge(N+i, 2*N+1, 1)
print(dinic.max_flow(2*N, 2*N+1))


Compiler output:
a.cc:15:31: warning: multi-character character constant [-Wmultichar]
   15 |         self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
      |                               ^~~~
a.cc:15:40: warning: multi-character character constant [-Wmultichar]
   15 |         self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
      |                                        ^~~~~
a.cc:15:51: warning: multi-character character constant [-Wmultichar]
   15 |         self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
      |                                                   ^~~~~
a.cc:16:28: warning: multi-character character constant [-Wmultichar]
   16 |         self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})
      |                            ^~~~
a.cc:16:40: warning: multi-character character constant [-Wmultichar]
   16 |         self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})
      |                                        ^~~~~
a.cc:16:49: warning: multi-character character constant [-Wmultichar]
   16 |         self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})
      |                                                 ^~~~~
a.cc:27:22: warning: multi-character character constant [-Wmultichar]
   27 |                 if e['cap'] > 0 and self.level[e['to']] < 0:
      |                      ^~~~~
a.cc:27:50: warning: multi-character character constant [-Wmultichar]
   27 |                 if e['cap'] > 0 and self.level[e['to']] < 0:
      |                                                  ^~~~
a.cc:28:34: warning: multi-character character constant [-Wmultichar]
   28 |                     self.level[e['to']] = self.level[v] + 1
      |                                  ^~~~
a.cc:29:31: warning: multi-character character constant [-Wmultichar]
   29 |                     que.put(e['to'])
      |                               ^~~~
a.cc:36:18: warning: multi-character character constant [-Wmultichar]
   36 |             if e['cap'] > 0 and self.level[v] < self.level[e['to']]:
      |                  ^~~~~
a.cc:36:62: warning: multi-character character constant [-Wmultichar]
   36 |             if e['cap'] > 0 and self.level[v] < self.level[e['to']]:
      |                                                              ^~~~
a.cc:37:32: warning: multi-character character constant [-Wmultichar]
   37 |                 d = self.dfs(e['to'], t, min(f, e['cap']))
      |                                ^~~~
a.cc:37:51: warning: multi-character character constant [-Wmultichar]
   37 |                 d = self.dfs(e['to'], t, min(f, e['cap']))
      |                                                   ^~~~~
a.cc:39:23: warning: multi-character character constant [-Wmultichar]
   39 |                     e['cap'] -= d
      |                       ^~~~~
a.cc:40:30: warning: multi-character character constant [-Wmultichar]
   40 |                     self.G[e['to']][e['rev']]['cap'] += d
      |                              ^~~~
a.cc:40:39: warning: multi-character character constant [-Wmultichar]
   40 |                     self.G[e['to']][e['rev']]['cap'] += d
      |                                       ^~~~~
a.cc:40:47: warning: multi-character character constant [-Wmultichar]
   40 |                     self.G[e['to']][e['rev']]['cap'] += d
      |                                               ^~~~~
a.cc:2:1: error: 'import' does not name a type
    2 | import queue
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:15:73: error: expected unqualified-id before ')' token
   15 |         self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
      |                                                                         ^
a.cc:16:76: error: expected unqualified-id before ')' token
   16 |         self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})
      |                                                                            ^
a.cc:21:9: error: 'que' does not name a type
   21 |         que = queue.Queue()
      |         ^~~