You will be given a two-dimensional array with row consisting values 0 or 1.  
A move consists of choosing any column or row, and toggling all the 0’s as 1’s and 1’s as 0’s.  
After making the required moves, every row represents a binary number and the score of the matrix will be sum of all the numbers represented as binary numbers in each row.  
Find the highest possible score.  
$Example:$ 
Input:

0 0 1 1

1 0 1 0

1 1 0 0  
Output:

39
Explanation:

Toggled to

1 1 1 1

1 0 0 1

1 1 1 1  
0b1111 + 0b1001 + 0b1111 = 15 + 9 + 15 = 39

-----Input:-----
- First line will contains $m$, $n$ for the size of the 2-D array. 
- Contains $m$ lines of $n$ space-separated values each. 

-----Output:-----
Single integer which is the maximum score obtained by the sum of binary numbers.

-----Constraints-----
- $1 \leq m, n \leq 20$
- $A[i][j] = 1$ or $0$ 

-----Sample Input:-----
3 4  
0 0 1 1  
1 0 1 0  
1 1 0 0  

-----Sample Output:-----
39

Starter code:

Solutions:
def matrixScore(A):
        """
        :type A: List[List[int]]
        :rtype: int
        """
        m,n = len(A),len(A[0])
        # 行变换
        for i in range(m):
            if A[i][0] == 1: continue
            for j in range(n):
                A[i][j] = 1 - A[i][j]

        # 列变换
        res = 0
        for rows in zip(*A):
         # 始终使1的个数是更大的
            cnt1 = max(rows.count(1), rows.count(0))
            res += cnt1 * 2**(n-1)
            n -= 1
        return res
m, n = [int(s) for s in input().split(" ")]
arr = [[int(s) for s in input().split(" ")] for i in range(m)]
ans = matrixScore(arr)
print(ans)


m, n = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(m)]

m, n = len(A), len(A[0])
for i in range(m):
    if A[i][0] == 0:
        for j in range(n): A[i][j] ^= 1

for j in range(n):
    cnt = sum(A[i][j] for i in range(m))
    if cnt < m - cnt:
        for i in range(m): A[i][j] ^= 1

print(sum(int("".join(map(str, A[i])), 2) for i in range(m)))

R,C=map(int,input().split())
A=[]
for i in range(R):
    p=list(map(int,input().split()))
    A.append(p)
m, n = len(A), len(A[0])
for i in range(m):
    if(A[i][0]==0):
        for j in range(n):
            A[i][j]^=1
        
for j in range(n): 
    cnt=0
    for i in range(m):
        if(A[i][j]==1):
            cnt+=1
    if(cnt<(m-cnt)):
        for i in range(m):
            A[i][j]^=1
res=0
for i in range(m):
    ans=""
    for j in range(n):
        ans+=str(A[i][j])
    res+=int(ans,2)
print(res)

R,C=map(int,input().split())
A=[]
for i in range(R):
    p=list(map(int,input().split()))
    A.append(p)
m, n = len(A), len(A[0])
for i in range(m):
    if A[i][0] == 0: 
        for j in range(n): A[i][j] ^= 1 
        
for j in range(n): 
    cnt=0
    for i in range(m):
        if(A[i][j]==1):
            cnt+=1
    if(cnt<(m-cnt)):
        for i in range(m):
            A[i][j]^=1

#print(sum(int("".join(map(str, A[i])), 2) for i in range(m)))
res=0
for i in range(m):
    ans=""
    for j in range(n):
        ans+=str(A[i][j])
    res+=int(ans,2)
print(res)

R,C=map(int,input().split())
A=[]
for i in range(R):
    p=list(map(int,input().split()))
    A.append(p)
m, n = len(A), len(A[0])
for i in range(m):
    if A[i][0] == 0: 
        for j in range(n): A[i][j] ^= 1 
        
for j in range(n): 
    cnt=0
    for i in range(m):
        if(A[i][j]==1):
            cnt+=1
    if cnt < m - cnt: 
        for i in range(m): A[i][j] ^= 1

#print(sum(int("".join(map(str, A[i])), 2) for i in range(m)))
res=0
for i in range(m):
    ans=""
    for j in range(n):
        ans+=str(A[i][j])
    res+=int(ans,2)
print(res)

R,C=list(map(int,input().split()))
A=[]
for i in range(R):
    p=list(map(int,input().split()))
    A.append(p)
m, n = len(A), len(A[0])
for i in range(m):
    if A[i][0] == 0: 
        for j in range(n): A[i][j] ^= 1 
        
for j in range(n): 
    cnt=0
    for i in range(m):
        if(A[i][j]==1):
            cnt+=1
    if cnt < m - cnt: 
        for i in range(m): A[i][j] ^= 1

print(sum(int("".join(map(str, A[i])), 2) for i in range(m)))


R,C=list(map(int,input().split()))
A=[]
for i in range(R):
    p=list(map(int,input().split()))
    A.append(p)
m, n = len(A), len(A[0])
for i in range(m):
    if A[i][0] == 0: 
        for j in range(n): A[i][j] ^= 1 
        
for j in range(n): 
    cnt = sum(A[i][j] for i in range(m))
    if cnt < m - cnt: 
        for i in range(m): A[i][j] ^= 1

print(sum(int("".join(map(str, A[i])), 2) for i in range(m)))



def row(array,j):
    for i in range(len(array[0])):
        if(array[j][i]==0):
            array[j][i]=1
        else:
            array[j][i]=0


def col(array,j):
    for i in range(len(array)):
        if(array[i][j]==0):
            array[i][j] =1
        else:
            array[i][j] = 0



m,n = list(map(int,input().split(" ")))
lt = []
for i in range(m):
    temp = list(map(int,input().split(" ")))
    lt.append(temp)
for i in range(len(lt)):
    if(lt[i][0]==0):
        row(lt,i)

for i in range(1,len(lt[0])):
    count1 =0
    count0 =0
    for j in range(len(lt)):
        if(lt[j][i]==0):
            count0 = count0+1
        else:
            count1 = count1 +1
    if(count0>count1):
        col(lt,i)
st = []
for i in range(len(lt)):
    temp1 =""
    for j in range(len(lt[i])):
        temp1 = temp1 + str(lt[i][j])
    st.append(temp1)
ans = 0
#print(st)
for i in range(len(st)):
    ans = ans+int(st[i],2)
print(ans)



def row(array,j):
    for i in range(len(array[0])):
        if(array[j][i]==0):
            array[j][i]=1
        else:
            array[j][i]=0


def col(array,j):
    for i in range(len(array)):
        if(array[i][j]==0):
            array[i][j] =1
        else:
            array[i][j] = 0



m,n = list(map(int,input().split(" ")))
lt = []
for i in range(m):
    temp = list(map(int,input().split(" ")))
    lt.append(temp)
for i in range(len(lt)):
    if(lt[i][0]==0):
        row(lt,i)

for i in range(1,len(lt[0])):
    count1 =0
    count0 =0
    for j in range(len(lt)):
        if(lt[j][i]==0):
            count0 = count0+1
        else:
            count1 = count1 +1
    if(count0>count1):
        col(lt,i)
st = []
for i in range(len(lt)):
    temp1 =""
    for j in range(len(lt[i])):
        temp1 = temp1 + str(lt[i][j])
    st.append(temp1)
ans = 0
#print(st)
for i in range(len(st)):
    ans = ans+int(st[i],2)
print(ans)


class Solution:
    def matrixScore(self, A):
        m, n = len(A), len(A[0])
        for i in range(m):
            if A[i][0] == 0: 
                for j in range(n): A[i][j] ^= 1 
        
        for j in range(n): 
            cnt = sum(A[i][j] for i in range(m))
            if cnt < m - cnt: 
                for i in range(m): A[i][j] ^= 1
        return sum(int("".join(map(str, A[i])), 2) for i in range(m))
n,m=map(int,input().split())
A=[]
for _ in range(n):
    x=list(map(int,input().split()))
    A.append(x)
c=Solution()
print(c.matrixScore(A))

R,C=list(map(int,input().split()))
A=[]
for i in range(R):
    p=list(map(int,input().split()))
    A.append(p)
m, n = len(A), len(A[0])
for i in range(m):
    if A[i][0] == 0: 
        for j in range(n): A[i][j] ^= 1 
        
for j in range(n): 
    cnt = sum(A[i][j] for i in range(m))
    if cnt < m - cnt: 
        for i in range(m): A[i][j] ^= 1

print(sum(int("".join(map(str, A[i])), 2) for i in range(m)))