[Python3] Simple Bitmask DP
\nclass Solution:\n    def maxCompatibilitySum(self, students: List[List[int]], mentors: List[List[int]]) -> int:\n        m = len(students)\n        n = len(st
```\nclass Solution:\n    def maxCompatibilitySum(self, students: List[List[int]], mentors: List[List[int]]) -> int:\n        m = len(students)\n        n = len(students[0])\n        complete = (1 << m) - 1\n        scores = [[0] * m for _ in range(m)]\n        def calc(st, me):\n            score = 0\n            for i in range(n):\n                if st[i] == me[i]:\n                    score += 1\n            return score\n        for i in range(m):\n            for j in range(m):\n                scores[i][j] = calc(students[i], mentors[j])\n        @lru_cache(None)\n        def dfs(mask1, mask2):\n            if mask1 == complete:\n                return 0\n            res = 0\n            for i in range(m):\n                if (mask1 >> i) & 1:\n                    continue\n                for j in range(m):\n                    if (mask2 >> j) & 1:\n                        continue\n                    res = max(res, dfs(mask1 ^ (1 << i), mask2 ^ (1 << j)) + scores[i][j])\n            return res\n        res = dfs(0, 0)\n        dfs.cache_clear()\n        return res\n```
[]