Problem p03133 (python)

Fixed submission:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    A = []
    A_str = []
    for i in range(N):
        input_raw = read_func().strip().split()
        A_str.append(input_raw)
    is_all_zero_set = set([])
    for i in range(M):
        is_all_zero = True
        for j in range(N):
            if A_str[j][i] != "0":
                is_all_zero = False
                break
        if is_all_zero == True:
            is_all_zero_set.add(i)


    for i in range(N):
        col = -1
        a = 0
        for j in range(M):
            if j in is_all_zero_set:
                continue
            col += 1
            a += int(A_str[i][j]) << col
        A.append(a)
    M_new = col + 1
##    is_set = set([])
##    is_all_zero_set = set([])
##    A_ = [0 for i in range(N)]
##    all_zero_count = 0

##    for i in range(max(M, N)):
##        is_all_zero = True
##        for j in range(N):
##            if (A[j] & (0x01 << i)) > 0 and j not in is_set:
##                A_[i] = A[j]
##                is_set.add(j)
##                break

##    for i in range(max(M, N)):
##        is_all_zero = True
##        for j in range(N):
##            if (A[j] & (0x01 << i)) > 0:
##                is_all_zero =False
##            if (A[j] & (0x01 << i)) > 0 and j not in is_set:
##                A_[i] = A[j]
##                is_set.add(j)
##                is_all_zero =False
##                break
##        if is_all_zero == True:
##            is_all_zero_set.add(i)
##            all_zero_count += 1
##            for j in range(N):
##                if j not in is_set:
##                    A_[i] = A[j]
##                    is_set.add(j)
##                    break

    for i in range(min(N, M_new)):
        if (A[i] >> i) & 0x01 == 0:
            for j in range(i + 1, N):
                if (A[j] >> i) & 0x01 > 0:
                    tmp = A[j]
                    A[j] = A[i]
                    A[i] = tmp

        for j in range(N):
            if j == i:
                continue
            if ((A[j] >> i) & 0x01) > 0:
                A[j] = A[j] ^ A[i]
    r = 0
    for i in range(N):
        if A[i] != 0:
            r += 1
    k = N - min(r, M_new)
    count1 = 1L
    for i in range(M-1):
        count1 = (count1 * 2L)%998244353
    count2 = 1L
    for i in range(N):
        count2 = (count2 * 2L)%998244353
    count3 = 1L
    for i in range(k):
        count3 = (count3 * 2L)%998244353
    count = (count1 * ((count2 - count3) %998244353))%998244353
    print count



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    A = []
    for i in range(N):
        input_raw = read_func().strip().split()
        a = 0
        for j in range(M):
            a += int(input_raw[j]) << j
        A.append(a)
    is_set = set([])
    is_all_zero_set = set([])
    A_ = [0 for i in range(N)]
    all_zero_count = 0


    for i in range(max(M, N)):
        is_all_zero = True
        for j in range(N):
            if (A[j] & (0x01 << i)) > 0:
                is_all_zero =False
            if (A[j] & (0x01 << i)) > 0 and j not in is_set:
                A_[i] = A[j]
                is_set.add(j)
                is_all_zero =False
                break
        if is_all_zero == True:
            is_all_zero_set.add(i)
            all_zero_count += 1
            for j in range(N):
                if j not in is_set:
                    A_[i] = A[j]
                    is_set.add(j)
                    break

    row = -1
    for i in range(min(N, M)):
        if i in is_all_zero_set:
            continue
        row += 1
        for j in range(row+1, N):
            if ((A_[j] >> i) & 0x01) > 0:
                A_[j] = A_[j] ^ A_[row]
    r = 0
    for i in range(N):
        if A_[i] != 0:
            r += 1
    k = N - min(r, M - all_zero_count)
    count1 = 1L
    for i in range(M-1):
        count1 = (count1 * 2L)%998244353
    count2 = 1L
    for i in range(N):
        count2 = (count2 * 2L)%998244353
    count3 = 1L
    for i in range(k):
        count3 = (count3 * 2L)%998244353
    count = (count1 * ((count2 - count3) %998244353))%998244353
    print count



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    A = []
    for i in range(N):
        input_raw = read_func().strip().split()
        a = 0
        for j in range(M):
            a += int(input_raw[j]) << j
        A.append(a)
    is_set = set([])
    is_all_zero_set = set([])
    A_ = [0 for i in range(N)]
    all_zero_count = 0
    for i in range(max(M, N)):
        is_all_zero = True
        for j in range(N):
            if (A[j] & (0x01 << i)) > 0:
                is_all_zero =False
            if (A[j] & (0x01 << i)) > 0 and j not in is_set:
                A_[i] = A[j]
                is_set.add(j)
                is_all_zero =False
                break
        if is_all_zero == True:
            is_all_zero_set.add(i)
            all_zero_count += 1
            for j in range(N):
                if j not in is_set:
                    A_[i] = A[j]
                    is_set.add(j)
                    break

    row = -1
    for i in range(min(N, M)):
        if i in is_all_zero_set:
            continue
        row += 1
        for j in range(row+1, N):
            if ((A_[j] >> row) & 0x01) > 0:
                A_[j] = A_[j] ^ A_[row]
    r = 0
    for i in range(N):
        if A_[i] != 0:
            r += 1
    k = N - min(r, M - all_zero_count)
    count1 = 1L
    for i in range(M-1):
        count1 = (count1 * 2L)%998244353
    count2 = 1L
    for i in range(N):
        count2 = (count2 * 2L)%998244353
    count3 = 1L
    for i in range(k):
        count3 = (count3 * 2L)%998244353
    count = (count1 * ((count2 - count3) %998244353))%998244353
    print count



if __name__ == '__main__':
    main()