defgf2_rank(rows):""" Find rank of a matrix over GF2. The rows of the matrix are given as nonnegative integers, thought of as bit-strings. This function modifies the input list. Use gf2_rank(rows.copy()) instead of gf2_rank(rows) to avoid modifying rows. """rank=0whilerows:pivot_row=rows.pop()ifpivot_row:rank+=1lsb=pivot_row&-pivot_rowforindex,rowinenumerate(rows):ifrow&lsb:rows[index]=row^pivot_rowreturnrankdefis_linear_combination(keys,test):rows=keys.copy()rows.append(test)returnlen(rows)>gf2_rank(rows)keys,remain=[],[]forpinpublic:if0inp:keys.append(p[0]+p[1])else:remain.append(p)whileremain:cur_remain=[]forpinremain:ifis_linear_combination(keys,p[0]):keys.append(p[1])elifis_linear_combination(keys,p[1]):keys.append(p[0])else:cur_remain.append(p)remain=cur_remainkeystream=recover_keystream(keys,public)print(bits_to_bytes(xor(enc,keystream)))# b'pbctf{I_hope_you_enjoyed_this_challenge_now_how_about_playing_Metroid_Dread?}'