Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate, combinations
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]



n = val()
l = []

for i in range(n):
    l.append(li())



def return_substrings(x):
    all_combnations = [sorted(l) for i in range(len(x)) for l in combinations(x, i+1)]
    return list(all_combnations)



def findans(arr):
    ans = 0

    for j in arr:
        for k in arr:
            ans += l[j][k]
    
    return ans
def givemask(arr):
    mask = 0
    for i in arr:
        mask += 1 << i
    return mask


d = {}
for i in return_substrings(range(n)):
    d[tuple(i)] = [findans(i), givemask(i)]

# print(d)


@lru_cache(None)
def dp(mask = 0):
    if mask == 2 ** n - 1:return 0


    currans = 0
    l1 = [j for j in range(n) if (mask >> j) & 1 == 0]
    l2 = []
    for iteration in return_substrings(l1):
        # curr = findans(iteration)
        # masknow = 0
        # for i in iteration:
        #     masknow += 1 << i
        curr, masknow = d[tuple(iteration)]

        currans = max(currans, curr + dp(mask + masknow))
    
    return currans


print(dp() // 2)

Fixed submission:
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate, combinations
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]




n = val()
l = []

for i in range(n):
    l.append(li())


ans = [-float('inf') for i in range(2 ** n)]

ans[0] = 0

for i in range(1, 2 ** n):


    curr = 0
    for j in range(n):
        for k in range(n):
            if (i >> j) & 1 == (i >> k) & 1 == 1:curr += l[j][k]
    
    curr //= 2

    ind = i & (i - 1)

    while ind:
        curr = max(curr, ans[ind] + ans[ind ^ i])
        ind = (ind - 1) & i
    
    ans[i] = curr

print(max(ans))

Buggy python submission (verdict: Runtime Error):
from decimal import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
M = mod = 10**9 + 7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
def li4():return [float(i) for i in input().rstrip('\n').split(' ')]

def givevalue(p):
    global l
    tot = 0
    for s in p:
        for i in s:
            for j in s:
                tot += l[i][j]
    # print('tot : ',tot//2)
    return tot//2

ans = 0
def currentvalue(ind,p):
    global l,ans
    if ind == len(l):
        #print(p)
        ans += 1
        currentvalue.ma = max(currentvalue.ma,givevalue(p))
    maxind = 0
    while maxind < len(l) - 1 and len(p[maxind + 1]):maxind += 1
    for j in range(min(len(p),maxind + 1)):
        p[j].add(ind)
        currentvalue(ind + 1,p.copy())
        p[j].remove(ind)


n = val()
l = []
for i in range(n):l.append(li())



p = [set() for i in range(n)]

currentvalue.ma = 0
currentvalue(0,p)
print(currentvalue.ma)
# print('total counts : ',ans)

Fixed submission:
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate, combinations
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]




n = val()
l = []

for i in range(n):
    l.append(li())


ans = [-float('inf') for i in range(2 ** n)]

ans[0] = 0

for i in range(1, 2 ** n):


    curr = 0
    for j in range(n):
        for k in range(n):
            if (i >> j) & 1 == (i >> k) & 1 == 1:curr += l[j][k]
    
    curr //= 2

    ind = i & (i - 1)

    while ind:
        curr = max(curr, ans[ind] + ans[ind ^ i])
        ind = (ind - 1) & i
    
    ans[i] = curr

print(max(ans))