Problem p03133 (python)

Fixed submission:
import numpy as np
import random

mod=998244353


n,m=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]

#n,m=300,300
#A=[[int(random.randint(0,1)) for j in range(m)] for i in range(n)]


#A=np.array(A)

#print("A")
i=0
j=0
r=0 #rank
while i<n and j<m :
    #print(i)
    t=0
    if A[i][j]==0 :
        k=i
        while k<n and A[k][j]==0 :
            k+=1
        if k<n :
            A[i],A[k]=A[k],A[i]

            #print(A)
        else :
            t=1
            j+=1
    if t==0 :
        r+=1
        for p in range(i+1,n):
            if A[p][j]>0 :
                for kk in range(j,m):
                    A[p][kk]=(A[p][kk]-A[i][kk])%2
        i+=1
        j+=1



#r=0
#j=0
#for i in range(m):
#    if j<n :
#        if A[j][i]!=0 :
#            r+=1
#            j+=1

for i in range(n):
    for j in range(m):
        A[i][j]=int(A[i][j])
#print(A)
#print(r) #rank

a=1
b=1

for i in range(n+m-1):
    a=(a*2)%mod
for i in range(n+m-1-r):
    b=(b*2)%mod

print((a-b)%mod)

Buggy submission (verdict: Runtime Error):
import numpy as np

mod=998244353


n,m=map(int,input().split())
A=[list(map(float,input().split())) for i in range(n)]

A.sort(reverse=1)
A=np.array(A)

# if A[0][0]!=0

#print(A)
for i in range(min(n,m)):
    #print(A)
    A=list(A)
    A[i:].sort(reverse=1,key=lambda x:x[i])
    if A[i][i]==0 :
        A[i:].sort(key=lambda x:x[i])
    A=np.array(A)
    if A[i][i]!=0 :
        w=A[i][i]
        for k in range(m):
            
            A[i][k]/=w
        for j in range(i+1,n):
            A[j]-=A[i]*A[j][i]

#print(A)

r=0
j=0
for i in range(m):
    if A[j][i]!=0 :
        r+=1
        j+=1

for i in range(n):
    for i in range(m):
        A[i][j]=int(A[i][j])
#print(A)
print(r) #rank

a=1
b=1

for i in range(n+m-1):
    a=(a*2)%mod
for i in range(n+m-1-r):
    b=(b*2)%mod
#print((a-b)%mod)

Buggy submission (verdict: Runtime Error):
import numpy as np

mod=998244353


n,m=map(int,input().split())
A=[list(map(float,input().split())) for i in range(n)]

A.sort(reverse=1)
A=np.array(A)

# if A[0][0]!=0

#print(A)
for i in range(min(n,m)):
    #print(A)
    A=list(A)
    A[i:].sort(reverse=1,key=lambda x:x[i])
    if A[i][i]==0 :
        A[i:].sort(key=lambda x:x[i])
    A=np.array(A)
    if A[i][i]!=0 :
        w=A[i][i]
        for k in range(m):
            
            A[i][k]/=w
        for j in range(i+1,n):
            A[j]-=A[i]*A[j][i]

#print(A)

r=0
j=0
for i in range(m):
    if A[j][i]!=0 :
        r+=1
        j+=1

for i in range(n):
    for i in range(m):
        A[i][j]=int(A[i][j])
#print(A)
#print(r) #rank

a=1
b=1

for i in range(n+m-1):
    a=(a*2)%mod
for i in range(n+m-1-r):
    b=(b*2)%mod
print((a-b)%mod)

Buggy submission (verdict: Runtime Error):
import numpy as np

mod=998244353


n,m=map(int,input().split())
A=[list(map(float,input().split())) for i in range(n)]

A.sort(reverse=1)
A=np.array(A)

# if A[0][0]!=0

#print(A)
for i in range(min(n,m)):
    #print(A)
    A=list(A)
    A[i:].sort(reverse=1,key=lambda x:x[i])
    A=np.array(A)
    if A[i][i]!=0 :
        w=A[i][i]
        for k in range(m):
            
            A[i][k]/=w
        for j in range(i+1,n):
            A[j]-=A[i]*A[j][i]

#print(A)

r=0
j=0
for i in range(m):
    if A[j][i]!=0 :
        r+=1
        j+=1

#print(r) #rank

a=1
b=1

for i in range(n+m-1):
    a=(a*2)%mod
for i in range(n+m-1-r):
    b=(b*2)%mod
print((a-b)%mod)