Find all pairs of numbers such that the number of binary 1's in their OR is maximum
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.