Find all pairs of numbers such that the number of binary 1's in their OR is maximum So, I tried to solve this question and my code did not execute within time-limits.
https://www.hackerrank.com/challenges/acm-icpc-team

Here's my code,

from itertools import combinations
nm =input().split()
n = int(nm[0])
m = int(nm[1])
mat=[]
z=[]
for i in range(n):
    mat.append(input())  
a=combinations(range(1,n+1),2)

for i in a:
    count=0
    for j in range(m):
        if mat[i[0]-1][j]=="0" and mat[i[1]-1][j]=="0":
            count=count+1  
    z.append(m-count)            
print(max(z))
print(z.count(max(z)))


How can I improve it?
I don't have much time, and don't see any quick performance suggestions, but,

mat = []
for i in range(n):
    mat.append(input())


Can be written more terse as a list comprehension:

mat = [input() for _ in range(n)]


And note how you never use i. If you don't use a variable, you can indicate that it isn't needed by calling it _. That's a placeholder convention to say that "I needed to create a variable, but I don't need it".



count=count+1


can be

count += 1




Also, please be more careful with spaces around operators. In some places, you use no spaces, in some places you use one on each side, and then in one case, you have

nm =input().split()


I prefer one per side, but regardless of what you choose, you should be consistent.