You are viewing a single comment's thread. Return to all comments →
from itertools import product K, M = map(int, input().split()) S = [[int(i)**2 for i in input().split()[1:]] for k in range(K)] print(max(map(lambda x: sum(x) % M, product(*S))))
Seems like cookies are disabled on this browser, please enable them to open this website
Maximize It!
You are viewing a single comment's thread. Return to all comments →